LCOV - code coverage report
Current view: top level - src/userobjects - RhieChowInterpolatorBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #31405 (292dce) with base fef103 Lines: 61 68 89.7 %
Date: 2025-09-04 07:54:44 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 :     _displaced(dynamic_cast<DisplacedProblem *>(&(UserObject::_subproblem)))
      87             : {
      88        7972 :   if (!_p)
      89           0 :     paramError(NS::pressure, "the pressure must be a INSFVPressureVariable.");
      90        7972 :   checkBlocks(*_p);
      91             : 
      92        7970 :   if (!_u)
      93           0 :     paramError("u", "the u velocity must be an INSFVVelocityVariable.");
      94        7970 :   checkBlocks(*_u);
      95        7968 :   _var_numbers.push_back(_u->number());
      96             : 
      97        7968 :   if (_dim >= 2)
      98             :   {
      99        7217 :     if (!_v)
     100           0 :       mooseError("In two or more dimensions, the v velocity must be supplied and it must be an "
     101             :                  "INSFVVelocityVariable.");
     102        7217 :     checkBlocks(*_v);
     103        7217 :     _var_numbers.push_back(_v->number());
     104             :   }
     105             : 
     106        7968 :   if (_dim >= 3)
     107             :   {
     108         114 :     if (!_w)
     109           0 :       mooseError("In three-dimensions, the w velocity must be supplied and it must be an "
     110             :                  "INSFVVelocityVariable.");
     111         114 :     checkBlocks(*_w);
     112         114 :     _var_numbers.push_back(_w->number());
     113             :   }
     114             : 
     115        7968 :   fillContainer(NS::pressure, _ps);
     116        7968 :   fillContainer("u", _us);
     117             : 
     118        7968 :   if (_dim >= 2)
     119             :   {
     120        7217 :     fillContainer("v", _vs);
     121        7217 :     if (_v->faceInterpolationMethod() != _u->faceInterpolationMethod())
     122           0 :       mooseError("x and y velocity component face interpolation methods do not match");
     123             : 
     124        7217 :     if (_dim >= 3)
     125             :     {
     126         114 :       fillContainer("w", _ws);
     127         114 :       if (_w->faceInterpolationMethod() != _u->faceInterpolationMethod())
     128           0 :         mooseError("x and z velocity component face interpolation methods do not match");
     129             :     }
     130             :   }
     131             : 
     132        7968 :   if (&(UserObject::_subproblem) != &(TaggingInterface::_subproblem))
     133           0 :     mooseError("Different subproblems in RhieChowInterpolatorBase!");
     134             : 
     135        7968 :   const auto & velocity_interp_method = params.get<MooseEnum>("velocity_interp_method");
     136        7968 :   if (velocity_interp_method == "average")
     137          21 :     _velocity_interp_method = Moose::FV::InterpMethod::Average;
     138        7947 :   else if (velocity_interp_method == "rc")
     139        7947 :     _velocity_interp_method = Moose::FV::InterpMethod::RhieChow;
     140        7968 : }
     141             : 
     142             : Real
     143       26489 : RhieChowInterpolatorBase::getVolumetricFaceFlux(const Moose::FV::InterpMethod m,
     144             :                                                 const FaceInfo & fi,
     145             :                                                 const Moose::StateArg & time,
     146             :                                                 const THREAD_ID tid,
     147             :                                                 bool subtract_mesh_velocity) const
     148             : {
     149       26489 :   return raw_value(this->getVelocity(m, fi, time, tid, subtract_mesh_velocity)) * fi.normal();
     150             : }

Generated by: LCOV version 1.14