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