LCOV - code coverage report
Current view: top level - src/userobjects - RhieChowInterpolatorBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 62 69 89.9 %
Date: 2025-08-14 10:14:56 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             : #include "libmesh/mesh_base.h"
      26             : #include "libmesh/elem_range.h"
      27             : #include "libmesh/parallel_algebra.h"
      28             : #include "libmesh/remote_elem.h"
      29             : #include "metaphysicl/dualsemidynamicsparsenumberarray.h"
      30             : #include "metaphysicl/parallel_dualnumber.h"
      31             : #include "metaphysicl/parallel_dynamic_std_array_wrapper.h"
      32             : #include "metaphysicl/parallel_semidynamicsparsenumberarray.h"
      33             : #include "timpi/parallel_sync.h"
      34             : 
      35             : using namespace libMesh;
      36             : 
      37             : InputParameters
      38       15936 : RhieChowInterpolatorBase::validParams()
      39             : {
      40       15936 :   auto params = RhieChowFaceFluxProvider::validParams();
      41       15936 :   params += TaggingInterface::validParams();
      42       15936 :   params += ADFunctorInterface::validParams();
      43             : 
      44       15936 :   params.addClassDescription(
      45             :       "Computes the Rhie-Chow velocity based on gathered 'a' coefficient data.");
      46             : 
      47             :   // Avoid uninitialized residual objects
      48       15936 :   params.suppressParameter<bool>("force_preic");
      49             : 
      50       15936 :   params.addRequiredParam<VariableName>(NS::pressure, "The pressure variable.");
      51       31872 :   params.addRequiredParam<VariableName>("u", "The x-component of velocity");
      52       31872 :   params.addParam<VariableName>("v", "The y-component of velocity");
      53       31872 :   params.addParam<VariableName>("w", "The z-component of velocity");
      54             : 
      55       31872 :   MooseEnum velocity_interp_method("average rc", "rc");
      56       31872 :   params.addParam<MooseEnum>(
      57             :       "velocity_interp_method",
      58             :       velocity_interp_method,
      59             :       "The interpolation to use for the velocity. Options are "
      60             :       "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
      61             : 
      62       15936 :   return params;
      63       15936 : }
      64             : 
      65        7972 : RhieChowInterpolatorBase::RhieChowInterpolatorBase(const InputParameters & params)
      66             :   : RhieChowFaceFluxProvider(params),
      67             :     TaggingInterface(this),
      68             :     ADFunctorInterface(this),
      69       15944 :     _moose_mesh(UserObject::_subproblem.mesh()),
      70        7972 :     _mesh(_moose_mesh.getMesh()),
      71        7972 :     _dim(blocksMaxDimension()),
      72        7972 :     _p(dynamic_cast<INSFVPressureVariable *>(
      73        7972 :         &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
      74        7972 :     _u(dynamic_cast<INSFVVelocityVariable *>(
      75       15944 :         &UserObject::_subproblem.getVariable(0, getParam<VariableName>("u")))),
      76       23165 :     _v(isParamValid("v") ? dynamic_cast<INSFVVelocityVariable *>(
      77       29635 :                                &UserObject::_subproblem.getVariable(0, getParam<VariableName>("v")))
      78             :                          : nullptr),
      79       16058 :     _w(isParamValid("w") ? dynamic_cast<INSFVVelocityVariable *>(
      80        8314 :                                &UserObject::_subproblem.getVariable(0, getParam<VariableName>("w")))
      81             :                          : nullptr),
      82        7972 :     _ps(libMesh::n_threads(), nullptr),
      83        7972 :     _us(libMesh::n_threads(), nullptr),
      84        7972 :     _vs(libMesh::n_threads(), nullptr),
      85        7972 :     _ws(libMesh::n_threads(), nullptr),
      86       15944 :     _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
      87       15944 :     _displaced(dynamic_cast<DisplacedProblem *>(&(UserObject::_subproblem)))
      88             : {
      89        7972 :   if (!_p)
      90           0 :     paramError(NS::pressure, "the pressure must be a INSFVPressureVariable.");
      91        7972 :   checkBlocks(*_p);
      92             : 
      93        7970 :   if (!_u)
      94           0 :     paramError("u", "the u velocity must be an INSFVVelocityVariable.");
      95        7970 :   checkBlocks(*_u);
      96        7968 :   _var_numbers.push_back(_u->number());
      97             : 
      98        7968 :   if (_dim >= 2)
      99             :   {
     100        7217 :     if (!_v)
     101           0 :       mooseError("In two or more dimensions, the v velocity must be supplied and it must be an "
     102             :                  "INSFVVelocityVariable.");
     103        7217 :     checkBlocks(*_v);
     104        7217 :     _var_numbers.push_back(_v->number());
     105             :   }
     106             : 
     107        7968 :   if (_dim >= 3)
     108             :   {
     109         114 :     if (!_w)
     110           0 :       mooseError("In three-dimensions, the w velocity must be supplied and it must be an "
     111             :                  "INSFVVelocityVariable.");
     112         114 :     checkBlocks(*_w);
     113         114 :     _var_numbers.push_back(_w->number());
     114             :   }
     115             : 
     116        7968 :   fillContainer(NS::pressure, _ps);
     117        7968 :   fillContainer("u", _us);
     118             : 
     119        7968 :   if (_dim >= 2)
     120             :   {
     121        7217 :     fillContainer("v", _vs);
     122        7217 :     if (_v->faceInterpolationMethod() != _u->faceInterpolationMethod())
     123           0 :       mooseError("x and y velocity component face interpolation methods do not match");
     124             : 
     125        7217 :     if (_dim >= 3)
     126             :     {
     127         114 :       fillContainer("w", _ws);
     128         114 :       if (_w->faceInterpolationMethod() != _u->faceInterpolationMethod())
     129           0 :         mooseError("x and z velocity component face interpolation methods do not match");
     130             :     }
     131             :   }
     132             : 
     133        7968 :   if (&(UserObject::_subproblem) != &(TaggingInterface::_subproblem))
     134           0 :     mooseError("Different subproblems in RhieChowInterpolatorBase!");
     135             : 
     136        7968 :   const auto & velocity_interp_method = params.get<MooseEnum>("velocity_interp_method");
     137        7968 :   if (velocity_interp_method == "average")
     138          21 :     _velocity_interp_method = Moose::FV::InterpMethod::Average;
     139        7947 :   else if (velocity_interp_method == "rc")
     140        7947 :     _velocity_interp_method = Moose::FV::InterpMethod::RhieChow;
     141        7968 : }
     142             : 
     143             : Real
     144       26489 : RhieChowInterpolatorBase::getVolumetricFaceFlux(const Moose::FV::InterpMethod m,
     145             :                                                 const FaceInfo & fi,
     146             :                                                 const Moose::StateArg & time,
     147             :                                                 const THREAD_ID tid,
     148             :                                                 bool subtract_mesh_velocity) const
     149             : {
     150       26489 :   return raw_value(this->getVelocity(m, fi, time, tid, subtract_mesh_velocity)) * fi.normal();
     151             : }

Generated by: LCOV version 1.14