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 if (_num_phases != 2)
50 mooseError("The Dictator announces that the number of phases is ",
51 _dictator.numPhases(),
52 " whereas PorousFlow2PhaseHysPS can only be used for 2-phase simulation. The "
53 "Dictator is always watching.");
54}
55
56void
62
63void
65{
66 // size stuff correctly and prepare the derivative matrices with zeroes
68
70 const Real dpc = dcapillaryPressureQp(1.0 - _phase1_saturation[_qp]); // d(Pc)/d(S0)
71
72 if (!_nodal_material)
73 {
74 (*_grads_qp)[_qp][0] = -_phase1_grads_qp[_qp];
75 (*_grads_qp)[_qp][1] = _phase1_grads_qp[_qp];
76 (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
77 (*_gradp_qp)[_qp][1] = _phase0_gradp_qp[_qp] - dpc * (*_grads_qp)[_qp][1];
78 }
79
80 // _porepressure depends on _phase0_porepressure, and its derivative is 1
81 if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
82 {
83 // _phase0_porepressure is a PorousFlow variable
84 for (unsigned phase = 0; phase < _num_phases; ++phase)
85 {
86 (*_dporepressure_dvar)[_qp][phase][_pvar] = 1.0;
87 if (!_nodal_material)
88 (*_dgradp_qp_dgradv)[_qp][phase][_pvar] = 1.0;
89 }
90 }
91
92 // _saturation is only dependent on _phase1_saturation, and its derivative is +/- 1
93 if (_dictator.isPorousFlowVariable(_phase1_saturation_varnum))
94 {
95 // _phase1_saturation is a PorousFlow variable
96 // _phase1_porepressure depends on saturation through the capillary pressure function
97 (*_dsaturation_dvar)[_qp][0][_svar] = -1.0;
98 (*_dsaturation_dvar)[_qp][1][_svar] = 1.0;
99 (*_dporepressure_dvar)[_qp][1][_svar] = -dpc;
100
101 if (!_nodal_material)
102 {
103 (*_dgrads_qp_dgradv)[_qp][0][_svar] = -1.0;
104 (*_dgrads_qp_dgradv)[_qp][1][_svar] = 1.0;
105 const Real d2pc_qp = d2capillaryPressureQp(1.0 - _phase1_saturation[_qp]); // d^2(Pc)/dS0^2
106 (*_dgradp_qp_dv)[_qp][1][_svar] = d2pc_qp * (*_grads_qp)[_qp][1];
107 (*_dgradp_qp_dgradv)[_qp][1][_svar] = -dpc;
108 }
109 }
110}
111
112void
114{
115 _saturation[_qp][0] = 1.0 - _phase1_saturation[_qp];
116 _saturation[_qp][1] = _phase1_saturation[_qp];
117 _pc[_qp] = capillaryPressureQp(1.0 - _phase1_saturation[_qp]);
118 _porepressure[_qp][0] = _phase0_porepressure[_qp];
119 _porepressure[_qp][1] = _phase0_porepressure[_qp] + _pc[_qp];
120}
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.