www.mooseframework.org
RichardsLumpedMassChange.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 
12 // MOOSE includes
13 #include "MooseVariable.h"
14 
15 // C++ includes
16 #include <iostream>
17 
19 
22 {
24  params.addRequiredParam<UserObjectName>(
25  "richardsVarNames_UO", "The UserObject that holds the list of Richards variables.");
26  params.addRequiredParam<std::vector<UserObjectName>>(
27  "density_UO",
28  "List of names of user objects that define the fluid density (or densities for "
29  "multiphase). In the multiphase case, for ease of use, the density, Seff and "
30  "Sat UserObjects are the same format as for RichardsMaterial, but only the one "
31  "relevant for the specific phase is actually used.");
32  params.addRequiredParam<std::vector<UserObjectName>>(
33  "seff_UO",
34  "List of name of user objects that define effective saturation as a function of "
35  "porepressure(s)");
36  params.addRequiredParam<std::vector<UserObjectName>>(
37  "sat_UO",
38  "List of names of user objects that define saturation as a function of effective saturation");
39  return params;
40 }
41 
43  : TimeKernel(parameters),
44  _richards_name_UO(getUserObject<RichardsVarNames>("richardsVarNames_UO")),
45  _num_p(_richards_name_UO.num_v()),
46  _pvar(_richards_name_UO.richards_var_num(_var.number())),
47 
48  _porosity(getMaterialProperty<Real>("porosity")),
49  _porosity_old(getMaterialProperty<Real>("porosity_old")),
50 
51  // in the following: first get the userobject names that were inputted, then get the _pvar one
52  // of these, then get the actual userobject that this corresponds to, then finally & gives
53  // pointer to RichardsDensity (or whatever) object.
54  _seff_UO(
55  getUserObjectByName<RichardsSeff>(getParam<std::vector<UserObjectName>>("seff_UO")[_pvar])),
56  _sat_UO(
57  getUserObjectByName<RichardsSat>(getParam<std::vector<UserObjectName>>("sat_UO")[_pvar])),
58  _density_UO(getUserObjectByName<RichardsDensity>(
59  getParam<std::vector<UserObjectName>>("density_UO")[_pvar]))
60 {
61  _ps_at_nodes.resize(_num_p);
62  _ps_old_at_nodes.resize(_num_p);
63 
64  for (unsigned int pnum = 0; pnum < _num_p; ++pnum)
65  {
68  }
69 
70  _dseff.resize(_num_p);
71 }
72 
73 Real
75 {
76  // current values:
78  const Real seff = _seff_UO.seff(_ps_at_nodes, _i);
79  const Real sat = _sat_UO.sat(seff);
80  const Real mass = _porosity[_qp] * density * sat;
81 
82  // old values:
83  const Real density_old = _density_UO.density((*_ps_old_at_nodes[_pvar])[_i]);
84  const Real seff_old = _seff_UO.seff(_ps_old_at_nodes, _i);
85  const Real sat_old = _sat_UO.sat(seff_old);
86  const Real mass_old = _porosity_old[_qp] * density_old * sat_old;
87 
88  return _test[_i][_qp] * (mass - mass_old) / _dt;
89 }
90 
91 Real
93 {
94  if (_i != _j)
95  return 0.0;
96 
98  const Real ddensity = _density_UO.ddensity((*_ps_at_nodes[_pvar])[_i]);
99 
100  const Real seff = _seff_UO.seff(_ps_at_nodes, _i);
102 
103  const Real sat = _sat_UO.sat(seff);
104  const Real dsat = _sat_UO.dsat(seff);
105 
106  const Real mass_prime = _porosity[_qp] * (ddensity * sat + density * _dseff[_pvar] * dsat);
107 
108  return _test[_i][_qp] * mass_prime / _dt;
109 }
110 
111 Real
113 {
115  return 0.0;
116  if (_i != _j)
117  return 0.0;
118  const unsigned int dvar = _richards_name_UO.richards_var_num(jvar);
119 
121 
122  const Real seff = _seff_UO.seff(_ps_at_nodes, _i);
124 
125  const Real dsat = _sat_UO.dsat(seff);
126 
127  const Real mass_prime = _porosity[_qp] * density * _dseff[dvar] * dsat;
128 
129  return _test[_i][_qp] * mass_prime / _dt;
130 }
virtual void dseff(std::vector< const VariableValue *> p, unsigned int qp, std::vector< Real > &result) const =0
derivative(s) of effective saturation as a function of porepressure(s) at given quadpoint of the elem...
const RichardsDensity & _density_UO
The userobject that computes fluid density (as a function of the porepressure)
const RichardsSat & _sat_UO
The userobject that computes saturation (as a function of effective saturation) for this variable...
virtual Real ddensity(Real p) const =0
derivative of fluid density wrt porepressure This must be over-ridden in derived classes to provide a...
Saturation of a phase as a function of effective saturation of that phase, and its derivatives wrt ef...
Definition: RichardsSat.h:19
Base class for effective saturation as a function of porepressure(s) The functions seff...
Definition: RichardsSeff.h:18
static InputParameters validParams()
registerMooseObject("RichardsApp", RichardsLumpedMassChange)
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 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 ...
static const std::string density
Definition: NS.h:33
const RichardsSeff & _seff_UO
The userobject that computes effective saturation (as a function of porepressure(s)) for this variabl...
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
Real & _dt
This holds maps between pressure_var or pressure_var, sat_var used in RichardsMaterial and kernels...
Real dsat(Real) const
derivative of saturation wrt effective saturation
Definition: RichardsSat.C:64
RichardsLumpedMassChange(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual Real density(Real p) const =0
fluid density as a function of porepressure This must be over-ridden in derived classes to provide an...
const VariableTestValue & _test
virtual Real seff(std::vector< const VariableValue *> p, unsigned int qp) const =0
effective saturation as a function of porepressure(s) at given quadpoint of the element ...
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const VariableValue * nodal_var_old(unsigned int richards_var_num) const
The old nodal variable values for the given richards_var_num.
unsigned int _i
d(fluid mass in porespace)/dt with the fluid mass being lumped to the nodes.
const RichardsVarNames & _richards_name_UO
holds info regarding the names of the Richards variables and methods for extracting values of these v...
unsigned int _j
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _num_p
number of richards variables
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number
Real sat(Real seff) const
saturation as a function of effective saturation
Definition: RichardsSat.C:59
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...
static InputParameters validParams()
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 _qp
const MaterialProperty< Real > & _porosity
current value of the porosity