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