MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn > Class Template Reference

Front-end to create source term objects. More...

#include <lbsrctermcontroller.h>

Collaboration diagram for maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >:
[legend]

Public Member Functions

void reg_function (const MString &p_name, srcTermConstructor fact_function)
 Adds a new LbSrcTerm object to the function registry. More...
 
LbSrcTerm< nDim, nDist, SysEqn > * create_srcTerm (const MString &p_name, LbSolverDxQy< nDim, nDist, SysEqn > *p_solver)
 Create an lb source term object and return a pointer to it. More...
 

Static Public Member Functions

static LbSrcTermFactoryinstance ()
 Creates a static instance of LbSrcTermFactory. More...
 

Private Types

using srcTermConstructor = std::function< LbSrcTerm< nDim, nDist, SysEqn > *(LbSolverDxQy< nDim, nDist, SysEqn > *)>
 

Private Member Functions

 LbSrcTermFactory ()
 

Private Attributes

std::map< std::string, srcTermConstructorm_function_reg
 

Detailed Description

template<MInt nDim, MInt nDist, class SysEqn>
class maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >
Author
Miro Gondrum
Date
01.02.2022

This class holds a list (function_reg) where all source terms are automatically registered if they are derived from LbSrcTerm and include in their implementation the line:

static LbRegSrcTerm<LbSrcTermNAME> reg("unique_srcTerm_name");

To create a new source term, simply copy one of the existing ones and change the name. It will be found automatically, no includes are necessary.

Definition at line 47 of file lbsrctermcontroller.h.

Member Typedef Documentation

◆ srcTermConstructor

template<MInt nDim, MInt nDist, class SysEqn >
using maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::srcTermConstructor = std::function<LbSrcTerm<nDim, nDist, SysEqn>*(LbSolverDxQy<nDim, nDist, SysEqn>*)>
private

Definition at line 48 of file lbsrctermcontroller.h.

Constructor & Destructor Documentation

◆ LbSrcTermFactory()

template<MInt nDim, MInt nDist, class SysEqn >
maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::LbSrcTermFactory ( )
inlineprivate

Definition at line 75 of file lbsrctermcontroller.h.

75{};

Member Function Documentation

◆ create_srcTerm()

template<MInt nDim, MInt nDist, class SysEqn >
LbSrcTerm< nDim, nDist, SysEqn > * maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::create_srcTerm ( const MString p_name,
LbSolverDxQy< nDim, nDist, SysEqn > *  p_solver 
)
Author
Miro Gondrum
Date
01.02.2022
Parameters
[in]p_namename of the source term (as stored in the registry)
Returns
Pointer to the source term object

Definition at line 22 of file lbsrctermcontroller.cpp.

23 {
24 LbSrcTerm<nDim, nDist, SysEqn>* instance = nullptr;
25 auto it = m_function_reg.find(p_name);
26 if(it != m_function_reg.end()) {
27 // call constructor with relevant input args
28 instance = it->second(p_solver);
29 } else {
30 std::stringstream ss;
31 ss << "lbSrcTerms: " << p_name << " is not defined!" << std::endl;
32 ss << "Defined are the following lbSrcTerm for d" << nDim << "q" << nDist << ": " << std::endl;
33 for(const auto& i : m_function_reg) {
34 ss << " " << i.first << std::endl;
35 }
36 TERMM(1, ss.str());
37 }
38 return instance;
39}
static LbSrcTermFactory * instance()
Creates a static instance of LbSrcTermFactory.
std::map< std::string, srcTermConstructor > m_function_reg

◆ instance()

template<MInt nDim, MInt nDist, class SysEqn >
LbSrcTermFactory< nDim, nDist, SysEqn > * maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::instance
static
Author
Miro Gondrum
Date
01.02.2022
Returns
Pointer to a static instance of LbSrcTermFactory

Definition at line 15 of file lbsrctermcontroller.cpp.

15 {
16 static LbSrcTermFactory<nDim, nDist, SysEqn> fact;
17 return &fact;
18}

◆ reg_function()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::reg_function ( const MString p_name,
srcTermConstructor  fact_function 
)
inline
Author
Miro Gondrum
Date
01.02.2022
Parameters
[in]p_nameThe name of the source term
[in]fact_functionThe source term constructor

Definition at line 64 of file lbsrctermcontroller.h.

64{ m_function_reg[p_name] = fact_function; }

Member Data Documentation

◆ m_function_reg

template<MInt nDim, MInt nDist, class SysEqn >
std::map<std::string, srcTermConstructor> maia::lb::LbSrcTermFactory< nDim, nDist, SysEqn >::m_function_reg
private

data structure to associate srcTerm names with their implementations

Definition at line 76 of file lbsrctermcontroller.h.


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