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 -------------------------------------------------------------------------------
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_(),
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 
142 void 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 
157  patchTypes[bottomPatchID] = mappedWallPolyPatch::typeName;
158 
159  if (internal_)
160  {
161  patchTypes[topPatchID] = mappedWallPolyPatch::typeName;
162  }
163  else
164  {
165  patchTypes[topPatchID] = polyPatch::typeName;
166  }
167 
168  if (dict_.get<bool>("columnCells"))
169  {
170  patchTypes[sidePatchID] = emptyPolyPatch::typeName;
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_,
228  regionName,
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 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
mappedWallPolyPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::extrudeModel
Top level extrusion model class.
Definition: extrudeModel.H:76
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.C:366
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Definition: objectRegistryTemplates.C:379
Foam::compressible::makePatchTypeField
makePatchTypeField(fvPatchScalarField, alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField)
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
patchTypes
wordList patchTypes(nPatches)
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::regionModels::thermalBaffleModels::thermalBaffleModel
Definition: thermalBaffleModel.H:60
Foam::dictionary::writeEntry
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
Definition: dictionaryIO.C:164
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
thermalBaffleFvPatchScalarField.H
patchNames
wordList patchNames(nPatches)
compressible
bool compressible
Definition: pEqn.H:2
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
virtual void write(Ostream &os) const
Write.
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.C:726
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::polyPatch::New
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:35
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
emptyPolyPatch.H
Foam::compressible::thermalBaffleFvPatchScalarField
This boundary condition provides a coupled temperature condition between multiple mesh regions.
Definition: thermalBaffleFvPatchScalarField.H:310
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::compressible::thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
thermalBaffleFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: thermalBaffleFvPatchScalarField.C:44
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField
Mixed boundary condition for temperature and radiation heat transfer to be used for in multiregion ca...
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.H:154
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::compressible::thermalBaffleFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: thermalBaffleFvPatchScalarField.C:235
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::fvMesh::name
const word & name() const
Return reference to name.
Definition: fvMesh.H:300
Foam::compressible::thermalBaffleFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: thermalBaffleFvPatchScalarField.C:251