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