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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
30 #include "emptyPolyPatch.H"
31 #include "mappedWallPolyPatch.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace compressible
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const fvPatch& p,
46 )
47 :
49  owner_(false),
50  baffle_(),
51  dict_(dictionary::null),
52  extrudeMeshPtr_()
53 {}
54 
55 
57 (
59  const fvPatch& p,
61  const fvPatchFieldMapper& mapper
62 )
63 :
65  (
66  ptf,
67  p,
68  iF,
69  mapper
70  ),
71  owner_(ptf.owner_),
72  baffle_(),
73  dict_(ptf.dict_),
74  extrudeMeshPtr_()
75 {}
76 
77 
79 (
80  const fvPatch& p,
82  const dictionary& dict
83 )
84 :
86  owner_(false),
87  baffle_(),
88  dict_(dict),
89  extrudeMeshPtr_()
90 {
91 
92  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
93 
95 
96  if (thisMesh.name() == polyMesh::defaultRegion)
97  {
98  const word regionName = dict_.lookupOrDefault<word>("region", "none");
99 
100  const word baffleName("3DBaffle" + regionName);
101 
102  if
103  (
104  !thisMesh.time().foundObject<fvMesh>(regionName)
105  && regionName != "none"
106  )
107  {
108  if (extrudeMeshPtr_.empty())
109  {
110  createPatchMesh();
111  }
112 
113  baffle_.reset(baffle::New(thisMesh, dict).ptr());
114  owner_ = true;
115  baffle_->rename(baffleName);
116  }
117  }
118 }
119 
120 
122 (
125 )
126 :
128  owner_(ptf.owner_),
129  baffle_(),
130  dict_(ptf.dict_),
131  extrudeMeshPtr_()
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
137 
139 (
140  const fvPatchFieldMapper& m
141 )
142 {
143  mixedFvPatchScalarField::autoMap(m);
144 }
145 
146 
148 (
149  const fvPatchScalarField& ptf,
150  const labelList& addr
151 )
152 {
153  mixedFvPatchScalarField::rmap(ptf, addr);
154 }
155 
156 
157 void thermalBaffleFvPatchScalarField::createPatchMesh()
158 {
159  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
160 
161  const word regionName(dict_.get<word>("region"));
162 
163  List<polyPatch*> regionPatches(3);
164  List<word> patchNames(regionPatches.size());
165  List<word> patchTypes(regionPatches.size());
166  List<dictionary> dicts(regionPatches.size());
167 
168  patchNames[bottomPatchID] = word("bottom");
169  patchNames[sidePatchID] = word("side");
170  patchNames[topPatchID] = word("top");
171 
172  patchTypes[bottomPatchID] = mappedWallPolyPatch::typeName;
173  patchTypes[topPatchID] = mappedWallPolyPatch::typeName;
174 
175  if (dict_.get<bool>("columnCells"))
176  {
177  patchTypes[sidePatchID] = emptyPolyPatch::typeName;
178  }
179  else
180  {
181  patchTypes[sidePatchID] = polyPatch::typeName;
182  }
183 
184  const mappedPatchBase& mpp =
185  refCast<const mappedPatchBase>(patch().patch(), dict_);
186 
187  const word coupleGroup(mpp.coupleGroup());
188 
189  wordList inGroups(1);
190  inGroups[0] = coupleGroup;
191 
192  dicts[bottomPatchID].add("coupleGroup", coupleGroup);
193  dicts[bottomPatchID].add("inGroups", inGroups);
194  dicts[bottomPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
195 
196  const word coupleGroupSlave =
197  coupleGroup.substr(0, coupleGroup.find('_')) + "_slave";
198 
199  inGroups[0] = coupleGroupSlave;
200  dicts[topPatchID].add("coupleGroup", coupleGroupSlave);
201  dicts[topPatchID].add("inGroups", inGroups);
202  dicts[topPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
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  if (extrudeMeshPtr_.empty())
234  {
236  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
237  << " patchMeshPtr not set."
238  << endl;
239  }
240 }
241 
242 
244 {
245  if (this->updated())
246  {
247  return;
248  }
249 
250  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
251 
252  if (owner_ && thisMesh.name() == polyMesh::defaultRegion)
253  {
254  baffle_->evolve();
255  }
256 
258 }
259 
260 
262 {
264 
265  const fvMesh& thisMesh = patch().boundaryMesh().mesh();
266 
267  if (owner_ && (thisMesh.name() == polyMesh::defaultRegion))
268  {
269  os.writeEntry("extrudeModel", dict_.get<word>("extrudeModel"));
270 
271  os.writeEntry("nLayers", dict_.get<label>("nLayers"));
272 
273  os.writeEntry("expansionRatio", dict_.get<scalar>("expansionRatio"));
274 
275  os.writeEntry("columnCells", dict_.get<Switch>("columnCells"));
276 
277  const word extrudeModel(dict_.get<word>("extrudeModel") + "Coeffs");
278 
280  os << dict_.subDict(extrudeModel) << nl;
281 
282  os.writeEntry("region", dict_.get<word>("region"));
283 
284  os.writeEntry("active", dict_.get<Switch>("active"));
285 
286  os.writeKeyword("thermoType");
287  os << dict_.subDict("thermoType") << nl;
288 
289  os.writeKeyword("mixture");
290  os << dict_.subDict("mixture") << nl;
291 
292  os.writeKeyword("radiation");
293  os << dict_.subDict("radiation") << nl;
294  }
295 }
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
301 (
304 );
305 
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 } // End namespace compressible
310 } // End namespace Foam
311 
312 
313 // ************************************************************************* //
Foam::fvPatchField< scalar >
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:70
mappedWallPolyPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::extrudeModel
Top level extrusion model class.
Definition: extrudeModel.H:76
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:312
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.C:179
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
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:290
patchTypes
wordList patchTypes(nPatches)
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:385
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::regionModels::thermalBaffleModels::thermalBaffleModel
Definition: thermalBaffleModel.H:60
Foam::compressible::thermalBaffleFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: thermalBaffleFvPatchScalarField.C:139
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
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:523
thermalBaffleFvPatchScalarField.H
patchNames
wordList patchNames(nPatches)
compressible
bool compressible
Definition: pEqn.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.C:350
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 a pointer to a new patch created on freestore from.
Definition: polyPatchNew.C:35
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:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
emptyPolyPatch.H
Foam::compressible::thermalBaffleFvPatchScalarField
This boundary condition provides a coupled temperature condition between multiple mesh regions.
Definition: thermalBaffleFvPatchScalarField.H:180
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:43
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::compressible::turbulentTemperatureRadCoupledMixedFvPatchScalarField
Mixed boundary condition for temperature and radiation heat transfer to be used for in multiregion ca...
Definition: turbulentTemperatureRadCoupledMixedFvPatchScalarField.H:141
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:246
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::compressible::thermalBaffleFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: thermalBaffleFvPatchScalarField.C:148
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:243
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
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:266
Foam::compressible::thermalBaffleFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: thermalBaffleFvPatchScalarField.C:261