Simulation

Typedefs

using simu_callback_t = SimulationBase *(*)(SettingManager *stg_mgr, MPI_Comm mpicomm)

Static constructor signature for simulation factory.

Functions

template<typename cons_t>
Simulation<cons_t> *get_simu(p4est_t *p4est)

Generic getter to obtain a pointer to the simulation from p4est

Parameters:

p4est[in]

class SimulationBase
#include “Simulation.h”

Base class for the creation of a canoP simulation.

Contains the time stepping integration procedure and the p4est_iterate loops to perform the numerical scheme independently of the quadrant data (qdata) in each leaf of the AMR trees. Collect performance (timing) and monitoring (statistics) information. A real simulation should derived from this class, to define the qdata and adapt the time loop and p4est_iterate loops if needed.

Subclassed by Simulation< cons_t >

getters

getters to get needed stg/p4est objects and ghost_qdata

inline SettingManager *get_stg_mgr()
inline AmrManager *get_amr_mgr()
inline p4est_t *get_p4est()
inline p4est_ghost_t *get_ghost()
inline p4est_mesh_t *get_mesh()
inline p4est_wrap_t *get_wrap()
virtual void *get_ghost_qdata_ptr() = 0

setters

setters to set pointers to p4est/simu ans size of ghost_qdata

inline void set_p4est_io_mgr()
inline void set_simu_amr_mgr()
virtual void set_ghost_qdata_size(int size) = 0

Time loop operations

They may be overriden in a derived simulation class

int restarted()

Check if the simulation has been restarted.

void initial_refinement()

Perform initial refinement.

int finished()

Check if current time is larger than end time.

void compute_time_step()

Compute the allowed time step.

void next_iteration()

Perform the scheme with p4est_iterate loops.

int should_adapt()

Provides a strategy to decide when to adapt.

void adapt(int initial_refine)

Perform amr cycle operations.

int should_write()

Decides if the simulation should dump data.

void write_restart_file()

Write restart file using internal p4est format.

void write_statistics()

collect and write statistics if enabled

virtual void write_output_file() = 0

dump solution to file (need qdata)

Public Functions

SimulationBase(SettingManager *stg_mgr, MPI_Comm mpicomm, int qdata_t_sizeof)

We need to pass here qdata size, because p4est is initialized in amr_mgr constructor the actual qdata_t is a template parameter only known in derived concrete simulation class.

Parameters:
  • stg_mgr[in] a SettingManager object (to parse input setting file)

  • mpicomm[in] MPI communicator

  • qdata_t_sizeof[in] size of qdata_t hold by each p4est quadrant

virtual ~SimulationBase()

Public Members

MPI_Comm m_mpicomm

MPI communicator.

SettingManager *m_stg_mgr

setting manager to handle input setting files

IoManager *m_io_mgr

io manager to handle data input/output

AmrManager *m_amr_mgr

amr manager to handle amr cycle operations

StatManager *m_stat_mgr

stat manager to gather performance statistics

std::string m_model

model (default unknown, options monofluid, bifluid5eq or bifluid7eq)

double m_tcurrent

user defined start time (default 0.0)

double m_tmax

user defined maximum time (default 1.0)

double m_cfl

user defined Courant–Friedrichs–Lewy number (default 0.8)

int m_space_order

space order of the scheme (MUSCL, default 1, options 1 or 2)

int m_time_order

time order of the scheme (Hancock, default 1, options 1 or 2)

double m_t

the time at the current iteration

double m_dt
int m_iteration

the time step at the current level

the current iteration

p4est_gloidx_t m_total_num_cell_update

nb of cell update

Factory<void, iv_callback_t> iv_factory

Factory containing callback operations for p4est_iterate on cell volumes.

Factory<void, if_callback_t> if_factory

Factory containing callback operations for p4est_iterate on cell faces.

template<typename cons_t>
class Simulation : public SimulationBase
#include “Simulation.h”

Prototype derived class for the creation of a canoP simulation.

This derived class is a prototype for a set of conservative variables. Primitive variables prim_t, the quadrant data qdata_t and the parameters param_t are deduced from cons_t (see Qdata.h). This class contains operations that requires the existence of a qdata. The template parameter cons_t will be specialized as a function of the simulation type.

factories

factories storing the different callbackes

