LCOV - code coverage report
Current view: top level - src/functormaterials - NSFVDispersePhaseDragFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 43 48 89.6 %
Date: 2026-05-29 20:37:52 Functions: 5 14 35.7 %
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 "NSFVDispersePhaseDragFunctorMaterial.h"
      11             : #include "NS.h"
      12             : #include "NavierStokesMethods.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", NSFVDispersePhaseDragFunctorMaterial);
      15             : 
      16             : InputParameters
      17         209 : NSFVDispersePhaseDragFunctorMaterial::validParams()
      18             : {
      19         209 :   InputParameters params = FunctorMaterial::validParams();
      20         209 :   params.addClassDescription("Computes drag coefficient for dispersed phase.");
      21         418 :   params.addParam<MooseFunctorName>("drag_coef_name",
      22             :                                     "Darcy_coefficient",
      23             :                                     "Name of the scalar friction coefficient defined. The vector "
      24             :                                     "coefficient is suffixed with _vec");
      25         418 :   params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
      26         418 :   params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
      27         418 :   params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
      28         209 :   params.addRequiredParam<MooseFunctorName>(NS::density, "Continuous phase density.");
      29         209 :   params.addRequiredParam<MooseFunctorName>(NS::mu, "Mixture Density");
      30         418 :   params.addParam<MooseFunctorName>(
      31         418 :       "particle_diameter", 1.0, "Diameter of particles in the dispersed phase.");
      32         209 :   return params;
      33           0 : }
      34             : 
      35         109 : NSFVDispersePhaseDragFunctorMaterial::NSFVDispersePhaseDragFunctorMaterial(
      36         109 :     const InputParameters & parameters)
      37             :   : FunctorMaterial(parameters),
      38         109 :     _dim(_subproblem.mesh().dimension()),
      39         218 :     _u_var(getFunctor<ADReal>("u")),
      40         327 :     _v_var(parameters.isParamValid("v") ? &(getFunctor<ADReal>("v")) : nullptr),
      41         109 :     _w_var(parameters.isParamValid("w") ? &(getFunctor<ADReal>("w")) : nullptr),
      42         109 :     _rho_mixture(getFunctor<ADReal>(NS::density)),
      43         109 :     _mu_mixture(getFunctor<ADReal>(NS::mu)),
      44         327 :     _particle_diameter(getFunctor<ADReal>("particle_diameter"))
      45             : {
      46         109 :   if (_dim >= 2 && !_v_var)
      47           0 :     paramError("v",
      48             :                "In two or more dimensions, the v velocity must be supplied and it must be an "
      49             :                "INSFVVelocityVariable.");
      50             : 
      51         109 :   if (_dim >= 3 && !_w_var)
      52           0 :     paramError("w",
      53             :                "In three-dimensions, the w velocity must be supplied and it must be an "
      54             :                "INSFVVelocityVariable.");
      55             : 
      56     8895177 :   const auto f = [this](const auto & r, const auto & t) -> ADReal
      57             :   {
      58             :     using std::pow;
      59             : 
      60    17790354 :     ADRealVectorValue velocity(_u_var(r, t));
      61     8895177 :     if (_dim > 1)
      62     8895177 :       velocity(1) = (*_v_var)(r, t);
      63     8895177 :     if (_dim > 2)
      64           0 :       velocity(2) = (*_w_var)(r, t);
      65     8895177 :     const auto speed = NS::computeSpeed<ADReal>(velocity);
      66             : 
      67     8895177 :     const auto Re_particle =
      68     8895177 :         _particle_diameter(r, t) * speed * _rho_mixture(r, t) / _mu_mixture(r, t);
      69             : 
      70     8895177 :     if (Re_particle <= 1000)
      71             :     {
      72     8895177 :       if (MetaPhysicL::raw_value(Re_particle) < 0)
      73          29 :         mooseException("Cannot take a non-integer power of a negative number");
      74    26685444 :       return 1.0 + 0.15 * pow(Re_particle, 0.687);
      75             :     }
      76             :     else
      77           0 :       return 0.0183 * Re_particle;
      78         109 :   };
      79         436 :   const auto & f_func = addFunctorProperty<ADReal>(getParam<MooseFunctorName>("drag_coef_name"), f);
      80             : 
      81             :   // Define the vector friction coefficient
      82      177260 :   const auto f_vec = [&f_func](const auto & r, const auto & t) -> ADRealVectorValue
      83             :   {
      84      177260 :     const auto f_value = f_func(r, t);
      85      177260 :     return ADRealVectorValue(f_value, f_value, f_value);
      86         109 :   };
      87         436 :   addFunctorProperty<ADRealVectorValue>(getParam<MooseFunctorName>("drag_coef_name") + "_vec",
      88             :                                         f_vec);
      89         327 : }

Generated by: LCOV version 1.14