www.mooseframework.org
PorousFlowHeatVolumetricExpansion.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 // MOOSE includes
11 #include "MooseVariable.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<TimeKernel>();
18  params.addParam<bool>("strain_at_nearest_qp",
19  false,
20  "When calculating nodal porosity that depends on strain, use the strain at "
21  "the nearest quadpoint. This adds a small extra computational burden, and "
22  "is not necessary for simulations involving only linear lagrange elements. "
23  " If you set this to true, you will also want to set the same parameter to "
24  "true for related Kernels and Materials");
25  params.addRequiredParam<UserObjectName>(
26  "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names.");
27  params.addClassDescription("Energy-density*rate_of_solid_volumetric_expansion");
28  return params;
29 }
30 
32  const InputParameters & parameters)
33  : TimeKernel(parameters),
34  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
35  _var_is_porflow_var(_dictator.isPorousFlowVariable(_var.number())),
36  _num_phases(_dictator.numPhases()),
37  _fluid_present(_num_phases > 0),
38  _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
39  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
40  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")),
41  _dporosity_dgradvar(
42  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")),
43  _nearest_qp(_strain_at_nearest_qp
44  ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal")
45  : nullptr),
46  _rock_energy_nodal(getMaterialProperty<Real>("PorousFlow_matrix_internal_energy_nodal")),
47  _drock_energy_nodal_dvar(
48  getMaterialProperty<std::vector<Real>>("dPorousFlow_matrix_internal_energy_nodal_dvar")),
49  _fluid_density(
50  _fluid_present
51  ? &getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")
52  : nullptr),
53  _dfluid_density_dvar(_fluid_present
54  ? &getMaterialProperty<std::vector<std::vector<Real>>>(
55  "dPorousFlow_fluid_phase_density_nodal_dvar")
56  : nullptr),
57  _fluid_saturation_nodal(
58  _fluid_present ? &getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")
59  : nullptr),
60  _dfluid_saturation_nodal_dvar(_fluid_present
61  ? &getMaterialProperty<std::vector<std::vector<Real>>>(
62  "dPorousFlow_saturation_nodal_dvar")
63  : nullptr),
64  _energy_nodal(_fluid_present
65  ? &getMaterialProperty<std::vector<Real>>(
66  "PorousFlow_fluid_phase_internal_energy_nodal")
67  : nullptr),
68  _denergy_nodal_dvar(_fluid_present
69  ? &getMaterialProperty<std::vector<std::vector<Real>>>(
70  "dPorousFlow_fluid_phase_internal_energy_nodal_dvar")
71  : nullptr),
72  _strain_rate_qp(getMaterialProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
73  _dstrain_rate_qp_dvar(getMaterialProperty<std::vector<RealGradient>>(
74  "dPorousFlow_volumetric_strain_rate_qp_dvar"))
75 {
76 }
77 
78 Real
80 {
81  Real energy = (1.0 - _porosity[_i]) * _rock_energy_nodal[_i];
82  for (unsigned ph = 0; ph < _num_phases; ++ph)
83  energy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
84  (*_energy_nodal)[_i][ph] * _porosity[_i];
85 
86  return _test[_i][_qp] * energy * _strain_rate_qp[_qp];
87 }
88 
89 Real
91 {
92  return computedEnergyQpJac(_var.number()) + computedVolQpJac(_var.number());
93 }
94 
95 Real
97 {
98  return computedEnergyQpJac(jvar) + computedVolQpJac(jvar);
99 }
100 
101 Real
103 {
105  return 0.0;
106 
107  Real energy = (1.0 - _porosity[_i]) * _rock_energy_nodal[_i];
108  for (unsigned ph = 0; ph < _num_phases; ++ph)
109  energy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
110  (*_energy_nodal)[_i][ph] * _porosity[_i];
111 
112  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
113  Real dvol = _dstrain_rate_qp_dvar[_qp][pvar] * _grad_phi[_j][_qp];
114 
115  return _test[_i][_qp] * energy * dvol;
116 }
117 Real
119 {
121  return 0.0;
122 
123  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
124  const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
125 
126  Real denergy = -_dporosity_dgradvar[_i][pvar] * _grad_phi[_j][_i] * _rock_energy_nodal[_i];
127  for (unsigned ph = 0; ph < _num_phases; ++ph)
128  denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
129  (*_energy_nodal)[_i][ph] * _dporosity_dgradvar[_i][pvar] * _grad_phi[_j][nearest_qp];
130 
131  if (_i != _j)
132  return _test[_i][_qp] * denergy * _strain_rate_qp[_qp];
133 
134  denergy += _drock_energy_nodal_dvar[_i][pvar] * (1.0 - _porosity[_i]);
135  denergy -= _rock_energy_nodal[_i] * _dporosity_dvar[_i][pvar];
136  for (unsigned ph = 0; ph < _num_phases; ++ph)
137  {
138  denergy += (*_dfluid_density_dvar)[_i][ph][pvar] * (*_fluid_saturation_nodal)[_i][ph] *
139  (*_energy_nodal)[_i][ph] * _porosity[_i];
140  denergy += (*_fluid_density)[_i][ph] * (*_dfluid_saturation_nodal_dvar)[_i][ph][pvar] *
141  (*_energy_nodal)[_i][ph] * _porosity[_i];
142  denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
143  (*_denergy_nodal_dvar)[_i][ph][pvar] * _porosity[_i];
144  denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
145  (*_energy_nodal)[_i][ph] * _dporosity_dvar[_i][pvar];
146  }
147 
148  return _test[_i][_qp] * denergy * _strain_rate_qp[_qp];
149 }
InputParameters validParams< PorousFlowHeatVolumetricExpansion >()
Real computedVolQpJac(unsigned int jvar)
Derivative of volumetric-strain part of the residual with respect to the Variable with variable numbe...
Real computedEnergyQpJac(unsigned int jvar)
Derivative of energy part of the residual with respect to the Variable with variable number jvar...
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(porous-flow variable)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const MaterialProperty< std::vector< Real > > *const _fluid_density
nodal fluid density
PorousFlowHeatVolumetricExpansion(const InputParameters &parameters)
const MaterialProperty< Real > & _strain_rate_qp
strain rate
const MaterialProperty< Real > & _porosity
porosity
const MaterialProperty< std::vector< Real > > & _drock_energy_nodal_dvar
d(nodal rock energy density)/d(PorousFlow variable)
const MaterialProperty< std::vector< RealGradient > > & _dstrain_rate_qp_dvar
d(strain rate)/d(porous-flow variable)
const MaterialProperty< Real > & _rock_energy_nodal
nodal rock energy density
const PorousFlowDictator & _dictator
holds info on the Porous Flow variables
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad porous-flow variable)
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
const unsigned int _num_phases
number of fluid phases
const bool _strain_at_nearest_qp
whether the porosity uses the volumetric strain at the closest quadpoint