https://mooseframework.inl.gov
NSMachAux.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 
10 // Navier-Stokes includes
11 #include "NSMachAux.h"
12 #include "NS.h"
13 
14 // FluidProperties includes
16 
17 // MOOSE includes
18 #include "MooseMesh.h"
19 
20 #include "metaphysicl/raw_type.h"
21 
22 registerMooseObject("NavierStokesApp", NSMachAux);
23 
26 {
28 
29  params.addClassDescription(
30  "Auxiliary kernel for computing the Mach number assuming an ideal gas.");
31  params.addParam<bool>("use_material_properties",
32  false,
33  "Whether to use material properties to compute the Mach number");
34  params.addCoupledVar(NS::velocity_x, "x-velocity");
35  params.addCoupledVar(NS::velocity_y, "y-velocity"); // Only required in >= 2D
36  params.addCoupledVar(NS::velocity_z, "z-velocity"); // Only required in 3D...
37  params.addCoupledVar(NS::specific_volume, "specific volume");
38  params.addCoupledVar(NS::specific_internal_energy, "internal energy");
39  params.addRequiredParam<UserObjectName>("fluid_properties",
40  "The name of the user object for fluid properties");
41 
42  return params;
43 }
44 
46  : AuxKernel(parameters),
47  _use_mat_props(getParam<bool>("use_material_properties")),
48  _u_vel(_use_mat_props ? nullptr : &coupledValue(NS::velocity_x)),
49  _v_vel(_use_mat_props ? nullptr
50  : (_mesh.dimension() >= 2 ? &coupledValue(NS::velocity_y) : &_zero)),
51  _w_vel(_use_mat_props ? nullptr
52  : (_mesh.dimension() == 3 ? &coupledValue(NS::velocity_z) : &_zero)),
53  _specific_volume(_use_mat_props ? nullptr : &coupledValue(NS::specific_volume)),
54  _specific_internal_energy(_use_mat_props ? nullptr
55  : &coupledValue(NS::specific_internal_energy)),
56  _mat_speed(_use_mat_props ? &getADMaterialProperty<Real>(NS::speed) : nullptr),
57  _mat_pressure(_use_mat_props ? &getADMaterialProperty<Real>(NS::pressure) : nullptr),
58  _mat_T_fluid(_use_mat_props ? &getADMaterialProperty<Real>(NS::T_fluid) : nullptr),
59  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
60 {
61 }
62 
63 Real
65 {
66  if (_use_mat_props)
68  _fp.c_from_p_T((*_mat_pressure)[_qp], (*_mat_T_fluid)[_qp]));
69  else
70  return RealVectorValue((*_u_vel)[_qp], (*_v_vel)[_qp], (*_w_vel)[_qp]).norm() /
72 }
auto norm() const -> decltype(std::norm(Real()))
Auxiliary kernel for computing the Mach number assuming an ideal gas.
Definition: NSMachAux.h:21
static const std::string speed
Definition: NS.h:143
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const VariableValue *const _u_vel
Definition: NSMachAux.h:36
const VariableValue *const _specific_internal_energy
Definition: NSMachAux.h:40
static const std::string velocity_z
Definition: NS.h:48
auto raw_value(const Eigen::Map< T > &in)
static InputParameters validParams()
Definition: NSMachAux.C:25
static const std::string velocity_x
Definition: NS.h:46
static const std::string specific_internal_energy
Definition: NS.h:62
void addRequiredParam(const std::string &name, const std::string &doc_string)
const SinglePhaseFluidProperties & _fp
Definition: NSMachAux.h:52
static const std::string T_fluid
Definition: NS.h:106
static const std::string specific_volume
Definition: NS.h:81
const VariableValue *const _specific_volume
Definition: NSMachAux.h:39
Common class for single phase fluid properties.
const VariableValue *const _w_vel
Definition: NSMachAux.h:38
static const std::string velocity_y
Definition: NS.h:47
const VariableValue *const _v_vel
Definition: NSMachAux.h:37
void addCoupledVar(const std::string &name, const std::string &doc_string)
const ADMaterialProperty< Real > *const _mat_speed
speed
Definition: NSMachAux.h:43
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
NSMachAux(const InputParameters &parameters)
Definition: NSMachAux.C:45
static const std::string pressure
Definition: NS.h:56
const ADMaterialProperty< Real > *const _mat_T_fluid
fluid temperature
Definition: NSMachAux.h:49
void addClassDescription(const std::string &doc_string)
const bool _use_mat_props
Whether to use material properties instead of coupled variables to compute the Mach number...
Definition: NSMachAux.h:34
static InputParameters validParams()
registerMooseObject("NavierStokesApp", NSMachAux)
const ADMaterialProperty< Real > *const _mat_pressure
pressure
Definition: NSMachAux.h:46
virtual Real computeValue()
Definition: NSMachAux.C:64