LCOV - code coverage report
Current view: top level - src/functormaterials - DittusBoelterFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 27 32 84.4 %
Date: 2025-08-13 06:50:25 Functions: 3 16 18.8 %
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 "DittusBoelterFunctorMaterial.h"
      11             : #include "NavierStokesMethods.h"
      12             : #include "NS.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", DittusBoelterFunctorMaterial);
      15             : registerMooseObject("NavierStokesApp", ADDittusBoelterFunctorMaterial);
      16             : 
      17             : template <bool is_ad>
      18             : InputParameters
      19          41 : DittusBoelterFunctorMaterialTempl<is_ad>::validParams()
      20             : {
      21          41 :   InputParameters params = FunctorMaterial::validParams();
      22          82 :   params.addRequiredParam<MooseFunctorName>("Hw", "Heat transfer coefficient material property");
      23          82 :   params.addRequiredParam<MooseFunctorName>("D_h", "Hydraulic diameter");
      24          82 :   params.addRequiredParam<MooseFunctorName>("k", "Heat conductivity of the fluid");
      25          41 :   params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "Fluid temperature");
      26          82 :   params.addRequiredParam<MooseFunctorName>("T_wall", "Wall temperature");
      27          41 :   params.addRequiredParam<MooseFunctorName>(NS::Prandtl, "The Prandtl number");
      28          41 :   params.addRequiredParam<MooseFunctorName>(NS::Reynolds, "The Reynolds number");
      29          41 :   params.addClassDescription(
      30             :       "Computes wall heat transfer coefficient using Dittus-Boelter equation");
      31          41 :   return params;
      32           0 : }
      33             : 
      34             : template <bool is_ad>
      35          22 : DittusBoelterFunctorMaterialTempl<is_ad>::DittusBoelterFunctorMaterialTempl(
      36             :     const InputParameters & parameters)
      37             :   : FunctorMaterial(parameters),
      38          22 :     _D_h(getFunctor<GenericReal<is_ad>>("D_h")),
      39          44 :     _k(getFunctor<GenericReal<is_ad>>("k")),
      40          22 :     _T(getFunctor<GenericReal<is_ad>>(NS::T_fluid)),
      41          44 :     _T_wall(getFunctor<GenericReal<is_ad>>("T_wall")),
      42          22 :     _prandtl(getFunctor<GenericReal<is_ad>>(NS::Prandtl)),
      43          22 :     _reynolds(getFunctor<GenericReal<is_ad>>(NS::Reynolds))
      44             : {
      45          66 :   addFunctorProperty<GenericReal<is_ad>>(
      46             :       "Hw",
      47        4950 :       [this](const auto & r, const auto & t) -> GenericReal<is_ad>
      48             :       {
      49           0 :         const Real n =
      50        4950 :             (MetaPhysicL::raw_value(_T(r, t)) < MetaPhysicL::raw_value(_T_wall(r, t))) ? 0.4 : 0.3;
      51        4950 :         const auto Re = _reynolds(r, t);
      52        4950 :         if (const auto raw_Re = MetaPhysicL::raw_value(Re); raw_Re < 1e4 || raw_Re > 1.2e5)
      53           0 :           flagSolutionWarning(
      54             :               "Reynolds number out of the range of validity of the Dittus-Boelter correlation");
      55        4950 :         const auto Pr = _prandtl(r, t);
      56        4950 :         if (const auto raw_Pr = MetaPhysicL::raw_value(Pr); raw_Pr < 0.7 || raw_Pr > 160)
      57           0 :           flagSolutionWarning(
      58             :               "Prandtl number out of the range of validity of the Dittus-Boelter correlation");
      59           0 :         const auto Nu = 0.023 * std::pow(Re, 0.8) * std::pow(Pr, n);
      60        4950 :         return NS::wallHeatTransferCoefficient(Nu, _k(r, t), _D_h(r, t));
      61             :       });
      62          44 : }
      63             : 
      64             : template class DittusBoelterFunctorMaterialTempl<false>;
      65             : template class DittusBoelterFunctorMaterialTempl<true>;

Generated by: LCOV version 1.14