GRINS-0.8.0
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | Private Member Functions
GRINS::VariableFactoryAbstract Class Referenceabstract

#include <variable_factory.h>

Inheritance diagram for GRINS::VariableFactoryAbstract:
Inheritance graph
[legend]
Collaboration diagram for GRINS::VariableFactoryAbstract:
Collaboration graph
[legend]

Public Member Functions

 VariableFactoryAbstract (const std::string &name)
 
 ~VariableFactoryAbstract ()
 
virtual libMesh::UniquePtr< FEVariablesBasecreate ()
 Subclasses implement the actual construction of the Base object in create(). More...
 
- Public Member Functions inherited from GRINS::FactoryWithGetPot< FEVariablesBase >
 FactoryWithGetPot (const std::string &name)
 
 ~FactoryWithGetPot ()
 
- Public Member Functions inherited from GRINS::FactoryAbstract< FEVariablesBase >
virtual ~FactoryAbstract ()
 

Static Public Member Functions

static std::vector< std::string > build_var_names (const std::string &name)
 Build the variable names for the FEVariablesBase type (name), returned in the std::vector. More...
 
static std::string parse_fe_family (const std::string &name)
 
static std::string parse_fe_order (const std::string &name)
 
static void set_var_names (const std::vector< std::string > &var_names)
 Set the variable names before calling create() More...
 
static void set_var_indices (const std::vector< VariableIndex > &var_indices)
 Set the variable indices before calling create() More...
 
static void set_var_section (const std::string &var_section)
 Set the section for the input file before calling build_var_names() More...
 
static void set_subdomain_ids (const std::set< libMesh::subdomain_id_type > &subdomain_ids)
 
- Static Public Member Functions inherited from GRINS::FactoryWithGetPot< FEVariablesBase >
static void set_getpot (const GetPot &input)
 
- Static Public Member Functions inherited from GRINS::FactoryAbstract< FEVariablesBase >
static libMesh::UniquePtr< FEVariablesBasebuild (const std::string &name)
 Use this method to build objects of type Base. More...
 

Protected Member Functions

virtual void check_create_state () const
 Helper function to check required data is set when calling create() More...
 
virtual void reset_create_state ()
 Helper function to reset data before next call to create() More...
 
virtual libMesh::UniquePtr< FEVariablesBasebuild_fe_var (const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)=0
 Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices. More...
 
virtual std::vector< std::string > parse_var_names (const GetPot &input, const std::string &var_section)=0
 
virtual std::string parse_fe_family_impl (const GetPot &input, const std::string &var_section)=0
 
virtual std::string parse_fe_order_impl (const GetPot &input, const std::string &var_section)=0
 
std::string parse_var_option (const GetPot &input, const std::string &var_section, const std::string &option, const std::string &default_val) const
 
- Protected Member Functions inherited from GRINS::FactoryAbstract< FEVariablesBase >
 FactoryAbstract (const std::string &name)
 Constructor is protected. Use the build() method to construct Base objects. More...
 

Static Protected Member Functions

static void check_build_parse_state ()
 Helper function to check required data is set when calling build_* or parse_* methods. More...
 
static void reset_build_parse_state ()
 Helper function to check required data is set when calling build_* or parse_* methods. More...
 
- Static Protected Member Functions inherited from GRINS::FactoryAbstract< FEVariablesBase >
static FactoryAbstract< FEVariablesBase > & get_factory (const std::string &name)
 Helper method that looks up the factory and returns it if present, or error if it's not. More...
 
static DerivedType & get_factory_subclass (const std::string &name)
 Like get_factory, but will downcast to DerivedType. More...
 
static std::map< std::string, FactoryAbstract< FEVariablesBase > * > & factory_map ()
 

Static Protected Attributes

static const std::vector< std::string > * _var_names = NULL
 Variable component names needed for FEVariableBase construction. More...
 
static const std::vector< VariableIndex > * _var_indices = NULL
 Variable component indices needed for FEVariableBase construction. More...
 
