LCOV - code coverage report
Current view: top level - src/materials - ADRDG3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 57 58 98.3 %
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 "ADRDG3EqnMaterial.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "THMIndicesVACE.h"
      13             : #include "FlowModel1PhaseUtils.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial);
      16             : 
      17             : InputParameters
      18       18573 : ADRDG3EqnMaterial::validParams()
      19             : {
      20       18573 :   InputParameters params = Material::validParams();
      21       18573 :   params += SlopeReconstruction1DInterface<true>::validParams();
      22             : 
      23       18573 :   params.addClassDescription(
      24             :       "Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations");
      25             : 
      26       37146 :   params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
      27       37146 :   params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
      28       37146 :   params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
      29       37146 :   params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
      30       37146 :   params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
      31             : 
      32       37146 :   params.addRequiredParam<MaterialPropertyName>("direction",
      33             :                                                 "Flow channel direction material property name");
      34             : 
      35       37146 :   params.addRequiredParam<UserObjectName>("fluid_properties",
      36             :                                           "Name of fluid properties user object");
      37             : 
      38       18573 :   return params;
      39           0 : }
      40             : 
      41       14544 : ADRDG3EqnMaterial::ADRDG3EqnMaterial(const InputParameters & parameters)
      42             :   : Material(parameters),
      43             :     SlopeReconstruction1DInterface<true>(this),
      44             : 
      45       14544 :     _A_avg(adCoupledValue("A_elem")),
      46       14544 :     _A_linear(adCoupledValue("A_linear")),
      47       14544 :     _rhoA_avg(adCoupledValue("rhoA")),
      48       14544 :     _rhouA_avg(adCoupledValue("rhouA")),
      49       14544 :     _rhoEA_avg(adCoupledValue("rhoEA")),
      50             : 
      51       14544 :     _A_var(getVar("A_elem", 0)),
      52       14544 :     _rhoA_var(getVar("rhoA", 0)),
      53       14544 :     _rhouA_var(getVar("rhouA", 0)),
      54       14544 :     _rhoEA_var(getVar("rhoEA", 0)),
      55             : 
      56       29088 :     _dir(getMaterialProperty<RealVectorValue>("direction")),
      57             : 
      58       14544 :     _rhoA(declareADProperty<Real>("rhoA")),
      59       14544 :     _rhouA(declareADProperty<Real>("rhouA")),
      60       14544 :     _rhoEA(declareADProperty<Real>("rhoEA")),
      61             : 
      62       29088 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      63             : {
      64       14544 :   _U_vars.resize(THMVACE1D::N_FLUX_INPUTS);
      65       14544 :   _U_vars[THMVACE1D::RHOA] = _rhoA_var;
      66       14544 :   _U_vars[THMVACE1D::RHOUA] = _rhouA_var;
      67       14544 :   _U_vars[THMVACE1D::RHOEA] = _rhoEA_var;
      68       14544 :   _U_vars[THMVACE1D::AREA] = _A_var;
      69       14544 : }
      70             : 
      71             : void
      72    23412366 : ADRDG3EqnMaterial::computeQpProperties()
      73             : {
      74    23412366 :   if (_scheme == None)
      75             :   {
      76    18758010 :     const auto A_ratio = _A_linear[_qp] / _A_avg[_qp];
      77    37516020 :     _rhoA[_qp] = _rhoA_avg[_qp] * A_ratio;
      78    37516020 :     _rhouA[_qp] = _rhouA_avg[_qp] * A_ratio;
      79    37516020 :     _rhoEA[_qp] = _rhoEA_avg[_qp] * A_ratio;
      80             :   }
      81             :   else
      82             :   {
      83             :     // compute primitive variables from the cell-average solution
      84     4654356 :     std::vector<ADReal> U_avg(THMVACE1D::N_FLUX_INPUTS, 0.0);
      85     4654356 :     U_avg[THMVACE1D::RHOA] = _rhoA_avg[_qp];
      86     4654356 :     U_avg[THMVACE1D::RHOUA] = _rhouA_avg[_qp];
      87     4654356 :     U_avg[THMVACE1D::RHOEA] = _rhoEA_avg[_qp];
      88     4654356 :     U_avg[THMVACE1D::AREA] = _A_avg[_qp];
      89     4654356 :     auto W = FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U_avg, _fp);
      90             : 
      91             :     // compute and apply slopes to primitive variables
      92     4654356 :     const auto slopes = getElementSlopes(_current_elem);
      93     4654356 :     const auto delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp];
      94    18617424 :     for (unsigned int m = 0; m < THMVACE1D::N_PRIM_VARS; m++)
      95    27926136 :       W[m] = W[m] + slopes[m] * delta_x;
      96             : 
      97             :     // compute reconstructed conservative variables
      98             :     const auto U =
      99     4654356 :         FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W, _A_linear[_qp], _fp);
     100     4654356 :     _rhoA[_qp] = U[THMVACE1D::RHOA];
     101     4654356 :     _rhouA[_qp] = U[THMVACE1D::RHOUA];
     102     4654356 :     _rhoEA[_qp] = U[THMVACE1D::RHOEA];
     103             :   }
     104    23412366 : }
     105             : 
     106             : std::vector<ADReal>
     107    13534804 : ADRDG3EqnMaterial::computeElementPrimitiveVariables(const Elem * elem) const
     108             : {
     109             :   const auto U =
     110    13534804 :       FlowModel1PhaseUtils::getElementalSolutionVector<true>(elem, _U_vars, _is_implicit);
     111    27069608 :   return FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U, _fp);
     112             : }

Generated by: LCOV version 1.14