GRINS-0.6.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
24 
25 // libMesh
26 #include "libmesh/getpot.h"
27 #include "libmesh/parsed_function.h"
28 
29 namespace GRINS
30 {
31  template<class Mu>
33  ParameterUser("SpalartAllmarasViscosity"),
34  _mu(input),
35  _turbulence_vars(input, spalart_allmaras),
36  _sa_params(input)
37  {
38  if( !input.have_variable("Materials/Viscosity/mu") )
39  {
40  std::cerr<<"No viscosity has been specified."<<std::endl;
41 
42  libmesh_error();
43  }
44  return;
45  }
46 
47  template<class Mu>
48  void SpalartAllmarasViscosity<Mu>::init( libMesh::FEMSystem* system )
49  {
50  this->_turbulence_vars.init(system);
51  }
52 
53  template<class Mu>
54  libMesh::Real SpalartAllmarasViscosity<Mu>::operator()(AssemblyContext& context, unsigned int qp) const
55  {
56  // The physical viscosity
57  libMesh::Real mu_physical = this->_mu(context, qp);
58 
59  // The unscaled turbulent viscosity (the nu the SA physics solves for)
60  libMesh::Real nu = context.interior_value(this->_turbulence_vars.nu_var(),qp);
61 
62  // Assert that mu_value is greater than 0
63  if(nu < 0.0)
64  {
65  libmesh_warning("Negative turbulent viscosity encountered !");
66 
67  // We are using a negative S-A model, so will set eddy viscosity to zero
68  // if the turbulent viscosity nu < 0.0
69  nu = 0.0;
70  }
71 
72  // Step 1
73  libMesh::Real chi = nu/mu_physical;
74 
75  // Step 2
76  libMesh::Real fv1 = _sa_params.fv1(chi);
77 
78  // Step 3
79  libMesh::Real mu_turbulent = nu*fv1;
80 
81  // Compute the value of the total viscosity and return it
82  libMesh::Number mu_value = mu_turbulent + mu_physical; // Turbulent viscosity + physical viscosity
83 
84  return mu_value;
85  }
86 
87 } // namespace GRINS
88 
89 INSTANTIATE_TURBULENT_VISCOSITY_SUBCLASS(SpalartAllmarasViscosity);
libMesh::Real operator()(AssemblyContext &context, unsigned int qp) const
INSTANTIATE_TURBULENT_VISCOSITY_SUBCLASS(SpalartAllmarasViscosity)
const PhysicsName spalart_allmaras
GRINS namespace.
ParameterUser base class. Utility methods for subclasses.
void init(libMesh::FEMSystem *system)

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