LCOV - code coverage report
Current view: top level - src/utils - NSFVUtils.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #33380 (547b29) with base 8581c3 Lines: 33 50 66.0 %
Date: 2026-07-20 19:39:27 Functions: 7 9 77.8 %
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 "NSFVUtils.h"
      11             : #include "FEProblemBase.h"
      12             : #include "Factory.h"
      13             : #include "MooseObject.h"
      14             : #include "InputParameters.h"
      15             : #include "MooseEnum.h"
      16             : #include "MooseError.h"
      17             : #include "MooseTypes.h"
      18             : #include "MooseUtils.h"
      19             : 
      20             : namespace Moose
      21             : {
      22             : namespace FV
      23             : {
      24             : bool
      25       17426 : setInterpolationMethods(const MooseObject & obj,
      26             :                         Moose::FV::InterpMethod & advected_interp_method,
      27             :                         Moose::FV::InterpMethod & velocity_interp_method)
      28             : {
      29             :   const bool need_more_ghosting =
      30       17426 :       setInterpolationMethod(obj, advected_interp_method, "advected_interp_method");
      31             : 
      32       17426 :   const auto & velocity_interp_method_in = obj.getParam<MooseEnum>("velocity_interp_method");
      33       17426 :   if (velocity_interp_method_in == "average")
      34         296 :     velocity_interp_method = InterpMethod::Average;
      35       17130 :   else if (velocity_interp_method_in == "rc")
      36       17130 :     velocity_interp_method = InterpMethod::RhieChow;
      37             :   else
      38           0 :     obj.mooseError("Unrecognized interpolation type ", std::string(velocity_interp_method_in));
      39             : 
      40       17426 :   return need_more_ghosting;
      41             : }
      42             : 
      43             : InputParameters
      44       34923 : interpolationParameters()
      45             : {
      46       34923 :   auto params = advectedInterpolationParameter();
      47       69846 :   MooseEnum velocity_interp_method("average rc", "rc");
      48       69846 :   params.addParam<MooseEnum>(
      49             :       "velocity_interp_method",
      50             :       velocity_interp_method,
      51             :       "The interpolation to use for the velocity. Options are "
      52             :       "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
      53       34923 :   return params;
      54       34923 : }
      55             : }
      56             : }
      57             : 
      58             : namespace NS
      59             : {
      60             : MooseEnum
      61         864 : fvAdvectedInterpolationMethods()
      62             : {
      63        1728 :   return MooseEnum("average upwind vanLeer min_mod venkatakrishnan", "upwind");
      64             : }
      65             : 
      66             : std::string
      67         183 : fvAdvectedInterpolationMethodType(const MooseEnum & interpolation_method)
      68             : {
      69             :   const std::string method_name = interpolation_method;
      70         183 :   if (interpolation_method == "average")
      71          54 :     return "FVGeometricAverage";
      72         129 :   if (interpolation_method == "upwind")
      73         117 :     return "FVAdvectedUpwind";
      74          12 :   if (interpolation_method == "vanLeer")
      75           0 :     return "FVAdvectedVanLeerWeightBased";
      76          12 :   if (interpolation_method == "min_mod")
      77          12 :     return "FVAdvectedMinmodWeightBased";
      78           0 :   if (interpolation_method == "venkatakrishnan")
      79           0 :     return "FVAdvectedVenkatakrishnanDeferredCorrection";
      80             : 
      81           0 :   mooseError("Unsupported linear FV advected interpolation method '", method_name, "'.");
      82             : }
      83             : 
      84             : MooseEnum
      85         169 : fvFaceInterpolationMethods()
      86             : {
      87         338 :   return MooseEnum("average harmonic");
      88             : }
      89             : 
      90             : std::string
      91           0 : fvFaceInterpolationMethodType(const MooseEnum & interpolation_method)
      92             : {
      93             :   const std::string method_name = interpolation_method;
      94           0 :   if (interpolation_method == "average")
      95           0 :     return "FVGeometricAverage";
      96           0 :   if (interpolation_method == "harmonic")
      97           0 :     return "FVHarmonicAverage";
      98             : 
      99           0 :   mooseError("Unsupported linear FV face interpolation method '", method_name, "'.");
     100             : }
     101             : 
     102             : void
     103           0 : addFVFaceInterpolationMethod(FEProblemBase & problem,
     104             :                              Factory & factory,
     105             :                              const MooseEnum & interpolation_method)
     106             : {
     107             :   const std::string method_name = interpolation_method;
     108           0 :   if (problem.hasFVInterpolationMethod(method_name))
     109             :     return;
     110             : 
     111           0 :   const auto method_type = fvFaceInterpolationMethodType(interpolation_method);
     112             : 
     113           0 :   InputParameters params = factory.getValidParams(method_type);
     114           0 :   problem.addFVInterpolationMethod(method_type, method_name, params);
     115           0 : }
     116             : 
     117             : template <class T>
     118             : std::tuple<bool, T, T>
     119   234119109 : isPorosityJumpFace(const Moose::FunctorBase<T> & porosity,
     120             :                    const FaceInfo & fi,
     121             :                    const Moose::StateArg & time)
     122             : {
     123   234119109 :   if (!fi.neighborPtr() || (fi.elem().subdomain_id() == fi.neighbor().subdomain_id()))
     124             :     // We've agreed to only support porosity jump treatment at subdomain boundaries
     125   233623788 :     return {false, 0, 0};
     126             : 
     127             :   mooseAssert(porosity.hasBlocks(fi.elem().subdomain_id()) &&
     128             :                   porosity.hasBlocks(fi.neighbor().subdomain_id()),
     129             :               "Porosity should have blocks on both elem and neighbor");
     130             : 
     131      494817 :   const Moose::FaceArg face_elem{
     132             :       &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.elemPtr(), nullptr};
     133      494817 :   const Moose::FaceArg face_neighbor{
     134             :       &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.neighborPtr(), nullptr};
     135      494817 :   const auto eps_elem = porosity(face_elem, time), eps_neighbor = porosity(face_neighbor, time);
     136      494817 :   return {!MooseUtils::relativeFuzzyEqual(eps_elem, eps_neighbor), eps_elem, eps_neighbor};
     137             : }
     138             : 
     139             : template std::tuple<bool, Real, Real> isPorosityJumpFace<Real>(
     140             :     const Moose::FunctorBase<Real> & porosity, const FaceInfo & fi, const Moose::StateArg & time);
     141             : template std::tuple<bool, ADReal, ADReal> isPorosityJumpFace<ADReal>(
     142             :     const Moose::FunctorBase<ADReal> & porosity, const FaceInfo & fi, const Moose::StateArg & time);
     143             : }

Generated by: LCOV version 1.14