MoCSI API Reference
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
GenericSubmodule< T > Class Template Referenceabstract

Abstract base class for the submodules. Submodules are below managing modules and will only be run by them, not directly from the sim class. They can neither create fields (only access the local fields of their managing modules) nor alter elements in the sim class (they only posses a pointer to const). They can however also have an arbitrary number of submodules that they can execute themself when called. Their structure is otherwise a direct mirror of the managing modules. More...

#include <GenericSubmodule.h>

Inheritance diagram for GenericSubmodule< T >:
Inheritance graph
Collaboration diagram for GenericSubmodule< T >:
Collaboration graph

Public Member Functions

 GenericSubmodule ()
 Constructor without arguments. Will be employed when using the static modules registry.
 
virtual ~GenericSubmodule ()=default
 
 GenericSubmodule (const SimulationClassBase< T > *l_sim)
 Constructor to be preferably used when a module is created during runtime.
 
virtual bool setup (std::vector< std::shared_ptr< GenericSubmodule< T > > > all_submodules)
 
virtual bool exec (std::string_view param)=0
 
virtual bool init ()
 
virtual bool preTimeStep ()
 
virtual bool postTimeStep ()
 
virtual bool postNonLinIter ()
 
virtual bool output ()
 
virtual std::vector< std::string > getDependencies () const
 
std::vector< std::string > getSubmoduleList () const
 
bool isSetUp ()
 
void submodulesSetUp ()
 
virtual std::string_view getNameLocal () const =0
 
virtual void setFieldPtr (std::shared_ptr< std::valarray< T > > field_ptr)
 
void setSimPointer (SimulationClassBase< T > *sim)
 Setter function for the sim pointer. As the module is usually registered during static initialization when the sim class is not yet existing, this function is needed to set the pointer.
 
void setSubmodules (std::vector< std::shared_ptr< GenericSubmodule< T > > > all_submodules)
 Sets all the submodules of this module into their corresponding chains. Also sets their field-pointers to the field pointer of the managing module as a way to communicate between submodules.
 
void writeToGlobalIniContent (std::ofstream &global_stream)
 Function that writes the local ini file contents to the global ini file stream. "Tags" the keys with the name of the module in the format "module_name$key".
 
void overwriteLocalIniContent (const std::unordered_map< std::string, std::any > &global_ini_content)
 Writes the (already trimmed to the local content) data from the global ini file to the local ini file. This only overwrites the internal data and not the file contents itself.
 

Protected Attributes

ChainManager< GenericSubmodule< T > > sub_module_chain
 
std::shared_ptr< std::valarray< T > > module_field
 
const SimulationClassBase< T > * sim {}
 
std::vector< std::string > m_generic_submodules
 
InputManager ini_file_data
 
bool in_snapshot {false}
 
bool in_output {false}
 
char field_id
 
bool is_set_up {false}
 

Detailed Description

template<typename T>
class GenericSubmodule< T >

Abstract base class for the submodules. Submodules are below managing modules and will only be run by them, not directly from the sim class. They can neither create fields (only access the local fields of their managing modules) nor alter elements in the sim class (they only posses a pointer to const). They can however also have an arbitrary number of submodules that they can execute themself when called. Their structure is otherwise a direct mirror of the managing modules.

Constructor & Destructor Documentation

◆ GenericSubmodule() [1/2]

template<typename T >
GenericSubmodule< T >::GenericSubmodule ( )
inline

Constructor without arguments. Will be employed when using the static modules registry.

◆ ~GenericSubmodule()

template<typename T >
virtual GenericSubmodule< T >::~GenericSubmodule ( )
virtualdefault

◆ GenericSubmodule() [2/2]

Constructor to be preferably used when a module is created during runtime.

Parameters
l_simThe pointer to the sim class.

Member Function Documentation

◆ exec()

template<typename T >
virtual bool GenericSubmodule< T >::exec ( std::string_view  param)
pure virtual

◆ getDependencies()

template<typename T >
virtual std::vector< std::string > GenericSubmodule< T >::getDependencies ( ) const
inlinevirtual

◆ getNameLocal()

template<typename T >
virtual std::string_view GenericSubmodule< T >::getNameLocal ( ) const
pure virtual

◆ getSubmoduleList()

template<typename T >
std::vector< std::string > GenericSubmodule< T >::getSubmoduleList ( ) const
inline

◆ init()

template<typename T >
virtual bool GenericSubmodule< T >::init ( )
inlinevirtual

◆ isSetUp()

template<typename T >
bool GenericSubmodule< T >::isSetUp ( )
inline

◆ output()

template<typename T >
virtual bool GenericSubmodule< T >::output ( )
inlinevirtual

◆ overwriteLocalIniContent()

template<typename T >
void GenericSubmodule< T >::overwriteLocalIniContent ( const std::unordered_map< std::string, std::any > &  global_ini_content)
inline

Writes the (already trimmed to the local content) data from the global ini file to the local ini file. This only overwrites the internal data and not the file contents itself.

Parameters
global_ini_contentThe map containing the local partition of this module within the global ini file.

◆ postNonLinIter()

template<typename T >
virtual bool GenericSubmodule< T >::postNonLinIter ( )
inlinevirtual

◆ postTimeStep()

template<typename T >
virtual bool GenericSubmodule< T >::postTimeStep ( )
inlinevirtual

◆ preTimeStep()

template<typename T >
virtual bool GenericSubmodule< T >::preTimeStep ( )
inlinevirtual

◆ setFieldPtr()

template<typename T >
virtual void GenericSubmodule< T >::setFieldPtr ( std::shared_ptr< std::valarray< T > >  field_ptr)
inlinevirtual

◆ setSimPointer()

template<typename T >
void GenericSubmodule< T >::setSimPointer ( SimulationClassBase< T > *  sim)
inline

Setter function for the sim pointer. As the module is usually registered during static initialization when the sim class is not yet existing, this function is needed to set the pointer.

◆ setSubmodules()

template<typename T >
void GenericSubmodule< T >::setSubmodules ( std::vector< std::shared_ptr< GenericSubmodule< T > > >  all_submodules)
inline

Sets all the submodules of this module into their corresponding chains. Also sets their field-pointers to the field pointer of the managing module as a way to communicate between submodules.

◆ setup()

template<typename T >
virtual bool GenericSubmodule< T >::setup ( std::vector< std::shared_ptr< GenericSubmodule< T > > >  all_submodules)
inlinevirtual

◆ submodulesSetUp()

template<typename T >
void GenericSubmodule< T >::submodulesSetUp ( )
inline

◆ writeToGlobalIniContent()

template<typename T >
void GenericSubmodule< T >::writeToGlobalIniContent ( std::ofstream &  global_stream)
inline

Function that writes the local ini file contents to the global ini file stream. "Tags" the keys with the name of the module in the format "module_name$key".

Parameters
global_streamThe outstream containing all ini file data.

Member Data Documentation

◆ field_id

template<typename T >
char GenericSubmodule< T >::field_id
protected
Initial value:
{
'?'}

◆ in_output

template<typename T >
bool GenericSubmodule< T >::in_output {false}
protected

◆ in_snapshot

template<typename T >
bool GenericSubmodule< T >::in_snapshot {false}
protected

◆ ini_file_data

template<typename T >
InputManager GenericSubmodule< T >::ini_file_data
protected

◆ is_set_up

template<typename T >
bool GenericSubmodule< T >::is_set_up {false}
protected

◆ m_generic_submodules

template<typename T >
std::vector<std::string> GenericSubmodule< T >::m_generic_submodules
protected

◆ module_field

template<typename T >
std::shared_ptr<std::valarray<T> > GenericSubmodule< T >::module_field
protected

◆ sim

template<typename T >
const SimulationClassBase<T>* GenericSubmodule< T >::sim {}
protected

◆ sub_module_chain

template<typename T >
ChainManager<GenericSubmodule<T> > GenericSubmodule< T >::sub_module_chain
protected
Initial value:
{
"global"}

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