https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlow2PhaseHysPP.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
13
16{
18 params.addRequiredCoupledVar("phase0_porepressure",
19 "Variable that is the porepressure of phase 0. This is assumed to "
20 "be the liquid phase. It will be <= phase1_porepressure.");
21 params.addRequiredCoupledVar("phase1_porepressure",
22 "Variable that is the porepressure of phase 1 (the gas phase)");
23 params.addParam<unsigned>(
24 "liquid_phase", 0, "Phase number of the liquid phase (more precisely, the phase of phase0)");
26 "This Material is used for 2-phase situations. It calculates the 2 saturations given the 2 "
27 "porepressures, assuming the capillary pressure is hysteretic. Derivatives of these "
28 "quantities are also computed");
29 return params;
30}
31
34 _pc(_nodal_material ? declareProperty<Real>("PorousFlow_hysteretic_capillary_pressure_nodal")
35 : declareProperty<Real>("PorousFlow_hysteretic_capillary_pressure_qp")),
36 _phase0_porepressure(_nodal_material ? coupledDofValues("phase0_porepressure")
37 : coupledValue("phase0_porepressure")),
38 _phase0_gradp_qp(coupledGradient("phase0_porepressure")),
39 _phase0_porepressure_varnum(coupled("phase0_porepressure")),
40 _p0var(_dictator.isPorousFlowVariable(_phase0_porepressure_varnum)
41 ? _dictator.porousFlowVariableNum(_phase0_porepressure_varnum)
42 : 0),
43
44 _phase1_porepressure(_nodal_material ? coupledDofValues("phase1_porepressure")
45 : coupledValue("phase1_porepressure")),
46 _phase1_gradp_qp(coupledGradient("phase1_porepressure")),
47 _phase1_porepressure_varnum(coupled("phase1_porepressure")),
48 _p1var(_dictator.isPorousFlowVariable(_phase1_porepressure_varnum)
49 ? _dictator.porousFlowVariableNum(_phase1_porepressure_varnum)
50 : 0)
51{
52 checkNodalVariables({"phase0_porepressure", "phase1_porepressure"});
53
54 if (_num_phases != 2)
55 mooseError("The Dictator announces that the number of phases is ",
56 _dictator.numPhases(),
57 " whereas PorousFlow2PhaseHysPP can only be used for 2-phase simulation. When you "
58 "have efficient government, you have dictatorship.");
59}
60
61void
67
68void
70{
71 // size stuff correctly and prepare the derivative matrices with zeroes
73
75 const Real pc = _pc[_qp]; // >= 0
76 const Real ds = dliquidSaturationQp(pc); // dS/d(pc)
77
78 if (!_nodal_material)
79 {
80 (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
81 (*_gradp_qp)[_qp][1] = _phase1_gradp_qp[_qp];
82 (*_grads_qp)[_qp][0] = ds * ((*_gradp_qp)[_qp][1] - (*_gradp_qp)[_qp][0]);
83 (*_grads_qp)[_qp][1] = -(*_grads_qp)[_qp][0];
84 }
85
86 // the derivatives of porepressure with respect to porepressure
87 // remain fixed (at unity) throughout the simulation
88 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
89 {
90 (*_dporepressure_dvar)[_qp][0][_p0var] = 1.0;
91 if (!_nodal_material)
92 (*_dgradp_qp_dgradv)[_qp][0][_p0var] = 1.0;
93 }
94 if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
95 {
96 (*_dporepressure_dvar)[_qp][1][_p1var] = 1.0;
97 if (!_nodal_material)
98 (*_dgradp_qp_dgradv)[_qp][1][_p1var] = 1.0;
99 }
100
101 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
102 {
103 (*_dsaturation_dvar)[_qp][0][_p0var] = -ds;
104 (*_dsaturation_dvar)[_qp][1][_p0var] = ds;
105 }
106 if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
107 {
108 (*_dsaturation_dvar)[_qp][0][_p1var] = ds;
109 (*_dsaturation_dvar)[_qp][1][_p1var] = -ds;
110 }
111
112 _pc[_qp] = _phase1_porepressure[_qp] - _phase0_porepressure[_qp]; // this is >= 0
113 if (!_nodal_material)
114 {
115 const Real d2s_qp = d2liquidSaturationQp(pc); // d^2(S_qp)/d(pc_qp)^2
116 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
117 {
118 (*_dgrads_qp_dgradv)[_qp][0][_p0var] = -ds;
119 (*_dgrads_qp_dv)[_qp][0][_p0var] = -d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
120 (*_dgrads_qp_dgradv)[_qp][1][_p0var] = ds;
121 (*_dgrads_qp_dv)[_qp][1][_p0var] = d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
122 }
123 if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
124 {
125 (*_dgrads_qp_dgradv)[_qp][0][_p1var] = ds;
126 (*_dgrads_qp_dv)[_qp][0][_p1var] = d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
127 (*_dgrads_qp_dgradv)[_qp][1][_p1var] = -ds;
128 (*_dgrads_qp_dv)[_qp][1][_p1var] = -d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
129 }
130 }
131}
132
133void
135{
136 _porepressure[_qp][0] = _phase0_porepressure[_qp];
137 _porepressure[_qp][1] = _phase1_porepressure[_qp];
138 _pc[_qp] = _phase1_porepressure[_qp] - _phase0_porepressure[_qp]; // this is >= 0
139 const Real sat = liquidSaturationQp(_pc[_qp]);
140 _saturation[_qp][0] = sat;
141 _saturation[_qp][1] = 1.0 - sat;
142}
void mooseError(Args &&... args)
registerMooseObject("PorousFlowApp", PorousFlow2PhaseHysPP)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Material designed to calculate the 2 porepressures and 2 saturations, as well as derivatives of them,...
const VariableValue & _phase1_porepressure
Nodal or quadpoint value of porepressure of the one phase (eg, the gas phase)
const unsigned int _phase0_porepressure_varnum
Moose variable number of the phase0 porepressure.
const unsigned int _p0var
PorousFlow variable number of the phase0 porepressure.
const VariableGradient & _phase1_gradp_qp
Gradient(phase1_porepressure) at the qps.
void buildQpPPSS()
Assemble std::vectors of porepressure and saturation at the nodes and quadpoints.
virtual void computeQpProperties() override
const unsigned int _p1var
PorousFlow variable number of the phase1 porepressure.
MaterialProperty< Real > & _pc
Computed nodal or quadpoint values of capillary pressure.
const VariableGradient & _phase0_gradp_qp
Gradient(phase0_porepressure) at the qps.
static InputParameters validParams()
virtual void initQpStatefulProperties() override
const VariableValue & _phase0_porepressure
Nodal or quadpoint value of porepressure of the zero phase (eg, the water phase)
PorousFlow2PhaseHysPP(const InputParameters &parameters)
const unsigned int _phase1_porepressure_varnum
Moose variable number of the phase1 porepressure.
Base material designed to calculate and store quantities relevant for hysteretic capillary pressure c...
const unsigned int _num_phases
Number of phases.
GenericMaterialProperty< std::vector< Real >, is_ad > & _porepressure
Computed nodal or quadpoint values of porepressure of the phases.
GenericMaterialProperty< std::vector< Real >, is_ad > & _saturation
Computed nodal or qp saturation of the phases.