GRINS-0.6.0
source_term_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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/source_term_base.h"
27 
28 // libMesh
29 #include "libmesh/getpot.h"
30 #include "libmesh/string_to_enum.h"
31 #include "libmesh/fem_system.h"
32 
33 namespace GRINS
34 {
35  SourceTermBase::SourceTermBase( const std::string& physics_name, const GetPot& input )
36  : Physics(physics_name,input)
37  {
38  this->parse_var_info(input);
39 
40  return;
41  }
42 
44  {
45  return;
46  }
47 
48  void SourceTermBase::parse_var_info( const GetPot& input )
49  {
50  if( !input.have_variable("Physics/"+this->_physics_name+"/Variables/names") )
51  {
52  libMesh::err << "Error: Must have at least one variable for source function." << std::endl
53  << " Ensure that Physics/"+this->_physics_name+"/Variables/names is set." << std::endl;
54  libmesh_error();
55  }
56 
57  unsigned int n_vars = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/names");
58 
59  // Make sure we have consisent number of FE types and FE orders
62  unsigned int n_fe_types = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/FE_types");
63 
64  unsigned int n_fe_orders = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/FE_orders");
65 
66  if( n_fe_types != n_vars )
67  {
68  libMesh::err << "Error: Must have matching number of variable names and FE types." << std::endl
69  << " Found " << n_fe_types << " FE types and " << n_vars << " variables." << std::endl
70  << " Ensure Physics/"+this->_physics_name+"/Variables/FE_types is consistent." << std::endl;
71  libmesh_error();
72  }
73 
74  if( n_fe_orders != n_vars )
75  {
76  libMesh::err << "Error: Must have matching number of variable names and FE orders." << std::endl
77  << " Found " << n_fe_orders << " FE orders and " << n_vars << " variables." << std::endl
78  << " Ensure Physics/"+this->_physics_name+"/Variables/FE_orders is consistent." << std::endl;
79  libmesh_error();
80  }
81 
82  _var_names.reserve(n_vars);
83  _var_FE.reserve(n_vars);
84  _var_order.reserve(n_vars);
85  for( unsigned int v = 0; v < n_vars; v++ )
86  {
87  _var_names.push_back( input("Physics/"+this->_physics_name+"/Variables/names", "DIE!", v) );
88  _var_FE.push_back( libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(input("Physics/"+this->_physics_name+"/Variables/FE_types", "DIE!", v)) );
89  _var_order.push_back( libMesh::Utility::string_to_enum<GRINSEnums::Order>(input("Physics/"+this->_physics_name+"/Variables/FE_orders", "DIE!", v)) );
90  }
91 
92  return;
93  }
94 
95  void SourceTermBase::init_variables( libMesh::FEMSystem* system )
96  {
97  // We'd better have at least 1 variable read from input
98  libmesh_assert( !_var_names.empty() );
99 
100  _vars.resize( _var_names.size() );
101 
102  for( unsigned int var = 0; var < _vars.size(); var++ )
103  {
104  _vars[var] = system->add_variable( _var_names[var], _var_order[var], _var_FE[var] );
105  }
106 
107  return;
108  }
109 } // end namespace GRINS
std::vector< VariableIndex > _vars
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:106
GRINS namespace.
void parse_var_info(const GetPot &input)
Helper function.
std::vector< std::string > _var_names
const PhysicsName _physics_name
Name of the physics object. Used for reading physics specific inputs.
Definition: physics.h:254
virtual void init_variables(libMesh::FEMSystem *system)
Initialize variables for this physics.
std::vector< GRINSEnums::Order > _var_order
std::vector< GRINSEnums::FEFamily > _var_FE

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1