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

Public Member Functions

 MovingBC (double rho_low, double rho_high)
 
void set_rho_low (double rho_low)
 
void set_rho_high (double rho_high)
 
void set_xpos (double xpos)
 
double get_xpos () const
 
void set_xwidth (double xwidth)
 
double get_xwidth () const
 
void set_alpha (double alpha)
 
void set_disp (double disp)
 
void set_threshold (double threshold)
 
double get_threshold () const
 
const std::string & get_modifier_name () const override
 Get the name of the field modifier.
 
void apply (Model &m, double) override
 Apply the field modification to the model (pure virtual)
 
void fill_bc (Model &m)
 
- Public Member Functions inherited from pfc::FieldModifier
void set_field_name (const std::string &field_name)
 
const std::string & get_field_name () const
 
virtual ~FieldModifier ()=default
 Destructor for the FieldModifier class.
 

Member Function Documentation

◆ apply()

void pfc::MovingBC::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 moving_bc.hpp:89
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.

◆ get_modifier_name()

const std::string & pfc::MovingBC::get_modifier_name ( ) const
inlineoverridevirtual

Get the name of the field modifier.

This function is responsible for getting the name of the field modifier.

Returns
The modifier name.

Reimplemented from pfc::FieldModifier.


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