LCOV - code coverage report
Current view: top level - src/fviks - FVConvectionCorrelationInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 37 39 94.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 "FVConvectionCorrelationInterface.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", FVConvectionCorrelationInterface);
      14             : 
      15             : InputParameters
      16         149 : FVConvectionCorrelationInterface::validParams()
      17             : {
      18         149 :   InputParameters params = FVInterfaceKernel::validParams();
      19         149 :   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         149 :   params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "The fluid temperature variable");
      23         149 :   params.addRequiredParam<MooseFunctorName>(NS::T_solid, "The solid/wall temperature variable");
      24         298 :   params.addRequiredParam<MooseFunctorName>("h", "The convective heat transfer coefficient");
      25         298 :   params.addParam<Real>(
      26         298 :       "bulk_distance", -1, "The distance to the bulk for evaluating the fluid bulk temperature");
      27         298 :   params.addParam<bool>("wall_cell_is_bulk",
      28         298 :                         false,
      29             :                         "Use the wall cell centroid temperature for the fluid bulk temperature");
      30         149 :   return params;
      31           0 : }
      32             : 
      33          80 : FVConvectionCorrelationInterface::FVConvectionCorrelationInterface(const InputParameters & params)
      34             :   : FVInterfaceKernel(params),
      35          80 :     _temp_fluid(getFunctor<ADReal>(NS::T_fluid)),
      36          80 :     _temp_solid(getFunctor<ADReal>(NS::T_solid)),
      37         160 :     _htc(getFunctor<ADReal>("h")),
      38         160 :     _bulk_distance(getParam<Real>("bulk_distance")),
      39         160 :     _use_wall_cell(getParam<bool>("wall_cell_is_bulk")),
      40          80 :     _pl(mesh().getPointLocator()),
      41         160 :     _var1_is_fluid("wraps_" + var1().name() == _temp_fluid.functorName())
      42             : {
      43          80 :   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          80 : }
      48             : 
      49             : ADReal
      50       89472 : 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      178944 :       (elemIsOne() && _var1_is_fluid) || (!elemIsOne() && !_var1_is_fluid)
      57      178664 :           ? &_face_info->elem()
      58         280 :           : _face_info->neighborPtr();
      59             : 
      60             :   const Elem * bulk_elem;
      61       89472 :   const auto state = determineState();
      62       89472 :   if (!_use_wall_cell)
      63             :   {
      64         504 :     Point p = _face_info->faceCentroid();
      65         504 :     Point du = Point(MetaPhysicL::raw_value(_normal));
      66             :     du *= _bulk_distance;
      67             :     // The normal always points outwards from the elem (towards the neighbor)
      68         504 :     if (elem_on_fluid_side == &_face_info->elem())
      69             :       p -= du;
      70             :     else
      71             :       p += du;
      72         504 :     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      178944 :   const auto fluid_side = singleSidedFaceArg(_var1_is_fluid ? var1() : var2(), _face_info);
      84      178944 :   const auto solid_side = singleSidedFaceArg(_var1_is_fluid ? var2() : var1(), _face_info);
      85             : 
      86       89472 :   const auto bulk_elem_arg = makeElemArg(bulk_elem);
      87             : 
      88             :   /// We make sure that the gradient*normal part is addressed
      89             :   auto multipler =
      90       89752 :       _normal * (_face_info->faceCentroid() - bulk_elem->vertex_average()) > 0 ? 1 : -1;
      91             : 
      92       89472 :   return multipler * _htc(fluid_side, state) *
      93       89472 :          (_temp_fluid(bulk_elem_arg, state) - _temp_solid(solid_side, state));
      94             : }

Generated by: LCOV version 1.14