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-2022 OpenCFD Ltd
10 -------------------------------------------------------------------------------
11 License
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 
36 namespace Foam
37 {
38 namespace compressible
39 {
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const fvPatch& p,
47 )
48 :
50  owner_(false),
51  internal_(true),
52  baffle_(nullptr),
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_(nullptr),
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_(nullptr),
92  dict_(dict),
93  extrudeMeshPtr_()
94 {
95 
96  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
97 
98  word regionName("none");
99  dict_.readIfPresent("region", regionName);
100 
101  dict_.readIfPresent("internal", internal_);
102 
103  const word baffleName("3DBaffle" + regionName);
104 
105  if
106  (
107  !thisMesh.time().foundObject<fvMesh>(regionName)
108  && regionName != "none"
109  )
110  {
111  if (!extrudeMeshPtr_)
112  {
113  createPatchMesh();
114  }
115 
116  baffle_.reset(baffleType::New(thisMesh, dict));
117  owner_ = true;
118  baffle_->rename(baffleName);
119  }
120 }
121 
122 
124 (
125  const thermalBaffleFvPatchScalarField& ptf,
127 )
128 :
129  turbulentTemperatureRadCoupledMixedFvPatchScalarField(ptf, iF),
130  owner_(ptf.owner_),
131  internal_(ptf.internal_),
132  baffle_(nullptr),
133  dict_(ptf.dict_),
134  extrudeMeshPtr_()
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 void thermalBaffleFvPatchScalarField::createPatchMesh()
141 {
142  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
143 
144  const word regionName(dict_.get<word>("region"));
145 
146  polyPatchList regionPatches(3);
147  List<dictionary> dicts(regionPatches.size());
148  List<word> patchNames(regionPatches.size());
149  List<word> patchTypes(regionPatches.size());
150 
151  patchNames[bottomPatchID] = word("bottom");
152  patchNames[sidePatchID] = word("side");
153  patchNames[topPatchID] = word("top");
154 
155  patchTypes[bottomPatchID] = mappedWallPolyPatch::typeName;
156 
157  if (internal_)
158  {
159  patchTypes[topPatchID] = mappedWallPolyPatch::typeName;
160  }
161  else
162  {
163  patchTypes[topPatchID] = polyPatch::typeName;
164  }
165 
166  if (dict_.get<bool>("columnCells"))
167  {
168  patchTypes[sidePatchID] = emptyPolyPatch::typeName;
169  }
170  else
171  {
172  patchTypes[sidePatchID] = polyPatch::typeName;
173  }
174 
175  const auto& mpp = refCast<const mappedPatchBase>(patch().patch(), dict_);
176 
177  const word coupleGroup(mpp.coupleGroup());
178 
179  wordList inGroups(1);
180  inGroups[0] = coupleGroup;
181 
182  // The bottomPatchID is coupled with this patch
183  dicts[bottomPatchID].add("coupleGroup", coupleGroup);
184  dicts[bottomPatchID].add("inGroups", inGroups);
185  dicts[bottomPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
186  dicts[bottomPatchID].add("samplePatch", patch().name());
187  dicts[bottomPatchID].add("sampleRegion", thisMesh.name());
188 
189  // Internal baffle needs a coupled on the topPatchID
190  if (internal_)
191  {
192  const word coupleGroupSlave =
193  coupleGroup.substr(0, coupleGroup.find('_')) + "_slave";
194 
195  inGroups[0] = coupleGroupSlave;
196  dicts[topPatchID].add("coupleGroup", coupleGroupSlave);
197  dicts[topPatchID].add("inGroups", inGroups);
198  dicts[topPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
199  }
200 
201 
202  forAll(regionPatches, patchi)
203  {
204  dictionary& patchDict = dicts[patchi];
205  patchDict.set("nFaces", 0);
206  patchDict.set("startFace", 0);
207 
208  regionPatches.set
209  (
210  patchi,
212  (
213  patchTypes[patchi],
214  patchNames[patchi],
215  dicts[patchi],
216  patchi,
217  thisMesh.boundaryMesh()
218  )
219  );
220  }
221 
222  extrudeMeshPtr_.reset
223  (
224  new extrudePatchMesh
225  (
226  thisMesh,
227  patch(),
228  dict_,
230  regionPatches
231  )
232  );
233 }
234 
235 
237 {
238  if (this->updated())
239  {
240  return;
241  }
242 
243  if (owner_)
244  {
245  baffle_->evolve();
246  }
247 
249 }
250 
251 
253 {
255 
256  if (owner_)
257  {
258  os.writeEntry("extrudeModel", dict_.get<word>("extrudeModel"));
259 
260  os.writeEntry("nLayers", dict_.get<label>("nLayers"));
261 
262  os.writeEntry("expansionRatio", dict_.get<scalar>("expansionRatio"));
263 
264  os.writeEntry("columnCells", dict_.get<Switch>("columnCells"));
265 
266  const word extrudeModel(dict_.get<word>("extrudeModel") + "Coeffs");
267 
269 
270  os.writeEntry("region", dict_.get<word>("region"));
271 
272  os.writeEntryIfDifferent<bool>("internal", true, internal_);
273 
274  os.writeEntry("active", dict_.get<Switch>("active"));
275 
276  dict_.subDict("thermoType").writeEntry("thermoType", os);
277  dict_.subDict("mixture").writeEntry("mixture", os);
278  dict_.subDict("radiation").writeEntry("radiation", os);
279  }
280 }
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
286 (
288  thermalBaffleFvPatchScalarField
289 );
290 
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 } // End namespace compressible
295 } // End namespace Foam
296 
297 
298 // ************************************************************************* //
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
Definition: dictionaryIO.C:157
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
wordList patchTypes(nPatches)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Mixed boundary condition for temperature and radiation heat transfer, suitable for multiregion cases...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:360
static autoPtr< thermalBaffleModel > New(const fvMesh &mesh)
Return a reference to the selected model.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
Macros for easy insertion into run-time selection tables.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Top level extrusion model class.
Definition: extrudeModel.H:72
makePatchTypeField(fvPatchScalarField, alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField)
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
Definition: polyPatch.H:56
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
A FieldMapper for finite-volume patch fields.
wordList patchNames(nPatches)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
bool compressible
Definition: pEqn.H:2
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
OBJstream os(runTime.globalPath()/outputName)
thermalBaffleFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
List< word > wordList
List of word.
Definition: fileName.H:59
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
Definition: polyPatchNew.C:28
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
volScalarField & p
This boundary condition provides a coupled temperature condition between multiple mesh regions...
Namespace for OpenFOAM.