LCOV - code coverage report
Current view: top level - src/materials - ADRDG3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 70 73 95.9 %
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 "ADRDG3EqnMaterial.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "THMIndicesVACE.h"
      13             : #include "FlowModel1PhaseUtils.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial);
      16             : 
      17             : InputParameters
      18        9006 : ADRDG3EqnMaterial::validParams()
      19             : {
      20        9006 :   InputParameters params = Material::validParams();
      21        9006 :   params += SlopeReconstruction1DInterface<true>::validParams();
      22             : 
      23        9006 :   params.addClassDescription(
      24             :       "Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations");
      25             : 
      26       18012 :   params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
      27       18012 :   params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
      28       18012 :   params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
      29       18012 :   params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
      30       18012 :   params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
      31       18012 :   params.addCoupledVar("passives_times_area", "Passive transport solution variables");
      32             : 
      33       18012 :   params.addRequiredParam<MaterialPropertyName>("direction",
      34             :                                                 "Flow channel direction material property name");
      35             : 
      36       18012 :   params.addRequiredParam<UserObjectName>("fluid_properties",
      37             :                                           "Name of fluid properties user object");
      38             : 
      39        9006 :   return params;
      40           0 : }
      41             : 
      42        6969 : ADRDG3EqnMaterial::ADRDG3EqnMaterial(const InputParameters & parameters)
      43             :   : Material(parameters),
      44             :     SlopeReconstruction1DInterface<true>(this),
      45             : 
      46        6969 :     _A_avg(adCoupledValue("A_elem")),
      47        6969 :     _A_linear(adCoupledValue("A_linear")),
      48        6969 :     _rhoA_avg(adCoupledValue("rhoA")),
      49        6969 :     _rhouA_avg(adCoupledValue("rhouA")),
      50        6969 :     _rhoEA_avg(adCoupledValue("rhoEA")),
      51             : 
      52        6969 :     _A_var(getVar("A_elem", 0)),
      53        6969 :     _rhoA_var(getVar("rhoA", 0)),
      54        6969 :     _rhouA_var(getVar("rhouA", 0)),
      55        6969 :     _rhoEA_var(getVar("rhoEA", 0)),
      56             : 
      57       20907 :     _n_passives(isParamValid("passives_times_area") ? coupledComponents("passives_times_area") : 0),
      58             : 
      59       13938 :     _dir(getMaterialProperty<RealVectorValue>("direction")),
      60             : 
      61        6969 :     _rhoA(declareADProperty<Real>("rhoA")),
      62        6969 :     _rhouA(declareADProperty<Real>("rhouA")),
      63        6969 :     _rhoEA(declareADProperty<Real>("rhoEA")),
      64        6969 :     _passives_times_area(declareADProperty<std::vector<Real>>("passives_times_area")),
      65             : 
      66       13938 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      67             : {
      68        6969 :   _U_vars.resize(THMVACE1D::N_FLUX_INPUTS + _n_passives);
      69        6969 :   _U_vars[THMVACE1D::RHOA] = _rhoA_var;
      70        6969 :   _U_vars[THMVACE1D::RHOUA] = _rhouA_var;
      71        6969 :   _U_vars[THMVACE1D::RHOEA] = _rhoEA_var;
      72        6969 :   _U_vars[THMVACE1D::AREA] = _A_var;
      73        7029 :   for (const auto i : make_range(_n_passives))
      74             :   {
      75          60 :     _U_vars[THMVACE1D::N_FLUX_INPUTS + i] = getVar("passives_times_area", i);
      76         120 :     _passives_times_area_avg.push_back(&adCoupledValue("passives_times_area", i));
      77             :   }
      78        6969 : }
      79             : 
      80             : void
      81    14861229 : ADRDG3EqnMaterial::computeQpProperties()
      82             : {
      83    14861229 :   if (_scheme == None)
      84             :   {
      85    13084959 :     const auto A_ratio = _A_linear[_qp] / _A_avg[_qp];
      86    26169918 :     _rhoA[_qp] = _rhoA_avg[_qp] * A_ratio;
      87    26169918 :     _rhouA[_qp] = _rhouA_avg[_qp] * A_ratio;
      88    26169918 :     _rhoEA[_qp] = _rhoEA_avg[_qp] * A_ratio;
      89             : 
      90    13084959 :     _passives_times_area[_qp].resize(_n_passives);
      91    13182359 :     for (const auto i : make_range(_n_passives))
      92      194800 :       _passives_times_area[_qp][i] = (*_passives_times_area_avg[i])[_qp] * A_ratio;
      93             :   }
      94             :   else
      95             :   {
      96             :     // compute primitive variables from the cell-average solution
      97     1776270 :     std::vector<ADReal> U_avg(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
      98     1776270 :     U_avg[THMVACE1D::RHOA] = _rhoA_avg[_qp];
      99     1776270 :     U_avg[THMVACE1D::RHOUA] = _rhouA_avg[_qp];
     100     1776270 :     U_avg[THMVACE1D::RHOEA] = _rhoEA_avg[_qp];
     101     1776270 :     U_avg[THMVACE1D::AREA] = _A_avg[_qp];
     102     1776270 :     for (const auto i : make_range(_n_passives))
     103           0 :       U_avg[THMVACE1D::N_FLUX_INPUTS + i] = (*_passives_times_area_avg[i])[_qp];
     104     1776270 :     auto W = FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U_avg, _fp);
     105             : 
     106             :     // compute and apply slopes to primitive variables
     107     1776270 :     const auto slopes = getElementSlopes(_current_elem);
     108     1776270 :     const auto delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp];
     109     7105080 :     for (const auto m : make_range(W.size()))
     110     5328810 :       W[m] = W[m] + slopes[m] * delta_x;
     111             : 
     112             :     // compute reconstructed conservative variables
     113             :     const auto U =
     114     1776270 :         FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W, _A_linear[_qp], _fp);
     115     1776270 :     _rhoA[_qp] = U[THMVACE1D::RHOA];
     116     1776270 :     _rhouA[_qp] = U[THMVACE1D::RHOUA];
     117     1776270 :     _rhoEA[_qp] = U[THMVACE1D::RHOEA];
     118     1776270 :     for (const auto i : make_range(_n_passives))
     119           0 :       _passives_times_area[_qp][i] = U[THMVACE1D::N_FLUX_INPUTS + i];
     120     1776270 :   }
     121    14861229 : }
     122             : 
     123             : std::vector<ADReal>
     124     5252458 : ADRDG3EqnMaterial::computeElementPrimitiveVariables(const Elem * elem) const
     125             : {
     126             :   const auto U =
     127     5252458 :       FlowModel1PhaseUtils::getElementalSolutionVector<true>(elem, _U_vars, _is_implicit);
     128    10504916 :   return FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U, _fp);
     129     5252458 : }

Generated by: LCOV version 1.14