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 if (_num_phases != 2)
53 mooseError("The Dictator announces that the number of phases is ",
54 _dictator.numPhases(),
55 " whereas PorousFlow2PhaseHysPP can only be used for 2-phase simulation. When you "
56 "have efficient government, you have dictatorship.");
57}
58
59void
65
66void
68{
69 // size stuff correctly and prepare the derivative matrices with zeroes
71
73 const Real pc = _pc[_qp]; // >= 0
74 const Real ds = dliquidSaturationQp(pc); // dS/d(pc)
75
76 if (!_nodal_material)
77 {
78 (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
79 (*_gradp_qp)[_qp][1] = _phase1_gradp_qp[_qp];
80 (*_grads_qp)[_qp][0] = ds * ((*_gradp_qp)[_qp][1] - (*_gradp_qp)[_qp][0]);
81 (*_grads_qp)[_qp][1] = -(*_grads_qp)[_qp][0];
82 }
83
84 // the derivatives of porepressure with respect to porepressure
85 // remain fixed (at unity) throughout the simulation
86 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
87 {
88 (*_dporepressure_dvar)[_qp][0][_p0var] = 1.0;
89 if (!_nodal_material)
90 (*_dgradp_qp_dgradv)[_qp][0][_p0var] = 1.0;
91 }
92 if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
93 {
94 (*_dporepressure_dvar)[_qp][1][_p1var] = 1.0;
95 if (!_nodal_material)
96 (*_dgradp_qp_dgradv)[_qp][1][_p1var] = 1.0;
97 }
98
99 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
100 {
101 (*_dsaturation_dvar)[_qp][0][_p0var] = -ds;
102 (*_dsaturation_dvar)[_qp][1][_p0var] = ds;
103 }
104 if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
105 {
106 (*_dsaturation_dvar)[_qp][0][_p1var] = ds;
107 (*_dsaturation_dvar)[_qp][1][_p1var] = -ds;
108 }
109
110 _pc[_qp] = _phase1_porepressure[_qp] - _phase0_porepressure[_qp]; // this is >= 0
111 if (!_nodal_material)
112 {
113 const Real d2s_qp = d2liquidSaturationQp(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 * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
118 (*_dgrads_qp_dgradv)[_qp][1][_p0var] = ds;
119 (*_dgrads_qp_dv)[_qp][1][_p0var] = d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_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 * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
125 (*_dgrads_qp_dgradv)[_qp][1][_p1var] = -ds;
126 (*_dgrads_qp_dv)[_qp][1][_p1var] = -d2s_qp * (_phase1_gradp_qp[_qp] - _phase0_gradp_qp[_qp]);
127 }
128 }
129}
130
131void
133{
134 _porepressure[_qp][0] = _phase0_porepressure[_qp];
135 _porepressure[_qp][1] = _phase1_porepressure[_qp];
136 _pc[_qp] = _phase1_porepressure[_qp] - _phase0_porepressure[_qp]; // this is >= 0
137 const Real sat = liquidSaturationQp(_pc[_qp]);
138 _saturation[_qp][0] = sat;
139 _saturation[_qp][1] = 1.0 - sat;
140}
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.