GRINS-0.8.0
spalart_allmaras_viscosity.C
Go to the documentation of this file.
1 // Public License as published by the Free Software Foundation.
2 //
3 // This library is distributed in the hope that it will be useful,
4 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6 // Lesser General Public License for more details.
7 //
8 // You should have received a copy of the GNU Lesser General Public
9 // License along with this library; if not, write to the Free Software
10 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
11 // Boston, MA 02110-1301 USA
12 //
13 //-----------------------------------------------------------------------el-
14 
15 
16 // This class
18 
19 //GRINS
20 #include "grins/common.h"
21 #include "grins/physics_naming.h"
24 #include "grins/parsed_viscosity.h"
27 #include "grins/single_variable.h"
28 
29 // libMesh
30 #include "libmesh/getpot.h"
31 #include "libmesh/parsed_function.h"
32 
33 namespace GRINS
34 {
35  template<class Mu>
37  : ParameterUser("SpalartAllmarasViscosity"),
38  _mu(input),
39  _turbulence_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<TurbulenceFEVariables>(VariablesParsing::turb_variable_name(input,PhysicsNaming::spalart_allmaras(),VariablesParsing::PHYSICS))),
40  _sa_params(input)
41  {
42  // Warning about this constructor being deprecated
43  {
44  std::string warning = "WARNING: Use of this constructor is DEPRECATED.\n";
45  warning += " Please update to use constructor with input material name.\n";
46  grins_warning(warning);
47  }
48 
49  if( !input.have_variable("Materials/Viscosity/mu") )
50  {
51  std::cerr<<"No viscosity has been specified."<<std::endl;
52 
53  libmesh_error();
54  }
55  return;
56  }
57 
58  template<class Mu>
59  SpalartAllmarasViscosity<Mu>::SpalartAllmarasViscosity( const GetPot& input, const std::string& material ):
60  ParameterUser("SpalartAllmarasViscosity"),
61  _mu(input,material),
62  _turbulence_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<TurbulenceFEVariables>(VariablesParsing::turb_variable_name(input,PhysicsNaming::spalart_allmaras(),VariablesParsing::PHYSICS))),
63  _sa_params(input)
64  {}
65 
66  template<class Mu>
68  ( const std::string & param_name,
70  const
71  {
72  ParameterUser::register_parameter(param_name, param_pointer);
73  this->_mu.register_parameter(param_name, param_pointer);
74  this->_sa_params.register_parameter(param_name, param_pointer);
75  }
76 
77  template<class Mu>
78  libMesh::Real SpalartAllmarasViscosity<Mu>::operator()(AssemblyContext& context, unsigned int qp) const
79  {
80  // The physical viscosity
81  libMesh::Real mu_physical = this->_mu(context, qp);
82 
83  // The unscaled turbulent viscosity (the nu the SA physics solves for)
84  libMesh::Real nu = context.interior_value(this->_turbulence_vars.nu(),qp);
85 
86  // Assert that mu_value is greater than 0
87  if(nu < 0.0)
88  {
89  libmesh_warning("Negative turbulent viscosity encountered !");
90 
91  // We are using a negative S-A model, so will set eddy viscosity to zero
92  // if the turbulent viscosity nu < 0.0
93  nu = 0.0;
94  }
95 
96  // Step 1
97  libMesh::Real chi = nu/mu_physical;
98 
99  // Step 2
100  libMesh::Real fv1 = _sa_params.fv1(chi);
101 
102  // Step 3
103  libMesh::Real mu_turbulent = nu*fv1;
104 
105  // Compute the value of the total viscosity and return it
106  libMesh::Number mu_value = mu_turbulent + mu_physical; // Turbulent viscosity + physical viscosity
107 
108  return mu_value;
109  }
110 
111 } // namespace GRINS
112 
113 INSTANTIATE_TURBULENT_VISCOSITY_SUBCLASS(SpalartAllmarasViscosity);
libMesh::Real operator()(AssemblyContext &context, unsigned int qp) const
INSTANTIATE_TURBULENT_VISCOSITY_SUBCLASS(SpalartAllmarasViscosity)
#define grins_warning(message)
Definition: common.h:34
GRINS namespace.
ParameterUser base class. Utility methods for subclasses.
virtual void register_parameter(const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
Each subclass will register its copy of an independent.
virtual void register_parameter(const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
Each subclass will register its copy of an independent.

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