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 "MassDiffusionBaseGasMixDGKernel.h" 11 : 12 : InputParameters 13 38 : MassDiffusionBaseGasMixDGKernel::validParams() 14 : { 15 38 : InputParameters params = ADDGKernel::validParams(); 16 : 17 76 : params.addRequiredParam<MaterialPropertyName>("density", "Mixture density material property"); 18 76 : params.addRequiredParam<MaterialPropertyName>("diffusion_coefficient", 19 : "Diffusion coefficient material property"); 20 76 : params.addRequiredParam<MaterialPropertyName>("mass_fraction", "Mass fraction material property"); 21 : 22 76 : params.addRequiredCoupledVar("A_linear", "Cross-sectional area"); 23 76 : params.addRequiredParam<MaterialPropertyName>("direction", 24 : "Flow channel direction material property"); 25 : 26 38 : params.addClassDescription("Adds mass diffusion for FlowChannelGasMix."); 27 : 28 38 : return params; 29 0 : } 30 : 31 20 : MassDiffusionBaseGasMixDGKernel::MassDiffusionBaseGasMixDGKernel(const InputParameters & parameters) 32 : : ADDGKernel(parameters), 33 : 34 20 : _rho_elem(getADMaterialProperty<Real>("density")), 35 40 : _rho_neig(getNeighborADMaterialProperty<Real>("density")), 36 40 : _D_elem(getADMaterialProperty<Real>("diffusion_coefficient")), 37 40 : _D_neig(getNeighborADMaterialProperty<Real>("diffusion_coefficient")), 38 40 : _mass_fraction_elem(getADMaterialProperty<Real>("mass_fraction")), 39 40 : _mass_fraction_neig(getNeighborADMaterialProperty<Real>("mass_fraction")), 40 : 41 20 : _A_linear(adCoupledValue("A_linear")), 42 60 : _dir(getMaterialProperty<RealVectorValue>("direction")) 43 : { 44 20 : } 45 : 46 : ADReal 47 30380 : MassDiffusionBaseGasMixDGKernel::computeQpResidual(Moose::DGResidualType type) 48 : { 49 30380 : const ADReal flux = computeQpFlux(); 50 30380 : const Real flux_sign_elem = _current_side * 2 - 1.0; 51 75950 : return type == Moose::Element ? flux_sign_elem * flux * _A_linear[_qp] * _test[_i][_qp] 52 106330 : : -flux_sign_elem * flux * _A_linear[_qp] * _test_neighbor[_i][_qp]; 53 : } 54 : 55 : void 56 30380 : MassDiffusionBaseGasMixDGKernel::computePositionChanges(Real & dx, Real & dx_side) const 57 : { 58 30380 : const Point x_elem = _current_elem->vertex_average(); 59 30380 : const Point x_neig = _neighbor_elem->vertex_average(); 60 30380 : dx = (x_neig - x_elem) * _dir[_qp]; 61 30380 : dx_side = (_q_point[_qp] - x_elem) * _dir[_qp]; 62 30380 : } 63 : 64 : ADReal 65 121520 : MassDiffusionBaseGasMixDGKernel::linearlyInterpolate(const ADReal & y_elem, 66 : const ADReal & y_neig, 67 : Real dx, 68 : Real dx_side) const 69 : { 70 121520 : const ADReal dydx = computeGradient(y_elem, y_neig, dx); 71 : 72 121520 : return y_elem + dydx * dx_side; 73 : } 74 : 75 : ADReal 76 151900 : MassDiffusionBaseGasMixDGKernel::computeGradient(const ADReal & y_elem, 77 : const ADReal & y_neig, 78 : Real dx) const 79 : { 80 151900 : return (y_neig - y_elem) / dx; 81 : }