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