LCOV - code coverage report
Current view: top level - src/functormaterials - NSFVDispersePhaseDragFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 43 48 89.6 %
Date: 2025-08-13 06:50:25 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         427 : NSFVDispersePhaseDragFunctorMaterial::validParams()
      18             : {
      19         427 :   InputParameters params = FunctorMaterial::validParams();
      20         427 :   params.addClassDescription("Computes drag coefficient for dispersed phase.");
      21         854 :   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         854 :   params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
      26         854 :   params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
      27         854 :   params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
      28         427 :   params.addRequiredParam<MooseFunctorName>(NS::density, "Continuous phase density.");
      29         427 :   params.addRequiredParam<MooseFunctorName>(NS::mu, "Mixture Density");
      30         854 :   params.addParam<MooseFunctorName>(
      31         854 :       "particle_diameter", 1.0, "Diameter of particles in the dispersed phase.");
      32         427 :   return params;
      33           0 : }
      34             : 
      35         227 : NSFVDispersePhaseDragFunctorMaterial::NSFVDispersePhaseDragFunctorMaterial(
      36         227 :     const InputParameters & parameters)
      37             :   : FunctorMaterial(parameters),
      38         227 :     _dim(_subproblem.mesh().dimension()),
      39         454 :     _u_var(getFunctor<ADReal>("u")),
      40         681 :     _v_var(parameters.isParamValid("v") ? &(getFunctor<ADReal>("v")) : nullptr),
      41         227 :     _w_var(parameters.isParamValid("w") ? &(getFunctor<ADReal>("w")) : nullptr),
      42         227 :     _rho_mixture(getFunctor<ADReal>(NS::density)),
      43         227 :     _mu_mixture(getFunctor<ADReal>(NS::mu)),
      44         681 :     _particle_diameter(getFunctor<ADReal>("particle_diameter"))
      45             : {
      46         227 :   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         227 :   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    13635705 :   const auto f = [this](const auto & r, const auto & t) -> ADReal
      57             :   {
      58    27271410 :     ADRealVectorValue velocity(_u_var(r, t));
      59    13635705 :     if (_dim > 1)
      60    13635705 :       velocity(1) = (*_v_var)(r, t);
      61    13635705 :     if (_dim > 2)
      62           0 :       velocity(2) = (*_w_var)(r, t);
      63    13635705 :     const auto speed = NS::computeSpeed<ADReal>(velocity);
      64             : 
      65    13635705 :     const auto Re_particle =
      66    13635705 :         _particle_diameter(r, t) * speed * _rho_mixture(r, t) / _mu_mixture(r, t);
      67             : 
      68    13635705 :     if (Re_particle <= 1000)
      69             :     {
      70    13635705 :       if (MetaPhysicL::raw_value(Re_particle) < 0)
      71          45 :         mooseException("Cannot take a non-integer power of a negative number");
      72    40906980 :       return 1.0 + 0.15 * std::pow(Re_particle, 0.687);
      73             :     }
      74             :     else
      75           0 :       return 0.0183 * Re_particle;
      76         227 :   };
      77         908 :   const auto & f_func = addFunctorProperty<ADReal>(getParam<MooseFunctorName>("drag_coef_name"), f);
      78             : 
      79             :   // Define the vector friction coefficient
      80      291185 :   const auto f_vec = [&f_func](const auto & r, const auto & t) -> ADRealVectorValue
      81             :   {
      82      291185 :     const auto f_value = f_func(r, t);
      83      291185 :     return ADRealVectorValue(f_value, f_value, f_value);
      84         227 :   };
      85         908 :   addFunctorProperty<ADRealVectorValue>(getParam<MooseFunctorName>("drag_coef_name") + "_vec",
      86             :                                         f_vec);
      87         681 : }

Generated by: LCOV version 1.14