Factory<qdata_t, hf_callback_t> m_hf_factory
Factory<qdata_t, df_callback_t> m_df_factory
Factory<qdata_t, st_callback_t> m_st_factory
Factory<qdata_t, ic_callback_t> m_ic_factory
Factory<qdata_t, bc_callback_t> m_bc_factory
Factory<qdata_t, rc_callback_t> m_rc_factory
Factory<void, sl_callback_t> m_sl_factory

callback-functions

callback functions that are chosen from settings inside factories

ic_callback_t m_ic_fn

initial condition callback

bc_callback_t m_bc_fn

boundary condition callback

rc_callback_t m_rc_fn

refine condition callback

sl_callback_t m_sl_fn

scalar limiter callback

hf_callback_t m_hf_fn

user hyperbolic flux callback

df_callback_t m_df_fn

user diffusion flux callback

st_callback_t m_st_fn

user source term callback

hf_callback_t m_hydro_fn

hydrodynamics flux callback

df_callback_t m_cond_fn

conductivity flux callback

df_callback_t m_visc_fn

viscosity flux callback

st_callback_t m_grav_fn

gravity source term callback

st_callback_t m_prelax_fn

pressure relaxation callback (for bifluid7eq)

st_callback_t m_vrelax_fn

velocity relaxation callback (for bifluid7eq)

getters

getters to get needed objects from qdata manager/ghost

inline QdataManager<cons_t> *get_qdata_mgr()
inline virtual void *get_ghost_qdata_ptr()
inline qdata_t *get_ghost_qdata()

setters

setters to set replace_fn, callbacks and iterators

inline void set_replace_fn_amr_mgr()
inline virtual void set_ghost_qdata_size(int size)
void set_iterator_volume()

set_iterator_volume register volume iterators into iv_factory

void set_iterator_face()

set_iterator_face register face iterators into if_factory

void set_callback()

Public Functions

Simulation(SettingManager *stg_mgr, MPI_Comm mpicomm)

The constructor checks if cons_t contains only double to allow for loops on variables inside cons_t.

Template Parameters:

cons_t – a type with a set of conservative variables

Parameters:
  • stg_mgr[in] a SettingManager object (to parse input setting file)

  • mpicomm[in] MPI communicator

~Simulation()
virtual void write_output_file()

dump solution to file (need qdata)

inline void register_user_callback()

Public Members

QdataManager<cons_t> *m_qdata_mgr

qdata manager to handle operations \

on data stored in a p4est quadrant std::vector< qdata_t > m_ghost_qdata

ghost qdata for MPI partition

std::string m_initial_condition

initial condition callback (default none)

std::string m_boundary_condition

boundary condition callback (default none)

std::string m_refine_condition

refine condition callback (default none)

std::string m_scalar_limiter

scalar limiter callback (default minmod)

std::string m_hyperbolic_flux

user-defined hyperbolic flux callback (default none)

std::string m_diffusion_flux

user-defined diffusion flux callback (default none)

std::string m_source_term

user-defined source term callback (default none)

std::string m_hydrodynamics_flux

hydrodynamics flux callback (default none)

std::string m_conductivity_flux

conductivity flux callback (default none)

std::string m_viscosity_flux

viscosity flux callback (default none)

std::string m_gravity_term

gravity source term callback (default none)

std::string m_pressure_relaxation_term

pressure relaxation callback (for bifluid7eq, default none)

std::string m_velocity_relaxation_term

velocity relaxation callback (for bifluid7eq, default none)

Public Static Functions

static inline specific app SimulationBase * create (SettingManager *stg_mgr, MPI_Comm mpicomm)

user callbacks defined in a \

Static wrapper around the constructor to provide a factory with the different simulation type constructors

Template Parameters:

cons_t – a type with a set of conservative variables

Parameters:
  • stg_mgr[in] a SettingManager object (to parse input setting file)

  • mpicomm[in] MPI communicator

Private Types

using prim_t = to_prim_t<cons_t>
using qdata_t = to_qdata_t<cons_t>
using param_t = to_param_t<cons_t>
using ic_callback_t = to_ic_callback_t<qdata_t>
using bc_callback_t = to_bc_callback_t<qdata_t>
using rc_callback_t = to_rc_callback_t<qdata_t>
using hf_callback_t = to_hf_callback_t<cons_t>
using st_callback_t = to_st_callback_t<cons_t>
using df_callback_t = to_df_callback_t<cons_t>