www.mooseframework.org
RichardsMassChange.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 
8 #include "RichardsMassChange.h"
9 
10 // MOOSE includes
11 #include "Material.h"
12 #include "MooseVariable.h"
13 
14 // C++ includes
15 #include <iostream>
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<TimeDerivative>();
22  params.addParam<bool>("use_supg",
23  false,
24  "True for using SUPG in this kernel, false otherwise. "
25  "This has no effect if the material does not use SUPG.");
26  params.addRequiredParam<UserObjectName>(
27  "richardsVarNames_UO", "The UserObject that holds the list of Richards variable names.");
28  return params;
29 }
30 
31 RichardsMassChange::RichardsMassChange(const InputParameters & parameters)
32  : TimeDerivative(parameters),
33  _richards_name_UO(getUserObject<RichardsVarNames>("richardsVarNames_UO")),
34  _pvar(_richards_name_UO.richards_var_num(_var.number())),
35 
36  _use_supg(getParam<bool>("use_supg")),
37 
38  _mass(getMaterialProperty<std::vector<Real>>("mass")),
39  _dmass(getMaterialProperty<std::vector<std::vector<Real>>>("dmass")),
40  _mass_old(getMaterialProperty<std::vector<Real>>("mass_old")),
41 
42  _tauvel_SUPG(getMaterialProperty<std::vector<RealVectorValue>>("tauvel_SUPG")),
43  _dtauvel_SUPG_dgradv(
44  getMaterialProperty<std::vector<std::vector<RealTensorValue>>>("dtauvel_SUPG_dgradv")),
45  _dtauvel_SUPG_dv(
46  getMaterialProperty<std::vector<std::vector<RealVectorValue>>>("dtauvel_SUPG_dv"))
47 {
48 }
49 
50 Real
52 {
53  Real test_fcn = _test[_i][_qp];
54  if (_use_supg)
55  test_fcn += _tauvel_SUPG[_qp][_pvar] * _grad_test[_i][_qp];
56  return test_fcn * (_mass[_qp][_pvar] - _mass_old[_qp][_pvar]) / _dt;
57 }
58 
59 Real
60 RichardsMassChange::computeQpJac(unsigned int wrt_num)
61 {
62  Real mass = _mass[_qp][_pvar];
63  Real mass_old = _mass_old[_qp][_pvar];
64  Real mass_prime = _phi[_j][_qp] * _dmass[_qp][_pvar][wrt_num];
65 
66  Real test_fcn = _test[_i][_qp];
67  Real test_fcn_prime = 0;
68 
69  if (_use_supg)
70  {
71  test_fcn += _tauvel_SUPG[_qp][_pvar] * _grad_test[_i][_qp];
72  test_fcn_prime +=
73  _grad_phi[_j][_qp] * (_dtauvel_SUPG_dgradv[_qp][_pvar][wrt_num] * _grad_test[_i][_qp]) +
74  _phi[_j][_qp] * _dtauvel_SUPG_dv[_qp][_pvar][wrt_num] * _grad_test[_i][_qp];
75  }
76  return (test_fcn * mass_prime + test_fcn_prime * (mass - mass_old)) / _dt;
77 }
78 
79 Real
81 {
82  return computeQpJac(_pvar);
83 }
84 
85 Real
87 {
89  return 0.0;
90  unsigned int dvar = _richards_name_UO.richards_var_num(jvar);
91  return computeQpJac(dvar);
92 }
virtual Real computeQpResidual()
const MaterialProperty< std::vector< std::vector< Real > > > & _dmass
d(fluid mass_i)/d(var_j)
const MaterialProperty< std::vector< Real > > & _mass
fluid mass (or fluid masses in multiphase) at quadpoints
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
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)
const MaterialProperty< std::vector< Real > > & _mass_old
old value of fluid mass (or fluid masses in multiphase) at quadpoints
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
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...
InputParameters validParams< RichardsMassChange >()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
RichardsMassChange(const InputParameters &parameters)
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number