24 params.
addParam<
bool>(
"strain_at_nearest_qp",
26 "When calculating nodal porosity that depends on strain, use the strain at " 27 "the nearest quadpoint. This adds a small extra computational burden, and " 28 "is not necessary for simulations involving only linear lagrange elements. " 29 " If you set this to true, you will also want to set the same parameter to " 30 "true for related Kernels and Materials");
33 "For mechanically-coupled systems, this Kernel will depend on the volumetric strain. " 34 "base_name should almost always be the same base_name as given to the TensorMechanics object " 35 "that computes strain. Supplying a base_name to this Kernel but not defining an associated " 36 "TensorMechanics strain calculator means that this Kernel will not depend on volumetric " 37 "strain. That could be useful when models contain solid mechanics that is not coupled to " 38 "porous flow, for example");
40 "PorousFlowDictator",
"The UserObject that holds the list of PorousFlow variable names.");
41 params.
set<
bool>(
"use_displaced_mesh") =
false;
52 _var_is_porflow_var(_dictator.isPorousFlowVariable(_var.number())),
53 _num_phases(_dictator.numPhases()),
54 _fluid_present(_num_phases > 0),
55 _strain_at_nearest_qp(this->template getParam<bool>(
"strain_at_nearest_qp")),
56 _base_name(this->isParamValid(
"base_name")
57 ? this->template getParam<
std::string>(
"base_name") +
"_" 60 this->template hasMaterialProperty<
RankTwoTensor>(_base_name +
"total_strain")),
61 _total_strain_old(_has_total_strain ? &this->template getMaterialPropertyOld<
RankTwoTensor>(
62 _base_name +
"total_strain")
64 _porosity(this->template getGenericMaterialProperty<
Real, is_ad>(
"PorousFlow_porosity_nodal")),
65 _porosity_old(this->template getMaterialPropertyOld<
Real>(
"PorousFlow_porosity_nodal")),
66 _dporosity_dvar(is_ad ? nullptr
67 : &this->template getMaterialProperty<
std::vector<
Real>>(
68 "dPorousFlow_porosity_nodal_dvar")),
69 _dporosity_dgradvar(is_ad ? nullptr
71 "dPorousFlow_porosity_nodal_dgradvar")),
72 _nearest_qp(_strain_at_nearest_qp ? &this->template getMaterialProperty<unsigned
int>(
73 "PorousFlow_nearestqp_nodal")
75 _rock_energy_nodal(this->template getGenericMaterialProperty<
Real, is_ad>(
76 "PorousFlow_matrix_internal_energy_nodal")),
77 _rock_energy_nodal_old(
78 this->template getMaterialPropertyOld<
Real>(
"PorousFlow_matrix_internal_energy_nodal")),
79 _drock_energy_nodal_dvar(is_ad ? nullptr
80 : &this->template getMaterialProperty<
std::vector<
Real>>(
81 "dPorousFlow_matrix_internal_energy_nodal_dvar")),
82 _fluid_density(_fluid_present
83 ? &this->template getGenericMaterialProperty<
std::vector<
Real>, is_ad>(
84 "PorousFlow_fluid_phase_density_nodal")
86 _fluid_density_old(_fluid_present ? &this->template getMaterialPropertyOld<
std::vector<
Real>>(
87 "PorousFlow_fluid_phase_density_nodal")
89 _dfluid_density_dvar(_fluid_present && !is_ad
90 ? &this->template getMaterialProperty<
std::vector<
std::vector<
Real>>>(
91 "dPorousFlow_fluid_phase_density_nodal_dvar")
93 _fluid_saturation_nodal(
94 _fluid_present ? &this->template getGenericMaterialProperty<
std::vector<
Real>, is_ad>(
95 "PorousFlow_saturation_nodal")
97 _fluid_saturation_nodal_old(_fluid_present
98 ? &this->template getMaterialPropertyOld<
std::vector<
Real>>(
99 "PorousFlow_saturation_nodal")
101 _dfluid_saturation_nodal_dvar(
102 _fluid_present && !is_ad
103 ? &this->template getMaterialProperty<
std::vector<
std::vector<
Real>>>(
104 "dPorousFlow_saturation_nodal_dvar")
106 _energy_nodal(_fluid_present
107 ? &this->template getGenericMaterialProperty<
std::vector<
Real>, is_ad>(
108 "PorousFlow_fluid_phase_internal_energy_nodal")
110 _energy_nodal_old(_fluid_present ? &this->template getMaterialPropertyOld<
std::vector<
Real>>(
111 "PorousFlow_fluid_phase_internal_energy_nodal")
113 _denergy_nodal_dvar(_fluid_present && !is_ad
114 ? &this->template getMaterialProperty<
std::vector<
std::vector<
Real>>>(
115 "dPorousFlow_fluid_phase_internal_energy_nodal_dvar")
120 template <
bool is_ad>
126 Real energy_old = (1.0 - _porosity_old[_i]) * _rock_energy_nodal_old[_i];
130 for (
unsigned ph = 0; ph < _num_phases; ++ph)
132 energy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
133 (*_energy_nodal)[_i][ph] * _porosity[_i];
134 energy_old += (*_fluid_density_old)[_i][ph] * (*_fluid_saturation_nodal_old)[_i][ph] *
135 (*_energy_nodal_old)[_i][ph] * _porosity_old[_i];
137 const Real strain = (_has_total_strain ? (*_total_strain_old)[_qp].trace() : 0.0);
139 return _test[_i][_qp] * (1.0 + strain) * (energy - energy_old) / _dt;
142 template <
bool is_ad>
146 if constexpr (!is_ad)
149 if (!_var_is_porflow_var)
151 return computeQpJac(_dictator.porousFlowVariableNum(_var.number()));
156 template <
bool is_ad>
160 if constexpr (!is_ad)
163 if (_dictator.notPorousFlowVariable(jvar))
165 return computeQpJac(_dictator.porousFlowVariableNum(jvar));
172 template <
bool is_ad>
176 if constexpr (!is_ad)
178 const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
180 const Real strain = (_has_total_strain ? (*_total_strain_old)[_qp].trace() : 0.0);
185 Real denergy = -(*_dporosity_dgradvar)[_i][pvar] * _grad_phi[_j][_i] * _rock_energy_nodal[_i];
186 for (
unsigned ph = 0; ph < _num_phases; ++ph)
187 denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
188 (*_energy_nodal)[_i][ph] * (*_dporosity_dgradvar)[_i][pvar] *
189 _grad_phi[_j][nearest_qp];
192 return _test[_i][_qp] * (1.0 + strain) * denergy / _dt;
195 denergy += -(*_dporosity_dvar)[_i][pvar] * _rock_energy_nodal[_i];
196 denergy += (1.0 - _porosity[_i]) * (*_drock_energy_nodal_dvar)[_i][pvar];
197 for (
unsigned ph = 0; ph < _num_phases; ++ph)
199 denergy += (*_dfluid_density_dvar)[_i][ph][pvar] * (*_fluid_saturation_nodal)[_i][ph] *
200 (*_energy_nodal)[_i][ph] * _porosity[_i];
201 denergy += (*_fluid_density)[_i][ph] * (*_dfluid_saturation_nodal_dvar)[_i][ph][pvar] *
202 (*_energy_nodal)[_i][ph] * _porosity[_i];
203 denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
204 (*_denergy_nodal_dvar)[_i][ph][pvar] * _porosity[_i];
205 denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
206 (*_energy_nodal)[_i][ph] * (*_dporosity_dvar)[_i][pvar];
208 return _test[_i][_qp] * (1.0 + strain) * denergy / _dt;
Moose::GenericType< Real, is_ad > GenericReal
static InputParameters validParams()
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
static InputParameters validParams()
Real computeQpJac(unsigned int pvar) const
Derivative of residual with respect to PorousFlow variable number pvar (non-AD path only) ...
PorousFlowEnergyTimeDerivativeTempl(const InputParameters ¶meters)
virtual GenericReal< is_ad > computeQpResidual() override
void libmesh_ignore(const Args &...)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeQpJacobian() override
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
Kernel = (heat_energy - heat_energy_old)/dt It is lumped to the nodes.
Base class for PorousFlow kernels that use mass-lumped (nodal) material properties.
registerMooseObject("PorousFlowApp", PorousFlowEnergyTimeDerivative)
void ErrorVector unsigned int