GRINS-0.7.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
19 #include "grins/parsed_viscosity.h"
20 
21 //GRINS
22 #include "grins/common.h"
23 #include "grins/physics_naming.h"
25 
26 // libMesh
27 #include "libmesh/getpot.h"
28 #include "libmesh/parsed_function.h"
29 
30 namespace GRINS
31 {
32  template<class Mu>
34  ParameterUser("SpalartAllmarasViscosity"),
35  _mu(input),
36  _turbulence_vars(input, PhysicsNaming::spalart_allmaras()),
37  _sa_params(input)
38  {
39  // Warning about this constructor being deprecated
40  {
41  std::string warning = "WARNING: Use of this constructor is DEPRECATED.\n";
42  warning += " Please update to use constructor with input material name.\n";
43  grins_warning(warning);
44  }
45 
46  if( !input.have_variable("Materials/Viscosity/mu") )
47  {
48  std::cerr<<"No viscosity has been specified."<<std::endl;
49 
50  libmesh_error();
51  }
52  return;
53  }
54 
55  template<class Mu>
56  SpalartAllmarasViscosity<Mu>::SpalartAllmarasViscosity( const GetPot& input, const std::string& material ):
57  ParameterUser("SpalartAllmarasViscosity"),
58  _mu(input,material),
59  _turbulence_vars(input, PhysicsNaming::spalart_allmaras()),
60  _sa_params(input)
61  {}
62 
63  template<class Mu>
65  ( const std::string & param_name,
67  const
68  {
69  ParameterUser::register_parameter(param_name, param_pointer);
70  this->_mu.register_parameter(param_name, param_pointer);
71  this->_sa_params.register_parameter(param_name, param_pointer);
72  }
73 
74  template<class Mu>
75  void SpalartAllmarasViscosity<Mu>::init( libMesh::FEMSystem* system )
76  {
77  this->_turbulence_vars.init(system);
78  }
79 
80  template<class Mu>
81  libMesh::Real SpalartAllmarasViscosity<Mu>::operator()(AssemblyContext& context, unsigned int qp) const
82  {
83  // The physical viscosity
84  libMesh::Real mu_physical = this->_mu(context, qp);
85 
86  // The unscaled turbulent viscosity (the nu the SA physics solves for)
87  libMesh::Real nu = context.interior_value(this->_turbulence_vars.nu(),qp);
88 
89  // Assert that mu_value is greater than 0
90  if(nu < 0.0)
91  {
92  libmesh_warning("Negative turbulent viscosity encountered !");
93 
94  // We are using a negative S-A model, so will set eddy viscosity to zero
95  // if the turbulent viscosity nu < 0.0
96  nu = 0.0;
97  }
98 
99  // Step 1
100  libMesh::Real chi = nu/mu_physical;
101 
102  // Step 2
103  libMesh::Real fv1 = _sa_params.fv1(chi);
104 
105  // Step 3
106  libMesh::Real mu_turbulent = nu*fv1;
107 
108  // Compute the value of the total viscosity and return it
109  libMesh::Number mu_value = mu_turbulent + mu_physical; // Turbulent viscosity + physical viscosity
110 
111  return mu_value;
112  }
113 
114 } // namespace GRINS
115 
116 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.
void init(libMesh::FEMSystem *system)
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 Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10