LCOV - code coverage report
Current view: top level - src/userobjects - ADNumericalFlux3EqnCentered.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 38 39 97.4 %
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 "ADNumericalFlux3EqnCentered.h"
      11             : #include "THMIndicesVACE.h"
      12             : #include "Numerics.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", ADNumericalFlux3EqnCentered);
      15             : 
      16             : InputParameters
      17           4 : ADNumericalFlux3EqnCentered::validParams()
      18             : {
      19           4 :   InputParameters params = ADNumericalFlux3EqnBase::validParams();
      20             : 
      21           4 :   params.addClassDescription(
      22             :       "Computes internal side flux for the 1-D, 1-phase, variable-area Euler equations using a "
      23             :       "centered average of the left and right side fluxes");
      24             : 
      25           8 :   params.addRequiredParam<UserObjectName>("fluid_properties",
      26             :                                           "Name for fluid properties user object");
      27             : 
      28           4 :   return params;
      29           0 : }
      30             : 
      31           2 : ADNumericalFlux3EqnCentered::ADNumericalFlux3EqnCentered(const InputParameters & parameters)
      32             :   : ADNumericalFlux3EqnBase(parameters),
      33             : 
      34           2 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      35             : {
      36           2 : }
      37             : 
      38             : void
      39           4 : ADNumericalFlux3EqnCentered::calcFlux(const std::vector<ADReal> & U1,
      40             :                                       const std::vector<ADReal> & U2,
      41             :                                       const RealVectorValue & nLR,
      42             :                                       const RealVectorValue & t1,
      43             :                                       const RealVectorValue & t2,
      44             :                                       std::vector<ADReal> & FL,
      45             :                                       std::vector<ADReal> & FR) const
      46             : {
      47           4 :   const std::vector<ADReal> flux1 = computeFlux(U1, nLR, t1, t2);
      48           4 :   const std::vector<ADReal> flux2 = computeFlux(U2, nLR, t1, t2);
      49             : 
      50           4 :   FL.resize(THMVACE3D::N_FLUX_OUTPUTS);
      51          24 :   for (unsigned int i = 0; i < THMVACE3D::N_FLUX_OUTPUTS; i++)
      52          60 :     FL[i] = 0.5 * (flux1[i] + flux2[i]);
      53             : 
      54           4 :   FR = FL;
      55           4 : }
      56             : 
      57             : std::vector<ADReal>
      58           8 : ADNumericalFlux3EqnCentered::computeFlux(const std::vector<ADReal> & U,
      59             :                                          const RealVectorValue & n,
      60             :                                          const RealVectorValue & t1,
      61             :                                          const RealVectorValue & t2) const
      62             : {
      63           8 :   const ADReal rhoA = U[THMVACE3D::RHOA];
      64           8 :   const ADReal rhouA = U[THMVACE3D::RHOUA];
      65           8 :   const ADReal rhovA = U[THMVACE3D::RHOVA];
      66           8 :   const ADReal rhowA = U[THMVACE3D::RHOWA];
      67           8 :   const ADReal rhoEA = U[THMVACE3D::RHOEA];
      68           8 :   const ADReal A = U[THMVACE3D::AREA];
      69             : 
      70             :   const ADReal rho = rhoA / A;
      71           8 :   const ADRealVectorValue uvec(rhouA / rhoA, rhovA / rhoA, rhowA / rhoA);
      72           8 :   const ADReal un = uvec * n;
      73           8 :   const ADReal ut1 = uvec * t1;
      74           8 :   const ADReal ut2 = uvec * t2;
      75          16 :   const ADReal v = 1.0 / rho;
      76             :   const ADReal E = rhoEA / rhoA;
      77           8 :   const ADReal e = E - 0.5 * uvec * uvec;
      78           8 :   const ADReal p = _fp.p_from_v_e(v, e);
      79           8 :   const ADReal H = E + p / rho;
      80             : 
      81           8 :   std::vector<ADReal> flux(THMVACE3D::N_FLUX_OUTPUTS, 0.0);
      82           8 :   flux[THMVACE3D::MASS] = rho * un * A;
      83           8 :   flux[THMVACE3D::MOM_NORM] = (rho * un * un + p) * A;
      84           8 :   flux[THMVACE3D::MOM_TAN1] = rho * un * ut1 * A;
      85           8 :   flux[THMVACE3D::MOM_TAN2] = rho * un * ut2 * A;
      86           8 :   flux[THMVACE3D::ENERGY] = rho * un * H * A;
      87             : 
      88           8 :   return flux;
      89             : }

Generated by: LCOV version 1.14