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 "LinearFVConvectiveHeatTransferBC.h" 11 : #include "NS.h" 12 : 13 : registerMooseObject("NavierStokesApp", LinearFVConvectiveHeatTransferBC); 14 : 15 : InputParameters 16 108 : LinearFVConvectiveHeatTransferBC::validParams() 17 : { 18 108 : InputParameters params = LinearFVAdvectionDiffusionBC::validParams(); 19 108 : params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "The fluid temperature variable"); 20 108 : params.addRequiredParam<MooseFunctorName>(NS::T_solid, "The solid/wall temperature variable"); 21 216 : params.addRequiredParam<MooseFunctorName>("h", "The convective heat transfer coefficient"); 22 108 : params.addClassDescription("Class describing a convective heat transfer between two domains."); 23 108 : return params; 24 0 : } 25 : 26 54 : LinearFVConvectiveHeatTransferBC::LinearFVConvectiveHeatTransferBC( 27 54 : const InputParameters & parameters) 28 : : LinearFVAdvectionDiffusionBC(parameters), 29 54 : _temp_fluid(getFunctor<Real>(NS::T_fluid)), 30 54 : _temp_solid(getFunctor<Real>(NS::T_solid)), 31 108 : _htc(getFunctor<Real>("h")), 32 54 : _var_is_fluid("wraps_" + _var.name() == _temp_fluid.functorName() || 33 270 : "wraps_" + _var.name() + "_raw_value" == _temp_fluid.functorName()) 34 : { 35 : // We determine which one is the source variable 36 54 : if (_var_is_fluid) 37 36 : _rhs_temperature = &_temp_solid; 38 : else 39 18 : _rhs_temperature = &_temp_fluid; 40 54 : } 41 : 42 : Real 43 88032 : LinearFVConvectiveHeatTransferBC::computeBoundaryValue() const 44 : { 45 88032 : const auto elem_info = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) 46 88032 : ? _current_face_info->elemInfo() 47 40464 : : _current_face_info->neighborInfo(); 48 : 49 88032 : return _var.getElemValue(*elem_info, determineState()); 50 : } 51 : 52 : Real 53 0 : LinearFVConvectiveHeatTransferBC::computeBoundaryNormalGradient() const 54 : { 55 0 : const auto face = singleSidedFaceArg(_current_face_info); 56 0 : const auto state = determineState(); 57 : 58 0 : const auto elem_info = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) 59 0 : ? _current_face_info->elemInfo() 60 0 : : _current_face_info->neighborInfo(); 61 : 62 : const auto neighbor_info = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) 63 0 : ? _current_face_info->neighborInfo() 64 0 : : _current_face_info->elemInfo(); 65 : 66 0 : const auto fluid_side_elem_info = _var_is_fluid ? elem_info : neighbor_info; 67 : 68 : // All this fuss is just for cases when we have an internal boundary, then the flux will change 69 : // signs depending on which side of the face we are at. 70 0 : const auto multiplier = _current_face_info->normal() * (_current_face_info->faceCentroid() - 71 : fluid_side_elem_info->centroid()) > 72 : 0 73 0 : ? 1 74 : : -1; 75 : 76 0 : return multiplier * _htc(face, state) * (_temp_fluid(face, state) - _temp_solid(face, state)); 77 : } 78 : 79 : Real 80 34080 : LinearFVConvectiveHeatTransferBC::computeBoundaryValueMatrixContribution() const 81 : { 82 : // We approximate the face value with the cell value here. 83 : // TODO: we can extend this to a 2-term expansion at some point when the need arises. 84 34080 : return 1.0; 85 : } 86 : 87 : Real 88 34080 : LinearFVConvectiveHeatTransferBC::computeBoundaryValueRHSContribution() const 89 : { 90 : // We approximate the face value with the cell value, we 91 : // don't need to add anything to the right hand side. 92 : // TODO: we can extend this to a 2-term expansion at some point when the need arises. 93 34080 : return 0.0; 94 : } 95 : 96 : Real 97 61056 : LinearFVConvectiveHeatTransferBC::computeBoundaryGradientMatrixContribution() const 98 : { 99 61056 : const auto face = singleSidedFaceArg(_current_face_info); 100 61056 : const auto state = determineState(); 101 : 102 : // We just put the heat transfer coefficient on the diagonal (multiplication with the 103 : // surface area is taken care of in the kernel). 104 61056 : return _htc(face, state); 105 : } 106 : 107 : Real 108 61056 : LinearFVConvectiveHeatTransferBC::computeBoundaryGradientRHSContribution() const 109 : { 110 61056 : const auto state = determineState(); 111 61056 : auto face = singleSidedFaceArg(_current_face_info); 112 : 113 : // We check where the functor contributing to the right hand side lives. We do this 114 : // because this functor lives on the domain where the variable of this kernel doesn't. 115 61056 : if (_rhs_temperature->hasFaceSide(*_current_face_info, true)) 116 34080 : face.face_side = _current_face_info->elemPtr(); 117 : else 118 53952 : face.face_side = _current_face_info->neighborPtr(); 119 : 120 61056 : return _htc(face, state) * (*_rhs_temperature)(face, state); 121 : }