static std::string _var_section = std::string("DIE!")
 Section of input to parse variable names in build_var_names. More...
 
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids = NULL
 Subdomain ids for the variable. More...
 
- Static Protected Attributes inherited from GRINS::FactoryWithGetPot< FEVariablesBase >
static const GetPot * _input
 We store only a raw pointer here because we can't make a copy. More...
 

Private Member Functions

 VariableFactoryAbstract ()
 

Detailed Description

Definition at line 42 of file variable_factory.h.

Constructor & Destructor Documentation

GRINS::VariableFactoryAbstract::VariableFactoryAbstract ( const std::string &  name)
inline

Definition at line 46 of file variable_factory.h.

47  : FactoryWithGetPot<FEVariablesBase>(name)
48  {}
GRINS::VariableFactoryAbstract::~VariableFactoryAbstract ( )
inline

Definition at line 50 of file variable_factory.h.

50 {};
GRINS::VariableFactoryAbstract::VariableFactoryAbstract ( )
private

Member Function Documentation

virtual libMesh::UniquePtr<FEVariablesBase> GRINS::VariableFactoryAbstract::build_fe_var ( const std::vector< std::string > &  var_names,
const std::vector< VariableIndex > &  var_indices,
const std::set< libMesh::subdomain_id_type > &  subdomain_ids 
)
protectedpure virtual

Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices.

This function will be called from within create(), which called from VariableFactoryAbstract::build. Note the var_names can be built a priori using the VariableFactoryAbstract::build_var_names() method.

Implemented in GRINS::SpeciesVariableFactory< VariableType >, and GRINS::VariableFactoryBasic< VariableType >.

Referenced by create().

std::vector< std::string > GRINS::VariableFactoryAbstract::build_var_names ( const std::string &  name)
static

Build the variable names for the FEVariablesBase type (name), returned in the std::vector.

Similarly to build(), this will grab the factory subclass and then internally call parse_var_names. set_getpot() must called before calling this method.

Definition at line 45 of file variable_factory.C.

References GRINS::FactoryWithGetPot< FEVariablesBase >::_input, _var_section, check_build_parse_state(), parse_var_names(), and reset_build_parse_state().

Referenced by GRINS::DefaultVariableBuilder::parse_var_names().

46  {
48 
49  VariableFactoryAbstract& factory = get_factory_subclass<VariableFactoryAbstract>(name);
50 
51  std::vector<std::string> var_names;
52  var_names = factory.parse_var_names( *_input, _var_section );
53 
55 
56  return var_names;
57  }
static std::string _var_section
Section of input to parse variable names in build_var_names.
static void check_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static void reset_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
void GRINS::VariableFactoryAbstract::check_build_parse_state ( )
staticprotected

Helper function to check required data is set when calling build_* or parse_* methods.

Definition at line 107 of file variable_factory.C.

References GRINS::FactoryWithGetPot< FEVariablesBase >::_input, and _var_section.

Referenced by build_var_names(), parse_fe_family(), and parse_fe_order().

108  {
109  if( !_input )
110  libmesh_error_msg("ERROR: Must call set_getpot() before calling VariableFactoryAbstract::build_var_names!");
111 
112  if( _var_section == std::string("DIE!") )
113  libmesh_error_msg("ERROR: Must call set_var_section() before calling VariableFactoryAbstract::build_var_names!");
114  }
static std::string _var_section
Section of input to parse variable names in build_var_names.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
void GRINS::VariableFactoryAbstract::check_create_state ( ) const
protectedvirtual

Helper function to check required data is set when calling create()

Definition at line 87 of file variable_factory.C.

References _subdomain_ids, _var_indices, and _var_names.

Referenced by create().

