https://mooseframework.inl.gov
FVConvectionCorrelationInterface.C
Go to the documentation of this file.
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 
11 #include "NS.h"
12 
14 
17 {
19  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  params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "The fluid temperature variable");
23  params.addRequiredParam<MooseFunctorName>(NS::T_solid, "The solid/wall temperature variable");
24  params.addRequiredParam<MooseFunctorName>("h", "The convective heat transfer coefficient");
25  params.addParam<Real>(
26  "bulk_distance", -1, "The distance to the bulk for evaluating the fluid bulk temperature");
27  params.addParam<bool>("wall_cell_is_bulk",
28  false,
29  "Use the wall cell centroid temperature for the fluid bulk temperature");
30  return params;
31 }
32 
34  : FVInterfaceKernel(params),
35  _temp_fluid(getFunctor<ADReal>(NS::T_fluid)),
36  _temp_solid(getFunctor<ADReal>(NS::T_solid)),
37  _htc(getFunctor<ADReal>("h")),
38  _bulk_distance(getParam<Real>("bulk_distance")),
39  _use_wall_cell(getParam<bool>("wall_cell_is_bulk")),
40  _pl(mesh().getPointLocator()),
41  _var1_is_fluid("wraps_" + var1().name() == _temp_fluid.functorName())
42 {
43  if (!_use_wall_cell && (_bulk_distance < 0))
44  mooseError(
45  "The bulk distance should be specified or 'wall_cell_is_bulk' should be set to true for "
46  "the FVTwoVarConvectionCorrelationInterface");
47 }
48 
49 ADReal
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 =
57  ? &_face_info->elem()
59 
60  const Elem * bulk_elem;
61  const auto state = determineState();
62  if (!_use_wall_cell)
63  {
64  Point p = _face_info->faceCentroid();
65  Point du = Point(MetaPhysicL::raw_value(_normal));
66  du *= _bulk_distance;
67  // The normal always points outwards from the elem (towards the neighbor)
68  if (elem_on_fluid_side == &_face_info->elem())
69  p -= du;
70  else
71  p += du;
72  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  const auto fluid_side = singleSidedFaceArg(_var1_is_fluid ? var1() : var2(), _face_info);
84  const auto solid_side = singleSidedFaceArg(_var1_is_fluid ? var2() : var1(), _face_info);
85 
86  const auto bulk_elem_arg = makeElemArg(bulk_elem);
87 
89  auto multipler =
90  _normal * (_face_info->faceCentroid() - bulk_elem->vertex_average()) > 0 ? 1 : -1;
91 
92  return multipler * _htc(fluid_side, state) *
93  (_temp_fluid(bulk_elem_arg, state) - _temp_solid(solid_side, state));
94 }
const bool _use_wall_cell
Whether to use the wall cell for the bulk fluid temperature.
const FaceInfo * _face_info
const MooseVariableFV< Real > & var1() const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
registerMooseObject("NavierStokesApp", FVConvectionCorrelationInterface)
const Moose::Functor< ADReal > & _temp_solid
The solid/wall temperature variable.
const Elem & elem() const
static const std::string T_solid
Definition: NS.h:107
Moose::StateArg determineState() const
const Point & faceCentroid() const
MeshBase & mesh
auto raw_value(const Eigen::Map< T > &in)
FVConvectionCorrelationInterface(const InputParameters &params)
static InputParameters validParams()
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
const Elem * neighborPtr() const
static const std::string T_fluid
Definition: NS.h:106
const std::string name
Definition: Setup.h:20
ADRealVectorValue _normal
const Moose::Functor< ADReal > & _temp_fluid
The fluid temperature variable.
const Moose::Functor< ADReal > & _htc
The convective heat transfer coefficient in the local element.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Moose::FaceArg singleSidedFaceArg(const MooseVariableFV< Real > &variable, const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
virtual bool elemIsOne() const
const bool _var1_is_fluid
Boolean to see if variable1 is the fluid.
const MooseVariableFV< Real > & var2() const
const Real _bulk_distance
The distance from the wall before evaluating the bulk temperature.