OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::Model Class Referenceabstract

The Model class represents the physics model for simulations in OpenPFC. More...

#include <model.hpp>

Inheritance diagram for pfc::Model:

Public Member Functions

 ~Model ()
 Destroy the Model object.
 
 Model (FFT &fft, const World &world)
 
 Model (const Model &)=delete
 Disable copy constructor.
 
Modeloperator= (const Model &)=delete
 Disable copy assignment operator.
 
bool is_rank0 () const noexcept
 Check if current MPI rank is 0.
 
const Worldget_world () const noexcept
 Get the decomposition object associated with the model.
 
FFTget_fft () noexcept
 
virtual void step (double t)=0
 
virtual void initialize (double dt)=0
 
virtual size_t get_allocated_memory_bytes () const
 
bool has_real_field (std::string_view field_name) const noexcept
 Check if the model has a real-valued field with the given name.
 
void add_real_field (std::string_view name, RealField &field)
 
bool has_complex_field (std::string_view field_name) const noexcept
 
void add_complex_field (std::string_view name, ComplexField &field)
 
RealField & get_real_field (std::string_view name)
 
const RealField & get_real_field (std::string_view name) const
 Retrieve a registered real-valued field by name (const version)
 
ComplexField & get_complex_field (std::string_view name)
 
const ComplexField & get_complex_field (std::string_view name) const
 Retrieve a registered complex-valued field by name (const version)
 
void add_field (const std::string &name, RealField &field)
 Add a field to the model.
 
void add_field (const std::string &name, ComplexField &field)
 Add a field to the model.
 
bool has_field (std::string_view field_name) const noexcept
 
virtual Field & get_field ()
 Get a reference to the default primary unknown field.
 

Detailed Description

The Model class represents the physics model for simulations in OpenPFC.

The Model class is responsible for introducing the physics to the simulation model. Users can override the initialize and step functions to define their own functionality and implement specific physics for their simulations.

The initialize function is called at the beginning of the simulation and is used to allocate arrays, pre-calculate operators used in time integration, and perform other necessary initialization tasks.

The step function is called sequentially during the time integration process. OpenPFC currently uses a semi-implicit time integration scheme, where the linear part is solved implicitly and the non-linear part is solved explicitly.

Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/utils/field_iteration.hpp, 03_simulator_workflow.cpp, 04_diffusion_model.cpp, 05_simulator.cpp, Accessing, Integration, and Space-time.

Member Function Documentation

◆ add_field() [1/2]

void pfc::Model::add_field ( const std::string &  name,
ComplexField &  field 
)
inline

Add a field to the model.

Parameters
nameName of the field
fieldReference to the ComplexField object representing the field

◆ add_field() [2/2]

void pfc::Model::add_field ( const std::string &  name,
RealField &  field 
)
inline

Add a field to the model.

Parameters
nameName of the field
fieldReference to the RealField object representing the field
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/model.hpp.

◆ get_complex_field()

const ComplexField & pfc::Model::get_complex_field ( std::string_view  name) const
inline

Retrieve a registered complex-valued field by name (const version)

Returns a const reference to a previously registered complex field for reading.

Parameters
nameName of the field to retrieve
Returns
Const reference to the ComplexField object
Exceptions
std::out_of_rangeif field name not registered
See also
get_complex_field() for non-const version

◆ get_field()

virtual Field & pfc::Model::get_field ( )
inlinevirtual

Get a reference to the default primary unknown field.

This is deprecated function and will likely be removed in future.

Returns
Reference to the RealField called "default"
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/model.hpp, and /home/runner/work/OpenPFC/OpenPFC/include/openpfc/simulator.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_real_field()

const RealField & pfc::Model::get_real_field ( std::string_view  name) const
inline

Retrieve a registered real-valued field by name (const version)

Returns a const reference to a previously registered field for reading.

Parameters
nameName of the field to retrieve
Returns
Const reference to the RealField object
Exceptions
std::out_of_rangeif field name not registered
See also
get_real_field() for non-const version

◆ get_world()

const World & pfc::Model::get_world ( ) const
inlinenoexcept

Get the decomposition object associated with the model.

Returns
Reference to the Decomposition object

Get the world object associated with the model.

Returns
Reference to the World object
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/model.hpp, /home/runner/work/OpenPFC/OpenPFC/include/openpfc/simulator.hpp, /home/runner/work/OpenPFC/OpenPFC/include/openpfc/utils/field_iteration.hpp, 03_simulator_workflow.cpp, 04_diffusion_model.cpp, 05_simulator.cpp, and Space-time.
Here is the caller graph for this function:

◆ has_real_field()

bool pfc::Model::has_real_field ( std::string_view  field_name) const
inlinenoexcept

Check if the model has a real-valued field with the given name.

Parameters
field_nameName of the field to check
Returns
True if the field exists, False otherwise
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/model.hpp.
Here is the caller graph for this function:

◆ initialize()

virtual void pfc::Model::initialize ( double  dt)
pure virtual

◆ is_rank0()

bool pfc::Model::is_rank0 ( ) const
inlinenoexcept

Check if current MPI rank is 0.

Useful for conditional output (only rank 0 prints).

Returns
true if rank is 0, false otherwise
Note
This function is thread-safe and has zero overhead (inline)
if (model.is_rank0()) {
std::cout << "Status message\n";
}
Represents the global simulation domain (the "world").
Definition world.hpp:91
Examples
/home/runner/work/OpenPFC/OpenPFC/include/openpfc/model.hpp, /home/runner/work/OpenPFC/OpenPFC/include/openpfc/simulator.hpp, 03_simulator_workflow.cpp, 04_diffusion_model.cpp, and 05_simulator.cpp.
Here is the caller graph for this function:

◆ step()

virtual void pfc::Model::step ( double  t)
pure virtual

Implemented in PFCModel, and Diffusion.


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