GRINS-0.6.0
low_mach_navier_stokes_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 
26 // This class
28 
29 // GRINS
30 #include "grins/assembly_context.h"
34 #include "grins/grins_enums.h"
35 
36 // libMesh
37 #include "libmesh/getpot.h"
38 #include "libmesh/string_to_enum.h"
39 #include "libmesh/fem_system.h"
40 
41 namespace GRINS
42 {
43 
44  template<class Mu, class SH, class TC>
45  LowMachNavierStokesBase<Mu,SH,TC>::LowMachNavierStokesBase(const std::string& physics_name, const GetPot& input)
46  : Physics(physics_name, input),
47  _mu(input),
48  _cp(input),
49  _k(input)
50  {
51  this->read_input_options(input);
52 
53  return;
54  }
55 
56  template<class Mu, class SH, class TC>
58  {
59  return;
60  }
61 
62  template<class Mu, class SH, class TC>
64  {
65  // Read FE info
66  this->_V_FE_family =
67  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+low_mach_navier_stokes+"/V_FE_family", "LAGRANGE") );
68 
69  this->_P_FE_family =
70  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+low_mach_navier_stokes+"/P_FE_family", "LAGRANGE") );
71 
72  this->_T_FE_family =
73  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>( input("Physics/"+low_mach_navier_stokes+"/T_FE_family", "LAGRANGE") );
74 
75  this->_V_order =
76  libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+low_mach_navier_stokes+"/V_order", "SECOND") );
77 
78  this->_P_order =
79  libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+low_mach_navier_stokes+"/P_order", "FIRST") );
80 
81  this->_T_order =
82  libMesh::Utility::string_to_enum<GRINSEnums::Order>( input("Physics/"+low_mach_navier_stokes+"/T_order", "SECOND") );
83 
84  // Read variable naming info
85  this->_u_var_name = input("Physics/VariableNames/u_velocity", u_var_name_default );
86  this->_v_var_name = input("Physics/VariableNames/v_velocity", v_var_name_default );
87  this->_w_var_name = input("Physics/VariableNames/w_velocity", w_var_name_default );
88  this->_p_var_name = input("Physics/VariableNames/pressure", p_var_name_default );
89  this->_T_var_name = input("Physics/VariableNames/temperature", T_var_name_default );
90 
91  // Read thermodynamic state info
92  this->set_parameter
93  (_p0, input, "Physics/"+low_mach_navier_stokes+"/p0", 0.0 ); /* thermodynamic pressure */
94  this->set_parameter
95  (_T0, input, "Physics/"+low_mach_navier_stokes+"/T0", 0.0 ); /* Reference temperature */
96  this->set_parameter
97  (_R, input, "Physics/"+low_mach_navier_stokes+"/R", 0.0 ); /* gas constant */
98 
99  if( _R <= 0.0 )
100  {
101  std::cerr << "=========================================" << std::endl
102  << " Error: Gas constant R must be positive. " << std::endl
103  << " Detected value R = " << _R << std::endl
104  << "=========================================" << std::endl;
105  libmesh_error();
106  }
107 
108  _p0_over_R = _p0/_R;
109 
110  _enable_thermo_press_calc = input("Physics/"+low_mach_navier_stokes+"/enable_thermo_press_calc", false );
111 
112  if( _enable_thermo_press_calc )
113  {
114  _p0_var_name = input("Physics/VariableNames/thermo_presure", "p0" );
115  }
116 
117  // Read gravity vector
118  unsigned int g_dim = input.vector_variable_size("Physics/"+low_mach_navier_stokes+"/g");
119 
120  _g(0) = input("Physics/"+low_mach_navier_stokes+"/g", 0.0, 0 );
121  _g(1) = input("Physics/"+low_mach_navier_stokes+"/g", 0.0, 1 );
122 
123  if( g_dim == 3)
124  _g(2) = input("Physics/"+low_mach_navier_stokes+"/g", 0.0, 2 );
125 
126  return;
127  }
128 
129  template<class Mu, class SH, class TC>
130  void LowMachNavierStokesBase<Mu,SH,TC>::init_variables( libMesh::FEMSystem* system )
131  {
132  // Get libMesh to assign an index for each variable
133  this->_dim = system->get_mesh().mesh_dimension();
134 
135  _u_var = system->add_variable( _u_var_name, this->_V_order, _V_FE_family);
136  _v_var = system->add_variable( _v_var_name, this->_V_order, _V_FE_family);
137 
138  if (_dim == 3)
139  _w_var = system->add_variable( _w_var_name, this->_V_order, _V_FE_family);
140  else
141  _w_var = _u_var;
142 
143  _p_var = system->add_variable( _p_var_name, this->_P_order, _P_FE_family);
144  _T_var = system->add_variable( _T_var_name, this->_T_order, _T_FE_family);
145 
146  /* If we need to compute the thermodynamic pressure, we force this to be a first
147  order scalar variable. */
148  if( _enable_thermo_press_calc )
149  _p0_var = system->add_variable( _p0_var_name, libMesh::FIRST, libMesh::SCALAR);
150 
151  return;
152  }
153 
154  template<class Mu, class SH, class TC>
156  {
157  const unsigned int dim = system->get_mesh().mesh_dimension();
158 
159  system->time_evolving(_u_var);
160  system->time_evolving(_v_var);
161 
162  if (dim == 3)
163  system->time_evolving(_w_var);
164 
165  system->time_evolving(_T_var);
166  system->time_evolving(_p_var);
167 
168  if( _enable_thermo_press_calc )
169  system->time_evolving(_p0_var);
170 
171  return;
172  }
173 
174  template<class Mu, class SH, class TC>
176  {
177  // We should prerequest all the data
178  // we will need to build the linear system
179  // or evaluate a quantity of interest.
180  context.get_element_fe(_u_var)->get_JxW();
181  context.get_element_fe(_u_var)->get_phi();
182  context.get_element_fe(_u_var)->get_dphi();
183  context.get_element_fe(_u_var)->get_xyz();
184 
185  context.get_element_fe(_T_var)->get_JxW();
186  context.get_element_fe(_T_var)->get_phi();
187  context.get_element_fe(_T_var)->get_dphi();
188  context.get_element_fe(_T_var)->get_xyz();
189 
190  context.get_element_fe(_p_var)->get_phi();
191  context.get_element_fe(_p_var)->get_xyz();
192 
193  return;
194  }
195 
196  template<class Mu, class SH, class TC>
198  ( const std::string & param_name,
200  const
201  {
202  ParameterUser::register_parameter(param_name, param_pointer);
203  _mu.register_parameter(param_name, param_pointer);
204  _cp.register_parameter(param_name, param_pointer);
205  _k.register_parameter(param_name, param_pointer);
206  }
207 
208 } // namespace GRINS
209 
210 // Instantiate
virtual void read_input_options(const GetPot &input)
Read options from GetPot input file.
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:106
const std::string p_var_name_default
pressure
virtual void register_parameter(const std::string &param_name, libMesh::ParameterMultiPointer< libMesh::Number > &param_pointer) const
Each subclass will register its copy of an independent.
virtual void init_variables(libMesh::FEMSystem *system)
Initialize variables for this physics.
const std::string v_var_name_default
y-velocity
GRINS namespace.
const std::string T_var_name_default
temperature
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Sets velocity variables to be time-evolving.
const std::string u_var_name_default
Default physics variable names.
virtual void register_parameter(const std::string &param_name, libMesh::ParameterMultiPointer< libMesh::Number > &param_pointer) const
Each subclass will register its copy of an independent.
const PhysicsName low_mach_navier_stokes
Physics class for Incompressible Navier-Stokes.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
const std::string w_var_name_default
z-velocity

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