www.mooseframework.org
PorousFlowFullySaturatedDarcyBase.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<Kernel>();
18  params.addRequiredParam<RealVectorValue>("gravity",
19  "Gravitational acceleration vector downwards (m/s^2)");
20  params.addParam<bool>("multiply_by_density",
21  true,
22  "If true, then this Kernel is the fluid mass "
23  "flux. If false, then this Kernel is the "
24  "fluid volume flux (which is common in "
25  "poro-mechanics)");
26  params.addRequiredParam<UserObjectName>(
27  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names");
28  params.addClassDescription("Darcy flux suitable for models involving a fully-saturated, single "
29  "phase, single component fluid. No upwinding is used");
30  return params;
31 }
32 
34  const InputParameters & parameters)
35  : Kernel(parameters),
36  _multiply_by_density(getParam<bool>("multiply_by_density")),
37  _permeability(getMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
38  _dpermeability_dvar(
39  getMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")),
40  _dpermeability_dgradvar(getMaterialProperty<std::vector<std::vector<RealTensorValue>>>(
41  "dPorousFlow_permeability_qp_dgradvar")),
42  _density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
43  _ddensity_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
44  "dPorousFlow_fluid_phase_density_qp_dvar")),
45  _viscosity(getMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
46  _dviscosity_dvar(
47  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_viscosity_qp_dvar")),
48  _pp(getMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
49  _grad_p(getMaterialProperty<std::vector<RealGradient>>("PorousFlow_grad_porepressure_qp")),
50  _dgrad_p_dgrad_var(getMaterialProperty<std::vector<std::vector<Real>>>(
51  "dPorousFlow_grad_porepressure_qp_dgradvar")),
52  _dgrad_p_dvar(getMaterialProperty<std::vector<std::vector<RealGradient>>>(
53  "dPorousFlow_grad_porepressure_qp_dvar")),
54  _porousflow_dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
55  _gravity(getParam<RealVectorValue>("gravity"))
56 {
58  mooseError("PorousFlowFullySaturatedDarcyBase should not be used for multi-phase scenarios as "
59  "it does no upwinding and does not include relative-permeability effects");
60 }
61 
62 Real
64 {
65  const unsigned ph = 0;
66  const Real mob = mobility();
67  const RealVectorValue flow =
68  _permeability[_qp] * (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
69  return _grad_test[_i][_qp] * mob * flow;
70 }
71 
72 Real
74 {
75  return computeQpOffDiagJacobian(_var.number());
76 }
77 
78 Real
80 {
82  return 0.0;
83 
84  const unsigned ph = 0;
85  const unsigned pvar = _porousflow_dictator.porousFlowVariableNum(jvar);
86 
87  const Real mob = mobility();
88  const Real dmob = dmobility(pvar) * _phi[_j][_qp];
89  ;
90 
91  const RealVectorValue flow =
92  _permeability[_qp] * (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
93  RealVectorValue dflow = _dpermeability_dvar[_qp][pvar] * _phi[_j][_qp] *
94  (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
95  for (unsigned i = 0; i < LIBMESH_DIM; ++i)
96  dflow += _dpermeability_dgradvar[_qp][i][pvar] * _grad_phi[_j][_qp](i) *
97  (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
98  dflow += _permeability[_qp] * (_grad_phi[_j][_qp] * _dgrad_p_dgrad_var[_qp][ph][pvar] -
99  _phi[_j][_qp] * _ddensity_dvar[_qp][ph][pvar] * _gravity);
100  dflow += _permeability[_qp] * (_dgrad_p_dvar[_qp][ph][pvar] * _phi[_j][_qp]);
101  return _grad_test[_i][_qp] * (dmob * flow + mob * dflow);
102 }
103 
104 Real
106 {
107  const unsigned ph = 0;
108  Real mob = 1.0 / _viscosity[_qp][ph];
110  mob *= _density[_qp][ph];
111  return mob;
112 }
113 
114 Real
116 {
117  const unsigned ph = 0;
118  Real dmob = -_dviscosity_dvar[_qp][ph][pvar] / std::pow(_viscosity[_qp][ph], 2);
120  dmob = _density[_qp][ph] * dmob + _ddensity_dvar[_qp][ph][pvar] / _viscosity[_qp][ph];
121  return dmob;
122 }
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _dpermeability_dgradvar
d(permeabiity)/d(grad(porous-flow variable))
const MaterialProperty< RealTensorValue > & _permeability
Permeability of porous material.
const MaterialProperty< std::vector< std::vector< RealGradient > > > & _dgrad_p_dvar
Derivative of Grad porepressure in each phase wrt PorousFlow variables.
InputParameters validParams< PorousFlowFullySaturatedDarcyBase >()
const RealVectorValue _gravity
Gravity pointing downwards.
const MaterialProperty< std::vector< std::vector< Real > > > & _ddensity_dvar
Derivative of the fluid density for each phase wrt PorousFlow variables (at the qp) ...
PorousFlowFullySaturatedDarcyBase(const InputParameters &parameters)
const MaterialProperty< std::vector< RealGradient > > & _grad_p
Gradient of the pore pressure in each phase.
const MaterialProperty< std::vector< Real > > & _viscosity
Viscosity of the fluid at the qp.
const MaterialProperty< std::vector< std::vector< Real > > > & _dviscosity_dvar
Derivative of the fluid viscosity wrt PorousFlow variables.
const bool _multiply_by_density
If true then the mobility contains the fluid density, otherwise it doesn&#39;t.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const MaterialProperty< std::vector< RealTensorValue > > & _dpermeability_dvar
d(permeabiity)/d(porous-flow variable)
virtual Real mobility() const
The mobility of the fluid = density / viscosity.
virtual Real dmobility(unsigned pvar) const
The derivative of the mobility with respect to the porous-flow variable pvar.
const PorousFlowDictator & _porousflow_dictator
PorousFlow UserObject.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
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 MaterialProperty< std::vector< std::vector< Real > > > & _dgrad_p_dgrad_var
Derivative of Grad porepressure in each phase wrt grad(PorousFlow variables)
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
const MaterialProperty< std::vector< Real > > & _density
Fluid density for each phase (at the qp)