www.mooseframework.org
PorousFlow2PhasePS.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 "PorousFlow2PhasePS.h"
12 
13 registerMooseObject("PorousFlowApp", PorousFlow2PhasePS);
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<PorousFlowVariableBase>();
20  params.addRequiredCoupledVar("phase0_porepressure",
21  "Variable that is the porepressure of phase 0 (the liquid phase)");
22  params.addRequiredCoupledVar("phase1_saturation",
23  "Variable that is the saturation of phase 1 (the gas phase)");
24  params.addRequiredParam<UserObjectName>("capillary_pressure",
25  "Name of the UserObject defining the capillary pressure");
26  params.addClassDescription("This Material calculates the 2 porepressures and the 2 saturations "
27  "in a 2-phase situation, and derivatives of these with "
28  "respect to the PorousFlowVariables.");
29  return params;
30 }
31 
32 PorousFlow2PhasePS::PorousFlow2PhasePS(const InputParameters & parameters)
33  : PorousFlowVariableBase(parameters),
34 
35  _phase0_porepressure(_nodal_material ? coupledDofValues("phase0_porepressure")
36  : coupledValue("phase0_porepressure")),
37  _phase0_gradp_qp(coupledGradient("phase0_porepressure")),
38  _phase0_porepressure_varnum(coupled("phase0_porepressure")),
39  _pvar(_dictator.isPorousFlowVariable(_phase0_porepressure_varnum)
40  ? _dictator.porousFlowVariableNum(_phase0_porepressure_varnum)
41  : 0),
42 
43  _phase1_saturation(_nodal_material ? coupledDofValues("phase1_saturation")
44  : coupledValue("phase1_saturation")),
45  _phase1_grads_qp(coupledGradient("phase1_saturation")),
46  _phase1_saturation_varnum(coupled("phase1_saturation")),
47  _svar(_dictator.isPorousFlowVariable(_phase1_saturation_varnum)
48  ? _dictator.porousFlowVariableNum(_phase1_saturation_varnum)
49  : 0),
50 
51  _pc_uo(getUserObject<PorousFlowCapillaryPressure>("capillary_pressure"))
52 {
53  if (_dictator.numPhases() != 2)
54  mooseError("The Dictator proclaims that the number of phases is ",
55  _dictator.numPhases(),
56  " whereas PorousFlow2PhasePS can only be used for 2-phase simulation. Be aware "
57  "that the Dictator has noted your mistake.");
58 }
59 
60 void
62 {
64  buildQpPPSS();
65 }
66 
67 void
69 {
70  // size stuff correctly and prepare the derivative matrices with zeroes
72 
73  buildQpPPSS();
74  const Real dpc = _pc_uo.dCapillaryPressure(1.0 - _phase1_saturation[_qp]);
75 
76  if (!_nodal_material)
77  {
78  (*_grads_qp)[_qp][0] = -_phase1_grads_qp[_qp];
79  (*_grads_qp)[_qp][1] = _phase1_grads_qp[_qp];
80  (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
81  (*_gradp_qp)[_qp][1] = _phase0_gradp_qp[_qp] - dpc * (*_grads_qp)[_qp][1];
82  }
83 
84  // _porepressure depends on _phase0_porepressure, and its derivative is 1
85  if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
86  {
87  // _phase0_porepressure is a PorousFlow variable
88  for (unsigned phase = 0; phase < _num_phases; ++phase)
89  {
90  _dporepressure_dvar[_qp][phase][_pvar] = 1.0;
91  if (!_nodal_material)
92  (*_dgradp_qp_dgradv)[_qp][phase][_pvar] = 1.0;
93  }
94  }
95 
96  // _saturation is only dependent on _phase1_saturation, and its derivative is +/- 1
97  if (_dictator.isPorousFlowVariable(_phase1_saturation_varnum))
98  {
99  // _phase1_saturation is a PorousFlow variable
100  // _phase1_porepressure depends on saturation through the capillary pressure function
101  _dsaturation_dvar[_qp][0][_svar] = -1.0;
102  _dsaturation_dvar[_qp][1][_svar] = 1.0;
103  _dporepressure_dvar[_qp][1][_svar] = -dpc;
104 
105  if (!_nodal_material)
106  {
107  (*_dgrads_qp_dgradv)[_qp][0][_svar] = -1.0;
108  (*_dgrads_qp_dgradv)[_qp][1][_svar] = 1.0;
109  const Real d2pc_qp = _pc_uo.d2CapillaryPressure(1.0 - _phase1_saturation[_qp]);
110  (*_dgradp_qp_dv)[_qp][1][_svar] = d2pc_qp * (*_grads_qp)[_qp][1];
111  (*_dgradp_qp_dgradv)[_qp][1][_svar] = -dpc;
112  }
113  }
114 }
115 
116 void
118 {
119  _saturation[_qp][0] = 1.0 - _phase1_saturation[_qp];
120  _saturation[_qp][1] = _phase1_saturation[_qp];
121  const Real pc = _pc_uo.capillaryPressure(1.0 - _phase1_saturation[_qp]);
122  _porepressure[_qp][0] = _phase0_porepressure[_qp];
123  _porepressure[_qp][1] = _phase0_porepressure[_qp] + pc;
124 }
PorousFlow2PhasePS::_phase1_saturation
const VariableValue & _phase1_saturation
Nodal or quadpoint value of saturation of phase one (eg, the gas phase)
Definition: PorousFlow2PhasePS.h:48
PorousFlow2PhasePS::_svar
const unsigned int _svar
PorousFlow variable number of the phase1 saturation.
Definition: PorousFlow2PhasePS.h:54
PorousFlowVariableBase::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlowVariableBase.C:74
PorousFlow2PhasePS::_phase1_grads_qp
const VariableGradient & _phase1_grads_qp
Gradient(phase1_saturation) at the qps.
Definition: PorousFlow2PhasePS.h:50
PorousFlow2PhasePS::PorousFlow2PhasePS
PorousFlow2PhasePS(const InputParameters &parameters)
Definition: PorousFlow2PhasePS.C:32
PorousFlow2PhasePS::_pc_uo
const PorousFlowCapillaryPressure & _pc_uo
Capillary pressure UserObject.
Definition: PorousFlow2PhasePS.h:56
PorousFlow2PhasePS::_phase1_saturation_varnum
const unsigned int _phase1_saturation_varnum
Moose variable number of the phase1 saturation.
Definition: PorousFlow2PhasePS.h:52
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlow2PhasePS)
PorousFlowCapillaryPressure
Base class for capillary pressure for multiphase flow in porous media.
Definition: PorousFlowCapillaryPressure.h:39
PorousFlow2PhasePS::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: PorousFlow2PhasePS.C:61
PorousFlow2PhasePS::_phase0_porepressure_varnum
const unsigned int _phase0_porepressure_varnum
Moose variable number of the phase0 porepressure.
Definition: PorousFlow2PhasePS.h:44
PorousFlowVariableBase::_num_phases
const unsigned int _num_phases
Number of phases.
Definition: PorousFlowVariableBase.h:35
PorousFlow2PhasePS::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlow2PhasePS.C:68
PorousFlow2PhasePS
Material designed to calculate fluid-phase porepressures and saturations at nodes and qps using a spe...
Definition: PorousFlow2PhasePS.h:24
PorousFlowCapillaryPressure.h
PorousFlowVariableBase
Base class for thermophysical variable materials, which assemble materials for primary variables such...
Definition: PorousFlowVariableBase.h:25
PorousFlow2PhasePS.h
PorousFlow2PhasePS::_pvar
const unsigned int _pvar
PorousFlow variable number of the phase0 porepressure.
Definition: PorousFlow2PhasePS.h:46
PorousFlowCapillaryPressure::capillaryPressure
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
Definition: PorousFlowCapillaryPressure.C:64
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
PorousFlow2PhasePS::_phase0_porepressure
const VariableValue & _phase0_porepressure
Nodal or quadpoint value of porepressure of phase zero (eg, the liquid phase)
Definition: PorousFlow2PhasePS.h:40
PorousFlowCapillaryPressure::dCapillaryPressure
virtual Real dCapillaryPressure(Real saturation, unsigned qp=0) const
Derivative of capillary pressure wrt true saturation.
Definition: PorousFlowCapillaryPressure.C:73
PorousFlow2PhasePS::_phase0_gradp_qp
const VariableGradient & _phase0_gradp_qp
Gradient(phase0_porepressure) at the qps.
Definition: PorousFlow2PhasePS.h:42
PorousFlow2PhasePS::buildQpPPSS
void buildQpPPSS()
Assemble std::vectors of porepressure and saturation at the nodes and quadpoints.
Definition: PorousFlow2PhasePS.C:117
PorousFlowCapillaryPressure::d2CapillaryPressure
virtual Real d2CapillaryPressure(Real saturation, unsigned qp=0) const
Second derivative of capillary pressure wrt true saturation.
Definition: PorousFlowCapillaryPressure.C:82
validParams< PorousFlow2PhasePS >
InputParameters validParams< PorousFlow2PhasePS >()
Definition: PorousFlow2PhasePS.C:17
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
PorousFlowVariableBase::_dsaturation_dvar
MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
d(saturation)/d(PorousFlow variable)
Definition: PorousFlowVariableBase.h:62
validParams< PorousFlowVariableBase >
InputParameters validParams< PorousFlowVariableBase >()
Definition: PorousFlowVariableBase.C:14