https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlow2PhaseHysPS.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{
19 "phase0_porepressure",
20 "Variable that is the porepressure of phase 0, which is the liquid phase");
22 "phase1_saturation", "Variable that is the saturation of phase 1, which is the gas phase");
23 params.addClassDescription("This Material is used for 2-phase situations. It calculates the 2 "
24 "saturations and 2 porepressures, assuming the capillary pressure is "
25 "hysteretic. Derivatives of these quantities are also computed");
26 return params;
27}
28
31 _pc(_nodal_material ? declareProperty<Real>("PorousFlow_hysteretic_capillary_pressure_nodal")
32 : declareProperty<Real>("PorousFlow_hysteretic_capillary_pressure_qp")),
33 _phase0_porepressure(_nodal_material ? coupledDofValues("phase0_porepressure")
34 : coupledValue("phase0_porepressure")),
35 _phase0_gradp_qp(coupledGradient("phase0_porepressure")),
36 _phase0_porepressure_varnum(coupled("phase0_porepressure")),
37 _pvar(_dictator.isPorousFlowVariable(_phase0_porepressure_varnum)
38 ? _dictator.porousFlowVariableNum(_phase0_porepressure_varnum)
39 : 0),
40
41 _phase1_saturation(_nodal_material ? coupledDofValues("phase1_saturation")
42 : coupledValue("phase1_saturation")),
43 _phase1_grads_qp(coupledGradient("phase1_saturation")),
44 _phase1_saturation_varnum(coupled("phase1_saturation")),
45 _svar(_dictator.isPorousFlowVariable(_phase1_saturation_varnum)
46 ? _dictator.porousFlowVariableNum(_phase1_saturation_varnum)
47 : 0)
48{
49 checkNodalVariables({"phase0_porepressure", "phase1_saturation"});
50
51 if (_num_phases != 2)
52 mooseError("The Dictator announces that the number of phases is ",
53 _dictator.numPhases(),
54 " whereas PorousFlow2PhaseHysPS can only be used for 2-phase simulation. The "
55 "Dictator is always watching.");
56}
57
58void
64
65void
67{
68 // size stuff correctly and prepare the derivative matrices with zeroes
70
72 const Real dpc = dcapillaryPressureQp(1.0 - _phase1_saturation[_qp]); // d(Pc)/d(S0)
73
74 if (!_nodal_material)
75 {
76 (*_grads_qp)[_qp][0] = -_phase1_grads_qp[_qp];
77 (*_grads_qp)[_qp][1] = _phase1_grads_qp[_qp];
78 (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
79 (*_gradp_qp)[_qp][1] = _phase0_gradp_qp[_qp] - dpc * (*_grads_qp)[_qp][1];
80 }
81
82 // _porepressure depends on _phase0_porepressure, and its derivative is 1
83 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
84 {
85 // _phase0_porepressure is a PorousFlow variable
86 for (unsigned phase = 0; phase < _num_phases; ++phase)
87 {
88 (*_dporepressure_dvar)[_qp][phase][_pvar] = 1.0;
89 if (!_nodal_material)
90 (*_dgradp_qp_dgradv)[_qp][phase][_pvar] = 1.0;
91 }
92 }
93
94 // _saturation is only dependent on _phase1_saturation, and its derivative is +/- 1
95 if (_dictator.isPorousFlowVariable(_phase1_saturation_varnum))
96 {
97 // _phase1_saturation is a PorousFlow variable
98 // _phase1_porepressure depends on saturation through the capillary pressure function
99 (*_dsaturation_dvar)[_qp][0][_svar] = -1.0;
100 (*_dsaturation_dvar)[_qp][1][_svar] = 1.0;
101 (*_dporepressure_dvar)[_qp][1][_svar] = -dpc;
102
103 if (!_nodal_material)
104 {
105 (*_dgrads_qp_dgradv)[_qp][0][_svar] = -1.0;
106 (*_dgrads_qp_dgradv)[_qp][1][_svar] = 1.0;
107 const Real d2pc_qp = d2capillaryPressureQp(1.0 - _phase1_saturation[_qp]); // d^2(Pc)/dS0^2
108 (*_dgradp_qp_dv)[_qp][1][_svar] = d2pc_qp * (*_grads_qp)[_qp][1];
109 (*_dgradp_qp_dgradv)[_qp][1][_svar] = -dpc;
110 }
111 }
112}
113
114void
116{
117 _saturation[_qp][0] = 1.0 - _phase1_saturation[_qp];
118 _saturation[_qp][1] = _phase1_saturation[_qp];
119 _pc[_qp] = capillaryPressureQp(1.0 - _phase1_saturation[_qp]);
120 _porepressure[_qp][0] = _phase0_porepressure[_qp];
121 _porepressure[_qp][1] = _phase0_porepressure[_qp] + _pc[_qp];
122}
void mooseError(Args &&... args)
registerMooseObject("PorousFlowApp", PorousFlow2PhaseHysPS)
void addRequiredCoupledVar(const std::string &name, 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 unsigned int _svar
PorousFlow variable number of the phase1 saturation.
static InputParameters validParams()
const VariableGradient & _phase0_gradp_qp
Gradient(phase0_porepressure) at the qps.
const VariableValue & _phase1_saturation
Nodal or quadpoint value of saturation of phase one (the gas phase)
const unsigned int _phase0_porepressure_varnum
Moose variable number of the phase0 porepressure.
const unsigned int _pvar
PorousFlow variable number of the phase0 porepressure.
virtual void computeQpProperties() override
virtual void initQpStatefulProperties() override
void buildQpPPSS()
Assemble std::vectors of porepressure and saturation at the nodes and quadpoints.
MaterialProperty< Real > & _pc
Computed nodal or quadpoint values of capillary pressure.
const VariableValue & _phase0_porepressure
Nodal or quadpoint value of porepressure of phase zero (the liquid phase)
PorousFlow2PhaseHysPS(const InputParameters &parameters)
const VariableGradient & _phase1_grads_qp
Gradient(phase1_saturation) at the qps.
const unsigned int _phase1_saturation_varnum
Moose variable number of the phase1 saturation.
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.