LCOV - code coverage report
Current view: top level - src/functormaterials - LinearFrictionFactorFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 40 43 93.0 %
Date: 2026-05-29 20:37:52 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          19 : LinearFrictionFactorFunctorMaterial::validParams()
      18             : {
      19          19 :   InputParameters params = FunctorMaterial::validParams();
      20          19 :   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          38 :   params.addRequiredParam<MooseFunctorName>("functor_name",
      26             :                                             "The name of functor storing the friction factor");
      27          19 :   params.addRequiredParam<MooseFunctorName>(NS::porosity, "porosity");
      28          19 :   params.addParam<MooseFunctorName>(
      29          19 :       NS::superficial_velocity_x, 0, "The x component of the fluid superficial velocity variable.");
      30          19 :   params.addParam<MooseFunctorName>(
      31          19 :       NS::superficial_velocity_y, 0, "The y component of the fluid superficial velocity variable.");
      32          19 :   params.addParam<MooseFunctorName>(
      33          19 :       NS::superficial_velocity_z, 0, "The z component of the fluid superficial velocity variable.");
      34          19 :   params.addParam<RealVectorValue>(
      35          19 :       "A", RealVectorValue(1, 1, 1), "Coefficient of the A * f(t) term");
      36          19 :   params.addParam<RealVectorValue>(
      37          19 :       "B", RealVectorValue(), "Coefficient of the B * g(t) * |v_I| term");
      38          38 :   params.addParam<MooseFunctorName>("f", "Functor f in the A * f(t) term");
      39          38 :   params.addParam<MooseFunctorName>("g", "Functor g in the B * g(t) * |v_I| term");
      40          19 :   return params;
      41           0 : }
      42             : 
      43          10 : LinearFrictionFactorFunctorMaterial::LinearFrictionFactorFunctorMaterial(
      44          10 :     const InputParameters & parameters)
      45             :   : FunctorMaterial(parameters),
      46          20 :     _functor_name(getParam<MooseFunctorName>("functor_name")),
      47          20 :     _A(getParam<RealVectorValue>("A")),
      48          20 :     _B(getParam<RealVectorValue>("B")),
      49          20 :     _f(getFunctor<ADReal>("f")),
      50          20 :     _g(getFunctor<ADReal>("g")),
      51          10 :     _eps(getFunctor<ADReal>(NS::porosity)),
      52          10 :     _superficial_vel_x(getFunctor<ADReal>(NS::superficial_velocity_x)),
      53          10 :     _superficial_vel_y(getFunctor<ADReal>(NS::superficial_velocity_y)),
      54          10 :     _superficial_vel_z(getFunctor<ADReal>(NS::superficial_velocity_z))
      55             : {
      56             :   // Check dimension of the mesh
      57             :   const unsigned int num_components_specified =
      58          10 :       parameters.isParamSetByUser(NS::superficial_velocity_x) +
      59          10 :       parameters.isParamSetByUser(NS::superficial_velocity_y) +
      60          10 :       parameters.isParamSetByUser(NS::superficial_velocity_z);
      61          10 :   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          30 :   addFunctorProperty<ADRealVectorValue>(
      68             :       _functor_name,
      69        3360 :       [this](const auto & r, const auto & t) -> ADRealVectorValue
      70             :       {
      71             :         // Compute speed
      72             :         // see PINSFVSpeedFunctorMaterial.C for explanation
      73       13440 :         const ADRealVectorValue superficial_vel(
      74        3360 :             _superficial_vel_x(r, t), _superficial_vel_y(r, t), _superficial_vel_z(r, t));
      75        3360 :         const auto speed = NS::computeSpeed<ADReal>(superficial_vel) / _eps(r, t);
      76             : 
      77        3360 :         return _A * _f(r, t) + _B * _g(r, t) * speed;
      78             :       });
      79          20 : }

Generated by: LCOV version 1.14