thermalBaffleFvPatchScalarField.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-2021 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
31#include "emptyPolyPatch.H"
32#include "mappedWallPolyPatch.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace compressible
39{
40
41// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42
44(
45 const fvPatch& p,
47)
48:
50 owner_(false),
51 internal_(true),
52 baffle_(),
53 dict_(),
54 extrudeMeshPtr_()
55{}
56
57
59(
61 const fvPatch& p,
63 const fvPatchFieldMapper& mapper
64)
65:
67 (
68 ptf,
69 p,
70 iF,
71 mapper
72 ),
73 owner_(ptf.owner_),
74 internal_(ptf.internal_),
75 baffle_(),
76 dict_(ptf.dict_),
77 extrudeMeshPtr_()
78{}
79
80
82(
83 const fvPatch& p,
85 const dictionary& dict
86)
87:
89 owner_(false),
90 internal_(true),
91 baffle_(),
92 dict_(dict),
93 extrudeMeshPtr_()
94{
95
96 const fvMesh& thisMesh = patch().boundaryMesh().mesh();
97
99
100 word regionName("none");
101 dict_.readIfPresent("region", regionName);
102
103 dict_.readIfPresent("internal", internal_);
104
105 const word baffleName("3DBaffle" + regionName);
106
107 if
108 (
109 !thisMesh.time().foundObject<fvMesh>(regionName)
110 && regionName != "none"
111 )
112 {
113 if (!extrudeMeshPtr_)
114 {
115 createPatchMesh();
116 }
117
118 baffle_.reset(baffle::New(thisMesh, dict).ptr());
119 owner_ = true;
120 baffle_->rename(baffleName);
121 }
122}
123
124
126(
129)
130:
132 owner_(ptf.owner_),
133 internal_(ptf.internal_),
134 baffle_(),
135 dict_(ptf.dict_),
136 extrudeMeshPtr_()
137{}
138
139
140// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141
142void thermalBaffleFvPatchScalarField::createPatchMesh()
143{
144 const fvMesh& thisMesh = patch().boundaryMesh().mesh();
145
146 const word regionName(dict_.get<word>("region"));
147
148 List<polyPatch*> regionPatches(3);
149 List<word> patchNames(regionPatches.size());
150 List<word> patchTypes(regionPatches.size());
151 List<dictionary> dicts(regionPatches.size());
152
153 patchNames[bottomPatchID] = word("bottom");
154 patchNames[sidePatchID] = word("side");
155 patchNames[topPatchID] = word("top");
156
158
159 if (internal_)
160 {
162 }
163 else
164 {
165 patchTypes[topPatchID] = polyPatch::typeName;
166 }
167
168 if (dict_.get<bool>("columnCells"))
169 {
171 }
172 else
173 {
174 patchTypes[sidePatchID] = polyPatch::typeName;
175 }
176
177 const mappedPatchBase& mpp =
178 refCast<const mappedPatchBase>(patch().patch(), dict_);
179
180 const word coupleGroup(mpp.coupleGroup());
181
182 wordList inGroups(1);
183 inGroups[0] = coupleGroup;
184
185 // The bottomPatchID is coupled with this patch
186 dicts[bottomPatchID].add("coupleGroup", coupleGroup);
187 dicts[bottomPatchID].add("inGroups", inGroups);
188 dicts[bottomPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
189 dicts[bottomPatchID].add("samplePatch", patch().name());
190 dicts[bottomPatchID].add("sampleRegion", thisMesh.name());
191
192 // Internal baffle needs a coupled on the topPatchID
193 if (internal_)
194 {
195 const word coupleGroupSlave =
196 coupleGroup.substr(0, coupleGroup.find('_')) + "_slave";
197
198 inGroups[0] = coupleGroupSlave;
199 dicts[topPatchID].add("coupleGroup", coupleGroupSlave);
200 dicts[topPatchID].add("inGroups", inGroups);
201 dicts[topPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
202 }
203
204
205 forAll(regionPatches, patchi)
206 {
207 dictionary& patchDict = dicts[patchi];
208 patchDict.set("nFaces", 0);
209 patchDict.set("startFace", 0);
210
211 regionPatches[patchi] = polyPatch::New
212 (
213 patchTypes[patchi],
214 patchNames[patchi],
215 dicts[patchi],
216 patchi,
217 thisMesh.boundaryMesh()
218 ).ptr();
219 }
220
221 extrudeMeshPtr_.reset
222 (
223 new extrudePatchMesh
224 (
225 thisMesh,
226 patch(),
227 dict_,
229 regionPatches
230 )
231 );
232}
233
234
236{
237 if (this->updated())
238 {
239 return;
240 }
241
242 if (owner_)
243 {
244 baffle_->evolve();
245 }
246
248}
249
250
252{
254
255 if (owner_)
256 {
257 os.writeEntry("extrudeModel", dict_.get<word>("extrudeModel"));
258
259 os.writeEntry("nLayers", dict_.get<label>("nLayers"));
260
261 os.writeEntry("expansionRatio", dict_.get<scalar>("expansionRatio"));
262
263 os.writeEntry("columnCells", dict_.get<Switch>("columnCells"));
264
265 const word extrudeModel(dict_.get<word>("extrudeModel") + "Coeffs");
266
268
269 os.writeEntry("region", dict_.get<word>("region"));
270
271 os.writeEntryIfDifferent<bool>("internal", true, internal_);
272
273 os.writeEntry("active", dict_.get<Switch>("active"));
274
275 dict_.subDict("thermoType").writeEntry("thermoType", os);
276 dict_.subDict("mixture").writeEntry("mixture", os);
277 dict_.subDict("radiation").writeEntry("radiation", os);
278 }
279}
280
281
282// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283
285(
288);
289
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293} // End namespace compressible
294} // End namespace Foam
295
296
297// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:251
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:78
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
This boundary condition provides a coupled temperature condition between multiple mesh regions.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Mixed boundary condition for temperature and radiation heat transfer to be used for in multiregion ca...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
Definition: dictionaryIO.C:164
Top level extrusion model class.
Definition: extrudeModel.H:77
virtual bool write()
Write the output fields.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const word & name() const
Return reference to name.
Definition: fvMesh.H:310
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
Foam::word regionName(Foam::polyMesh::defaultRegion)
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Definition: fvPatchField.H:676
bool compressible
Definition: pEqn.H:2
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
wordList patchTypes(nPatches)
wordList patchNames(nPatches)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.