LCOV - code coverage report
Current view: top level - src/dgkernels - ADNumericalFlux3EqnDGKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 48 49 98.0 %
Date: 2025-07-30 13:02:48 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       18573 : ADNumericalFlux3EqnDGKernel::validParams()
      19             : {
      20       18573 :   InputParameters params = ADDGKernel::validParams();
      21             : 
      22       18573 :   params.addClassDescription(
      23             :       "Adds side fluxes for the 1-D, 1-phase, variable-area Euler equations");
      24             : 
      25       37146 :   params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
      26       37146 :   params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
      27       37146 :   params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
      28       37146 :   params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
      29             : 
      30       37146 :   params.addRequiredParam<UserObjectName>("numerical_flux", "Name of numerical flux user object");
      31             : 
      32       18573 :   return params;
      33           0 : }
      34             : 
      35       14544 : ADNumericalFlux3EqnDGKernel::ADNumericalFlux3EqnDGKernel(const InputParameters & parameters)
      36             :   : ADDGKernel(parameters),
      37             : 
      38       14544 :     _A_elem(adCoupledValue("A_linear")),
      39       14544 :     _A_neig(adCoupledNeighborValue("A_linear")),
      40       29088 :     _rhoA1(getADMaterialProperty<Real>("rhoA")),
      41       29088 :     _rhouA1(getADMaterialProperty<Real>("rhouA")),
      42       29088 :     _rhoEA1(getADMaterialProperty<Real>("rhoEA")),
      43       29088 :     _p1(getADMaterialProperty<Real>("p")),
      44       29088 :     _rhoA2(getNeighborADMaterialProperty<Real>("rhoA")),
      45       29088 :     _rhouA2(getNeighborADMaterialProperty<Real>("rhouA")),
      46       29088 :     _rhoEA2(getNeighborADMaterialProperty<Real>("rhoEA")),
      47       29088 :     _p2(getNeighborADMaterialProperty<Real>("p")),
      48       14544 :     _numerical_flux(getUserObject<ADNumericalFlux3EqnBase>("numerical_flux")),
      49       14544 :     _rhoA_var(coupled("rhoA")),
      50       14544 :     _rhouA_var(coupled("rhouA")),
      51       14544 :     _rhoEA_var(coupled("rhoEA")),
      52       14544 :     _jmap(getIndexMapping()),
      53       29088 :     _equation_index(_jmap.at(_var.number()))
      54             : {
      55       14544 : }
      56             : 
      57             : ADReal
      58    24852048 : ADNumericalFlux3EqnDGKernel::computeQpResidual(Moose::DGResidualType type)
      59             : {
      60             :   // construct the left and right solution vectors from the reconstructed solution
      61    24852048 :   std::vector<ADReal> U1 = {_rhoA1[_qp], _rhouA1[_qp], _rhoEA1[_qp], _A_elem[_qp]};
      62    24852048 :   std::vector<ADReal> U2 = {_rhoA2[_qp], _rhouA2[_qp], _rhoEA2[_qp], _A_neig[_qp]};
      63             : 
      64    24852048 :   const Real nLR_dot_d = _current_side * 2 - 1.0;
      65             : 
      66             :   const std::vector<ADReal> & flux_elem =
      67    24852048 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d);
      68             :   const std::vector<ADReal> & flux_neig =
      69    24852048 :       _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d);
      70             : 
      71    24852048 :   ADReal re = 0.0;
      72    24852048 :   switch (type)
      73             :   {
      74    12426024 :     case Moose::Element:
      75    24852048 :       re = flux_elem[_equation_index] * _test[_i][_qp];
      76    12426024 :       break;
      77    12426024 :     case Moose::Neighbor:
      78    24852048 :       re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp];
      79    12426024 :       break;
      80             :   }
      81    24852048 :   return re;
      82    49704096 : }
      83             : 
      84             : std::map<unsigned int, unsigned int>
      85       14544 : ADNumericalFlux3EqnDGKernel::getIndexMapping() const
      86             : {
      87             :   std::map<unsigned int, unsigned int> jmap;
      88       14544 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMVACE1D::MASS));
      89       14544 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMVACE1D::MOMENTUM));
      90       14544 :   jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMVACE1D::ENERGY));
      91             : 
      92       14544 :   return jmap;
      93             : }

Generated by: LCOV version 1.14