www.mooseframework.org
RichardsLumpedMassChange.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 // MOOSE includes
11 #include "MooseVariable.h"
12 
13 // C++ includes
14 #include <iostream>
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<TimeKernel>();
21  params.addRequiredParam<UserObjectName>(
22  "richardsVarNames_UO", "The UserObject that holds the list of Richards variables.");
23  params.addRequiredParam<std::vector<UserObjectName>>(
24  "density_UO",
25  "List of names of user objects that define the fluid density (or densities for "
26  "multiphase). In the multiphase case, for ease of use, the density, Seff and "
27  "Sat UserObjects are the same format as for RichardsMaterial, but only the one "
28  "relevant for the specific phase is actually used.");
29  params.addRequiredParam<std::vector<UserObjectName>>(
30  "seff_UO",
31  "List of name of user objects that define effective saturation as a function of "
32  "porepressure(s)");
33  params.addRequiredParam<std::vector<UserObjectName>>(
34  "sat_UO",
35  "List of names of user objects that define saturation as a function of effective saturation");
36  return params;
37 }
38 
39 RichardsLumpedMassChange::RichardsLumpedMassChange(const InputParameters & parameters)
40  : TimeKernel(parameters),
41  _richards_name_UO(getUserObject<RichardsVarNames>("richardsVarNames_UO")),
42  _num_p(_richards_name_UO.num_v()),
43  _pvar(_richards_name_UO.richards_var_num(_var.number())),
44 
45  _porosity(getMaterialProperty<Real>("porosity")),
46  _porosity_old(getMaterialProperty<Real>("porosity_old")),
47 
48  // in the following: first get the userobject names that were inputted, then get the _pvar one
49  // of these, then get the actual userobject that this corresponds to, then finally & gives
50  // pointer to RichardsDensity (or whatever) object.
51  _seff_UO(&getUserObjectByName<RichardsSeff>(
52  getParam<std::vector<UserObjectName>>("seff_UO")[_pvar])),
53  _sat_UO(
54  &getUserObjectByName<RichardsSat>(getParam<std::vector<UserObjectName>>("sat_UO")[_pvar])),
55  _density_UO(&getUserObjectByName<RichardsDensity>(
56  getParam<std::vector<UserObjectName>>("density_UO")[_pvar]))
57 {
58  _ps_at_nodes.resize(_num_p);
59  _ps_old_at_nodes.resize(_num_p);
60 
61  for (unsigned int pnum = 0; pnum < _num_p; ++pnum)
62  {
65  }
66 
67  _dseff.resize(_num_p);
68 }
69 
70 Real
72 {
73  // current values:
74  const Real density = (*_density_UO).density((*_ps_at_nodes[_pvar])[_i]);
75  const Real seff = (*_seff_UO).seff(_ps_at_nodes, _i);
76  const Real sat = (*_sat_UO).sat(seff);
77  const Real mass = _porosity[_qp] * density * sat;
78 
79  // old values:
80  const Real density_old = (*_density_UO).density((*_ps_old_at_nodes[_pvar])[_i]);
81  const Real seff_old = (*_seff_UO).seff(_ps_old_at_nodes, _i);
82  const Real sat_old = (*_sat_UO).sat(seff_old);
83  const Real mass_old = _porosity_old[_qp] * density_old * sat_old;
84 
85  return _test[_i][_qp] * (mass - mass_old) / _dt;
86 }
87 
88 Real
90 {
91  if (_i != _j)
92  return 0.0;
93 
94  const Real density = (*_density_UO).density((*_ps_at_nodes[_pvar])[_i]);
95  const Real ddensity = (*_density_UO).ddensity((*_ps_at_nodes[_pvar])[_i]);
96 
97  const Real seff = (*_seff_UO).seff(_ps_at_nodes, _i);
98  (*_seff_UO).dseff(_ps_at_nodes, _i, _dseff);
99 
100  const Real sat = (*_sat_UO).sat(seff);
101  const Real dsat = (*_sat_UO).dsat(seff);
102 
103  const Real mass_prime = _porosity[_qp] * (ddensity * sat + density * _dseff[_pvar] * dsat);
104 
105  return _test[_i][_qp] * mass_prime / _dt;
106 }
107 
108 Real
110 {
112  return 0.0;
113  if (_i != _j)
114  return 0.0;
115  const unsigned int dvar = _richards_name_UO.richards_var_num(jvar);
116 
117  const Real density = (*_density_UO).density((*_ps_at_nodes[_pvar])[_i]);
118 
119  const Real seff = (*_seff_UO).seff(_ps_at_nodes, _i);
120  (*_seff_UO).dseff(_ps_at_nodes, _i, _dseff);
121 
122  const Real dsat = (*_sat_UO).dsat(seff);
123 
124  const Real mass_prime = _porosity[_qp] * density * _dseff[dvar] * dsat;
125 
126  return _test[_i][_qp] * mass_prime / _dt;
127 }
const VariableValue * nodal_var_old(unsigned int richards_var_num) const
The old nodal variable values for the given richards_var_num.
Saturation of a phase as a function of effective saturation of that phase, and its derivatives wrt ef...
Definition: RichardsSat.h:23
Base class for effective saturation as a function of porepressure(s) The functions seff...
Definition: RichardsSeff.h:22
std::vector< const VariableValue * > _ps_old_at_nodes
Holds the nodal values of pressures at timestep_begin, in same way as _ps_at_nodes.
const std::string density
Definition: NS.h:15
const VariableValue * nodal_var(unsigned int richards_var_num) const
The nodal variable values for the given richards_var_num To extract a the value of pressure variable ...
bool not_richards_var(unsigned int moose_var_num) const
returns true if moose_var_num is not a richards var
const MaterialProperty< Real > & _porosity_old
value of the porosity at the start of the timestep
This holds maps between pressure_var or pressure_var, sat_var used in RichardsMaterial and kernels...
RichardsLumpedMassChange(const InputParameters &parameters)
InputParameters validParams< RichardsLumpedMassChange >()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const RichardsVarNames & _richards_name_UO
holds info regarding the names of the Richards variables and methods for extracting values of these v...
unsigned int _num_p
number of richards variables
Base class for fluid density as a function of porepressure The functions density, ddensity and d2dens...
std::vector< const VariableValue * > _ps_at_nodes
Holds the values of pressures at all the nodes of the element Eg: _ps_at_nodes[_pvar] is a pointer to...
std::vector< Real > _dseff
holds nodal values of d(Seff)/dP_i
unsigned int _pvar
the index of this variable in the list of Richards variables held by _richards_name_UO.
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number
const MaterialProperty< Real > & _porosity
current value of the porosity