LCOV - code coverage report
Current view: top level - src/dgkernels - ADNumericalFlux3EqnDGKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 67 68 98.5 %
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 "ADNumericalFlux3EqnDGKernel.h"
      11             : #include "ADNumericalFlux3EqnBase.h"
      12             : #include "MooseVariable.h"
      13             : #include "THMIndicesVACE.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", ADNumericalFlux3EqnDGKernel);
      16             : 
      17             : InputParameters
      18       13118 : ADNumericalFlux3EqnDGKernel::validParams()
      19             : {
      20       13118 :   InputParameters params = ADDGKernel::validParams();
      21             : 
      22       13118 :   params.addClassDescription(
      23             :       "Adds side fluxes for the 1-D, 1-phase, variable-area Euler equations");
      24             : 
      25       26236 :   params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
      26       26236 :   params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
      27       26236 :   params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
      28       26236 :   params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
      29       26236 :   params.addCoupledVar("passives_times_area", "Passive transport solution variables");
      30             : 
      31       26236 :   params.addRequiredParam<UserObjectName>("numerical_flux", "Name of numerical flux user object");
      32             : 
      33       13118 :   return params;
      34           0 : }
      35             : 
      36        6989 : ADNumericalFlux3EqnDGKernel::ADNumericalFlux3EqnDGKernel(const InputParameters & parameters)
      37             :   : ADDGKernel(parameters),
      38             : 
      39        6989 :     _A_elem(adCoupledValue("A_linear")),
      40        6989 :     _A_neig(adCoupledNeighborValue("A_linear")),
      41       13978 :     _rhoA1(getADMaterialProperty<Real>("rhoA")),
      42       13978 :     _rhouA1(getADMaterialProperty<Real>("rhouA")),
      43       13978 :     _rhoEA1(getADMaterialProperty<Real>("rhoEA")),
      44       13978 :     _passives_times_area1(getADMaterialProperty<std::vector<Real>>("passives_times_area")),
      45       13978 :     _p1(getADMaterialProperty<Real>("p")),
      46       13978 :     _rhoA2(getNeighborADMaterialProperty<Real>("rhoA")),
      47       13978 :     _rhouA2(getNeighborADMaterialProperty<Real>("rhouA")),
      48       13978 :     _rhoEA2(getNeighborADMaterialProperty<Real>("rhoEA")),
      49       13978 :     _passives_times_area2(getNeighborADMaterialProperty<std::vector<Real>>("passives_times_area")),
      50       13978 :     _p2(getNeighborADMaterialProperty<Real>("p")),
      51        6989 :     _numerical_flux(getUserObject<ADNumericalFlux3EqnBase>("numerical_flux")),
      52        6989 :     _rhoA_var(coupled("rhoA")),
      53        6989 :     _rhouA_var(coupled("rhouA")),
      54        6989 :     _rhoEA_var(coupled("rhoEA")),
      55       20967 :     _n_passives(isParamValid("passives_times_area") ? coupledComponents("passives_times_area") : 0),
      56        6989 :     _jmap(getIndexMapping()),
      57       13978 :     _equation_index(_jmap.at(_var.number()))
      58             : {
      59        6989 : }
      60             : 
      61             : ADReal
      62    14252652 : ADNumericalFlux3EqnDGKernel::computeQpResidual(Moose::DGResidualType type)
      63             : {
      64             :   // left reconstructed solution
      65    14252652 :   std::vector<ADReal> U1(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
      66    14252652 :   U1[THMVACE1D::RHOA] = _rhoA1[_qp];
      67    14252652 :   U1[THMVACE1D::RHOUA] = _rhouA1[_qp];
      68    14252652 :   U1[THMVACE1D::RHOEA] = _rhoEA1[_qp];
      69    14252652 :   U1[THMVACE1D::AREA] = _A_elem[_qp];
      70    14444712 :   for (const auto i : make_range(_n_passives))
      71      192060 :     U1[THMVACE1D::N_FLUX_INPUTS + i] = _passives_times_area1[_qp][i];
      72             : 
      73             :   // right reconstructed solution
      74    14252652 :   std::vector<ADReal> U2(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
      75    14252652 :   U2[THMVACE1D::RHOA] = _rhoA2[_qp];
      76    14252652 :   U2[THMVACE1D::RHOUA] = _rhouA2[_qp];
      77    14252652 :   U2[THMVACE1D::RHOEA] = _rhoEA2[_qp];
      78    14252652 :   U2[THMVACE1D::AREA] = _A_neig[_qp];
      79    14444712 :   for (const auto i : make_range(_n_passives))
      80      192060 :     U2[THMVACE1D::N_FLUX_INPUTS + i] = _passives_times_area2[_qp][i];
      81             : 
      82    14252652 :   const Real nLR_dot_d = _current_side * 2 - 1.0;
      83             : 
      84             :   const std::vector<ADReal> & flux_elem =
      85    14252652 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d);
      86             :   const std::vector<ADReal> & flux_neig =
      87    14252652 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d);
      88             : 
      89    14252652 :   ADReal re = 0.0;
      90    14252652 :   switch (type)
      91             :   {
      92     7126326 :     case Moose::Element:
      93    14252652 :       re = flux_elem[_equation_index] * _test[_i][_qp];
      94     7126326 :       break;
      95     7126326 :     case Moose::Neighbor:
      96    14252652 :       re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp];
      97     7126326 :       break;
      98             :   }
      99    14252652 :   return re;
     100    14252652 : }
     101             : 
     102             : std::map<unsigned int, unsigned int>
     103        6989 : ADNumericalFlux3EqnDGKernel::getIndexMapping() const
     104             : {
     105             :   std::map<unsigned int, unsigned int> jmap;
     106        6989 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMVACE1D::MASS));
     107        6989 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMVACE1D::MOMENTUM));
     108        6989 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMVACE1D::ENERGY));
     109        7089 :   for (const auto i : make_range(_n_passives))
     110         200 :     jmap.insert(std::pair<unsigned int, unsigned int>(coupled("passives_times_area", i),
     111         100 :                                                       THMVACE1D::N_FLUX_OUTPUTS + i));
     112             : 
     113        6989 :   return jmap;
     114             : }

Generated by: LCOV version 1.14