Line data Source code
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 : 10 : #include "Q2PNegativeNodalMassOld.h" 11 : 12 : // MOOSE includes 13 : #include "MooseVariable.h" 14 : 15 : // C++ includes 16 : #include <iostream> 17 : 18 : registerMooseObject("RichardsApp", Q2PNegativeNodalMassOld); 19 : 20 : InputParameters 21 56 : Q2PNegativeNodalMassOld::validParams() 22 : { 23 56 : InputParameters params = TimeKernel::validParams(); 24 112 : params.addRequiredParam<UserObjectName>( 25 : "fluid_density", 26 : "A RichardsDensity UserObject that defines the fluid density as a function of pressure."); 27 112 : 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 112 : 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 56 : params.addClassDescription("- fluid_mass"); 39 56 : return params; 40 0 : } 41 : 42 28 : Q2PNegativeNodalMassOld::Q2PNegativeNodalMassOld(const InputParameters & parameters) 43 : : TimeKernel(parameters), 44 28 : _density(getUserObject<RichardsDensity>("fluid_density")), 45 28 : _other_var_nodal_old(coupledDofValuesOld("other_var")), 46 56 : _var_is_pp(getParam<bool>("var_is_porepressure")), 47 84 : _porosity_old(getMaterialProperty<Real>("porosity_old")) 48 : { 49 28 : } 50 : 51 : Real 52 84384 : Q2PNegativeNodalMassOld::computeQpResidual() 53 : { 54 : Real density_old; 55 : Real mass_old; 56 : 57 84384 : if (_var_is_pp) 58 : { 59 42192 : density_old = _density.density(_var.dofValuesOld()[_i]); 60 42192 : mass_old = _porosity_old[_qp] * density_old * (1 - _other_var_nodal_old[_i]); 61 : } 62 : else 63 : { 64 42192 : density_old = _density.density(_other_var_nodal_old[_i]); 65 42192 : mass_old = _porosity_old[_qp] * density_old * _var.dofValuesOld()[_i]; 66 : } 67 : 68 84384 : return _test[_i][_qp] * (-mass_old) / _dt; 69 : }