BioDynaMo  v1.05.120-25dc9790
Public Member Functions | Private Member Functions | Private Attributes | List of all members
bdm::Continuum Class Referenceabstract

Continuum class to interface with BioDynaMo for hybrid simulations. More...

#include <continuum_interface.h>

Inheritance diagram for bdm::Continuum:
[legend]
Collaboration diagram for bdm::Continuum:
[legend]

Public Member Functions

 Continuum ()=default
 
 Continuum (const TRootIOCtor *)
 
virtual ~Continuum ()=default
 
void IntegrateTimeAsynchronously (real_t dt)
 
virtual void Initialize ()=0
 
virtual void Update ()=0
 
virtual void Step (real_t dt)=0
 
int GetContinuumId () const
 Returns the ID of the continuum. More...
 
void SetContinuumId (int id)
 Sets the ID of the continuum. More...
 
const std::string & GetContinuumName () const
 Returns the name of the continuum. More...
 
void SetContinuumName (const std::string &name)
 Sets the name of the continuum. More...
 
real_t GetSimulatedTime () const
 Returns the time simulated by the continuum. More...
 
void SetTimeStep (real_t dt)
 
real_t GetTimeStep () const
 Returns the time step for the continuum. More...
 

Private Member Functions

 BDM_CLASS_DEF (Continuum, 1)
 

Private Attributes

std::string continuum_name_ = ""
 Name of the continuum. More...
 
real_t time_step_ = std::numeric_limits<real_t>::max()
 
real_t simulated_time_ = 0.0
 Passed simulation time for the continuum. More...
 
real_t time_to_simulate_ = 0.0
 Time that the continuum (still) has to integrate. More...
 
int continuum_id_ = -1
 Id of the continuum. More...
 

Detailed Description

Continuum class to interface with BioDynaMo for hybrid simulations.

This class is used to interface arbitrary Continuum implementations with BioDynaMo. The continuum may be a single- or multi-threaded, or possibly even a GPU implementation. Furthermore, it can be of arbitrary dimension. We provide more specific interfaces for scalar and vector fields (see ScalarField and VectorField). The interface is pure virtual, thus, the user must implement the methods (Initialize, Update, Step) in the derived class. The DiffusionGrid class is an example of such a derived class implementing a continuum (scalar field) via a finite difference discretization for the diffusion equation. Another example is given in the demo analytic_continuum which attaches an analytic scalar field to the simulation.

The class is included into the BioDynaMo simulation scheme through the ContinuumOp class. This class is a stand-alone operation, i.e., it is called once per simulation step (if its frequency is 1). This call to the ContinuumOp::operator() method triggers the execution of the IntegrateTimeAsynchronously method, which in turn calls the Step method with appropriate time step(s). Note that there are two options to influence the synchronisation of the simulation: the frequency of the ContinuumOp and the time step of the Continuum. The former defines the synchronization frequency between ABM and the continuum. The latter defines the time step of the continuum. Note that the scheduler passes a time step of 0 to the ContinuumOp in the first simulation step, which does not call back to Step in this case. Thus, Step() is called in the second time step the earliest (later for higher frequencies).

Definition at line 52 of file continuum_interface.h.

Constructor & Destructor Documentation

◆ Continuum() [1/2]

bdm::Continuum::Continuum ( )
default

◆ Continuum() [2/2]

bdm::Continuum::Continuum ( const TRootIOCtor *  )
inlineexplicit

Definition at line 55 of file continuum_interface.h.

◆ ~Continuum()

virtual bdm::Continuum::~Continuum ( )
virtualdefault

Member Function Documentation

◆ BDM_CLASS_DEF()

bdm::Continuum::BDM_CLASS_DEF ( Continuum  ,
 
)
private

◆ GetContinuumId()

int bdm::Continuum::GetContinuumId ( ) const
inline

Returns the ID of the continuum.

Definition at line 87 of file continuum_interface.h.

