LCOV - code coverage report
Current view: top level - src/functormaterials - PINSFVSpeedFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 47 52 90.4 %
Date: 2026-05-29 20:37:52 Functions: 9 33 27.3 %
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 "PINSFVSpeedFunctorMaterial.h"
      11             : #include "NS.h"
      12             : #include "NavierStokesMethods.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", PINSFVSpeedFunctorMaterial);
      15             : 
      16             : InputParameters
      17        1643 : PINSFVSpeedFunctorMaterial::validParams()
      18             : {
      19        1643 :   InputParameters params = FunctorMaterial::validParams();
      20        1643 :   params.addClassDescription("This is the material class used to compute the interstitial velocity"
      21             :                              " norm for the incompressible and weakly compressible primitive "
      22             :                              "superficial finite-volume implementation of porous media equations.");
      23             : 
      24        1643 :   params.addRequiredParam<MooseFunctorName>(NS::porosity, "porosity");
      25        1643 :   params.addParam<MooseFunctorName>(
      26        1643 :       NS::superficial_velocity_x, 0, "The x component of the fluid superficial velocity variable.");
      27        1643 :   params.addParam<MooseFunctorName>(
      28        1643 :       NS::superficial_velocity_y, 0, "The y component of the fluid superficial velocity variable.");
      29        1643 :   params.addParam<MooseFunctorName>(
      30        1643 :       NS::superficial_velocity_z, 0, "The z component of the fluid superficial velocity variable.");
      31        8215 :   auto add_property = [&params](const auto & property_name)
      32             :   {
      33       16430 :     params.addParam<MooseFunctorName>(property_name,
      34             :                                       property_name,
      35             :                                       "The name to give the declared '" + property_name +
      36             :                                           "' functor property");
      37        8215 :   };
      38        1643 :   add_property(NS::velocity);
      39        1643 :   add_property(NS::speed);
      40        1643 :   add_property(NS::velocity_x);
      41        1643 :   add_property(NS::velocity_y);
      42        1643 :   add_property(NS::velocity_z);
      43        3286 :   params.addParam<bool>("define_interstitial_velocity_components",
      44        3286 :                         true,
      45             :                         "Whether to define the interstitial velocity functors");
      46             : 
      47        1643 :   return params;
      48           0 : }
      49             : 
      50         849 : PINSFVSpeedFunctorMaterial::PINSFVSpeedFunctorMaterial(const InputParameters & parameters)
      51             :   : FunctorMaterial(parameters),
      52         849 :     _eps(getFunctor<ADReal>(NS::porosity)),
      53         849 :     _superficial_vel_x(getFunctor<ADReal>(NS::superficial_velocity_x)),
      54         849 :     _superficial_vel_y(getFunctor<ADReal>(NS::superficial_velocity_y)),
      55         849 :     _superficial_vel_z(getFunctor<ADReal>(NS::superficial_velocity_z))
      56             : {
      57             :   // Check dimension of the mesh
      58             :   const unsigned int num_components_specified =
      59         849 :       parameters.isParamSetByUser(NS::superficial_velocity_x) +
      60         849 :       parameters.isParamSetByUser(NS::superficial_velocity_y) +
      61         849 :       parameters.isParamSetByUser(NS::superficial_velocity_z);
      62         849 :   if (num_components_specified != blocksMaxDimension())
      63           0 :     mooseError("Only ",
      64             :                num_components_specified,
      65             :                " superficial velocity components were provided for a mesh of dimension ",
      66           0 :                blocksMaxDimension());
      67             : 
      68             :   // Interstitial velocity is needed by certain correlations
      69        2547 :   const auto & interstitial_velocity = addFunctorProperty<ADRealVectorValue>(
      70             :       getParam<MooseFunctorName>(NS::velocity),
      71    18935122 :       [this](const auto & r, const auto & t) -> ADRealVectorValue
      72             :       {
      73    75740488 :         return ADRealVectorValue(
      74    18935122 :                    _superficial_vel_x(r, t), _superficial_vel_y(r, t), _superficial_vel_z(r, t)) /
      75    37870244 :                _eps(r, t);
      76             :       });
      77             : 
      78             :   // Speed is normal of regular interstitial velocity
      79             :   // This is needed to compute the Reynolds number
      80        2547 :   addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::speed),
      81    18587922 :                              [&interstitial_velocity](const auto & r, const auto & t) -> ADReal
      82    18587922 :                              { return NS::computeSpeed<ADReal>(interstitial_velocity(r, t)); });
      83             : 
      84             :   // This is not needed for non-porous media, but they can use the 'speed' functor for some friction
      85             :   // models
      86        1698 :   if (getParam<bool>("define_interstitial_velocity_components"))
      87             :   {
      88        2487 :     addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_x),
      89      170000 :                                [&interstitial_velocity](const auto & r, const auto & t) -> ADReal
      90      170000 :                                { return interstitial_velocity(r, t)(0); });
      91        2487 :     addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_y),
      92      170000 :                                [&interstitial_velocity](const auto & r, const auto & t) -> ADReal
      93      170000 :                                { return interstitial_velocity(r, t)(1); });
      94        2487 :     addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_z),
      95           0 :                                [&interstitial_velocity](const auto & r, const auto & t) -> ADReal
      96           0 :                                { return interstitial_velocity(r, t)(2); });
      97             :   }
      98        5034 : }

Generated by: LCOV version 1.14