www.mooseframework.org
PorousFlow1PhaseMD_Gaussian.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 
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<PorousFlowVariableBase>();
19  params.addRequiredCoupledVar("mass_density",
20  "Variable that represents log(mass-density) of the single phase");
21  params.addRequiredRangeCheckedParam<Real>(
22  "al",
23  "al>0",
24  "For this class, the capillary function is assumed to be saturation = "
25  "exp(-(al*porepressure)^2) for porepressure<0.");
26  params.addRequiredRangeCheckedParam<Real>(
27  "density_P0", "density_P0>0", "The density of the fluid phase at zero porepressure");
28  params.addRequiredRangeCheckedParam<Real>(
29  "bulk_modulus", "bulk_modulus>0", "The constant bulk modulus of the fluid phase");
30  params.addClassDescription("This Material is used for the single-phase situation where "
31  "log(mass-density) is the primary variable. calculates the 1 "
32  "porepressure and the 1 saturation in a 1-phase situation, "
33  "and derivatives of these with respect to the PorousFlowVariables. A "
34  "gaussian capillary function is assumed");
35  return params;
36 }
37 
39  : PorousFlowVariableBase(parameters),
40 
41  _al(getParam<Real>("al")),
42  _al2(std::pow(_al, 2)),
43  _logdens0(std::log(getParam<Real>("density_P0"))),
44  _bulk(getParam<Real>("bulk_modulus")),
45  _recip_bulk(1.0 / _al / _bulk),
46  _recip_bulk2(std::pow(_recip_bulk, 2)),
47 
48  _md_var(_nodal_material ? coupledDofValues("mass_density") : coupledValue("mass_density")),
49  _gradmd_qp_var(coupledGradient("mass_density")),
50  _md_varnum(coupled("mass_density")),
51  _pvar(_dictator.isPorousFlowVariable(_md_varnum) ? _dictator.porousFlowVariableNum(_md_varnum)
52  : 0)
53 {
54  if (_num_phases != 1)
55  mooseError("The Dictator proclaims that the number of phases is ",
56  _dictator.numPhases(),
57  " whereas PorousFlow1PhaseMD_Gaussian can only be used for 1-phase simulations. Be "
58  "aware that the Dictator has noted your mistake.");
59 }
60 
61 void
63 {
65  buildPS();
66 }
67 
68 void
70 {
71  // size stuff correctly and prepare the derivative matrices with zeroes
73 
74  buildPS();
75 
76  if (!_nodal_material)
77  {
78  if (_md_var[_qp] >= _logdens0)
79  {
80  (*_gradp_qp)[_qp][0] = _gradmd_qp_var[_qp] * _bulk;
81  (*_grads_qp)[_qp][0] = 0.0;
82  }
83  else
84  {
85  (*_gradp_qp)[_qp][0] =
86  _gradmd_qp_var[_qp] / (_recip_bulk - 2.0 * _al * _porepressure[_qp][0]) / _al;
87  (*_grads_qp)[_qp][0] =
88  -2.0 * _al2 * _porepressure[_qp][0] * _saturation[_qp][0] * (*_gradp_qp)[_qp][0];
89  }
90  }
91 
92  if (_dictator.notPorousFlowVariable(_md_varnum))
93  return;
94 
95  if (_md_var[_qp] >= _logdens0)
96  {
97  // fully saturated at the node or quadpoint
98  _dporepressure_dvar[_qp][0][_pvar] = _bulk;
99  _dsaturation_dvar[_qp][0][_pvar] = 0.0;
100  }
101  else
102  {
103  const Real pp = _porepressure[_qp][0];
104  _dporepressure_dvar[_qp][0][_pvar] = 1.0 / (_recip_bulk - 2.0 * _al * pp) / _al;
105  const Real sat = _saturation[_qp][0];
106  _dsaturation_dvar[_qp][0][_pvar] = -2.0 * _al2 * pp * sat * _dporepressure_dvar[_qp][0][_pvar];
107  }
108 
109  if (!_nodal_material)
110  {
111  if (_md_var[_qp] >= _logdens0)
112  {
113  // fully saturated at the quadpoint
114  (*_dgradp_qp_dgradv)[_qp][0][_pvar] = _bulk;
115  (*_dgradp_qp_dv)[_qp][0][_pvar] = 0.0;
116  (*_dgrads_qp_dgradv)[_qp][0][_pvar] = 0.0;
117  (*_dgrads_qp_dv)[_qp][0][_pvar] = 0.0;
118  }
119  else
120  {
121  const Real pp = _porepressure[_qp][0];
122  (*_dgradp_qp_dgradv)[_qp][0][_pvar] = 1.0 / (_recip_bulk - 2.0 * _al * pp) / _al;
123  (*_dgradp_qp_dv)[_qp][0][_pvar] = _gradmd_qp_var[_qp] * 2.0 * _al *
124  _dporepressure_dvar[_qp][0][_pvar] /
125  std::pow(_recip_bulk - 2.0 * _al * pp, 2.0) / _al;
126  const Real sat = _saturation[_qp][0];
127  (*_dgrads_qp_dgradv)[_qp][0][_pvar] =
128  -2.0 * _al2 * pp * sat * (*_dgradp_qp_dgradv)[_qp][0][_pvar];
129  (*_dgrads_qp_dv)[_qp][0][_pvar] =
130  -2.0 * _al2 * _dporepressure_dvar[_qp][0][_pvar] * sat * (*_gradp_qp)[_qp][0];
131  (*_dgrads_qp_dv)[_qp][0][_pvar] +=
132  -2.0 * _al2 * pp * _dsaturation_dvar[_qp][0][_pvar] * (*_gradp_qp)[_qp][0];
133  (*_dgrads_qp_dv)[_qp][0][_pvar] += -2.0 * _al2 * pp * sat * (*_dgradp_qp_dv)[_qp][0][_pvar];
134  }
135  }
136 }
137 
138 void
140 {
141  if (_md_var[_qp] >= _logdens0)
142  {
143  // full saturation
144  _porepressure[_qp][0] = (_md_var[_qp] - _logdens0) * _bulk;
145  _saturation[_qp][0] = 1.0;
146  }
147  else
148  {
149  // v = logdens0 + p/bulk - (al p)^2
150  // 0 = (v-logdens0) - p/bulk + (al p)^2
151  // 2 al p = (1/al/bulk) +/- sqrt((1/al/bulk)^2 - 4(v-logdens0)) (the "minus" sign is chosen)
152  // s = exp(-(al*p)^2)
153  _porepressure[_qp][0] =
154  (_recip_bulk - std::sqrt(_recip_bulk2 + 4.0 * (_logdens0 - _md_var[_qp]))) / (2.0 * _al);
155  _saturation[_qp][0] = std::exp(-std::pow(_al * _porepressure[_qp][0], 2.0));
156  }
157 }
PorousFlowVariableBase::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlowVariableBase.C:74
pow
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Definition: ExpressionBuilder.h:673
PorousFlow1PhaseMD_Gaussian::_md_var
const VariableValue & _md_var
Nodal or quadpoint value of mass-density of the fluid phase.
Definition: PorousFlow1PhaseMD_Gaussian.h:53
validParams< PorousFlow1PhaseMD_Gaussian >
InputParameters validParams< PorousFlow1PhaseMD_Gaussian >()
Definition: PorousFlow1PhaseMD_Gaussian.C:16
PorousFlow1PhaseMD_Gaussian
Material designed to calculate fluid-phase porepressure and saturation for the single-phase situation...
Definition: PorousFlow1PhaseMD_Gaussian.h:25
PorousFlow1PhaseMD_Gaussian.h
PorousFlowVariableBase::_num_phases
const unsigned int _num_phases
Number of phases.
Definition: PorousFlowVariableBase.h:35
PorousFlow1PhaseMD_Gaussian::_gradmd_qp_var
const VariableGradient & _gradmd_qp_var
Gradient(_mass-density at quadpoints)
Definition: PorousFlow1PhaseMD_Gaussian.h:56
PorousFlow1PhaseMD_Gaussian::_bulk
const Real _bulk
Fluid density = _dens0*exp(P/_bulk)
Definition: PorousFlow1PhaseMD_Gaussian.h:44
PorousFlowVariableBase
Base class for thermophysical variable materials, which assemble materials for primary variables such...
Definition: PorousFlowVariableBase.h:25
PorousFlow1PhaseMD_Gaussian::_md_varnum
const unsigned int _md_varnum
Moose variable number of the mass-density.
Definition: PorousFlow1PhaseMD_Gaussian.h:59
PorousFlow1PhaseMD_Gaussian::_al
const Real _al
Gaussian parameter: saturation = exp(-(al*p)^2)
Definition: PorousFlow1PhaseMD_Gaussian.h:35
PorousFlow1PhaseMD_Gaussian::_recip_bulk
const Real _recip_bulk
1/_bulk/_al
Definition: PorousFlow1PhaseMD_Gaussian.h:47
PorousFlowVariableBase::_porepressure
MaterialProperty< std::vector< Real > > & _porepressure
Computed nodal or quadpoint values of porepressure of the phases.
Definition: PorousFlowVariableBase.h:44
PorousFlow1PhaseMD_Gaussian::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlow1PhaseMD_Gaussian.C:69
PorousFlowVariableBase::_dporepressure_dvar
MaterialProperty< std::vector< std::vector< Real > > > & _dporepressure_dvar
d(porepressure)/d(PorousFlow variable)
Definition: PorousFlowVariableBase.h:47
PorousFlow1PhaseMD_Gaussian::buildPS
virtual void buildPS()
Definition: PorousFlow1PhaseMD_Gaussian.C:139
PorousFlow1PhaseMD_Gaussian::_pvar
const unsigned int _pvar
PorousFlow variable number of the mass-density.
Definition: PorousFlow1PhaseMD_Gaussian.h:62
PorousFlow1PhaseMD_Gaussian::_logdens0
const Real _logdens0
Fluid density = _dens0*exp(P/_bulk)
Definition: PorousFlow1PhaseMD_Gaussian.h:41
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlow1PhaseMD_Gaussian)
PorousFlow1PhaseMD_Gaussian::_al2
const Real _al2
_al2 = al*al
Definition: PorousFlow1PhaseMD_Gaussian.h:38
PorousFlow1PhaseMD_Gaussian::_recip_bulk2
const Real _recip_bulk2
(1/_bulk)^2
Definition: PorousFlow1PhaseMD_Gaussian.h:50
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
PorousFlow1PhaseMD_Gaussian::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: PorousFlow1PhaseMD_Gaussian.C:62
PorousFlowVariableBase::_dsaturation_dvar
MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
d(saturation)/d(PorousFlow variable)
Definition: PorousFlowVariableBase.h:62
PorousFlow1PhaseMD_Gaussian::PorousFlow1PhaseMD_Gaussian
PorousFlow1PhaseMD_Gaussian(const InputParameters &parameters)
Definition: PorousFlow1PhaseMD_Gaussian.C:38
validParams< PorousFlowVariableBase >
InputParameters validParams< PorousFlowVariableBase >()
Definition: PorousFlowVariableBase.C:14