https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousPrimitiveVarMaterial.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
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_velocity_x, "The x-velocity times the porosity");
28 params.addCoupledVar(NS::superficial_velocity_y, "The y-velocity times the porosity");
29 params.addCoupledVar(NS::superficial_velocity_z, "The z-velocity 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 // primitive variables
40 _var_pressure(adCoupledValue(NS::pressure)),
41 _grad_var_pressure(adCoupledGradient(NS::pressure)),
42 _var_T_fluid(adCoupledValue(NS::T_fluid)),
43 _grad_var_T_fluid(adCoupledGradient(NS::T_fluid)),
44 _var_sup_vel_x(adCoupledValue(NS::superficial_velocity_x)),
45 _grad_var_sup_vel_x(adCoupledGradient(NS::superficial_velocity_x)),
46 _var_sup_vel_y(isCoupled(NS::superficial_velocity_y)
47 ? adCoupledValue(NS::superficial_velocity_y)
48 : _ad_zero),
49 _grad_var_sup_vel_y(isCoupled(NS::superficial_velocity_y)
50 ? adCoupledGradient(NS::superficial_velocity_y)
51 : _ad_grad_zero),
52 _var_sup_vel_z(isCoupled(NS::superficial_velocity_z)
53 ? adCoupledValue(NS::superficial_velocity_z)
54 : _ad_zero),
55 _grad_var_sup_vel_z(isCoupled(NS::superficial_velocity_z)
56 ? adCoupledGradient(NS::superficial_velocity_z)
57 : _ad_grad_zero),
58 _pressure_dot(_is_transient ? adCoupledDot(NS::pressure) : _ad_zero),
59 _T_fluid_dot(_is_transient ? adCoupledDot(NS::T_fluid) : _ad_zero),
60 _sup_vel_x_dot(_is_transient ? adCoupledDot(NS::superficial_velocity_x) : _ad_zero),
61 _sup_vel_y_dot((isCoupled(NS::superficial_velocity_y) && _is_transient)
62 ? adCoupledDot(NS::superficial_velocity_y)
63 : _ad_zero),
64 _sup_vel_z_dot((isCoupled(NS::superficial_velocity_z) && _is_transient)
65 ? adCoupledDot(NS::superficial_velocity_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_x(declareADProperty<Real>(NS::superficial_velocity_x)),
75 _grad_sup_vel_x(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_x))),
76 _sup_vel_y(declareADProperty<Real>(NS::superficial_velocity_y)),
77 _grad_sup_vel_y(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_y))),
78 _sup_vel_z(declareADProperty<Real>(NS::superficial_velocity_z)),
79 _grad_sup_vel_z(declareADProperty<RealVectorValue>(NS::grad(NS::superficial_velocity_z))),
80 // properties: for viz
81 _rho(declareADProperty<Real>(NS::density)),
82 _sup_rho_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_density))),
83 _velocity(declareADProperty<RealVectorValue>(NS::velocity)),
84 _vel_x(declareADProperty<Real>(NS::velocity_x)),
85 _vel_y(declareADProperty<Real>(NS::velocity_y)),
86 _vel_z(declareADProperty<Real>(NS::velocity_z)),
87 _sup_mom_x(declareADProperty<Real>(NS::superficial_momentum_x)),
88 _sup_mom_y(declareADProperty<Real>(NS::superficial_momentum_y)),
89 _sup_mom_z(declareADProperty<Real>(NS::superficial_momentum_z)),
90 _sup_mom_x_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_x))),
91 _sup_mom_y_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_y))),
92 _sup_mom_z_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_momentum_z))),
93 _sup_rho_et_dot(declareADProperty<Real>(NS::time_deriv(NS::superficial_total_energy_density))),
94 _mom(declareADProperty<RealVectorValue>(NS::momentum)),
95 _mom_x(declareADProperty<Real>(NS::momentum_x)),
96 _mom_y(declareADProperty<Real>(NS::momentum_y)),
97 _mom_z(declareADProperty<Real>(NS::momentum_z)),
98 _speed(declareADProperty<Real>(NS::speed)),
99 _rho_et(declareADProperty<Real>(NS::total_energy_density)),
100 _e(declareADProperty<Real>(NS::specific_internal_energy)),
101 _ht(declareADProperty<Real>(NS::specific_total_enthalpy))
102{
104 mooseError("You must couple in a superficial y-velocity when solving 2D or 3D problems.");
105
107 mooseError("You must couple in a superficial z-velocity when solving 3D problems.");
108}
109
110void
112{
113 // Our primitive variable set
118 const VectorValue<ADReal> superficial_velocity = {
120 _sup_vel_x[_qp] = superficial_velocity(0);
121 _sup_vel_y[_qp] = superficial_velocity(1);
122 _sup_vel_z[_qp] = superficial_velocity(2);
126
127 ADReal drho_dp, drho_dT;
128 _fluid.rho_from_p_T(_pressure[_qp], _T_fluid[_qp], _rho[_qp], drho_dp, drho_dT);
129 const auto rho_dot = drho_dp * _pressure_dot[_qp] + drho_dT * _T_fluid_dot[_qp];
130 _sup_rho_dot[_qp] = _epsilon[_qp] * rho_dot;
131
132 _velocity[_qp] = superficial_velocity / _epsilon[_qp];
133 _vel_x[_qp] = _velocity[_qp](0);
134 _vel_y[_qp] = _velocity[_qp](1);
135 _vel_z[_qp] = _velocity[_qp](2);
136 const auto superficial_momentum = superficial_velocity * _rho[_qp];
137 _sup_mom_x[_qp] = superficial_momentum(0);
138 _sup_mom_y[_qp] = superficial_momentum(1);
139 _sup_mom_z[_qp] = superficial_momentum(2);
143
144 const auto v = 1. / _rho[_qp];
145 const auto v_dot = -rho_dot / (_rho[_qp] * _rho[_qp]);
146 ADReal de_dT, de_dv;
147 _fluid.e_from_T_v(_T_fluid[_qp], v, _e[_qp], de_dT, de_dv);
148 const auto e_dot = de_dT * _T_fluid_dot[_qp] + de_dv * v_dot;
149 const auto et = _e[_qp] + _velocity[_qp] * _velocity[_qp] / 2.;
150 const auto velocity_dot =
151 VectorValue<ADReal>(_sup_vel_x_dot[_qp], _sup_vel_y_dot[_qp], _sup_vel_z_dot[_qp]) /
152 _epsilon[_qp];
153 const auto et_dot = e_dot + _velocity[_qp] * velocity_dot;
154 _sup_rho_et_dot[_qp] = _epsilon[_qp] * (rho_dot * et + et_dot * _rho[_qp]);
155
159 _mom[_qp] = {_mom_x[_qp], _mom_y[_qp], _mom_z[_qp]};
160
162
163 _rho_et[_qp] = _rho[_qp] * et;
164 _ht[_qp] = et + _pressure[_qp] / _rho[_qp];
165}
DualNumber< Real, DNDerivativeType, true > ADReal
const double v
registerMooseObject("NavierStokesApp", PorousPrimitiveVarMaterial)
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
unsigned int _qp
MooseMesh & _mesh
static InputParameters validParams()
void mooseError(Args &&... args) const
virtual unsigned int dimension() const
This object takes a primitive porous-flow variable set (pressure, superficial velocity,...
ADMaterialProperty< RealVectorValue > & _grad_T_fluid
ADMaterialProperty< Real > & _sup_mom_y_dot
ADMaterialProperty< Real > & _ht
ADMaterialProperty< Real > & _mom_z
const ADVariableGradient & _grad_var_sup_vel_x
const ADVariableValue & _sup_vel_x_dot
ADMaterialProperty< Real > & _sup_mom_z
const ADVariableGradient & _grad_var_sup_vel_z
const ADVariableValue & _var_sup_vel_z
ADMaterialProperty< RealVectorValue > & _velocity
static InputParameters validParams()
const SinglePhaseFluidProperties & _fluid
fluid properties
const MaterialProperty< Real > & _epsilon
porosity
ADMaterialProperty< Real > & _speed
ADMaterialProperty< Real > & _vel_x
ADMaterialProperty< Real > & _sup_vel_z
const ADVariableValue & _sup_vel_y_dot
const ADVariableGradient & _grad_var_sup_vel_y
virtual void computeQpProperties() override
ADMaterialProperty< Real > & _sup_mom_x_dot
ADMaterialProperty< RealVectorValue > & _mom
ADMaterialProperty< Real > & _sup_vel_y
ADMaterialProperty< Real > & _vel_z
ADMaterialProperty< Real > & _pressure
properties: primitives
ADMaterialProperty< Real > & _rho
ADMaterialProperty< Real > & _sup_rho_dot
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_x
const ADVariableValue & _pressure_dot
ADMaterialProperty< Real > & _sup_mom_x
const ADVariableGradient & _grad_var_T_fluid
ADMaterialProperty< Real > & _rho_et
ADMaterialProperty< Real > & _T_fluid
ADMaterialProperty< Real > & _mom_x
ADMaterialProperty< RealVectorValue > & _grad_pressure
ADMaterialProperty< Real > & _sup_rho_et_dot
ADMaterialProperty< Real > & _sup_mom_z_dot
const ADVariableGradient & _grad_var_pressure
const ADVariableValue & _var_sup_vel_x
ADMaterialProperty< Real > & _e
const ADVariableValue & _var_pressure
primitive variables
ADMaterialProperty< Real > & _vel_y
const ADVariableValue & _sup_vel_z_dot
ADMaterialProperty< Real > & _mom_y
ADMaterialProperty< Real > & _sup_mom_y
ADMaterialProperty< Real > & _sup_vel_x
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_z
const ADVariableValue & _var_sup_vel_y
PorousPrimitiveVarMaterial(const InputParameters &parameters)
ADMaterialProperty< RealVectorValue > & _grad_sup_vel_y
Common class for single phase fluid properties.
static const std::string superficial_velocity_y
Definition NS.h:52
static const std::string T_fluid
Definition NS.h:110
static const std::string superficial_velocity_z
Definition NS.h:53
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
static const std::string porosity
Definition NS.h:108
static const std::string superficial_velocity_x
Definition NS.h:51
static const std::string fluid
Definition NS.h:88
static const std::string pressure
Definition NS.h:57