◆ GetContinuumName()

const std::string& bdm::Continuum::GetContinuumName ( ) const
inline

Returns the name of the continuum.

Definition at line 93 of file continuum_interface.h.

◆ GetSimulatedTime()

real_t bdm::Continuum::GetSimulatedTime ( ) const
inline

Returns the time simulated by the continuum.

Definition at line 99 of file continuum_interface.h.

◆ GetTimeStep()

real_t bdm::Continuum::GetTimeStep ( ) const

Returns the time step for the continuum.

Definition at line 60 of file continuum_interface.cc.

◆ Initialize()

virtual void bdm::Continuum::Initialize ( )
pure virtual

Initializes the continuum. This method is called via Scheduler::Initialize. For some implementations, this method may be useful, other may not require it. A possibly use case is that agents move in a stationary continuum that is the solution to a timeindependent PDE. In this case, the Initialize method could be used to solve the PDE once at the beginning of the simulation.

Implemented in bdm::DiffusionGrid.

◆ IntegrateTimeAsynchronously()

void bdm::Continuum::IntegrateTimeAsynchronously ( real_t  dt)

Manages the time evolution of the continuum. The method is called by the ContinuumOp::operator() method. The method calls the Step method with the appropriate time step(s) as defined via the time_step_ member. If the time step is not set, dt is used.

Definition at line 22 of file continuum_interface.cc.

◆ SetContinuumId()

void bdm::Continuum::SetContinuumId ( int  id)
inline

Sets the ID of the continuum.

Definition at line 90 of file continuum_interface.h.

◆ SetContinuumName()

void bdm::Continuum::SetContinuumName ( const std::string &  name)
inline

Sets the name of the continuum.

Definition at line 96 of file continuum_interface.h.

◆ SetTimeStep()

void bdm::Continuum::SetTimeStep ( real_t  dt)

Sets the (max.) time step for the continuum time integration with Step. The way that the time step is treated in the IntegrateTimeAsynchronously call suggests to use dt > 1e-6 (real_t = float) or dt > 1e-8 (real_t = double).

Definition at line 58 of file continuum_interface.cc.

◆ Step()

virtual void bdm::Continuum::Step ( real_t  dt)
pure virtual

This method integrates the continuum model in time by dt. Typically, the continuum is the solution of a partial differential equation (PDE). Thus, the step method is used to advance the solution in time. If your numerical scheme has requirements for it's parameters depending on dt, make sure to verify them in this method.

Implemented in bdm::DiffusionGrid.

◆ Update()

virtual void bdm::Continuum::Update ( )
pure virtual

Updates the continuum. Since this method is public, it can be called form anyone and trigger an update of the continuum model. We envision that this can be used for mesh refinements or for other purposes. The DiffusionGrid, for instance, reconstructs the grid under certain conditions with this member function.

Implemented in bdm::DiffusionGrid.

Member Data Documentation

◆ continuum_id_

int bdm::Continuum::continuum_id_ = -1
private

Id of the continuum.

Definition at line 126 of file continuum_interface.h.

◆ continuum_name_

std::string bdm::Continuum::continuum_name_ = ""
private

Name of the continuum.

Definition at line 112 of file continuum_interface.h.

◆ simulated_time_

real_t bdm::Continuum::simulated_time_ = 0.0
private

Passed simulation time for the continuum.

Definition at line 120 of file continuum_interface.h.

◆ time_step_

real_t bdm::Continuum::time_step_ = std::numeric_limits<real_t>::max()
private

Time step of the continuum (may differ from the simulation time step). If not set, the implementation defaults to stepping with simulation_time_step * continuum_op->frequency_.

Definition at line 117 of file continuum_interface.h.

◆ time_to_simulate_

real_t bdm::Continuum::time_to_simulate_ = 0.0
private

Time that the continuum (still) has to integrate.

Definition at line 123 of file continuum_interface.h.


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