Loading...
Searching...
No Matches
thermalBaffleModel.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "thermalBaffleModel.H"
30#include "fvMesh.H"
32#include "wedgePolyPatch.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace regionModels
41{
42
43// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44
45defineTypeNameAndDebug(thermalBaffleModel, 0);
46defineRunTimeSelectionTable(thermalBaffleModel, mesh);
47defineRunTimeSelectionTable(thermalBaffleModel, dictionary);
48
49
50// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51
53{
55 return true;
56}
57
58
60{
62 return true;
63}
64
65
66void thermalBaffleModel::init()
67{
68 if (active_)
69 {
71
72 // Check if region mesh in 1-D
73 label nTotalEdges = 0;
74 const label patchi = intCoupledPatchIDs_[0];
75 nTotalEdges = 2*nLayers_*rbm[patchi].nInternalEdges();
76 nTotalEdges +=
77 nLayers_*(rbm[patchi].nEdges() - rbm[patchi].nInternalEdges());
78
79 label nTotalFaces = 0;
80 forAll(rbm, patchi)
81 {
82 if (
83 rbm[patchi].size()
84 &&
85 (
86 isA<wedgePolyPatch>(rbm[patchi])
87 || isA<emptyPolyPatch>(rbm[patchi])
88 )
89 )
90 {
91 nTotalFaces += rbm[patchi].size();
92 }
93 }
94
95 oneD_ =
96 (
97 returnReduce(nTotalEdges, sumOp<label>())
98 == returnReduce(nTotalFaces, sumOp<label>())
99 );
100
101 if (oneD_)
102 {
103 Info << "\nThe thermal baffle is 1D\n" << endl;
104 }
105 else
106 {
107 Info << "\nThe thermal baffle is 3D\n" << endl;
108 }
109
111 {
112 const label patchi = intCoupledPatchIDs_[i];
113 const polyPatch& pp = rbm[patchi];
114
115 if
116 (
118 && oneD_
120 )
121 {
123 << "' not type '"
124 << mappedVariableThicknessWallPolyPatch::typeName
125 << "'. This is necessary for 1D solution "
126 << " and variable thickness"
127 << "\n for patch. " << pp.name()
128 << exit(FatalError);
129 }
130 else if (!isA<mappedWallPolyPatch>(pp))
131 {
133 << "' not type '"
134 << mappedWallPolyPatch::typeName
135 << "'. This is necessary for 3D solution"
136 << "\n for patch. " << pp.name()
137 << exit(FatalError);
138 }
139 }
140
142 {
143 const label patchi = intCoupledPatchIDs_[0];
144 const polyPatch& pp = rbm[patchi];
145 const mappedVariableThicknessWallPolyPatch& ppCoupled =
146 refCast
147 <
148 const mappedVariableThicknessWallPolyPatch
149 >(pp);
150
151 thickness_ = ppCoupled.thickness();
152
153 // Check that thickness has the right size
154 if (thickness_.size() != pp.size())
155 {
157 << " coupled patches in thermalBaffle are " << nl
158 << " different sizes from list thickness" << nl
159 << exit(FatalError);
160 }
161
162 // Calculate thickness of the baffle on the first face only.
163 if (delta_.value() == 0.0)
164 {
165 forAll(ppCoupled, localFacei)
166 {
167 label facei = ppCoupled.start() + localFacei;
168
169 label faceO =
170 boundaryFaceOppositeFace_[localFacei];
171
172 delta_.value() = mag
173 (
174 regionMesh().faceCentres()[facei]
175 - regionMesh().faceCentres()[faceO]
176 );
177 break;
178 }
179 }
181 }
182}
183
184
185// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
186
187thermalBaffleModel::thermalBaffleModel(const fvMesh& mesh)
188:
189 regionModel1D(mesh, "thermalBaffle"),
191 delta_("delta", dimLength, Zero),
192 oneD_(false),
194{}
195
196
197thermalBaffleModel::thermalBaffleModel
198(
199 const word& modelType,
200 const fvMesh& mesh,
201 const dictionary& dict
202
203)
204:
205 regionModel1D(mesh, "thermalBaffle", modelType, dict, true),
206 thickness_(),
207 delta_("delta", dimLength, Zero),
208 oneD_(false),
209 constantThickness_(dict.getOrDefault("constantThickness", true))
210{
211 init();
212}
213
214
215thermalBaffleModel::thermalBaffleModel
216(
217 const word& modelType,
218 const fvMesh& mesh
219)
220:
221 regionModel1D(mesh, "thermalBaffle", modelType),
222 thickness_(),
223 delta_("delta", dimLength, Zero),
224 oneD_(false),
225 constantThickness_(getOrDefault("constantThickness", true))
227 init();
228}
229
230
231// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
234{}
235
236
237// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
238
240{}
241
242
243// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244
245} // End namespace thermalBaffleModels
246} // End namespace regionModels
247} // End namespace Foam
248
249// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
label size() const noexcept
The number of entries in the list.
Definition UPtrListI.H:106
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
Base class for 1-D region models.
labelList boundaryFaceOppositeFace_
Global boundary face IDs oppositte coupled patch.
label nLayers_
Number of layers in the region.
virtual bool read()
Read control parameters from dictionary.
const fvMesh & regionMesh() const
Return the region mesh database.
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
virtual bool read()
Read control parameters from IO dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
messageStream Info
Information stream (stdout output on master, null elsewhere).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299