GRINS-0.7.0
boussinesq_buoyancy_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-2016 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 #include "grins_config.h"
26 
27 // This class
29 
30 // GRINS
31 #include "grins/common.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  BoussinesqBuoyancyBase::BoussinesqBuoyancyBase( const std::string& physics_name, const GetPot& input )
45  : Physics(physics_name,input),
46  _flow_vars(input,PhysicsNaming::incompressible_navier_stokes()),
47  _press_var(input,PhysicsNaming::incompressible_navier_stokes(), true /*is_constraint_var*/),
48  _temp_vars(input,PhysicsNaming::heat_transfer()),
49  _rho(0.0),
50  _T_ref(1.0),
51  _beta_T(1.0)
52  {
53  this->read_property(input,
54  "Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/rho_ref",
55  "Density",
56  _rho);
57 
58  this->read_property(input,
59  "Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/T_ref",
60  "ReferenceTemperature",
61  _T_ref);
62 
63 
64  this->read_property(input,
65  "Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/beta_T",
66  "ThermalExpansionCoeff",
67  _beta_T);
68 
69  unsigned int g_dim = input.vector_variable_size("Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/g");
70 
71  _g(0) = input("Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/g", 0.0, 0 );
72  _g(1) = input("Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/g", 0.0, 1 );
73 
74  if( g_dim == 3)
75  _g(2) = input("Physics/"+PhysicsNaming::boussinesq_buoyancy()+"/g", 0.0, 2 );
76 
77  this->register_variables();
78  }
79 
81  {
82  return;
83  }
84 
86  {
88  this->_press_var);
90  this->_flow_vars);
92  this->_temp_vars);
93  }
94 
95  void BoussinesqBuoyancyBase::init_variables( libMesh::FEMSystem* system )
96  {
97  // Get libMesh to assign an index for each variable
98  this->_dim = system->get_mesh().mesh_dimension();
99 
100  _temp_vars.init(system);
101  _flow_vars.init(system);
102  this->_press_var.init(system);
103 
104  return;
105  }
106 
107  void BoussinesqBuoyancyBase::read_property( const GetPot& input,
108  const std::string& old_option,
109  const std::string& property,
110  libMesh::Real& value )
111  {
113 
114  // Can't specify both material and rho_ref
116  old_option,
117  "Materials/"+material+"/"+property+"/value" );
118 
119  // Deprecated
120  if( input.have_variable(old_option) )
121  {
122  MaterialsParsing::dep_input_warning( old_option,property+"/value" );
123 
124  this->set_parameter
125  (value, input,
126  old_option, 1.0 /*Old default*/);
127  }
128  // Preferred
129  else if( input.have_variable("Materials/"+material+"/"+property+"/value" ) )
130  {
131  this->set_parameter
132  (value, input,
133  "Materials/"+material+"/"+property+"/value", 0.0 /*default*/);
134  }
135  // If nothing was set, we default to 1.0. Deprecated, what was I thinking
136  else
137  {
138  this->no_input_warning( input,
139  old_option,
140  material,
141  property );
142  this->set_parameter
143  (value, input, old_option, 1.0 /*default*/);
144  }
145 
146  // Make sure density is positive
147  if( value <= 0.0 )
148  {
149  libmesh_error_msg("ERROR: Detected non-positive "+property+"!");
150  }
151  }
152 
153  void BoussinesqBuoyancyBase::no_input_warning( const GetPot& input,
154  const std::string& old_option,
155  const std::string& material,
156  const std::string& property )
157  {
158  std::string warning;
160  {
161  warning = "WARNING: Neither "+old_option+"\n";
162  warning += " nor a material_name was detected in input\n";
163  warning + " "+property+" is defaulting to 1.0. This behavior is DEPRECATED!\n";
164  warning += " Please update to use Material/MATERIAL_NAME/"+property+"/value\n";
165  }
166  else
167  {
168  warning = "WARNING: Neither "+old_option+"\n";
169  warning += " nor Material/"+material+"/"+property+"/value\n";
170  warning + " "+property+" is defaulting to 1.0. This behavior is DEPRECATED!\n";
171  warning += " Please update to use Material/MATERIAL_NAME/"+property+"/value\n";
172  }
173 
174  grins_warning(warning);
175  }
176 
177 
178 
179 } // namespace GRINS
virtual void set_parameter(libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
virtual void init(libMesh::FEMSystem *system)
Add variables to the system.
void read_property(const GetPot &input, const std::string &old_option, const std::string &property, libMesh::Real &value)
Helper function for parsing/maintaing backward compatibility.
libMesh::Point _g
Gravitational vector.
virtual void init_variables(libMesh::FEMSystem *system)
Initialization of BoussinesqBuoyancy variables.
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:107
unsigned int _dim
Physical dimension of problem.
static std::string temperature_section()
#define grins_warning(message)
Definition: common.h:34
virtual void init(libMesh::FEMSystem *system)
Add variables to the system.
static void check_and_register_variable(const std::string &var_name, const FEVariablesBase &variable)
First check if var_name is registered and then register.
GRINS namespace.
static std::string velocity_section()
libMesh::Number _T_ref
reference temperature
static std::string pressure_section()
static PhysicsName boussinesq_buoyancy()
void no_input_warning(const GetPot &input, const std::string &old_option, const std::string &material, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
static void dep_input_warning(const std::string &old_option, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
static void duplicate_input_test(const GetPot &input, const std::string &option1, const std::string &option2)
Helper function for parsing/maintaing backward compatibility.
static std::string material_name(const GetPot &input, const std::string &physics)
Get the name of the material in the Physics/physics section.
libMesh::Number _beta_T
coefficient of thermal expansion
static bool have_material(const GetPot &input, const std::string &physics)
Check if Physics/physics section has a material variable.
PrimitiveTempFEVariables _temp_vars

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