https://mooseframework.inl.gov
MixingLengthTurbulentViscosityFunctorMaterial.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "NS.h"
12 
14 registerMooseObjectRenamed("NavierStokesApp",
15  MixingLengthTurbulentViscosityMaterial,
16  "08/01/2024 00:00",
18 
21 {
23  params.addClassDescription("Computes the material property corresponding to the total viscosity"
24  "comprising the mixing length model turbulent total_viscosity"
25  "and the molecular viscosity.");
26  params.addRequiredParam<MooseFunctorName>("u", "The x-velocity");
27  params.addParam<MooseFunctorName>("v", 0, "y-velocity"); // only required in 2D and 3D
28  params.addParam<MooseFunctorName>("w", 0, "z-velocity"); // only required in 3D
29  params.addRequiredParam<MooseFunctorName>("mixing_length", "Turbulent eddy mixing length.");
30  params.addRequiredParam<MooseFunctorName>("mu", "The viscosity");
31  params.addRequiredParam<MooseFunctorName>("rho", "The value for the density");
32  return params;
33 }
34 
36  const InputParameters & parameters)
37  : FunctorMaterial(parameters),
38  _mesh_dimension(_mesh.dimension()),
39  _u_vel(getFunctor<ADReal>("u")),
40  _v_vel(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr),
41  _w_vel(isParamValid("w") ? &getFunctor<ADReal>("v") : nullptr),
42  _mixing_len(getFunctor<ADReal>(NS::mixing_length)),
43  _mu(getFunctor<ADReal>("mu")),
44  _rho(getFunctor<ADReal>("rho"))
45 {
46  addFunctorProperty<ADReal>(
48  [this](const auto & r, const auto & t) -> ADReal
49  {
50  constexpr Real offset = 1e-15; // prevents explosion of sqrt(x) derivative to infinity
51 
52  const auto grad_u = _u_vel.gradient(r, t);
53 
54  ADReal symmetric_strain_tensor_norm = 2.0 * Utility::pow<2>(grad_u(0));
55  if (_mesh_dimension >= 2)
56  {
57  const auto grad_v = _v_vel->gradient(r, t);
58 
59  symmetric_strain_tensor_norm +=
60  2.0 * Utility::pow<2>(grad_v(1)) + Utility::pow<2>(grad_v(0) + grad_u(1));
61  if (_mesh_dimension >= 3)
62  {
63  const auto grad_w = _w_vel->gradient(r, t);
64 
65  symmetric_strain_tensor_norm += 2.0 * Utility::pow<2>(grad_w(2)) +
66  Utility::pow<2>(grad_u(2) + grad_w(0)) +
67  Utility::pow<2>(grad_v(2) + grad_w(1));
68  }
69  }
70  symmetric_strain_tensor_norm = std::sqrt(symmetric_strain_tensor_norm + offset);
71 
72  // Return the sum of turbulent viscosity and dynamic viscosity
73  return _mu(r, t) +
74  _rho(r, t) * symmetric_strain_tensor_norm * Utility::pow<2>(_mixing_len(r, t));
75  });
76 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string mixing_length
Definition: NS.h:74
const Moose::Functor< ADReal > *const _w_vel
z-component velocity
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
const Moose::Functor< ADReal > & _u_vel
x-component velocity
const Moose::Functor< ADReal > *const _v_vel
y-component velocity
registerMooseObjectRenamed("NavierStokesApp", MixingLengthTurbulentViscosityMaterial, "08/01/2024 00:00", MixingLengthTurbulentViscosityFunctorMaterial)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("NavierStokesApp", MixingLengthTurbulentViscosityFunctorMaterial)
void addClassDescription(const std::string &doc_string)
static const std::string total_viscosity
Definition: NS.h:78
const Moose::Functor< ADReal > & _mixing_len
Turbulent eddy mixing length.