www.mooseframework.org
PorousFlow2PhasePP.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 
10 #include "PorousFlow2PhasePP.h"
12 
13 registerMooseObject("PorousFlowApp", PorousFlow2PhasePP);
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<PorousFlowVariableBase>();
20  params.addRequiredCoupledVar("phase0_porepressure",
21  "Variable that is the porepressure of phase "
22  "0 (eg, the water phase). It will be <= "
23  "phase1_porepressure.");
24  params.addRequiredCoupledVar("phase1_porepressure",
25  "Variable that is the porepressure of phase 1 (eg, the gas phase)");
26  params.addRequiredParam<UserObjectName>("capillary_pressure",
27  "Name of the UserObject defining the capillary pressure");
28  params.addClassDescription("This Material calculates the 2 porepressures and the 2 saturations "
29  "in a 2-phase situation, and derivatives of these with "
30  "respect to the PorousFlowVariables");
31  return params;
32 }
33 
34 PorousFlow2PhasePP::PorousFlow2PhasePP(const InputParameters & parameters)
35  : PorousFlowVariableBase(parameters),
36 
37  _phase0_porepressure(_nodal_material ? coupledDofValues("phase0_porepressure")
38  : coupledValue("phase0_porepressure")),
39  _phase0_gradp_qp(coupledGradient("phase0_porepressure")),
40  _phase0_porepressure_varnum(coupled("phase0_porepressure")),
41  _p0var(_dictator.isPorousFlowVariable(_phase0_porepressure_varnum)
42  ? _dictator.porousFlowVariableNum(_phase0_porepressure_varnum)
43  : 0),
44 
45  _phase1_porepressure(_nodal_material ? coupledDofValues("phase1_porepressure")
46  : coupledValue("phase1_porepressure")),
47  _phase1_gradp_qp(coupledGradient("phase1_porepressure")),
48  _phase1_porepressure_varnum(coupled("phase1_porepressure")),
49  _p1var(_dictator.isPorousFlowVariable(_phase1_porepressure_varnum)
50  ? _dictator.porousFlowVariableNum(_phase1_porepressure_varnum)
51  : 0),
52  _pc_uo(getUserObject<PorousFlowCapillaryPressure>("capillary_pressure"))
53 {
54  if (_num_phases != 2)
55  mooseError("The Dictator announces that the number of phases is ",
56  _dictator.numPhases(),
57  " whereas PorousFlow2PhasePP can only be used for 2-phase simulation. When you "
58  "have an efficient government, you have a dictatorship.");
59 }
60 
61 void
63 {
65  buildQpPPSS();
66 }
67 
68 void
70 {
71  // size stuff correctly and prepare the derivative matrices with zeroes
73 
74  const Real pc = buildQpPPSS();
75  const Real ds = _pc_uo.dSaturation(pc); // dS/d(pc)
76 
77  if (!_nodal_material)
78  {
79  (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
80  (*_gradp_qp)[_qp][1] = _phase1_gradp_qp[_qp];
81  (*_grads_qp)[_qp][0] = ds * ((*_gradp_qp)[_qp][0] - (*_gradp_qp)[_qp][1]);
82  (*_grads_qp)[_qp][1] = -(*_grads_qp)[_qp][0];
83  }
84 
85  // the derivatives of porepressure with respect to porepressure
86  // remain fixed (at unity) throughout the simulation
87  if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
88  {
89  _dporepressure_dvar[_qp][0][_p0var] = 1.0;
90  if (!_nodal_material)
91  (*_dgradp_qp_dgradv)[_qp][0][_p0var] = 1.0;
92  }
93  if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
94  {
95  _dporepressure_dvar[_qp][1][_p1var] = 1.0;
96  if (!_nodal_material)
97  (*_dgradp_qp_dgradv)[_qp][1][_p1var] = 1.0;
98  }
99 
100  if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
101  {
102  _dsaturation_dvar[_qp][0][_p0var] = ds;
103  _dsaturation_dvar[_qp][1][_p0var] = -ds;
104  }
105  if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
106  {
107  _dsaturation_dvar[_qp][0][_p1var] = -ds;
108  _dsaturation_dvar[_qp][1][_p1var] = ds;
109  }
110 
111  if (!_nodal_material)
112  {
113  const Real d2s_qp = _pc_uo.d2Saturation(pc); // d^2(S_qp)/d(pc_qp)^2
114  if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
115  {
116  (*_dgrads_qp_dgradv)[_qp][0][_p0var] = ds;
117  (*_dgrads_qp_dv)[_qp][0][_p0var] = d2s_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
118  (*_dgrads_qp_dgradv)[_qp][1][_p0var] = -ds;
119  (*_dgrads_qp_dv)[_qp][1][_p0var] = -d2s_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
120  }
121  if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
122  {
123  (*_dgrads_qp_dgradv)[_qp][0][_p1var] = -ds;
124  (*_dgrads_qp_dv)[_qp][0][_p1var] = -d2s_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
125  (*_dgrads_qp_dgradv)[_qp][1][_p1var] = ds;
126  (*_dgrads_qp_dv)[_qp][1][_p1var] = d2s_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
127  }
128  }
129 }
130 
131 Real
133 {
134  _porepressure[_qp][0] = _phase0_porepressure[_qp];
135  _porepressure[_qp][1] = _phase1_porepressure[_qp];
136  const Real pc = _phase0_porepressure[_qp] - _phase1_porepressure[_qp]; // this is <= 0
137  const Real sat = _pc_uo.saturation(pc);
138  _saturation[_qp][0] = sat;
139  _saturation[_qp][1] = 1.0 - sat;
140  return pc;
141 }
PorousFlowCapillaryPressure::dSaturation
Real dSaturation(Real pc, unsigned qp=0) const
Derivative of saturation wrt capillary pressure.
Definition: PorousFlowCapillaryPressure.C:103
validParams< PorousFlow2PhasePP >
InputParameters validParams< PorousFlow2PhasePP >()
Definition: PorousFlow2PhasePP.C:17
PorousFlowVariableBase::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlowVariableBase.C:74
PorousFlow2PhasePP::_phase0_porepressure_varnum
const unsigned int _phase0_porepressure_varnum
Moose variable number of the phase0 porepressure.
Definition: PorousFlow2PhasePP.h:44
PorousFlow2PhasePP::_p1var
const unsigned int _p1var
PorousFlow variable number of the phase1 porepressure.
Definition: PorousFlow2PhasePP.h:54
PorousFlow2PhasePP::_phase1_porepressure_varnum
const unsigned int _phase1_porepressure_varnum
Moose variable number of the phase1 porepressure.
Definition: PorousFlow2PhasePP.h:52
PorousFlow2PhasePP::_phase0_porepressure
const VariableValue & _phase0_porepressure
Nodal or quadpoint value of porepressure of the zero phase (eg, the water phase)
Definition: PorousFlow2PhasePP.h:40
PorousFlowCapillaryPressure
Base class for capillary pressure for multiphase flow in porous media.
Definition: PorousFlowCapillaryPressure.h:39
PorousFlow2PhasePP::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: PorousFlow2PhasePP.C:62
PorousFlow2PhasePP::_phase1_gradp_qp
const VariableGradient & _phase1_gradp_qp
Gradient(phase1_porepressure) at the qps.
Definition: PorousFlow2PhasePP.h:50
PorousFlowVariableBase::_num_phases
const unsigned int _num_phases
Number of phases.
Definition: PorousFlowVariableBase.h:35
PorousFlow2PhasePP::_phase1_porepressure
const VariableValue & _phase1_porepressure
Nodal or quadpoint value of porepressure of the one phase (eg, the gas phase)
Definition: PorousFlow2PhasePP.h:48
PorousFlowCapillaryPressure.h
PorousFlow2PhasePP::buildQpPPSS
Real buildQpPPSS()
Assemble std::vectors of porepressure and saturation at the nodes and quadpoints, and return the capi...
Definition: PorousFlow2PhasePP.C:132
PorousFlowVariableBase
Base class for thermophysical variable materials, which assemble materials for primary variables such...
Definition: PorousFlowVariableBase.h:25
PorousFlow2PhasePP::_phase0_gradp_qp
const VariableGradient & _phase0_gradp_qp
Gradient(phase0_porepressure) at the qps.
Definition: PorousFlow2PhasePP.h:42
PorousFlow2PhasePP::_pc_uo
const PorousFlowCapillaryPressure & _pc_uo
Capillary pressure UserObject.
Definition: PorousFlow2PhasePP.h:56
PorousFlowVariableBase::_porepressure
MaterialProperty< std::vector< Real > > & _porepressure
Computed nodal or quadpoint values of porepressure of the phases.
Definition: PorousFlowVariableBase.h:44
PorousFlowVariableBase::_dporepressure_dvar
MaterialProperty< std::vector< std::vector< Real > > > & _dporepressure_dvar
d(porepressure)/d(PorousFlow variable)
Definition: PorousFlowVariableBase.h:47
PorousFlow2PhasePP::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlow2PhasePP.C:69
PorousFlow2PhasePP
Base material designed to calculate fluid phase porepressure and saturation for the two-phase situati...
Definition: PorousFlow2PhasePP.h:24
PorousFlow2PhasePP::_p0var
const unsigned int _p0var
PorousFlow variable number of the phase0 porepressure.
Definition: PorousFlow2PhasePP.h:46
PorousFlowCapillaryPressure::d2Saturation
Real d2Saturation(Real pc, unsigned qp=0) const
Second derivative of saturation wrt capillary pressure.
Definition: PorousFlowCapillaryPressure.C:109
PorousFlow2PhasePP::PorousFlow2PhasePP
PorousFlow2PhasePP(const InputParameters &parameters)
Definition: PorousFlow2PhasePP.C:34
PorousFlow2PhasePP.h
PorousFlowVariableBase::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: PorousFlowVariableBase.C:66
PorousFlowVariableBase::_saturation
MaterialProperty< std::vector< Real > > & _saturation
Computed nodal or qp saturation of the phases.
Definition: PorousFlowVariableBase.h:59
PorousFlowCapillaryPressure::saturation
Real saturation(Real pc, unsigned qp=0) const
Saturation as a function of capillary pressure.
Definition: PorousFlowCapillaryPressure.C:97
PorousFlowVariableBase::_dsaturation_dvar
MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
d(saturation)/d(PorousFlow variable)
Definition: PorousFlowVariableBase.h:62
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlow2PhasePP)
validParams< PorousFlowVariableBase >
InputParameters validParams< PorousFlowVariableBase >()
Definition: PorousFlowVariableBase.C:14