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

Generated by: LCOV version 1.14