LCOV - code coverage report
Current view: top level - src/dgkernels - MassDiffusionBaseGasMixDGKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 35 36 97.2 %
Date: 2025-07-30 13:02:48 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14