www.mooseframework.org
Q2PNegativeNodalMassOld.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  "fluid_density",
23  "A RichardsDensity UserObject that defines the fluid density as a function of pressure.");
24  params.addRequiredCoupledVar("other_var",
25  "The other variable in the 2-phase system. If "
26  "Variable=porepressure, then other_var should be the "
27  "saturation Variable, and vice-versa.");
28  params.addRequiredParam<bool>(
29  "var_is_porepressure",
30  "This flag is needed to correctly calculate the Jacobian entries. If "
31  "set to true, this Kernel will assume it is describing the mass of "
32  "the phase with porepressure as its Variable (eg, the liquid phase). "
33  "If set to false, this Kernel will assumed it is describing the mass "
34  "of the phase with saturation as its variable (eg, the gas phase)");
35  params.addClassDescription("- fluid_mass");
36  return params;
37 }
38 
39 Q2PNegativeNodalMassOld::Q2PNegativeNodalMassOld(const InputParameters & parameters)
40  : TimeKernel(parameters),
41  _density(getUserObject<RichardsDensity>("fluid_density")),
42  _other_var_nodal_old(coupledNodalValueOld("other_var")),
43  _var_is_pp(getParam<bool>("var_is_porepressure")),
44  _porosity_old(getMaterialProperty<Real>("porosity_old"))
45 {
46 }
47 
48 Real
50 {
51  Real density_old;
52  Real mass_old;
53 
54  if (_var_is_pp)
55  {
56  density_old = _density.density(_var.nodalSlnOld()[_i]);
57  mass_old = _porosity_old[_qp] * density_old * (1 - _other_var_nodal_old[_i]);
58  }
59  else
60  {
61  density_old = _density.density(_other_var_nodal_old[_i]);
62  mass_old = _porosity_old[_qp] * density_old * _var.nodalSlnOld()[_i];
63  }
64 
65  return _test[_i][_qp] * (-mass_old) / _dt;
66 }
InputParameters validParams< Q2PNegativeNodalMassOld >()
const RichardsDensity & _density
Q2PNegativeNodalMassOld(const InputParameters &parameters)
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...
bool _var_is_pp
whether the "other variable" is actually porepressure
const MaterialProperty< Real > & _porosity_old
value of the porosity at the start of the timestep
Base class for fluid density as a function of porepressure The functions density, ddensity and d2dens...
const VariableValue & _other_var_nodal_old
old value of the other variable (this is porepressure if the Variable is saturation) ...