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 "Q2PSaturationDiffusion.h" 11 : 12 : registerMooseObject("RichardsApp", Q2PSaturationDiffusion); 13 : 14 : InputParameters 15 28 : Q2PSaturationDiffusion::validParams() 16 : { 17 28 : InputParameters params = Kernel::validParams(); 18 56 : params.addRequiredParam<UserObjectName>( 19 : "fluid_density", 20 : "A RichardsDensity UserObject that defines the fluid density as a function of pressure."); 21 56 : params.addRequiredParam<UserObjectName>( 22 : "fluid_relperm", 23 : "A RichardsRelPerm UserObject that defines the fluid relative permeability " 24 : "as a function of water saturation (eg RichardsRelPermPower)"); 25 56 : params.addRequiredCoupledVar("porepressure_variable", 26 : "The variable representing the porepressure"); 27 56 : params.addRequiredParam<Real>("fluid_viscosity", "The fluid dynamic viscosity"); 28 56 : params.addRequiredParam<Real>("diffusivity", "Diffusivity as a function of S"); 29 28 : params.addClassDescription("Diffusion part of the Flux according to Darcy-Richards flow. The " 30 : "Variable of this Kernel must be the saturation."); 31 28 : return params; 32 0 : } 33 : 34 14 : Q2PSaturationDiffusion::Q2PSaturationDiffusion(const InputParameters & parameters) 35 : : Kernel(parameters), 36 14 : _density(getUserObject<RichardsDensity>("fluid_density")), 37 14 : _relperm(getUserObject<RichardsRelPerm>("fluid_relperm")), 38 14 : _pp(coupledValue("porepressure_variable")), 39 14 : _pp_var_num(coupled("porepressure_variable")), 40 28 : _viscosity(getParam<Real>("fluid_viscosity")), 41 28 : _permeability(getMaterialProperty<RealTensorValue>("permeability")), 42 42 : _diffusivity(getParam<Real>("diffusivity")) 43 : { 44 14 : } 45 : 46 : Real 47 42192 : Q2PSaturationDiffusion::computeQpResidual() 48 : { 49 42192 : Real coef = _diffusivity * _relperm.relperm(_u[_qp]) * _density.density(_pp[_qp]) / _viscosity; 50 42192 : return coef * _grad_test[_i][_qp] * (_permeability[_qp] * _grad_u[_qp]); 51 : } 52 : 53 : Real 54 106880 : Q2PSaturationDiffusion::computeQpJacobian() 55 : { 56 106880 : Real coef = _diffusivity * _relperm.relperm(_u[_qp]) * _density.density(_pp[_qp]) / _viscosity; 57 106880 : Real coefp = _diffusivity * _relperm.drelperm(_u[_qp]) * _density.density(_pp[_qp]) / _viscosity; 58 106880 : return coefp * _phi[_j][_qp] * _grad_test[_i][_qp] * (_permeability[_qp] * _grad_u[_qp]) + 59 106880 : coef * _grad_test[_i][_qp] * (_permeability[_qp] * _grad_phi[_j][_qp]); 60 : } 61 : 62 : Real 63 105280 : Q2PSaturationDiffusion::computeQpOffDiagJacobian(unsigned int jvar) 64 : { 65 105280 : if (jvar != _pp_var_num) 66 : return 0.0; 67 104768 : Real coefp = _diffusivity * _relperm.relperm(_u[_qp]) * _density.ddensity(_pp[_qp]) / _viscosity; 68 104768 : return coefp * _phi[_j][_qp] * (_grad_test[_i][_qp] * (_permeability[_qp] * _grad_u[_qp])); 69 : }