OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
Integration

with Model fields

// Model stores fields as std::vector<T> (Field = std::vector<double>)
pfc::Model model(world, std::move(fft));
model.add_real_field("density");
// Get field data
auto& field_data = model.get_real_field("density");
// Create DiscreteField wrapper for coordinate-aware operations
auto inbox = pfc::fft::get_inbox(model.get_fft());
{inbox.high[0] - inbox.low[0] + 1,
inbox.high[1] - inbox.low[1] + 1,
inbox.high[2] - inbox.low[2] + 1},
{inbox.low[0], inbox.low[1], inbox.low[2]},
pfc::world::get_origin(world),
pfc::world::get_spacing(world)
);
// Initialize using DiscreteField's apply()
discrete_field.apply([](double x, double y, double z) {
return std::sin(x);
});
// Copy data back to Model
field_data = discrete_field.get_data();
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