multiple fields (for future multi-field support)
public:
auto& density = model.
get_real_field(get_field_name());
std::fill(density.begin(), density.end(), 0.5);
}
};
Definition field_modifier.hpp:240
virtual void apply(Model &model, double time)=0
Apply the field modification to the model (pure virtual)
The Model class represents the physics model for simulations in OpenPFC.
Definition model.hpp:95
Usage in Simulator:
- Initial conditions: Applied once before time integration via
Simulator::add_initial_condition()
- Boundary conditions: Applied every time step (or at intervals) via
Simulator::add_boundary_condition()
- Application order: ICs first, then BCs, in the order added
Performance Considerations:
- Boundary conditions are in the hot path (applied every step)
- Minimize allocations in
apply()
- Consider caching computed values if expensive
- Use direct indexing (avoid coordinate transformations when possible)
Known Limitations:
- Currently designed for single-field access via
get_field_name()
- TODO: Support modifying multiple fields in one modifier (see TODO comment)
- No built-in support for parallel reduction operations
- Note
- The
time parameter allows implementing time-dependent boundary conditions, but most initial conditions ignore it (t=0 at IC application)
- Warning
- Modifiers have direct mutable access to model state. Ensure your
apply() implementation maintains physical correctness and doesn't violate model invariants.
- See also
- Model::get_real_field() for field access
-
Model::get_complex_field() for k-space operations
-
Simulator::add_initial_condition() for IC registration
-
Simulator::add_boundary_condition() for BC registration
-
initial_conditions/ for built-in IC implementations
-
boundary_conditions/ for built-in BC implementations