LCOV - code coverage report
Current view: top level - src/userobjects - RhieChowInterpolatorBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #31653 (1b668c) with base bb0a08 Lines: 61 68 89.7 %
Date: 2025-11-03 17:04:41 Functions: 3 3 100.0 %
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 "RhieChowInterpolatorBase.h"
      11             : #include "INSFVAttributes.h"
      12             : #include "GatherRCDataElementThread.h"
      13             : #include "GatherRCDataFaceThread.h"
      14             : #include "SubProblem.h"
      15             : #include "MooseMesh.h"
      16             : #include "SystemBase.h"
      17             : #include "NS.h"
      18             : #include "Assembly.h"
      19             : #include "INSFVVelocityVariable.h"
      20             : #include "INSFVPressureVariable.h"
      21             : #include "PiecewiseByBlockLambdaFunctor.h"
      22             : #include "VectorCompositeFunctor.h"
      23             : #include "FVElementalKernel.h"
      24             : 
      25             : using namespace libMesh;
      26             : 
      27             : InputParameters
      28       16088 : RhieChowInterpolatorBase::validParams()
      29             : {
      30       16088 :   auto params = RhieChowFaceFluxProvider::validParams();
      31       16088 :   params += TaggingInterface::validParams();
      32       16088 :   params += ADFunctorInterface::validParams();
      33             : 
      34       16088 :   params.addClassDescription(
      35             :       "Computes the Rhie-Chow velocity based on gathered 'a' coefficient data.");
      36             : 
      37             :   // Avoid uninitialized residual objects
      38       16088 :   params.suppressParameter<bool>("force_preic");
      39             : 
      40       16088 :   params.addRequiredParam<VariableName>(NS::pressure, "The pressure variable.");
      41       32176 :   params.addRequiredParam<VariableName>("u", "The x-component of velocity");
      42       32176 :   params.addParam<VariableName>("v", "The y-component of velocity");
      43       32176 :   params.addParam<VariableName>("w", "The z-component of velocity");
      44             : 
      45       32176 :   MooseEnum velocity_interp_method("average rc", "rc");
      46       32176 :   params.addParam<MooseEnum>(
      47             :       "velocity_interp_method",
      48             :       velocity_interp_method,
      49             :       "The interpolation to use for the velocity. Options are "
      50             :       "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
      51             : 
      52       16088 :   return params;
      53       16088 : }
      54             : 
      55        8048 : RhieChowInterpolatorBase::RhieChowInterpolatorBase(const InputParameters & params)
      56             :   : RhieChowFaceFluxProvider(params),
      57             :     TaggingInterface(this),
      58             :     ADFunctorInterface(this),
      59       16096 :     _moose_mesh(UserObject::_subproblem.mesh()),
      60        8048 :     _mesh(_moose_mesh.getMesh()),
      61        8048 :     _dim(blocksMaxDimension()),
      62        8048 :     _p(dynamic_cast<INSFVPressureVariable *>(
      63        8048 :         &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
      64        8048 :     _u(dynamic_cast<INSFVVelocityVariable *>(
      65       16096 :         &UserObject::_subproblem.getVariable(0, getParam<VariableName>("u")))),
      66       23374 :     _v(isParamValid("v") ? dynamic_cast<INSFVVelocityVariable *>(
      67       29882 :                                &UserObject::_subproblem.getVariable(0, getParam<VariableName>("v")))
      68             :                          : nullptr),
      69       16210 :     _w(isParamValid("w") ? dynamic_cast<INSFVVelocityVariable *>(
      70        8390 :                                &UserObject::_subproblem.getVariable(0, getParam<VariableName>("w")))
      71             :                          : nullptr),
      72        8048 :     _ps(libMesh::n_threads(), nullptr),
      73        8048 :     _us(libMesh::n_threads(), nullptr),
      74        8048 :     _vs(libMesh::n_threads(), nullptr),
      75        8048 :     _ws(libMesh::n_threads(), nullptr),
      76       16096 :     _displaced(dynamic_cast<DisplacedProblem *>(&(UserObject::_subproblem)))
      77             : {
      78        8048 :   if (!_p)
      79           0 :     paramError(NS::pressure, "the pressure must be a INSFVPressureVariable.");
      80        8048 :   checkBlocks(*_p);
      81             : 
      82        8046 :   if (!_u)
      83           0 :     paramError("u", "the u velocity must be an INSFVVelocityVariable.");
      84        8046 :   checkBlocks(*_u);
      85        8044 :   _var_numbers.push_back(_u->number());
      86             : 
      87        8044 :   if (_dim >= 2)
      88             :   {
      89        7274 :     if (!_v)
      90           0 :       mooseError("In two or more dimensions, the v velocity must be supplied and it must be an "
      91             :                  "INSFVVelocityVariable.");
      92        7274 :     checkBlocks(*_v);
      93        7274 :     _var_numbers.push_back(_v->number());
      94             :   }
      95             : 
      96        8044 :   if (_dim >= 3)
      97             :   {
      98         114 :     if (!_w)
      99           0 :       mooseError("In three-dimensions, the w velocity must be supplied and it must be an "
     100             :                  "INSFVVelocityVariable.");
     101         114 :     checkBlocks(*_w);
     102         114 :     _var_numbers.push_back(_w->number());
     103             :   }
     104             : 
     105        8044 :   fillContainer(NS::pressure, _ps);
     106        8044 :   fillContainer("u", _us);
     107             : 
     108        8044 :   if (_dim >= 2)
     109             :   {
     110        7274 :     fillContainer("v", _vs);
     111        7274 :     if (_v->faceInterpolationMethod() != _u->faceInterpolationMethod())
     112           0 :       mooseError("x and y velocity component face interpolation methods do not match");
     113             : 
     114        7274 :     if (_dim >= 3)
     115             :     {
     116         114 :       fillContainer("w", _ws);
     117         114 :       if (_w->faceInterpolationMethod() != _u->faceInterpolationMethod())
     118           0 :         mooseError("x and z velocity component face interpolation methods do not match");
     119             :     }
     120             :   }
     121             : 
     122        8044 :   if (&(UserObject::_subproblem) != &(TaggingInterface::_subproblem))
     123           0 :     mooseError("Different subproblems in RhieChowInterpolatorBase!");
     124             : 
     125        8044 :   const auto & velocity_interp_method = params.get<MooseEnum>("velocity_interp_method");
     126        8044 :   if (velocity_interp_method == "average")
     127          21 :     _velocity_interp_method = Moose::FV::InterpMethod::Average;
     128        8023 :   else if (velocity_interp_method == "rc")
     129        8023 :     _velocity_interp_method = Moose::FV::InterpMethod::RhieChow;
     130        8044 : }
     131             : 
     132             : Real
     133       26489 : RhieChowInterpolatorBase::getVolumetricFaceFlux(const Moose::FV::InterpMethod m,
     134             :                                                 const FaceInfo & fi,
     135             :                                                 const Moose::StateArg & time,
     136             :                                                 const THREAD_ID tid,
     137             :                                                 bool subtract_mesh_velocity) const
     138             : {
     139       26489 :   return raw_value(this->getVelocity(m, fi, time, tid, subtract_mesh_velocity)) * fi.normal();
     140             : }

Generated by: LCOV version 1.14