OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
Space-time

varying boundary condition

class TimeVaryingBC : public pfc::FieldModifier {
double m_frequency;
public:
TimeVaryingBC(double freq) : m_frequency(freq) {}
void apply(pfc::Model& model, double time) override {
auto& field = model.get_real_field(get_field_name());
const auto& world = model.get_world();
const auto& fft = model.get_fft();
auto inbox = pfc::fft::get_inbox(fft);
// Time-varying amplitude
double amplitude = std::sin(pfc::two_pi * m_frequency * time);
double dx = pfc::world::get_spacing(world, 0);
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++) {
if (i == 0) { // Left boundary
field[idx] = amplitude;
}
idx++;
}
}
}
}
};
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
const World & get_world() const noexcept
Get the decomposition object associated with the model.
Definition model.hpp:191