LCOV - code coverage report
Current view: top level - src/functormaterials - LinearFrictionFactorFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 40 43 93.0 %
Date: 2025-08-13 06:50:25 Functions: 3 8 37.5 %
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 "LinearFrictionFactorFunctorMaterial.h"
      11             : #include "NS.h"
      12             : #include "NavierStokesMethods.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", LinearFrictionFactorFunctorMaterial);
      15             : 
      16             : InputParameters
      17          41 : LinearFrictionFactorFunctorMaterial::validParams()
      18             : {
      19          41 :   InputParameters params = FunctorMaterial::validParams();
      20          41 :   params.addClassDescription(
      21             :       "Material class used to compute a friction factor of the form A * "
      22             :       "f(r, t) + B * g(r, t) * |v_I| with A, B vector constants, f(r, t) and g(r, t) "
      23             :       "functors of space and time, and |v_I| the interstitial speed");
      24             : 
      25          82 :   params.addRequiredParam<MooseFunctorName>("functor_name",
      26             :                                             "The name of functor storing the friction factor");
      27          41 :   params.addRequiredParam<MooseFunctorName>(NS::porosity, "porosity");
      28          41 :   params.addParam<MooseFunctorName>(
      29          41 :       NS::superficial_velocity_x, 0, "The x component of the fluid superficial velocity variable.");
      30          41 :   params.addParam<MooseFunctorName>(
      31          41 :       NS::superficial_velocity_y, 0, "The y component of the fluid superficial velocity variable.");
      32          41 :   params.addParam<MooseFunctorName>(
      33          41 :       NS::superficial_velocity_z, 0, "The z component of the fluid superficial velocity variable.");
      34          41 :   params.addParam<RealVectorValue>(
      35          41 :       "A", RealVectorValue(1, 1, 1), "Coefficient of the A * f(t) term");
      36          41 :   params.addParam<RealVectorValue>(
      37          41 :       "B", RealVectorValue(), "Coefficient of the B * g(t) * |v_I| term");
      38          82 :   params.addParam<MooseFunctorName>("f", "Functor f in the A * f(t) term");
      39          82 :   params.addParam<MooseFunctorName>("g", "Functor g in the B * g(t) * |v_I| term");
      40          41 :   return params;
      41           0 : }
      42             : 
      43          22 : LinearFrictionFactorFunctorMaterial::LinearFrictionFactorFunctorMaterial(
      44          22 :     const InputParameters & parameters)
      45             :   : FunctorMaterial(parameters),
      46          44 :     _functor_name(getParam<MooseFunctorName>("functor_name")),
      47          44 :     _A(getParam<RealVectorValue>("A")),
      48          44 :     _B(getParam<RealVectorValue>("B")),
      49          44 :     _f(getFunctor<ADReal>("f")),
      50          44 :     _g(getFunctor<ADReal>("g")),
      51          22 :     _eps(getFunctor<ADReal>(NS::porosity)),
      52          22 :     _superficial_vel_x(getFunctor<ADReal>(NS::superficial_velocity_x)),
      53          22 :     _superficial_vel_y(getFunctor<ADReal>(NS::superficial_velocity_y)),
      54          22 :     _superficial_vel_z(getFunctor<ADReal>(NS::superficial_velocity_z))
      55             : {
      56             :   // Check dimension of the mesh
      57             :   const unsigned int num_components_specified =
      58          22 :       parameters.isParamSetByUser(NS::superficial_velocity_x) +
      59          22 :       parameters.isParamSetByUser(NS::superficial_velocity_y) +
      60          22 :       parameters.isParamSetByUser(NS::superficial_velocity_z);
      61          22 :   if (num_components_specified != blocksMaxDimension())
      62           0 :     mooseError("Only ",
      63             :                num_components_specified,
      64             :                " superficial velocity components were provided for a mesh of dimension ",
      65           0 :                blocksMaxDimension());
      66             : 
      67          66 :   addFunctorProperty<ADRealVectorValue>(
      68             :       _functor_name,
      69        5040 :       [this](const auto & r, const auto & t) -> ADRealVectorValue
      70             :       {
      71             :         // Compute speed
      72             :         // see PINSFVSpeedFunctorMaterial.C for explanation
      73       20160 :         const ADRealVectorValue superficial_vel(
      74        5040 :             _superficial_vel_x(r, t), _superficial_vel_y(r, t), _superficial_vel_z(r, t));
      75        5040 :         const auto speed = NS::computeSpeed<ADReal>(superficial_vel) / _eps(r, t);
      76             : 
      77        5040 :         return _A * _f(r, t) + _B * _g(r, t) * speed;
      78             :       });
      79          44 : }

Generated by: LCOV version 1.14