35 template<
class Source>
36 void Foam::blockMesh::checkPatchLabels
39 const word& patchName,
46 face& f = patchFaces[facei];
52 const label bi = f[0];
53 const label fi = f[1];
58 <<
"Block index out of range for patch face " << f <<
nl 59 <<
" Number of blocks = " <<
size()
60 <<
", index = " << f[0] <<
nl 61 <<
" on patch " << patchName <<
", face " << facei
64 else if (fi >=
operator[](bi).blockShape().
faces().
size())
67 <<
"Block face index out of range for patch face " << f
69 <<
" Number of block faces = " 71 <<
", index = " << f[1] <<
nl 72 <<
" on patch " << patchName <<
", face " << facei
87 <<
"Negative point label " << f[fp] <<
nl 88 <<
" on patch " << patchName <<
", face " << facei
91 else if (f[fp] >= points.size())
94 <<
"Point label " << f[fp]
95 <<
" out of range 0.." << points.size() - 1 <<
nl 96 <<
" on patch " << patchName <<
", face " << facei
105 void Foam::blockMesh::readPatches
107 const dictionary& meshDescription,
115 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
116 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
119 ITstream& patchStream(meshDescription.lookup(
"patches"));
124 token firstToken(patchStream);
126 if (firstToken.isLabel())
128 nPatches = firstToken.labelToken();
130 tmpBlocksPatches.setSize(nPatches);
131 patchNames.setSize(nPatches);
132 patchTypes.setSize(nPatches);
133 nbrPatchNames.setSize(nPatches);
137 patchStream.putBack(firstToken);
141 patchStream.readBegin(
"patches");
145 token lastToken(patchStream);
149 lastToken.isPunctuation()
154 if (tmpBlocksPatches.size() <=
nPatches)
156 tmpBlocksPatches.setSize(nPatches + 1);
157 patchNames.setSize(nPatches + 1);
158 patchTypes.setSize(nPatches + 1);
159 nbrPatchNames.setSize(nPatches + 1);
162 patchStream.putBack(lastToken);
169 tmpBlocksPatches[
nPatches] = blockMeshTools::read<face>
179 if (patchNames[nPatches] == patchNames[i])
182 <<
"Duplicate patch " << patchNames[
nPatches]
183 <<
" at line " << patchStream.lineNumber()
191 patchNames[nPatches],
193 tmpBlocksPatches[nPatches]
201 if (patchTypes[nPatches-1] == cyclicPolyPatch::typeName)
203 word halfA = patchNames[nPatches-1] +
"_half0";
204 word halfB = patchNames[nPatches-1] +
"_half1";
207 <<
"Old-style cyclic definition." 208 <<
" Splitting patch " 209 << patchNames[nPatches-1] <<
" into two halves " 210 << halfA <<
" and " << halfB << endl
211 <<
" Alternatively use new 'boundary' dictionary syntax." 215 if (tmpBlocksPatches.size() <=
nPatches)
217 tmpBlocksPatches.setSize(nPatches + 1);
218 patchNames.setSize(nPatches + 1);
219 patchTypes.setSize(nPatches + 1);
220 nbrPatchNames.setSize(nPatches + 1);
224 patchNames[nPatches-1] = halfA;
225 nbrPatchNames[nPatches-1] = halfB;
228 patchTypes[
nPatches] = patchTypes[nPatches-1];
233 if ((tmpBlocksPatches[nPatches-1].
size() % 2) != 0)
236 <<
"Size of cyclic faces is not a multiple of 2 :" 237 << tmpBlocksPatches[nPatches-1]
240 label sz = tmpBlocksPatches[nPatches-1].size()/2;
241 faceList unsplitFaces(tmpBlocksPatches[nPatches-1],
true);
242 tmpBlocksPatches[nPatches-1] =
faceList 244 SubList<face>(unsplitFaces, sz)
248 SubList<face>(unsplitFaces, sz, sz)
254 patchStream >> lastToken;
256 patchStream.putBack(lastToken);
259 patchStream.readEnd(
"patches");
263 void Foam::blockMesh::readBoundary
265 const dictionary& meshDescription,
268 PtrList<dictionary>& patchDicts
272 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
273 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
277 const PtrList<entry> patchesInfo
279 meshDescription.lookup(
"boundary")
282 patchNames.setSize(patchesInfo.size());
283 tmpBlocksPatches.setSize(patchesInfo.size());
284 patchDicts.setSize(patchesInfo.size());
286 forAll(tmpBlocksPatches, patchi)
288 const entry& patchInfo = patchesInfo[
patchi];
290 if (!patchInfo.isDict())
293 <<
"Entry " << patchInfo <<
" in boundary section is not a" 294 <<
" valid dictionary." 298 patchNames[
patchi] = patchInfo.keyword();
301 patchDicts.set(patchi,
new dictionary(patchInfo.dict()));
304 tmpBlocksPatches[
patchi] = blockMeshTools::read<face>
306 patchDicts[
patchi].lookup(
"faces"),
322 void Foam::blockMesh::createCellShapes
327 const blockMesh& blocks = *
this;
329 tmpBlockCells.setSize(blocks.size());
332 tmpBlockCells[blocki] = blocks[blocki].blockShape();
341 const IOdictionary& meshDescription,
342 const word& regionName
347 "checkBlockFaceOrientation",
353 word defaultPatchName =
"defaultFaces";
354 word defaultPatchType = emptyPolyPatch::typeName;
359 if (
const dictionary* dictPtr = meshDescription.subDictPtr(
"defaultPatch"))
361 dictPtr->readIfPresent(
"name", defaultPatchName);
362 dictPtr->readIfPresent(
"type", defaultPatchType);
366 if (!meshDescription.readIfPresent(
"convertToMeters", scaleFactor_))
368 meshDescription.readIfPresent(
"scale", scaleFactor_);
372 if (meshDescription.found(
"edges"))
376 Info<<
"Creating block edges" <<
endl;
381 meshDescription.lookup(
"edges"),
382 blockEdge::iNew(meshDescription, geometry_, vertices_)
387 else if (verboseOutput)
389 Info<<
"No non-linear block edges defined" <<
endl;
394 if (meshDescription.found(
"faces"))
398 Info<<
"Creating block faces" <<
endl;
403 meshDescription.lookup(
"faces"),
404 blockFace::iNew(meshDescription, geometry_)
409 else if (verboseOutput)
411 Info<<
"No non-planar block faces defined" <<
endl;
418 Info<<
"Creating topology blocks" <<
endl;
423 meshDescription.lookup(
"blocks"),
424 block::iNew(meshDescription, vertices_, edges_, faces_)
432 polyMesh* blockMeshPtr =
nullptr;
438 Info<<
"Creating topology patches" <<
endl;
441 if (meshDescription.found(
"patches"))
443 Info<<
nl <<
"Reading patches section" <<
endl;
459 Info<<
nl <<
"Creating block mesh topology" <<
endl;
462 createCellShapes(tmpBlockCells);
465 Info<<
nl <<
"Reading physicalType from existing boundary file" <<
endl;
467 PtrList<dictionary>
patchDicts(patchNames.size());
472 meshDescription.time(),
473 meshDescription.time().constant(),
483 forAll(patchDicts, patchi)
485 if (!patchDicts.set(patchi))
487 patchDicts.set(patchi,
new dictionary());
490 dictionary& dict = patchDicts[
patchi];
493 if (!dict.found(
"type"))
495 dict.add(
"type", patchTypes[patchi],
false);
497 else if (word(dict.lookup(
"type")) != patchTypes[patchi])
500 <<
"For patch " << patchNames[
patchi]
501 <<
" overriding type '" << patchTypes[
patchi]
502 <<
"' with '" << word(dict.lookup(
"type"))
503 <<
"' (read from boundary file)" 510 dict.set(
"neighbourPatch", nbrPatchNames[patchi]);
514 blockMeshPtr =
new polyMesh
519 meshDescription.time().constant(),
520 meshDescription.time(),
534 else if (meshDescription.found(
"boundary"))
548 Info<<
nl <<
"Creating block mesh topology" <<
endl;
551 createCellShapes(tmpBlockCells);
553 blockMeshPtr =
new polyMesh
558 meshDescription.time().constant(),
559 meshDescription.time(),
574 check(*blockMeshPtr, meshDescription);
List< faceList > faceListList
#define forAll(list, i)
Loop across all elements in list.
const blockFaceList & faces() const
Return the curved faces.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
wordList patchTypes(nPatches)
const T & operator[](const label) const
Return element const reference.
PtrList< block > blockList
A PtrList of blocks.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
static const word null
An empty word.
const blockEdgeList & edges() const
Return the curved edges.
PtrList< dictionary > patchDicts() const
Get patch information from the topology mesh.
void preservePatchTypes(const objectRegistry &obr, const word &meshInstance, const fileName &meshDir, const wordList &patchNames, PtrList< dictionary > &patchDicts, const word &defaultFacesName, word &defaultFacesType)
Preserve patch types.
static Switch checkBlockFaceOrientation
Switch checking block face orientation.
label size() const
Return the number of elements in the UPtrList.
List< word > wordList
A List of words.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
void transfer(PtrList< T > &)
Transfer the contents of the argument PtrList into this PtrList.
Mesh consisting of general polyhedral cells.
wordList patchNames() const
Return patch names.