LCOV - code coverage report
Current view: top level - include/functormaterials - FunctorPebbleBedDragCoefficients.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 18 19 94.7 %
Date: 2025-08-14 10:14:56 Functions: 5 20 25.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             : #pragma once
      11             : 
      12             : #include "FunctorIsotropicDragCoefficients.h"
      13             : #include "NS.h"
      14             : 
      15             : /**
      16             :  * Abstract base class to compute isotropic drag coefficients in a
      17             :  * pebble bed. These correlations generally share common proportionalities to
      18             :  * porosity, hydraulic diameter, etc. that are placed into this
      19             :  * base class. The Darcy coefficient in this case scales a term with
      20             :  * proportionality \f$\frac{1}{D_h^2}\f$,
      21             :  * while the Forchheimer coefficient scales a term with proportionality
      22             :  * \f$\frac{1}{D_h}\f$.
      23             :  */
      24             : template <typename Derived>
      25             : class FunctorPebbleBedDragCoefficients : public FunctorIsotropicDragCoefficients<Derived>
      26             : {
      27             :   friend class FunctorIsotropicDragCoefficients<Derived>;
      28             : 
      29             : public:
      30             :   FunctorPebbleBedDragCoefficients(const InputParameters & parameters);
      31             : 
      32             :   static InputParameters validParams();
      33             : 
      34             : protected:
      35             :   template <typename Space, typename Time>
      36             :   ADReal computeDarcyPrefactor(const Space & r, const Time & t);
      37             : 
      38             :   template <typename Space, typename Time>
      39             :   ADReal computeForchheimerPrefactor(const Space & r, const Time & t);
      40             : 
      41             :   /// Compute hydraulic diameter in the bed
      42             :   template <typename Space, typename Time>
      43             :   ADReal computeHydraulicDiameter(const Space & r, const Time & t);
      44             : 
      45             :   /// porosity
      46             :   const Moose::Functor<ADReal> & _eps;
      47             : 
      48             :   /// fluid density
      49             :   const Moose::Functor<ADReal> & _rho;
      50             : 
      51             :   /// pebble diameter
      52             :   const Real & _d_pebble;
      53             : };
      54             : 
      55             : template <typename Derived>
      56             : InputParameters
      57          41 : FunctorPebbleBedDragCoefficients<Derived>::validParams()
      58             : {
      59          41 :   InputParameters params = FunctorIsotropicDragCoefficients<Derived>::validParams();
      60          82 :   params.addRequiredRangeCheckedParam<Real>(
      61             :       NS::pebble_diameter, NS::pebble_diameter + " > 0.0", "Pebble diameter");
      62          41 :   params.addRequiredParam<MooseFunctorName>(NS::porosity, "Porosity");
      63             : 
      64          41 :   params.addParam<MooseFunctorName>(NS::density, NS::density, "Density");
      65          41 :   return params;
      66           0 : }
      67             : 
      68             : template <typename Derived>
      69          22 : FunctorPebbleBedDragCoefficients<Derived>::FunctorPebbleBedDragCoefficients(
      70             :     const InputParameters & parameters)
      71             :   : FunctorIsotropicDragCoefficients<Derived>(parameters),
      72          22 :     _eps(this->template getFunctor<ADReal>(NS::porosity)),
      73          22 :     _rho(this->template getFunctor<ADReal>(NS::density)),
      74          22 :     _d_pebble(this->template getParam<Real>(NS::pebble_diameter))
      75             : {
      76          22 : }
      77             : 
      78             : template <typename Derived>
      79             : template <typename Space, typename Time>
      80             : ADReal
      81      644000 : FunctorPebbleBedDragCoefficients<Derived>::computeDarcyPrefactor(const Space & r, const Time & t)
      82             : {
      83      644000 :   const auto Dh = computeHydraulicDiameter(r, t);
      84      644000 :   return 1 / (Dh * Dh);
      85             : }
      86             : 
      87             : template <typename Derived>
      88             : template <typename Space, typename Time>
      89             : ADReal
      90      644000 : FunctorPebbleBedDragCoefficients<Derived>::computeForchheimerPrefactor(const Space & r,
      91             :                                                                        const Time & t)
      92             : {
      93             :   // Why the factor of 2? Because we multiply by a factor of 1/2 in the friction kernel to be
      94             :   // consistent with the formulation of Forchheimer in
      95             :   // https://holzmann-cfd.com/community/blog-and-tools/darcy-forchheimer and
      96             :   // https://www.simscale.com/knowledge-base/predict-darcy-and-forchheimer-coefficients-for-perforated-plates-using-analytical-approach/
      97      644000 :   return 2 / computeHydraulicDiameter(r, t);
      98             : }
      99             : 
     100             : template <typename Derived>
     101             : template <typename Space, typename Time>
     102             : ADReal
     103     1288000 : FunctorPebbleBedDragCoefficients<Derived>::computeHydraulicDiameter(const Space & r, const Time & t)
     104             : {
     105             :   mooseAssert(1.0 - _eps(r, t).value() > 1e-8,
     106             :               "Bed hydraulic diameter is ill-defined at porosity of 1.");
     107     2576000 :   return _eps(r, t) * _d_pebble / (1.0 - _eps(r, t));
     108             : }

Generated by: LCOV version 1.14