GRINS-0.8.0
constant_viscosity.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 
26 // This class
28 
29 //GRINS
30 #include "grins/physics_naming.h"
31 #include "grins/common.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 
36 namespace GRINS
37 {
38 
39  ConstantViscosity::ConstantViscosity( const GetPot& input )
40  : ParameterUser("ConstantViscosity"),
41  ViscosityBase(),
42  _mu(1.0)
43  {
44  // Warning about this constructor being deprecated
45  {
46  std::string warning = "WARNING: Use of this constructor is DEPRECATED.\n";
47  warning += " Please update to use constructor with input material name.\n";
48  grins_warning(warning);
49  }
50 
51  if( !input.have_variable("Materials/Viscosity/mu") )
52  {
53  libmesh_warning("No Materials/Viscosity/mu specified!\n");
54  // Try and get the viscosity from other specifications
55  this->set_parameter
56  (_mu, input, "Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/mu", _mu);
57  }
58  else
59  {
60  this->set_parameter
61  (_mu, input, "Materials/Viscosity/mu", _mu);
62  }
63  }
64 
65  ConstantViscosity::ConstantViscosity( const GetPot& input, const std::string& material )
66  : ParameterUser("ConstantViscosity"),
67  ViscosityBase(),
68  _mu( 0.0 ) // Initialize to nonsense value
69  {
70  this->check_input_consistency(input,material);
71 
72  if( input.have_variable("Materials/"+material+"/Viscosity/value") &&
73  input.have_variable("Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/mu") )
74  {
75  libmesh_error_msg("Error: Cannot specify both Materials/"+material+"/Viscosity/value and Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/mu");
76  }
77 
78  // If we have the "new" version, then parse it
79  if( input.have_variable("Materials/"+material+"/Viscosity/value") )
80  {
81  this->set_parameter
82  (_mu, input, "Materials/"+material+"/Viscosity/value", _mu);
83  }
84  // If instead we have the old version, use that.
85  else if( input.have_variable("Materials/Viscosity/mu") )
86  {
87  this->old_mu_warning();
88 
89  this->set_parameter
90  (_mu, input, "Materials/Viscosity/mu", _mu);
91  }
92  /* If we don't have the new version of materials parsing or
93  explicitly have the old version, we're assuming an even older
94  version. Both of the older versions are deprecated. */
95  else if( !input.have_variable("Materials/Viscosity/mu") &&
96  !input.have_variable("Materials/"+material+"/Viscosity/value") )
97  {
98  std::string warning = "WARNING: No Materials/Viscosity/mu or\n";
99  warning += " Materials/"+material+"/Viscosity/value specified!\n";
100  warning += " We are assuming then that you want to specify through\n";
101  warning += " Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/mu.\n";
102  warning += " This is DEPRECATED. Please updated to use Materials/"+material+"/Viscosity/value.\n";
103  grins_warning(warning);
104 
105  // Try and get the viscosity from other specifications
106  this->set_parameter
107  (_mu, input, "Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/mu", _mu);
108  }
109  else
110  {
111  // This shouldn't happen
112  libmesh_error();
113  }
114 
115  // We'd better have postive viscosity when we're all done.
116  libmesh_assert_greater( _mu, 0.0 );
117  }
118 
120  {
121  return;
122  }
123 
124 } // 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.
void old_mu_warning() const
#define grins_warning(message)
Definition: common.h:34
Base class for viscosity models.
GRINS namespace.
ParameterUser base class. Utility methods for subclasses.
static PhysicsName incompressible_navier_stokes()
void check_input_consistency(const GetPot &input, const std::string &material) const

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