https://mooseframework.inl.gov
PorousMixedVarMaterial.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 "PorousMixedVarMaterial.h"
12 #include "NS.h"
13 #include "NavierStokesMethods.h"
14 
15 // FluidProperties includes
17 
19 
22 {
23  auto params = Material::validParams();
24  params.addRequiredParam<UserObjectName>(NS::fluid, "fluid userobject");
25  params.addRequiredCoupledVar(NS::pressure, "The pressure");
26  params.addRequiredCoupledVar(NS::T_fluid, "The fluid temperature");
27  params.addRequiredCoupledVar(NS::superficial_momentum_x, "The x-momentum times the porosity");
28  params.addCoupledVar(NS::superficial_momentum_y, "The y-momentum times the porosity");
29  params.addCoupledVar(NS::superficial_momentum_z, "The z-momentum times the porosity");
30  params.addClassDescription("Provides access to variables for a primitive variable set "
31  "of pressure, temperature, and superficial velocity");
32  params.addRequiredParam<MaterialPropertyName>(NS::porosity, "the porosity");
33  return params;
34 }
35 
37  : Material(params),
38  _fluid(UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
39  // mixed variables
40  _var_pressure(adCoupledValue(NS::pressure)),
41  _grad_var_pressure(adCoupledGradient(NS::pressure)),
42  _pressure_dot(_is_transient ? adCoupledDot(NS::pressure) : _ad_zero),
43  _var_T_fluid(adCoupledValue(NS::T_fluid)),
44  _grad_var_T_fluid(adCoupledGradient(NS::T_fluid)),
45  _T_fluid_dot(_is_transient ? adCoupledDot(NS::T_fluid) : _ad_zero),
46  _var_sup_mom_x(adCoupledValue(NS::superficial_momentum_x)),
47  _grad_var_sup_mom_x(adCoupledGradient(NS::superficial_momentum_x)),
48  _var_sup_mom_y(isCoupled(NS::superficial_momentum_y)
49  ? adCoupledValue(NS::superficial_momentum_y)
50  : _ad_zero),
51  _grad_var_sup_mom_y(isCoupled(NS::superficial_momentum_y)
52  ? adCoupledGradient(NS::superficial_momentum_y)
53  : _ad_grad_zero),
54  _var_sup_mom_z(isCoupled(NS::superficial_momentum_z)
55  ? adCoupledValue(NS::superficial_momentum_z)
56  : _ad_zero),
57  _grad_var_sup_mom_z(isCoupled(NS::superficial_momentum_z)
58  ? adCoupledGradient(NS::superficial_momentum_z)
59  : _ad_grad_zero),
60  _var_sup_mom_x_dot(_is_transient ? adCoupledDot(NS::superficial_momentum_x) : _ad_zero),
61  _var_sup_mom_y_dot((isCoupled(NS::superficial_momentum_y) && _is_transient)
62  ? adCoupledDot(NS::superficial_momentum_y)
63  : _ad_zero),
64  _var_sup_mom_z_dot((isCoupled(NS::superficial_momentum_z) && _is_transient)
65  ? adCoupledDot(NS::superficial_momentum_z)
66  : _ad_zero),
67  // porosity
68  _epsilon(getMaterialProperty<Real>(NS::porosity)),
69  // properties: primitives
70  _pressure(declareADProperty<Real>(NS::pressure)),
71  _grad_pressure(declareADProperty<RealVectorValue>(NS::grad(NS::pressure))),
72  _T_fluid(declareADProperty<Real>(NS::T_fluid)),
73  _grad_T_fluid(declareADProperty<RealVectorValue>(NS::grad(NS::T_fluid))),
74  _sup_vel(declareADProperty<RealVectorValue>(NS::superficial_velocity)),
75  _sup_vel_x(declareADProperty<Real>(NS::superficial_velocity_x)),
76  _grad_sup_vel_x(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_x))),
77  _sup_vel_y(declareADProperty<Real>(NS::superficial_velocity_y)),
78  _grad_sup_vel_y(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_y))),
79  _sup_vel_z(declareADProperty<Real>(NS::superficial_velocity_z)),
80  _grad_sup_vel_z(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_z))),
81  // properties: for viz
82  _rho(declareADProperty<Real>(NS::density)),
83  _sup_rho_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_density))),
84  _velocity(declareADProperty<RealVectorValue>(NS::velocity)),
85  _vel_x(declareADProperty<Real>(NS::velocity_x)),
86  _vel_y(declareADProperty<Real>(NS::velocity_y)),
87  _vel_z(declareADProperty<Real>(NS::velocity_z)),
88  _sup_mom_x(declareADProperty<Real>(NS::superficial_momentum_x)),
89  _sup_mom_y(declareADProperty<Real>(NS::superficial_momentum_y)),
90  _sup_mom_z(declareADProperty<Real>(NS::superficial_momentum_z)),
91  _sup_mom_x_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_x))),
92  _sup_mom_y_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_y))),
93  _sup_mom_z_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_z))),
94  _sup_rho_et_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_total_energy_density))),
95  _mom(declareADProperty<RealVectorValue>(NS::momentum)),
96  _mom_x(declareADProperty<Real>(NS::momentum_x)),
97  _mom_y(declareADProperty<Real>(NS::momentum_y)),
98  _mom_z(declareADProperty<Real>(NS::momentum_z)),
99  _speed(declareADProperty<Real>(NS::speed)),
100  _rho_et(declareADProperty<Real>(NS::total_energy_density)),
101  _e(declareADProperty<Real>(NS::specific_internal_energy)),
102  _ht(declareADProperty<Real>(NS::specific_total_enthalpy))
103 {
105  mooseError("You must couple in a superficial y-momentum when solving 2D or 3D problems.");
106 
108  mooseError("You must couple in a superficial z-momentum when solving 3D problems.");
109 }
110 
111 void
113 {
114  // Our primitive variable set
119  const VectorValue<ADReal> superficial_momentum = {
121  _sup_mom_x[_qp] = superficial_momentum(0);
122  _sup_mom_y[_qp] = superficial_momentum(1);
123  _sup_mom_z[_qp] = superficial_momentum(2);
127 
128  ADReal drho_dp, drho_dT;
129  _fluid.rho_from_p_T(_pressure[_qp], _T_fluid[_qp], _rho[_qp], drho_dp, drho_dT);
130  const auto rho_dot = drho_dp * _pressure_dot[_qp] + drho_dT * _T_fluid_dot[_qp];
131  const auto grad_rho = drho_dp * _grad_pressure[_qp] + drho_dT * _grad_T_fluid[_qp];
132  _sup_rho_dot[_qp] = _epsilon[_qp] * rho_dot;
133 
134  _sup_vel[_qp] = superficial_momentum / _rho[_qp];
135  _sup_vel_x[_qp] = _sup_vel[_qp](0);
136  _sup_vel_y[_qp] = _sup_vel[_qp](1);
137  _sup_vel_z[_qp] = _sup_vel[_qp](2);
139  superficial_momentum(0) / (_rho[_qp] * _rho[_qp]) * grad_rho;
141  superficial_momentum(1) / (_rho[_qp] * _rho[_qp]) * grad_rho;
143  superficial_momentum(2) / (_rho[_qp] * _rho[_qp]) * grad_rho;
144  const auto sup_vel_x_dot = _var_sup_mom_x_dot[_qp] / _rho[_qp] -
145  superficial_momentum(0) / (_rho[_qp] * _rho[_qp]) * rho_dot;
146  const auto sup_vel_y_dot = _var_sup_mom_y_dot[_qp] / _rho[_qp] -
147  superficial_momentum(1) / (_rho[_qp] * _rho[_qp]) * rho_dot;
148  const auto sup_vel_z_dot = _var_sup_mom_z_dot[_qp] / _rho[_qp] -
149  superficial_momentum(2) / (_rho[_qp] * _rho[_qp]) * rho_dot;
150 
152  _vel_x[_qp] = _velocity[_qp](0);
153  _vel_y[_qp] = _velocity[_qp](1);
154  _vel_z[_qp] = _velocity[_qp](2);
155 
156  const auto v = 1. / _rho[_qp];
157  const auto v_dot = -rho_dot / (_rho[_qp] * _rho[_qp]);
158  ADReal de_dT, de_dv;
159  _fluid.e_from_T_v(_T_fluid[_qp], v, _e[_qp], de_dT, de_dv);
160  const auto e_dot = de_dT * _T_fluid_dot[_qp] + de_dv * v_dot;
161  const auto et = _e[_qp] + _velocity[_qp] * _velocity[_qp] / 2.;
162  const auto velocity_dot =
163  VectorValue<ADReal>(sup_vel_x_dot, sup_vel_y_dot, sup_vel_z_dot) / _epsilon[_qp];
164  const auto et_dot = e_dot + _velocity[_qp] * velocity_dot;
165  _sup_rho_et_dot[_qp] = _epsilon[_qp] * (rho_dot * et + et_dot * _rho[_qp]);
166 
170  _mom[_qp] = {_mom_x[_qp], _mom_y[_qp], _mom_z[_qp]};
171 
173 
174  _rho_et[_qp] = _rho[_qp] * et;
175  _ht[_qp] = et + _pressure[_qp] / _rho[_qp];
176 }
static const std::string superficial_density
Definition: NS.h:34
static const std::string total_energy_density
Definition: NS.h:65
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
const ADVariableValue & _var_sup_mom_z_dot
static const std::string momentum_x
Definition: NS.h:35
const ADVariableValue & _var_T_fluid
static const std::string superficial_velocity
Definition: NS.h:53
const ADVariableGradient & _grad_var_T_fluid
ADMaterialProperty< Real > & _T_fluid
registerMooseObject("NavierStokesApp", PorousMixedVarMaterial)
ADMaterialProperty< Real > & _sup_mom_x
ADMaterialProperty< Real > & _rho_et
static InputParameters validParams()
static const std::string speed
Definition: NS.h:143
ADMaterialProperty< Real > & _mom_y
ADMaterialProperty< Real > & _sup_rho_dot
static const std::string momentum
Definition: NS.h:83
virtual void computeQpProperties() override
static const std::string superficial_momentum_y
Definition: NS.h:40
ADMaterialProperty< RealVectorValue > & _grad_pressure
ADMaterialProperty< Real > & _sup_mom_z
const ADVariableValue & _var_sup_mom_z
const ADVariableGradient & _grad_var_sup_mom_z
static const std::string velocity_z
Definition: NS.h:48
static const std::string superficial_momentum_x
Definition: NS.h:39
const SinglePhaseFluidProperties & _fluid
fluid properties
static const std::string density
Definition: NS.h:33
This object takes a mixed porous-flow variable set (pressure, rho epsilon U, T_fluid) and computes al...
static const std::string fluid
Definition: NS.h:87
static const std::string superficial_momentum_z
Definition: NS.h:41
ADMaterialProperty< RealVectorValue > & _grad_T_fluid
const MaterialProperty< Real > & _epsilon
porosity
static const std::string velocity_x
Definition: NS.h:46
ADMaterialProperty< Real > & _sup_mom_z_dot
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_z
static const std::string specific_internal_energy
Definition: NS.h:62
ADMaterialProperty< Real > & _sup_mom_x_dot
ADMaterialProperty< Real > & _vel_x
const ADVariableValue & _pressure_dot
unsigned int _qp
static const std::string porosity
Definition: NS.h:104
MooseMesh & _mesh
ADMaterialProperty< RealVectorValue > & _mom
static const std::string T_fluid
Definition: NS.h:106
const ADVariableGradient & _grad_var_pressure
static InputParameters validParams()
ADMaterialProperty< Real > & _vel_z
virtual unsigned int dimension() const
static const std::string superficial_velocity_y
Definition: NS.h:51
ADMaterialProperty< Real > & _mom_x
ADMaterialProperty< Real > & _sup_vel_x
ADMaterialProperty< Real > & _mom_z
ADMaterialProperty< Real > & _pressure
properties: primitives
const ADVariableValue & _var_pressure
primitive variables
Common class for single phase fluid properties.
static const std::string velocity_y
Definition: NS.h:47
ADMaterialProperty< Real > & _ht
ADMaterialProperty< Real > & _sup_mom_y
std::string grad(const std::string &var)
Definition: NS.h:91
ADMaterialProperty< RealVectorValue > & _velocity
static const std::string momentum_y
Definition: NS.h:36
const ADVariableGradient & _grad_var_sup_mom_y
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
static const std::string specific_total_enthalpy
Definition: NS.h:69
ADMaterialProperty< Real > & _sup_rho_et_dot
const ADVariableValue & _var_sup_mom_y
ADMaterialProperty< Real > & _sup_vel_y
static const std::string pressure
Definition: NS.h:56
const ADVariableValue & _var_sup_mom_x
void mooseError(Args &&... args) const
ADMaterialProperty< Real > & _speed
static const std::string superficial_total_energy_density
Definition: NS.h:66
const ADVariableGradient & _grad_var_sup_mom_x
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_x
static const std::string velocity
Definition: NS.h:45
ADMaterialProperty< Real > & _vel_y
static const std::string momentum_z
Definition: NS.h:37
PorousMixedVarMaterial(const InputParameters &parameters)
ADMaterialProperty< RealVectorValue > & _sup_vel
ADMaterialProperty< Real > & _rho
ADMaterialProperty< Real > & _e
ADMaterialProperty< Real > & _sup_vel_z
ADMaterialProperty< Real > & _sup_mom_y_dot
const ADVariableValue & _var_sup_mom_x_dot
static const std::string superficial_velocity_z
Definition: NS.h:52
std::string time_deriv(const std::string &var)
Definition: NS.h:97
const ADVariableValue & _var_sup_mom_y_dot
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_y
static const std::string superficial_velocity_x
Definition: NS.h:50
const ADVariableValue & _T_fluid_dot