GRINS-0.8.0
variable_factory.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This class
26 #include "grins/variable_factory.h"
27 
28 namespace GRINS
29 {
30  libMesh::UniquePtr<FEVariablesBase> VariableFactoryAbstract::create()
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  }
44 
45  std::vector<std::string> VariableFactoryAbstract::build_var_names( const std::string& name )
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  }
58 
59  std::string VariableFactoryAbstract::parse_fe_family( const std::string& name )
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  }
72 
73  std::string VariableFactoryAbstract::parse_fe_order( const std::string& name )
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  }
86 
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  }
98 
100  {
101  _var_names = NULL;
102  _var_indices = NULL;
103  _subdomain_ids = NULL;
104  }
105 
106 
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  }
115 
117  {
118  _input = NULL;
119  _var_section = std::string("DIE!");
120  }
121 
122  // Full specialization for the Factory<FEVariablesBase>
123  template<>
124  std::map<std::string, FactoryAbstract<FEVariablesBase>*>&
126  {
127  static std::map<std::string, FactoryAbstract<FEVariablesBase>*> _map;
128  return _map;
129  }
130 
131  // Definition of static members
132  template<>
134  const std::vector<std::string>* VariableFactoryAbstract::_var_names = NULL;
135  const std::vector<VariableIndex>* VariableFactoryAbstract::_var_indices = NULL;
136  std::string VariableFactoryAbstract::_var_section = std::string("DIE!");
137  const std::set<libMesh::subdomain_id_type>* VariableFactoryAbstract::_subdomain_ids = NULL;
138 
139 } // end namespace GRINS
static std::string _var_section
Section of input to parse variable names in build_var_names.
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()
static void check_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
virtual std::vector< std::string > parse_var_names(const GetPot &input, const std::string &var_section)=0
virtual void reset_create_state()
Helper function to reset data before next call to create()
static std::map< std::string, FactoryAbstract< Base > * > & factory_map()
virtual libMesh::UniquePtr< FEVariablesBase > create()
Subclasses implement the actual construction of the Base object in create().
static const std::vector< std::string > * _var_names
Variable component names needed for FEVariableBase construction.
static void reset_build_parse_state()
Helper function to check required data is set when calling build_* or parse_* methods.
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.
virtual std::string parse_fe_family_impl(const GetPot &input, const std::string &var_section)=0
GRINS namespace.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
static std::string parse_fe_family(const std::string &name)
static const std::set< libMesh::subdomain_id_type > * _subdomain_ids
Subdomain ids for the variable.
virtual std::string parse_fe_order_impl(const GetPot &input, const std::string &var_section)=0
static const std::vector< VariableIndex > * _var_indices
Variable component indices needed for FEVariableBase construction.
static std::string parse_fe_order(const std::string &name)
Abstract factory that provides availability of GetPot.

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