www.mooseframework.org
PorousFlowFullySaturatedMassTimeDerivative.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  MooseEnum coupling_type("Hydro ThermoHydro HydroMechanical ThermoHydroMechanical", "Hydro");
19  params.addParam<MooseEnum>("coupling_type",
20  coupling_type,
21  "The type of simulation. For simulations involving Mechanical "
22  "deformations, you will need to supply the correct Biot coefficient. "
23  "For simulations involving Thermal flows, you will need an associated "
24  "ConstantThermalExpansionCoefficient Material");
25  params.addRangeCheckedParam<Real>(
26  "biot_coefficient", 1.0, "biot_coefficient>=0 & biot_coefficient<=1", "Biot coefficient");
27  params.addParam<bool>("multiply_by_density",
28  true,
29  "If true, then this Kernel is the time derivative of the fluid "
30  "mass. If false, then this Kernel is the derivative of the "
31  "fluid volume (which is common in poro-mechanics)");
32  params.addRequiredParam<UserObjectName>(
33  "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names.");
34  params.addClassDescription("Fully-saturated version of the single-component, single-phase fluid "
35  "mass derivative wrt time");
36  return params;
37 }
38 
40  const InputParameters & parameters)
41  : TimeKernel(parameters),
42  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
43  _var_is_porflow_var(_dictator.isPorousFlowVariable(_var.number())),
44  _multiply_by_density(getParam<bool>("multiply_by_density")),
45  _coupling_type(getParam<MooseEnum>("coupling_type").getEnum<CouplingTypeEnum>()),
46  _includes_thermal(_coupling_type == CouplingTypeEnum::ThermoHydro ||
47  _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
48  _includes_mechanical(_coupling_type == CouplingTypeEnum::HydroMechanical ||
49  _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
50  _biot_coefficient(getParam<Real>("biot_coefficient")),
51  _biot_modulus(getMaterialProperty<Real>("PorousFlow_constant_biot_modulus_qp")),
52  _thermal_coeff(
53  _includes_thermal
54  ? &getMaterialProperty<Real>("PorousFlow_constant_thermal_expansion_coefficient_qp")
55  : nullptr),
56  _fluid_density(
57  _multiply_by_density
58  ? &getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")
59  : nullptr),
60  _dfluid_density_dvar(_multiply_by_density
61  ? &getMaterialProperty<std::vector<std::vector<Real>>>(
62  "dPorousFlow_fluid_phase_density_qp_dvar")
63  : nullptr),
64  _pp(getMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
65  _pp_old(getMaterialPropertyOld<std::vector<Real>>("PorousFlow_porepressure_qp")),
66  _dpp_dvar(
67  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_porepressure_qp_dvar")),
68  _temperature(_includes_thermal ? &getMaterialProperty<Real>("PorousFlow_temperature_qp")
69  : nullptr),
70  _temperature_old(_includes_thermal ? &getMaterialPropertyOld<Real>("PorousFlow_temperature_qp")
71  : nullptr),
72  _dtemperature_dvar(
73  _includes_thermal
74  ? &getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")
75  : nullptr),
76  _strain_rate(_includes_mechanical
77  ? &getMaterialProperty<Real>("PorousFlow_volumetric_strain_rate_qp")
78  : nullptr),
79  _dstrain_rate_dvar(_includes_mechanical
80  ? &getMaterialProperty<std::vector<RealGradient>>(
81  "dPorousFlow_volumetric_strain_rate_qp_dvar")
82  : nullptr)
83 {
84  if (_dictator.numComponents() != 1 || _dictator.numPhases() != 1)
85  mooseError("PorousFlowFullySaturatedMassTimeDerivative is only applicable to single-phase, "
86  "single-component fluid-flow problems. The Dictator proclaims that you have more "
87  "than one phase or more than one fluid component. The Dictator does not take such "
88  "mistakes lightly");
89 }
90 
91 Real
93 {
94  const unsigned phase = 0;
95  Real volume = (_pp[_qp][phase] - _pp_old[_qp][phase]) / _dt / _biot_modulus[_qp];
97  volume -= (*_thermal_coeff)[_qp] * ((*_temperature)[_qp] - (*_temperature_old)[_qp]) / _dt;
99  volume += _biot_coefficient * (*_strain_rate)[_qp];
101  return _test[_i][_qp] * (*_fluid_density)[_qp][phase] * volume;
102  return _test[_i][_qp] * volume;
103 }
104 
105 Real
107 {
109  if (!_var_is_porflow_var)
110  return 0.0;
111  return computeQpJac(_dictator.porousFlowVariableNum(_var.number()));
112 }
113 
114 Real
116 {
119  return 0.0;
121 }
122 
123 Real
125 {
126  const unsigned phase = 0;
127  Real volume = (_pp[_qp][phase] - _pp_old[_qp][phase]) / _dt / _biot_modulus[_qp];
128  Real dvolume = _dpp_dvar[_qp][phase][pvar] / _dt / _biot_modulus[_qp] * _phi[_j][_qp];
129  if (_includes_thermal)
130  {
131  volume -= (*_thermal_coeff)[_qp] * ((*_temperature)[_qp] - (*_temperature_old)[_qp]) / _dt;
132  dvolume -= (*_thermal_coeff)[_qp] * (*_dtemperature_dvar)[_qp][pvar] / _dt * _phi[_j][_qp];
133  }
135  {
136  volume += _biot_coefficient * (*_strain_rate)[_qp];
137  dvolume += _biot_coefficient * (*_dstrain_rate_dvar)[_qp][pvar] * _grad_phi[_j][_qp];
138  }
140  return _test[_i][_qp] * ((*_fluid_density)[_qp][phase] * dvolume +
141  (*_dfluid_density_dvar)[_qp][phase][pvar] * _phi[_j][_qp] * volume);
142  return _test[_i][_qp] * dvolume;
143 }
const bool _var_is_porflow_var
Whether the Variable for this Kernel is a PorousFlow variable.
const MaterialProperty< std::vector< Real > > & _pp
Quadpoint pore pressure in each phase.
const MaterialProperty< Real > & _biot_modulus
Constant Biot modulus.
const bool _includes_thermal
Whether thermal contributions should be added to the residual.
unsigned int numComponents() const
the number of fluid components
const bool _includes_mechanical
Whether mechanical contributions should be added to the residual.
InputParameters validParams< PorousFlowFullySaturatedMassTimeDerivative >()
Real computeQpJac(unsigned int pvar)
Jacobian contribution for the PorousFlow variable pvar.
const MaterialProperty< std::vector< std::vector< Real > > > & _dpp_dvar
Derivative of porepressure in each phase wrt the PorousFlow variables.
const PorousFlowDictator & _dictator
PorousFlow UserObject.
const Real _biot_coefficient
Biot coefficient (used in simulations involving Mechanical deformations)
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numPhases() const
the number of fluid phases
const bool _multiply_by_density
If true then the Kernel is the time derivative of the fluid mass, otherwise it is the derivative of t...
CouplingTypeEnum
Determines whether mechanical and/or thermal contributions should be added to the residual...
PorousFlowFullySaturatedMassTimeDerivative(const InputParameters &parameters)
const MaterialProperty< std::vector< Real > > & _pp_old
Old value of quadpoint pore pressure in each phase.
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number