https://mooseframework.inl.gov
ReynoldsNumberFunctorAux.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 "MooseMesh.h"
12 #include "NS.h"
13 
15 
18 {
20  params.addClassDescription("Computes rho*u*L/mu.");
21  params.addRequiredParam<MooseFunctorName>(NS::speed, "The fluid speed");
22  params.addRequiredParam<MooseFunctorName>(NS::density, "The fluid density");
23  params.addRequiredParam<MooseFunctorName>(NS::mu, "The fluid dynamic viscosity");
24  return params;
25 }
26 
28  : AuxKernel(parameters),
29  _speed(getFunctor<ADReal>(NS::speed)),
30  _rho(getFunctor<ADReal>(NS::density)),
31  _mu(getFunctor<ADReal>(NS::mu)),
32  _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var))
33 {
34  if (!_use_qp_arg && !dynamic_cast<MooseVariableFV<Real> *>(&_var))
35  paramError(
36  "variable",
37  "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
38 
39  if (isNodal())
40  mooseError("This AuxKernel only supports Elemental fields");
41 }
42 
43 Real
45 {
47  const auto state = determineState();
48 
49  if (_use_qp_arg)
50  {
51  const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
52  return _current_elem->hmax() * raw_value(_rho(qp_arg, state)) *
53  raw_value(_speed(qp_arg, state)) / raw_value(_mu(qp_arg, state));
54  }
55  else
56  {
57  const auto elem_arg = makeElemArg(_current_elem);
58  return _current_elem->hmax() * raw_value(_rho(elem_arg, state)) *
59  raw_value(_speed(elem_arg, state)) / raw_value(_mu(elem_arg, state));
60  }
61 }
static InputParameters validParams()
const Moose::Functor< ADReal > & _rho
The fluid density.
const Moose::Functor< ADReal > & _speed
The fluid speed.
static const std::string speed
Definition: NS.h:143
Moose::StateArg determineState() const
static const std::string density
Definition: NS.h:33
auto raw_value(const Eigen::Map< T > &in)
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
static const std::string mu
Definition: NS.h:123
const bool _use_qp_arg
Whether to use a quadrature-based argument to evaluate the functors.
void paramError(const std::string &param, Args... args) const
ReynoldsNumberFunctorAux(const InputParameters &parameters)
MooseVariableField< Real > & _var
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
void mooseError(Args &&... args) const
const Elem *const & _current_elem
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const Moose::Functor< ADReal > & _mu
The fluid dynamic viscosity.
Computes rho*u*L/mu where L is the maximum element dimension.
const MooseArray< Point > & _q_point
registerMooseObject("NavierStokesApp", ReynoldsNumberFunctorAux)