OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::RandomSeeds Class Reference
Inheritance diagram for pfc::RandomSeeds:
Collaboration diagram for pfc::RandomSeeds:

Public Member Functions

void set_amplitude (double amplitude)
 
double get_amplitude () const
 
void set_density (double density)
 
double get_density () const
 
void apply (Model &m, double) override
 Apply the field modification to the model (pure virtual)
 
- Public Member Functions inherited from pfc::FieldModifier
void set_field_name (const std::string &field_name)
 
const std::string & get_field_name () const
 
virtual const std::string & get_modifier_name () const
 Get the name of the field modifier.
 
virtual ~FieldModifier ()=default
 Destructor for the FieldModifier class.
 

Member Function Documentation

◆ apply()

void pfc::RandomSeeds::apply ( Model model,
double  time 
)
inlineoverridevirtual

Apply the field modification to the model (pure virtual)

This is the main interface method that derived classes must implement to define their modification logic. The method receives full mutable access to the Model and current simulation time, allowing arbitrary modifications.

Implementation Responsibilities:

  • Retrieve field(s) via model.get_real_field() or model.get_complex_field()
  • Access geometry via model.get_world() and model.get_fft()
  • Modify field values according to modifier's purpose
  • Handle MPI parallelism (operate on local subdomain)

Typical Implementation Pattern:

void apply(pfc::Model& model, double time) override {
// 1. Get field to modify
auto& field = model.get_real_field(get_field_name());
// 2. Get geometry information
const auto& world = model.get_world();
const auto& fft = model.get_fft();
auto inbox = pfc::fft::get_inbox(fft);
// 3. Loop over local subdomain
int idx = 0;
for (int k = inbox.low[2]; k <= inbox.high[2]; k++) {
for (int j = inbox.low[1]; j <= inbox.high[1]; j++) {
for (int i = inbox.low[0]; i <= inbox.high[0]; i++) {
// Compute modification based on position and/or time
auto pos = pfc::world::to_coords(world, Int3{i, j, k});
field[idx++] = compute_value(pos, time);
}
}
}
}
The Model class represents the physics model for simulations in OpenPFC.
Definition model.hpp:95
void apply(Model &m, double) override
Apply the field modification to the model (pure virtual)
Definition random_seeds.hpp:53
Represents the global simulation domain (the "world").
Definition world.hpp:91
Parameters
modelMutable reference to the Model containing fields to modify
timeCurrent simulation time (useful for time-dependent BCs)
Precondition
Model must have the field specified by get_field_name() registered
Postcondition
Field values are modified according to modifier's logic
Note
For initial conditions, time is typically 0.0
For boundary conditions, time reflects current simulation time
Method is called on every MPI rank; each rank operates on its subdomain
Warning
Ensure modifications maintain physical correctness and don't violate model invariants (e.g., mass conservation if required)
See also
Model::get_real_field() for field access
Model::get_world() for domain geometry
Model::get_fft() for subdomain bounds

Implements pfc::FieldModifier.


The documentation for this class was generated from the following file: