GRINS-0.7.0
List of all members | Public Member Functions | Protected Member Functions
GRINS::SingleFETypeVariable Class Reference

Class to encapsulate variables that have only one FEType/Order. More...

#include <single_fe_type_variable.h>

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

Public Member Functions

 SingleFETypeVariable (const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection, const std::string &default_family, const std::string &default_order, bool is_constraint_var)
 Deprecated, old style constructor. More...
 
 SingleFETypeVariable (const GetPot &input, const std::string &subsection, bool is_constraint_var)
 Primary constructor. More...
 
 ~SingleFETypeVariable ()
 
virtual void init (libMesh::FEMSystem *system)
 Add variables to the system. More...
 
- Public Member Functions inherited from GRINS::FEVariablesBase
 FEVariablesBase (bool is_constraint_var)
 
 ~FEVariablesBase ()
 
bool is_constraint_var () const
 
void set_neumann_bc_is_positive (bool is_positive)
 Reset whetever Neumann bc is postive or not. More...
 
libMesh::Real neumann_bc_sign () const
 
const std::vector< std::string > & active_var_names () const
 Return the var names that are active from this class. More...
 
const std::vector< VariableIndex > & var_indices () const
 

Protected Member Functions

void parse_family_and_order (const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection, std::vector< GRINSEnums::FEFamily > &family, std::vector< GRINSEnums::Order > &order, const std::string &default_family, const std::string &default_order)
 Helper function to parse FEFamily and Order. More...
 
void dup_family_order_check (const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix) const
 Check (and error if true) for old and new style FEFamily/Order input. More...
 
bool have_family_or_order (const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection) const
 Check for no presence of FEFamily/Order input. More...
 
void parse_old_style_with_warning (const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &default_family, const std::string &default_order, const std::string &subsection, GRINSEnums::FEFamily &family, GRINSEnums::Order &order)
 
void parse_new_style (const GetPot &input, const std::string &subsection, GRINSEnums::FEFamily &family, GRINSEnums::Order &order)
 
- Protected Member Functions inherited from GRINS::FEVariablesBase
void parse_names_from_input (const GetPot &input, const std::string &subsection, std::vector< std::string > &var_names, const std::vector< std::string > &default_names)
 Method to parse variable names from input. More...
 
void duplicate_name_section_check (const GetPot &input) const
 Check for old name style and new name style. If both present, error. More...
 
bool check_dep_name_input (const GetPot &input, const std::string &new_subsection) const
 Check for deprecated variable name input style. More...
 

Additional Inherited Members

- Protected Attributes inherited from GRINS::FEVariablesBase
std::vector< VariableIndex_vars
 
std::vector< std::string > _var_names
 
std::vector< GRINSEnums::FEFamily > _family
 
std::vector< GRINSEnums::Order > _order
 
bool _is_constraint_var
 Tracks whether this is a constraint variable. More...
 
libMesh::Real _neumann_bc_sign
 Track the sign of the Neumann BC term. Defaults to 1.0. More...
 

Detailed Description

Class to encapsulate variables that have only one FEType/Order.

This class only handles the FEType and Order. Subclasses will handle the construction/parsing of the variable names since we can have both "single variables" and variables like Velocity that have the same FEType for all the variables, but multiple variables with unique names.

Definition at line 39 of file single_fe_type_variable.h.

Constructor & Destructor Documentation

GRINS::SingleFETypeVariable::SingleFETypeVariable ( const GetPot &  input,
const std::string &  physics_name,
const std::string &  old_var_prefix,
const std::string &  subsection,
const std::string &  default_family,
const std::string &  default_order,
bool  is_constraint_var 
)

Deprecated, old style constructor.

This constructor is used for when there is possibly old deprecated styles of input for which we do additional checks/warnings. Otherwise, you should use the new constructor.

Definition at line 39 of file single_fe_type_variable.C.

References GRINS::FEVariablesBase::_family, GRINS::FEVariablesBase::_order, and parse_family_and_order().

47  {
48  _family.resize(1,libMesh::INVALID_FE);
49  _order.resize(1,libMesh::INVALID_ORDER);
50 
51  this->parse_family_and_order(input,
52  physics_name,
53  old_var_prefix,
54  subsection,
55  _family,
56  _order,
57  default_family,
58  default_order);
59 
60  libmesh_assert_not_equal_to( _family[0], libMesh::INVALID_FE);
61  libmesh_assert_not_equal_to( _order[0], libMesh::INVALID_ORDER);
62  }
std::vector< GRINSEnums::FEFamily > _family
std::vector< GRINSEnums::Order > _order
bool _is_constraint_var
Tracks whether this is a constraint variable.
void parse_family_and_order(const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection, std::vector< GRINSEnums::FEFamily > &family, std::vector< GRINSEnums::Order > &order, const std::string &default_family, const std::string &default_order)
Helper function to parse FEFamily and Order.
FEVariablesBase(bool is_constraint_var)
GRINS::SingleFETypeVariable::SingleFETypeVariable ( const GetPot &  input,
const std::string &  subsection,
bool  is_constraint_var 
)

Primary constructor.

Will parse from input section [Variables/<subsection>].

Definition at line 64 of file single_fe_type_variable.C.

References GRINS::FEVariablesBase::_family, GRINS::FEVariablesBase::_order, and parse_new_style().

68  {
69  _family.resize(1,libMesh::INVALID_FE);
70  _order.resize(1,libMesh::INVALID_ORDER);
71 
72  this->parse_new_style(input, subsection, _family[0], _order[0]);
73 
74  libmesh_assert_not_equal_to( _family[0], libMesh::INVALID_FE);
75  libmesh_assert_not_equal_to( _order[0], libMesh::INVALID_ORDER);
76  }
std::vector< GRINSEnums::FEFamily > _family
std::vector< GRINSEnums::Order > _order
bool _is_constraint_var
Tracks whether this is a constraint variable.
void parse_new_style(const GetPot &input, const std::string &subsection, GRINSEnums::FEFamily &family, GRINSEnums::Order &order)
FEVariablesBase(bool is_constraint_var)
GRINS::SingleFETypeVariable::~SingleFETypeVariable ( )
inline

Definition at line 61 of file single_fe_type_variable.h.

61 {};

Member Function Documentation

void GRINS::SingleFETypeVariable::dup_family_order_check ( const GetPot &  input,
const std::string &  physics_name,
const std::string &  old_var_prefix 
) const
protected

Check (and error if true) for old and new style FEFamily/Order input.

Actually, for the new style, we just check for the presence of a [Variables] section in order to be conservative.

Definition at line 168 of file single_fe_type_variable.C.

Referenced by parse_family_and_order().

171  {
172  // We'll error out if there's even a [Variables] section and the old style
173  // in order to be conservative.
174  if( ( input.have_variable("Physics/"+physics_name+"/FE_family") ||
175  input.have_variable("Physics/"+physics_name+"/order") ||
176  input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"FE_family") ||
177  input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"order")) &&
178  input.have_section("Variables") )
179  libmesh_error_msg("ERROR: Cannot have a [Variables] section and deprecated FE_family/order input style!");
180  }
bool GRINS::SingleFETypeVariable::have_family_or_order ( const GetPot &  input,
const std::string &  physics_name,
const std::string &  old_var_prefix,
const std::string &  subsection 
) const
protected

Check for no presence of FEFamily/Order input.

Definition at line 201 of file single_fe_type_variable.C.

Referenced by parse_family_and_order().

205  {
206  bool have_family_or_order = false;
207 
208  if( input.have_variable("Physics/"+physics_name+"/FE_family") ||
209  input.have_variable("Physics/"+physics_name+"/order") ||
210  input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"FE_family") ||
211  input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"order") ||
212  input.have_variable("Variables/"+subsection+"/fe_family") ||
213  input.have_variable("Variables/"+subsection+"/order") )
214  have_family_or_order = true;
215 
216  return have_family_or_order;
217  }
bool have_family_or_order(const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection) const
Check for no presence of FEFamily/Order input.
void GRINS::SingleFETypeVariable::init ( libMesh::FEMSystem *  system)
virtual

Add variables to the system.

This expects that _var_names has been setup during construction time by the subclasses.

Implements GRINS::FEVariablesBase.

Reimplemented in GRINS::DisplacementFEVariables, and GRINS::VelocityFEVariables.

Definition at line 78 of file single_fe_type_variable.C.

References GRINS::FEVariablesBase::_family, GRINS::FEVariablesBase::_order, GRINS::FEVariablesBase::_var_names, and GRINS::FEVariablesBase::_vars.

Referenced by GRINS::VelocityFEVariables::init(), GRINS::DisplacementFEVariables::init(), GRINS::ConvectionDiffusion::init_variables(), GRINS::BoussinesqBuoyancyBase::init_variables(), GRINS::ReactingLowMachNavierStokesAbstract::init_variables(), GRINS::AxisymmetricBoussinesqBuoyancy::init_variables(), GRINSTesting::VariablesTest::test_pressure(), GRINSTesting::VariablesTest::test_species_mass_fracs(), GRINSTesting::VariablesTest::test_temp(), and GRINSTesting::VariablesTest::test_var_constraint_and_warehouse().

79  {
80  // Make sure there's only one order and family
81  libmesh_assert_equal_to(_order.size(), 1);
82  libmesh_assert_equal_to(_family.size(), 1);
83 
84  const unsigned int n_vars = _var_names.size();
85  _vars.resize(n_vars);
86 
87  for( unsigned int v = 0; v < n_vars; v++ )
88  _vars[v] = system->add_variable( _var_names[v], _order[0], _family[0]);
89  }
std::vector< GRINSEnums::FEFamily > _family
std::vector< GRINSEnums::Order > _order
std::vector< std::string > _var_names
std::vector< VariableIndex > _vars
void GRINS::SingleFETypeVariable::parse_family_and_order ( const GetPot &  input,
const std::string &  physics_name,
const std::string &  old_var_prefix,
const std::string &  subsection,
std::vector< GRINSEnums::FEFamily > &  family,
std::vector< GRINSEnums::Order > &  order,
const std::string &  default_family,
const std::string &  default_order 
)
protected

Helper function to parse FEFamily and Order.

Mainly to encapsulate warning/using old style and new style. Note that default_family and default_order are only for the old style. In the new style, the user must specify the FEFamily and order in the input file. This function assumes that family and order have been properly sized. Currently assumes only a single family and order.

Definition at line 91 of file single_fe_type_variable.C.

References dup_family_order_check(), grins_warning, have_family_or_order(), parse_new_style(), and parse_old_style_with_warning().

Referenced by SingleFETypeVariable().

99  {
100  libmesh_assert_equal_to( family.size(), 1 );
101  libmesh_assert_equal_to( family.size(), order.size() );
102 
103  // Check if FEfamily/order set in both old style and new style.
104  // Errors out if both are present.
105  this->dup_family_order_check(input,physics_name,old_var_prefix);
106 
107  // If there's nothing about family or order, then we'll use the defaults.
108  // This is deprecated.
109  if( !this->have_family_or_order(input,physics_name,old_var_prefix,subsection) )
110  {
111  std::string warning = "WARNING: Could not find input for FE family and order for Variable "+subsection+".\n";
112  warning += " Using default values: FEFamily = "+default_family+", Order = "+default_order+"\n";
113  warning += " THIS IS DEPRECATED. In the future, you explicitly specify these in your input file\n";
114  warning += " using: [Variables/"+subsection+"/fe_family] and [Variables/"+subsection+"/order].\n";
115  grins_warning(warning);
116 
117  family[0] = libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(default_family);
118  order[0] = libMesh::Utility::string_to_enum<GRINSEnums::Order>(default_order);
119  }
120  // So here we know we have one or the other
121  else
122  {
123  // If we got here, there was one or the other, but it's possible they only specified one of them
124  // so we default to the default value in this case.
125  // Using this style of input is deprecated.
126  if( input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"FE_family") ||
127  input.have_variable("Physics/"+physics_name+"/"+old_var_prefix+"order"))
128  {
129  this->parse_old_style_with_warning(input,physics_name,"",default_family,default_order,
130  subsection,family[0],order[0]);
131  }
132  // Some of the old style didn't have the "prefix"
133  else if( input.have_variable("Physics/"+physics_name+"/FE_family") ||
134  input.have_variable("Physics/"+physics_name+"/order"))
135  {
136  this->parse_old_style_with_warning(input,physics_name,"",default_family,default_order,
137  subsection,family[0],order[0]);
138  }
139  // We must be using the new style
140  else
141  {
142  this->parse_new_style(input,subsection,family[0],order[0]);
143  }
144  }
145  }
void dup_family_order_check(const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix) const
Check (and error if true) for old and new style FEFamily/Order input.
bool have_family_or_order(const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &subsection) const
Check for no presence of FEFamily/Order input.
void parse_new_style(const GetPot &input, const std::string &subsection, GRINSEnums::FEFamily &family, GRINSEnums::Order &order)
#define grins_warning(message)
Definition: common.h:34
void parse_old_style_with_warning(const GetPot &input, const std::string &physics_name, const std::string &old_var_prefix, const std::string &default_family, const std::string &default_order, const std::string &subsection, GRINSEnums::FEFamily &family, GRINSEnums::Order &order)
void GRINS::SingleFETypeVariable::parse_new_style ( const GetPot &  input,
const std::string &  subsection,
GRINSEnums::FEFamily &  family,
GRINSEnums::Order &  order 
)
protected

Definition at line 182 of file single_fe_type_variable.C.

Referenced by parse_family_and_order(), and SingleFETypeVariable().

186  {
187  // Both options must've been specified
188  if( !input.have_variable("Variables/"+subsection+"/fe_family") )
189  libmesh_error_msg("ERROR: Could not find Variables/"+subsection+"/fe_family in input!");
190 
191  if( !input.have_variable("Variables/"+subsection+"/order") )
192  libmesh_error_msg("ERROR: Could not find Variables/"+subsection+"/order in input!");
193 
194  std::string family_in = input("Variables/"+subsection+"/fe_family", "DIE!");
195  std::string order_in = input("Variables/"+subsection+"/order", "DIE!");
196 
197  family = libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(family_in);
198  order = libMesh::Utility::string_to_enum<GRINSEnums::Order>(order_in);
199  }
void GRINS::SingleFETypeVariable::parse_old_style_with_warning ( const GetPot &  input,
const std::string &  physics_name,
const std::string &  old_var_prefix,
const std::string &  default_family,
const std::string &  default_order,
const std::string &  subsection,
GRINSEnums::FEFamily &  family,
GRINSEnums::Order &  order 
)
protected

Definition at line 147 of file single_fe_type_variable.C.

References grins_warning.

Referenced by parse_family_and_order().

155  {
156  std::string warning = "WARNING: Specifying Physics/"+physics_name+"/"+old_var_prefix+"FE_family and\n";
157  warning += " Physics/"+physics_name+"/"+old_var_prefix+"order is DEPRECATED! Please update and use\n";
158  warning += " [Variables/"+subsection+"/fe_family] and [Variables/"+subsection+"/order].\n";
159  grins_warning(warning);
160 
161  std::string family_in = input("Variables/"+subsection+"/fe_family", default_family );
162  std::string order_in = input("Variables/"+subsection+"/order", default_order );
163 
164  family = libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(family_in);
165  order = libMesh::Utility::string_to_enum<GRINSEnums::Order>(order_in);
166  }
#define grins_warning(message)
Definition: common.h:34

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

Generated on Thu Jun 2 2016 21:52:32 for GRINS-0.7.0 by  doxygen 1.8.10