https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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))
45 "The bulk distance should be specified or 'wall_cell_is_bulk' should be set to true for "
46 "the FVTwoVarConvectionCorrelationInterface");
47}
48
51{
52 const Elem * elem_on_fluid_side = _var1_is_fluid ? &elem1() : &elem2();
53
54 const Elem * bulk_elem;
55 const auto state = determineState();
56 if (!_use_wall_cell)
57 {
58 Point p = _face_info->faceCentroid();
59 const Point du = normal() * _bulk_distance;
61 p -= du;
62 else
63 p += du;
64 bulk_elem = (*_pl)(p);
65 }
66 else
67 bulk_elem = elem_on_fluid_side;
68
69 mooseAssert(bulk_elem,
70 "The element at bulk_distance from the wall was not found in the mesh. "
71 "Increase the number of ghost layers with the 'ghost_layers' parameter.");
72 mooseAssert((_var1_is_fluid ? var1() : var2()).hasBlocks(bulk_elem->subdomain_id()),
73 "The fluid temperature is not defined at bulk_distance from the wall.");
74
75 const auto fluid_side = _var1_is_fluid ? faceArg1(_htc) : faceArg2(_htc);
76 const auto solid_side = _var1_is_fluid ? faceArg2(_temp_solid) : faceArg1(_temp_solid);
77
78 const auto bulk_elem_arg = makeElemArg(bulk_elem);
79
80 return (_var1_is_fluid ? 1 : -1) * _htc(fluid_side, state) *
81 (_temp_fluid(bulk_elem_arg, state) - _temp_solid(solid_side, state));
82}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", FVConvectionCorrelationInterface)
const Real p
const std::string name
Definition Setup.h:21
const bool _use_wall_cell
Whether to use the wall cell for the bulk fluid temperature.
FVConvectionCorrelationInterface(const InputParameters &params)
const Real _bulk_distance
The distance from the wall before evaluating the bulk temperature.
const Moose::Functor< ADReal > & _temp_fluid
The fluid temperature variable.
const bool _var1_is_fluid
Boolean to see if variable1 is the fluid.
const Moose::Functor< ADReal > & _temp_solid
The solid/wall temperature variable.
const Moose::Functor< ADReal > & _htc
The convective heat transfer coefficient in the local element.
Moose::FaceArg faceArg2(Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
const Elem & elem2() const
const Elem & elem1() const
static InputParameters validParams()
Moose::FaceArg faceArg1(Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
Point normal() const
const FaceInfo * _face_info
const MooseVariableFV< Real > & var1() const
const MooseVariableFV< Real > & var2() const
const Point & faceCentroid() const
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
Moose::StateArg determineState() const
MeshBase & mesh
static const std::string T_fluid
Definition NS.h:110
static const std::string T_solid
Definition NS.h:111