OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
OscillatingBC Class Reference

Space-time varying BC: Oscillating left boundary. More...

Inheritance diagram for OscillatingBC:
Collaboration diagram for OscillatingBC:

Public Member Functions

 OscillatingBC (double frequency, double amplitude, double mean=0.0)
 
const std::string & get_modifier_name () const override
 Get the name of the field modifier.
 
void apply (Model &model, double time) 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 ~FieldModifier ()=default
 Destructor for the FieldModifier class.
 

Detailed Description

Space-time varying BC: Oscillating left boundary.

This demonstrates:

  • Time-dependent boundary conditions
  • Using the time parameter in apply()
  • Periodic forcing at boundaries
  • Boundary conditions as "driving forces"

Member Function Documentation

◆ apply()

void OscillatingBC::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);
}
}
}
}
void apply(Model &model, double time) override
Apply the field modification to the model (pure virtual)
Definition 07_field_modifiers.cpp:288
The Model class represents the physics model for simulations in OpenPFC.
Definition model.hpp:95
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 & OscillatingBC::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: