NLMech  0.1.0
inp::Policy Class Reference

A class to enforce certain policies to reduce memory loads. More...

#include <policy.h>

Collaboration diagram for inp::Policy:
Collaboration graph

Public Member Functions

Setter method
void addToTags (const size_t &level, const std::string &tag)
 Adds tag to specified level tag list. More...
 
void removeTag (const std::string &tag)
 Looks for tag in the level d_memControlFlag and if present removes it. More...
 
Getter method
bool populateData (const std::string &tag)
 Returns true/false depending on whether tag is found. More...
 
int getMemoryControlFlag ()
 Returns memory control flag. More...
 
bool enablePostProcessing ()
 Returns true if post-processing computation is to be done. More...
 

Static Public Member Functions

static void destroyInstance ()
 Destroys the instance.
 
static PolicygetInstance (inp::PolicyDeck *deck=nullptr)
 Returns the pointer to static class. Creates instance in its first call. More...
 

Private Member Functions

void init ()
 Initializes the data.
 
const Policyoperator= (const Policy &)
 Private copy operator. More...
 
 Policy (inp::PolicyDeck *deck=nullptr)
 Private constructor. More...
 
 Policy (Policy const &)
 Private operator.
 
 ~Policy ()
 Private destructor.
 

Private Attributes

bool d_enablePostProcessing
 Enable post-processing calculation. More...
 
std::vector< std::vector< std::string > > d_lTags
 List of variable names in different levels to help enforce the memory control.
 
size_t d_maxLevel
 Specify maximum level of memory control.
 
int d_memControlFlag
 Flag which indicates level of memory control to be enforced. More...
 
std::string d_modelTag
 Specify model tag.
 

Static Private Attributes

static Policyd_instance_p = nullptr
 Static instance of Policy class.
 

Detailed Description

A class to enforce certain policies to reduce memory loads.

We implement simple method to control population of data in simulation. Implementation can be made specific to particular model by simply assigning a tag to d_modelTag and defining a new rule for the tag in the inp::Policy::init.

For a given memory control flag i (can be 0,1,2,3), we look at the list of tags in inp::Policy::d_lTags to know whether we populate the data (given by tag, e.g. tag for data d_u in model::Model is Model_g_u) in the simulation. If it is in the list inp::Policy::d_lTags[i] then we do not populate this data in the simulation.

inp::Policy::d_lTags data is created in init() which is called when the getInstance() is invoked for the first time.

Note
If inp::Policy::d_enablePostProcessing is set to false then no postprocessing calculation will be carried out and no postprocessing data will be populated. So in a way inp::Policy::d_enablePostProcessing = false acts as strictest control.
Todo:
Modify constructor and getInstance() to set d_modelTag.

Constructor & Destructor Documentation

◆ Policy()

inp::Policy::Policy ( inp::PolicyDeck deck = nullptr)
explicitprivate

Private constructor.

Parameters
deckInput deck which contains user-specified information
Here is the call graph for this function:

Member Function Documentation

◆ addToTags()

void inp::Policy::addToTags ( const size_t &  level,
const std::string &  tag 
)

Adds tag to specified level tag list.

Parameters
levelLevel of tag list
tagTag to be appended to list

Referenced by fe::Mesh::Mesh().

Here is the caller graph for this function:

◆ enablePostProcessing()

bool inp::Policy::enablePostProcessing ( )

Returns true if post-processing computation is to be done.

Returns
Flag

◆ getInstance()

inp::Policy * inp::Policy::getInstance ( inp::PolicyDeck deck = nullptr)
static

Returns the pointer to static class. Creates instance in its first call.

Parameters
deckInput deck which contains user-specified information
Returns
Policy instance of static class Policy

Referenced by fe::Mesh::createData(), model::FDModel< T >::FDModel(), fe::MassMatrix::MassMatrix(), fe::Mesh::Mesh(), and model::Output::Output().

Here is the caller graph for this function:

◆ getMemoryControlFlag()

int inp::Policy::getMemoryControlFlag ( )

Returns memory control flag.

Returns
Flag

◆ operator=()

const Policy& inp::Policy::operator= ( const Policy )
private

Private copy operator.

Returns
Policy object after copying

◆ populateData()

bool inp::Policy::populateData ( const std::string &  tag)

Returns true/false depending on whether tag is found.

Parameters
tagTag to search for
Returns
bool True if it can be populated, false otherwise

◆ removeTag()

void inp::Policy::removeTag ( const std::string &  tag)

Looks for tag in the level d_memControlFlag and if present removes it.

Parameters
tagTag to be appended to list

Field Documentation

◆ d_enablePostProcessing

bool inp::Policy::d_enablePostProcessing
private

Enable post-processing calculation.

Default is true.

Referenced by Policy().

◆ d_memControlFlag

int inp::Policy::d_memControlFlag
private

Flag which indicates level of memory control to be enforced.

Default is 0 which means no control. Max at present is 2 which means as much control as possible.

Referenced by Policy().


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