88  {
89  if( !this->_var_names )
90  libmesh_error_msg("ERROR: must call set_var_names() before building FEVariablesBase!");
91 
92  if( !this->_var_indices )
93  libmesh_error_msg("ERROR: must call set_var_indices() before building FEVariablesBase!");
94 
95  if( !this->_subdomain_ids )
96  libmesh_error_msg("ERROR: must call set_subdomain_ids() before building FEVariablesBase!");
97  }
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
libMesh::UniquePtr< FEVariablesBase > GRINS::VariableFactoryAbstract::create ( )
virtual

Subclasses implement the actual construction of the Base object in create().

Implements GRINS::FactoryAbstract< FEVariablesBase >.

Definition at line 30 of file variable_factory.C.

References _subdomain_ids, _var_indices, _var_names, build_fe_var(), check_create_state(), and reset_create_state().

31  {
32  // Make sure all necessary state has been setup
33  this->check_create_state();
34 
35  libMesh::UniquePtr<FEVariablesBase> func;
36 
38 
39  // Reset state for error checking during next construction
40  this->reset_create_state();
41 
42  return func;
43  }
virtual libMesh::UniquePtr< FEVariablesBase > build_fe_var(const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)=0
Subclasses implement construction of the FEVariablesBase object using the var_names and var_indices...
virtual void check_create_state() const
Helper function to check required data is set when calling create()
virtual void reset_create_state()
Helper function to reset data before next call to create()
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
std::string GRINS::VariableFactoryAbstract::parse_fe_family ( const std::string &  name)
static

Definition at line 59 of file variable_factory.C.

References GRINS::FactoryWithGetPot< FEVariablesBase >::_input, _var_section, check_build_parse_state(), parse_fe_family_impl(), and reset_build_parse_state().

Referenced by GRINS::DefaultVariableBuilder::parse_fe_family().

60  {
62 
63  VariableFactoryAbstract& factory = get_factory_subclass<VariableFactoryAbstract>(name);
64 
65  std::string fe_family;
66  fe_family = factory.parse_fe_family_impl( *_input, _var_section );
67 
69 
70  return fe_family;
71  }
static std::string _var_section
Section of input to parse variable names in build_var_names.
static void check_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static void reset_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual std::string GRINS::VariableFactoryAbstract::parse_fe_family_impl ( const GetPot &  input,
const std::string &  var_section 
)
protectedpure virtual
std::string GRINS::VariableFactoryAbstract::parse_fe_order ( const std::string &  name)
static

Definition at line 73 of file variable_factory.C.

References GRINS::FactoryWithGetPot< FEVariablesBase >::_input, _var_section, check_build_parse_state(), parse_fe_order_impl(), and reset_build_parse_state().

Referenced by GRINS::DefaultVariableBuilder::parse_fe_order().

74  {
76 
77  VariableFactoryAbstract& factory = get_factory_subclass<VariableFactoryAbstract>(name);
78 
79  std::string order;
80  order = factory.parse_fe_order_impl( *_input, _var_section );
81 
83 
84  return order;
85  }
static std::string _var_section
Section of input to parse variable names in build_var_names.
static void check_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static void reset_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual std::string GRINS::VariableFactoryAbstract::parse_fe_order_impl ( const GetPot &  input,
const std::string &  var_section 
)
protectedpure virtual

Implemented in GRINS::VariableFactoryBase.

Referenced by parse_fe_order().

virtual std::vector<std::string> GRINS::VariableFactoryAbstract::parse_var_names ( const GetPot &  input,
const std::string &  var_section 
)
protectedpure virtual
std::string GRINS::VariableFactoryAbstract::parse_var_option ( const GetPot &  input,
const std::string &  var_section,
const std::string &  option,
const std::string &  default_val 
) const
inlineprotected

Definition at line 109 of file variable_factory.h.

Referenced by GRINS::VariableFactoryBase::parse_fe_family_impl(), and GRINS::VariableFactoryBase::parse_fe_order_impl().

113  {
114  std::string input_sec = var_section+"/"+option;
115  if(!input.have_variable(input_sec))
116  libmesh_error_msg("ERROR: Could not find Variable input option "+input_sec);
117 
118  return input(input_sec,default_val);
119  }
void GRINS::VariableFactoryAbstract::reset_build_parse_state ( )
staticprotected

Helper function to check required data is set when calling build_* or parse_* methods.

Definition at line 116 of file variable_factory.C.

References GRINS::FactoryWithGetPot< FEVariablesBase >::_input, and _var_section.

Referenced by build_var_names(), parse_fe_family(), and parse_fe_order().

117  {
118  _input = NULL;
119  _var_section = std::string("DIE!");
120  }
static std::string _var_section
Section of input to parse variable names in build_var_names.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
void GRINS::VariableFactoryAbstract::reset_create_state ( )
protectedvirtual

Helper function to reset data before next call to create()

Definition at line 99 of file variable_factory.C.

References _subdomain_ids, _var_indices, and _var_names.

Referenced by create().

100  {
101  _var_names = NULL;
102  _var_indices = NULL;
103  _subdomain_ids = NULL;
104  }
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
static void GRINS::VariableFactoryAbstract::set_subdomain_ids ( const std::set< libMesh::subdomain_id_type > &  subdomain_ids)
inlinestatic

Definition at line 77 of file variable_factory.h.

References _subdomain_ids.

Referenced by GRINS::VariableBuilder::build_fe_var().

78  { _subdomain_ids = &subdomain_ids; }
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
static void GRINS::VariableFactoryAbstract::set_var_indices ( const std::vector< VariableIndex > &  var_indices)
inlinestatic

Set the variable indices before calling create()

Definition at line 69 of file variable_factory.h.

References _var_indices.

Referenced by GRINS::VariableBuilder::build_fe_var().

70  { _var_indices = &var_indices; }
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
static void GRINS::VariableFactoryAbstract::set_var_names ( const std::vector< std::string > &  var_names)
inlinestatic

Set the variable names before calling create()

Definition at line 65 of file variable_factory.h.

References _var_names.

Referenced by GRINS::VariableBuilder::build_fe_var().

66  { _var_names = &var_names; }
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static void GRINS::VariableFactoryAbstract::set_var_section ( const std::string &  var_section)
inlinestatic

Set the section for the input file before calling build_var_names()

It is expected that user just need to call input(var_section+"/<user_option>")

Definition at line 74 of file variable_factory.h.

References _var_section.

Referenced by GRINS::DefaultVariableBuilder::parse_fe_family(), GRINS::DefaultVariableBuilder::parse_fe_order(), and GRINS::DefaultVariableBuilder::parse_var_names().

75  { _var_section = var_section; }
static std::string _var_section
Section of input to parse variable names in build_var_names.

Member Data Documentation

const std::set< libMesh::subdomain_id_type > * GRINS::VariableFactoryAbstract::_subdomain_ids = NULL
staticprotected

Subdomain ids for the variable.

Definition at line 132 of file variable_factory.h.

Referenced by check_create_state(), create(), reset_create_state(), and set_subdomain_ids().

const std::vector< VariableIndex > * GRINS::VariableFactoryAbstract::_var_indices = NULL
staticprotected

Variable component indices needed for FEVariableBase construction.

Definition at line 126 of file variable_factory.h.

Referenced by check_create_state(), create(), reset_create_state(), and set_var_indices().

const std::vector< std::string > * GRINS::VariableFactoryAbstract::_var_names = NULL
staticprotected

Variable component names needed for FEVariableBase construction.

Definition at line 123 of file variable_factory.h.

Referenced by check_create_state(), create(), reset_create_state(), and set_var_names().

std::string GRINS::VariableFactoryAbstract::_var_section = std::string("DIE!")
staticprotected

Section of input to parse variable names in build_var_names.

Definition at line 129 of file variable_factory.h.

Referenced by build_var_names(), check_build_parse_state(), parse_fe_family(), parse_fe_order(), reset_build_parse_state(), and set_var_section().


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

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1