LCOV - code coverage report
Current view: top level - src/fviks - FVConvectionCorrelationInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 37 39 94.9 %
Date: 2026-05-29 20:37:52 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 "FVConvectionCorrelationInterface.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", FVConvectionCorrelationInterface);
      14             : 
      15             : InputParameters
      16          70 : FVConvectionCorrelationInterface::validParams()
      17             : {
      18          70 :   InputParameters params = FVInterfaceKernel::validParams();
      19          70 :   params.addClassDescription("Computes the residual for a convective heat transfer across an "
      20             :                              "interface for the finite volume method, "
      21             :                              "using a correlation for the heat transfer coefficient.");
      22          70 :   params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "The fluid temperature variable");
      23          70 :   params.addRequiredParam<MooseFunctorName>(NS::T_solid, "The solid/wall temperature variable");
      24         140 :   params.addRequiredParam<MooseFunctorName>("h", "The convective heat transfer coefficient");
      25         140 :   params.addParam<Real>(
      26         140 :       "bulk_distance", -1, "The distance to the bulk for evaluating the fluid bulk temperature");
      27         140 :   params.addParam<bool>("wall_cell_is_bulk",
      28         140 :                         false,
      29             :                         "Use the wall cell centroid temperature for the fluid bulk temperature");
      30          70 :   return params;
      31           0 : }
      32             : 
      33          37 : FVConvectionCorrelationInterface::FVConvectionCorrelationInterface(const InputParameters & params)
      34             :   : FVInterfaceKernel(params),
      35          37 :     _temp_fluid(getFunctor<ADReal>(NS::T_fluid)),
      36          37 :     _temp_solid(getFunctor<ADReal>(NS::T_solid)),
      37          74 :     _htc(getFunctor<ADReal>("h")),
      38          74 :     _bulk_distance(getParam<Real>("bulk_distance")),
      39          74 :     _use_wall_cell(getParam<bool>("wall_cell_is_bulk")),
      40          37 :     _pl(mesh().getPointLocator()),
      41          74 :     _var1_is_fluid("wraps_" + var1().name() == _temp_fluid.functorName())
      42             : {
      43          37 :   if (!_use_wall_cell && (_bulk_distance < 0))
      44           0 :     mooseError(
      45             :         "The bulk distance should be specified or 'wall_cell_is_bulk' should be set to true for "
      46             :         "the FVTwoVarConvectionCorrelationInterface");
      47          37 : }
      48             : 
      49             : ADReal
      50       59704 : FVConvectionCorrelationInterface::computeQpResidual()
      51             : {
      52             :   // If variable1 is fluid and variable 1 is on elem or
      53             :   // if variable2 is fluid and variable 2 is on elem
      54             :   // the fluid element will be elem otherwise it is the neighbor
      55             :   const Elem * elem_on_fluid_side =
      56      119408 :       (elemIsOne() && _var1_is_fluid) || (!elemIsOne() && !_var1_is_fluid)
      57      119212 :           ? &_face_info->elem()
      58         196 :           : _face_info->neighborPtr();
      59             : 
      60             :   const Elem * bulk_elem;
      61       59704 :   const auto state = determineState();
      62       59704 :   if (!_use_wall_cell)
      63             :   {
      64         280 :     Point p = _face_info->faceCentroid();
      65         280 :     Point du = Point(MetaPhysicL::raw_value(_normal));
      66             :     du *= _bulk_distance;
      67             :     // The normal always points outwards from the elem (towards the neighbor)
      68         280 :     if (elem_on_fluid_side == &_face_info->elem())
      69             :       p -= du;
      70             :     else
      71             :       p += du;
      72         280 :     bulk_elem = (*_pl)(p);
      73             :   }
      74             :   else
      75             :     bulk_elem = elem_on_fluid_side;
      76             : 
      77             :   mooseAssert(bulk_elem,
      78             :               "The element at bulk_distance from the wall was not found in the mesh. "
      79             :               "Increase the number of ghost layers with the 'ghost_layers' parameter.");
      80             :   mooseAssert((_var1_is_fluid ? var1() : var2()).hasBlocks(bulk_elem->subdomain_id()),
      81             :               "The fluid temperature is not defined at bulk_distance from the wall.");
      82             : 
      83      119408 :   const auto fluid_side = singleSidedFaceArg(_var1_is_fluid ? var1() : var2(), _face_info);
      84      119408 :   const auto solid_side = singleSidedFaceArg(_var1_is_fluid ? var2() : var1(), _face_info);
      85             : 
      86       59704 :   const auto bulk_elem_arg = makeElemArg(bulk_elem);
      87             : 
      88             :   /// We make sure that the gradient*normal part is addressed
      89             :   auto multipler =
      90       59900 :       _normal * (_face_info->faceCentroid() - bulk_elem->vertex_average()) > 0 ? 1 : -1;
      91             : 
      92       59704 :   return multipler * _htc(fluid_side, state) *
      93       59704 :          (_temp_fluid(bulk_elem_arg, state) - _temp_solid(solid_side, state));
      94             : }

Generated by: LCOV version 1.14