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
70 : &this->template getMaterialProperty<
std::vector<RealGradient>>(
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")
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;
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;
211 libmesh_ignore(pvar);