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