LCOV - code coverage report
Current view: top level - src/dgkernels - NumericalFluxGasMixDGKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 61 62 98.4 %
Date: 2026-05-29 20:41:18 Functions: 4 4 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 "NumericalFluxGasMixDGKernel.h"
      11             : #include "NumericalFluxGasMixBase.h"
      12             : #include "MooseVariable.h"
      13             : #include "THMIndicesGasMix.h"
      14             : #include "THMNames.h"
      15             : 
      16             : registerMooseObject("ThermalHydraulicsApp", NumericalFluxGasMixDGKernel);
      17             : 
      18             : InputParameters
      19          76 : NumericalFluxGasMixDGKernel::validParams()
      20             : {
      21          76 :   InputParameters params = ADDGKernel::validParams();
      22             : 
      23          76 :   params.addClassDescription("Adds side fluxes from NumericalFluxGasMixBase objects.");
      24             : 
      25         152 :   params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
      26         152 :   params.addRequiredCoupledVar("xirhoA", "Conserved variable xi*rho*A");
      27         152 :   params.addRequiredCoupledVar("rhoA", "Conserved variable rho*A");
      28         152 :   params.addRequiredCoupledVar("rhouA", "Conserved variable rho*u*A");
      29         152 :   params.addRequiredCoupledVar("rhoEA", "Conserved variable rho*E*A");
      30             : 
      31         152 :   params.addRequiredParam<UserObjectName>("numerical_flux",
      32             :                                           "Name of NumericalFluxGasMixBase object");
      33             : 
      34          76 :   return params;
      35           0 : }
      36             : 
      37          40 : NumericalFluxGasMixDGKernel::NumericalFluxGasMixDGKernel(const InputParameters & parameters)
      38             :   : ADDGKernel(parameters),
      39             : 
      40          40 :     _A_elem(adCoupledValue("A_linear")),
      41          40 :     _A_neig(adCoupledNeighborValue("A_linear")),
      42          40 :     _xirhoA1(getADMaterialProperty<Real>(THM::XIRHOA)),
      43          40 :     _rhoA1(getADMaterialProperty<Real>(THM::RHOA)),
      44          40 :     _rhouA1(getADMaterialProperty<Real>(THM::RHOUA)),
      45          40 :     _rhoEA1(getADMaterialProperty<Real>(THM::RHOEA)),
      46          40 :     _xirhoA2(getNeighborADMaterialProperty<Real>(THM::XIRHOA)),
      47          40 :     _rhoA2(getNeighborADMaterialProperty<Real>(THM::RHOA)),
      48          40 :     _rhouA2(getNeighborADMaterialProperty<Real>(THM::RHOUA)),
      49          40 :     _rhoEA2(getNeighborADMaterialProperty<Real>(THM::RHOEA)),
      50          40 :     _numerical_flux(getUserObject<NumericalFluxGasMixBase>("numerical_flux")),
      51          40 :     _xirhoA_var(coupled("xirhoA")),
      52          40 :     _rhoA_var(coupled("rhoA")),
      53          40 :     _rhouA_var(coupled("rhouA")),
      54          40 :     _rhoEA_var(coupled("rhoEA")),
      55          40 :     _jmap(getIndexMapping()),
      56          80 :     _equation_index(_jmap.at(_var.number()))
      57             : {
      58          40 : }
      59             : 
      60             : ADReal
      61       60760 : NumericalFluxGasMixDGKernel::computeQpResidual(Moose::DGResidualType type)
      62             : {
      63             :   // construct the left and right solution vectors from the reconstructed solution
      64       60760 :   std::vector<ADReal> U1(THMGasMix1D::N_FLUX_INPUTS, 0.0);
      65       60760 :   U1[THMGasMix1D::XIRHOA] = _xirhoA1[_qp];
      66       60760 :   U1[THMGasMix1D::RHOA] = _rhoA1[_qp];
      67       60760 :   U1[THMGasMix1D::RHOUA] = _rhouA1[_qp];
      68       60760 :   U1[THMGasMix1D::RHOEA] = _rhoEA1[_qp];
      69       60760 :   U1[THMGasMix1D::AREA] = _A_elem[_qp];
      70             : 
      71       60760 :   std::vector<ADReal> U2(THMGasMix1D::N_FLUX_INPUTS, 0.0);
      72       60760 :   U2[THMGasMix1D::XIRHOA] = _xirhoA2[_qp];
      73       60760 :   U2[THMGasMix1D::RHOA] = _rhoA2[_qp];
      74       60760 :   U2[THMGasMix1D::RHOUA] = _rhouA2[_qp];
      75       60760 :   U2[THMGasMix1D::RHOEA] = _rhoEA2[_qp];
      76       60760 :   U2[THMGasMix1D::AREA] = _A_neig[_qp];
      77             : 
      78       60760 :   const Real nLR_dot_d = _current_side * 2 - 1.0;
      79             : 
      80             :   const std::vector<ADReal> & flux_elem =
      81       60760 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d);
      82             :   const std::vector<ADReal> & flux_neig =
      83       60760 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d);
      84             : 
      85       60760 :   ADReal re = 0.0;
      86       60760 :   switch (type)
      87             :   {
      88       30380 :     case Moose::Element:
      89       60760 :       re = flux_elem[_equation_index] * _test[_i][_qp];
      90       30380 :       break;
      91       30380 :     case Moose::Neighbor:
      92       60760 :       re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp];
      93       30380 :       break;
      94             :   }
      95       60760 :   return re;
      96       60760 : }
      97             : 
      98             : std::map<unsigned int, unsigned int>
      99          40 : NumericalFluxGasMixDGKernel::getIndexMapping() const
     100             : {
     101             :   std::map<unsigned int, unsigned int> jmap;
     102          40 :   jmap.insert(std::pair<unsigned int, unsigned int>(_xirhoA_var, THMGasMix1D::SPECIES));
     103          40 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMGasMix1D::MASS));
     104          40 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMGasMix1D::MOMENTUM));
     105          40 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMGasMix1D::ENERGY));
     106             : 
     107          40 :   return jmap;
     108             : }

Generated by: LCOV version 1.14