https://mooseframework.inl.gov
RichardsMassChange.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 
10 #include "RichardsMassChange.h"
11 
12 // MOOSE includes
13 #include "Material.h"
14 #include "MooseVariable.h"
15 
16 // C++ includes
17 #include <iostream>
18 
20 
23 {
25  params.addParam<bool>("use_supg",
26  false,
27  "True for using SUPG in this kernel, false otherwise. "
28  "This has no effect if the material does not use SUPG.");
29  params.addRequiredParam<UserObjectName>(
30  "richardsVarNames_UO", "The UserObject that holds the list of Richards variable names.");
31  return params;
32 }
33 
35  : TimeDerivative(parameters),
36  _richards_name_UO(getUserObject<RichardsVarNames>("richardsVarNames_UO")),
37  _pvar(_richards_name_UO.richards_var_num(_var.number())),
38 
39  _use_supg(getParam<bool>("use_supg")),
40 
41  _mass(getMaterialProperty<std::vector<Real>>("mass")),
42  _dmass(getMaterialProperty<std::vector<std::vector<Real>>>("dmass")),
43  _mass_old(getMaterialProperty<std::vector<Real>>("mass_old")),
44 
45  _tauvel_SUPG(getMaterialProperty<std::vector<RealVectorValue>>("tauvel_SUPG")),
46  _dtauvel_SUPG_dgradv(
47  getMaterialProperty<std::vector<std::vector<RealTensorValue>>>("dtauvel_SUPG_dgradv")),
48  _dtauvel_SUPG_dv(
49  getMaterialProperty<std::vector<std::vector<RealVectorValue>>>("dtauvel_SUPG_dv"))
50 {
51 }
52 
53 Real
55 {
56  Real test_fcn = _test[_i][_qp];
57  if (_use_supg)
58  test_fcn += _tauvel_SUPG[_qp][_pvar] * _grad_test[_i][_qp];
59  return test_fcn * (_mass[_qp][_pvar] - _mass_old[_qp][_pvar]) / _dt;
60 }
61 
62 Real
63 RichardsMassChange::computeQpJac(unsigned int wrt_num)
64 {
65  Real mass = _mass[_qp][_pvar];
66  Real mass_old = _mass_old[_qp][_pvar];
67  Real mass_prime = _phi[_j][_qp] * _dmass[_qp][_pvar][wrt_num];
68 
69  Real test_fcn = _test[_i][_qp];
70  Real test_fcn_prime = 0;
71 
72  if (_use_supg)
73  {
74  test_fcn += _tauvel_SUPG[_qp][_pvar] * _grad_test[_i][_qp];
75  test_fcn_prime +=
77  _phi[_j][_qp] * _dtauvel_SUPG_dv[_qp][_pvar][wrt_num] * _grad_test[_i][_qp];
78  }
79  return (test_fcn * mass_prime + test_fcn_prime * (mass - mass_old)) / _dt;
80 }
81 
82 Real
84 {
85  return computeQpJac(_pvar);
86 }
87 
88 Real
90 {
92  return 0.0;
93  unsigned int dvar = _richards_name_UO.richards_var_num(jvar);
94  return computeQpJac(dvar);
95 }
virtual Real computeQpResidual()
const MaterialProperty< std::vector< std::vector< Real > > > & _dmass
d(fluid mass_i)/d(var_j)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const MaterialProperty< std::vector< Real > > & _mass
fluid mass (or fluid masses in multiphase) at quadpoints
const VariablePhiGradient & _grad_phi
registerMooseObject("RichardsApp", RichardsMassChange)
bool _use_supg
whether to use SUPG for this kernel (not recommended)
const MaterialProperty< std::vector< std::vector< RealVectorValue > > > & _dtauvel_SUPG_dv
deriv of tau_SUPG wrt variable
static InputParameters validParams()
bool not_richards_var(unsigned int moose_var_num) const
returns true if moose_var_num is not a richards var
This holds maps between pressure_var or pressure_var, sat_var used in RichardsMaterial and kernels...
const MaterialProperty< std::vector< RealVectorValue > > & _tauvel_SUPG
tau_SUPG
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _dtauvel_SUPG_dgradv
derivative of tau_SUPG wrt grad(variable)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Kernel = (mass - mass_old)/dt where mass = porosity*density*saturation This is used for the time deri...
TensorValue< Real > RealTensorValue
const MaterialProperty< std::vector< Real > > & _mass_old
old value of fluid mass (or fluid masses in multiphase) at quadpoints
const VariableTestValue & _test
unsigned int _pvar
the Richards variable number eg, if richards name = &#39;pwater pgas poil&#39;, and this kernel is for pgas...
const RichardsVarNames & _richards_name_UO
holds info on the Richards variables
unsigned int _i
virtual Real computeQpJacobian()
Real computeQpJac(unsigned int wrt_num)
Derivative of residual with respect to wrt_num Richards variable This is used by both computeQpJacobi...
unsigned int _j
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number
const VariableTestGradient & _grad_test
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
static InputParameters validParams()
RichardsMassChange(const InputParameters &parameters)
const VariablePhiValue & _phi
unsigned int _qp