LCOV - code coverage report
Current view: top level - src/materials - ReynoldsNumberMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 45 46 97.8 %
Date: 2026-05-29 20:41:18 Functions: 3 3 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 "ReynoldsNumberMaterial.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "Numerics.h"
      13             : #include "MathUtils.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", ReynoldsNumberMaterial);
      16             : 
      17             : InputParameters
      18          47 : ReynoldsNumberMaterial::validParams()
      19             : {
      20          47 :   InputParameters params = Material::validParams();
      21             : 
      22          94 :   params.addCoupledVar("beta", "Remapped volume fraction of liquid");
      23          94 :   params.addRequiredCoupledVar("arhoA", "alpha*rho*A");
      24          94 :   params.addRequiredCoupledVar("arhouA", "alpha*rho*vel*A");
      25          94 :   params.addRequiredCoupledVar("arhoEA", "alpha*rho*E*A");
      26             : 
      27          94 :   params.addRequiredParam<MaterialPropertyName>("Re", "Reynolds number property name");
      28          94 :   params.addRequiredParam<MaterialPropertyName>("rho", "Density of the phase");
      29          94 :   params.addRequiredParam<MaterialPropertyName>("vel", "Velocity of the phase");
      30          94 :   params.addRequiredParam<MaterialPropertyName>("D_h", "Hydraulic diameter");
      31          94 :   params.addRequiredParam<MaterialPropertyName>("mu", "Dynamic viscosity of the phase");
      32             : 
      33          47 :   params.addClassDescription("Computes Reynolds number as a material property");
      34             : 
      35          47 :   return params;
      36           0 : }
      37             : 
      38          36 : ReynoldsNumberMaterial::ReynoldsNumberMaterial(const InputParameters & parameters)
      39             :   : DerivativeMaterialInterfaceTHM<Material>(parameters),
      40             : 
      41          36 :     _Re_name(getParam<MaterialPropertyName>("Re")),
      42             : 
      43          72 :     _rho(getMaterialProperty<Real>("rho")),
      44          48 :     _drho_dbeta(isCoupled("beta") ? &getMaterialPropertyDerivativeTHM<Real>("rho", "beta")
      45             :                                   : nullptr),
      46          36 :     _drho_darhoA(getMaterialPropertyDerivativeTHM<Real>("rho", "arhoA")),
      47             : 
      48          72 :     _vel(getMaterialProperty<Real>("vel")),
      49          36 :     _dvel_darhoA(getMaterialPropertyDerivativeTHM<Real>("vel", "arhoA")),
      50          36 :     _dvel_darhouA(getMaterialPropertyDerivativeTHM<Real>("vel", "arhouA")),
      51             : 
      52          72 :     _D_h(getMaterialProperty<Real>("D_h")),
      53             : 
      54          72 :     _mu(getMaterialProperty<Real>("mu")),
      55          60 :     _dmu_dbeta(isCoupled("beta") ? &getMaterialPropertyDerivative<Real>("mu", "beta") : nullptr),
      56          36 :     _dmu_darhoA(getMaterialPropertyDerivative<Real>("mu", "arhoA")),
      57          36 :     _dmu_darhouA(getMaterialPropertyDerivative<Real>("mu", "arhouA")),
      58          36 :     _dmu_darhoEA(getMaterialPropertyDerivative<Real>("mu", "arhoEA")),
      59             : 
      60          36 :     _Re(declareProperty<Real>(_Re_name)),
      61          42 :     _dRe_dbeta(isCoupled("beta") ? &declarePropertyDerivativeTHM<Real>(_Re_name, "beta") : nullptr),
      62          36 :     _dRe_darhoA(declarePropertyDerivativeTHM<Real>(_Re_name, "arhoA")),
      63          36 :     _dRe_darhouA(declarePropertyDerivativeTHM<Real>(_Re_name, "arhouA")),
      64          72 :     _dRe_darhoEA(declarePropertyDerivativeTHM<Real>(_Re_name, "arhoEA"))
      65             : {
      66          36 : }
      67             : 
      68             : void
      69          64 : ReynoldsNumberMaterial::computeQpProperties()
      70             : {
      71          64 :   _Re[_qp] = THM::Reynolds(1., _rho[_qp], _vel[_qp], _D_h[_qp], _mu[_qp]);
      72             : 
      73          64 :   const Real dRe_drho = std::fabs(_vel[_qp]) * _D_h[_qp] / _mu[_qp];
      74          64 :   const Real dRe_dvel = MathUtils::sign(_vel[_qp]) * _rho[_qp] * _D_h[_qp] / _mu[_qp];
      75          64 :   const Real dRe_dmu = -_rho[_qp] * std::fabs(_vel[_qp]) * _D_h[_qp] / std::pow(_mu[_qp], 2);
      76             : 
      77         128 :   if (isCoupled("beta"))
      78          52 :     (*_dRe_dbeta)[_qp] = dRe_drho * (*_drho_dbeta)[_qp] + dRe_dmu * (*_dmu_dbeta)[_qp];
      79          64 :   _dRe_darhoA[_qp] =
      80          64 :       dRe_drho * _drho_darhoA[_qp] + dRe_dvel * _dvel_darhoA[_qp] + dRe_dmu * _dmu_darhoA[_qp];
      81          64 :   _dRe_darhouA[_qp] = dRe_dvel * _dvel_darhouA[_qp] + dRe_dmu * _dmu_darhouA[_qp];
      82          64 :   _dRe_darhoEA[_qp] = dRe_dmu * _dmu_darhoEA[_qp];
      83          64 : }

Generated by: LCOV version 1.14