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
329 tmpBlockCells.setSize(blocks.size());
332 tmpBlockCells[blocki] = blocks[blocki].blockShape();
339 void Foam::blockMesh::defaultPatchError
341 const word& defaultPatchName,
342 const dictionary& meshDescription
350 <<
"The 'defaultPatch' type must be specified" 351 " for the '" << defaultPatchName <<
"' patch, e.g. for snappyHexMesh" 355 " name default; // optional\n" 358 <<
"or for 2D meshes" <<
nl <<
nl 361 " name frontAndBack; // optional\n" 371 const IOdictionary& meshDescription,
372 const word& regionName
377 "checkBlockFaceOrientation",
383 word defaultPatchName =
"defaultFaces";
384 word defaultPatchType = emptyPolyPatch::typeName;
385 bool defaultPatchTypeSet =
false;
390 if (
const dictionary* dictPtr = meshDescription.subDictPtr(
"defaultPatch"))
392 dictPtr->readIfPresent(
"name", defaultPatchName);
393 defaultPatchType = dictPtr->lookup<word>(
"type");
394 defaultPatchTypeSet =
true;
398 if (!meshDescription.readIfPresent(
"convertToMeters", scaleFactor_))
400 meshDescription.readIfPresent(
"scale", scaleFactor_);
404 if (meshDescription.found(
"edges"))
408 Info<<
"Creating block edges" <<
endl;
413 meshDescription.lookup(
"edges"),
414 blockEdge::iNew(meshDescription, geometry_, vertices_)
419 else if (verboseOutput)
421 Info<<
"No non-linear block edges defined" <<
endl;
426 if (meshDescription.found(
"faces"))
430 Info<<
"Creating block faces" <<
endl;
435 meshDescription.lookup(
"faces"),
436 blockFace::iNew(meshDescription, geometry_)
441 else if (verboseOutput)
443 Info<<
"No non-planar block faces defined" <<
endl;
450 Info<<
"Creating topology blocks" <<
endl;
455 meshDescription.lookup(
"blocks"),
456 block::iNew(meshDescription, vertices_, edges_, faces_)
464 polyMesh* blockMeshPtr =
nullptr;
470 Info<<
"Creating topology patches" <<
endl;
473 if (meshDescription.found(
"patches"))
476 <<
"Reading patches section" <<
nl 477 <<
" The 'patches' entry is deprecated and has been superseded" 478 <<
" by the more consistent and general 'boundary' entry." 495 Info<<
nl <<
"Creating block mesh topology" <<
endl;
498 createCellShapes(tmpBlockCells);
500 Info<<
nl <<
"Reading physicalType from existing boundary file" <<
endl;
502 PtrList<dictionary>
patchDicts(patchNames.size());
507 meshDescription.time(),
508 meshDescription.time().constant(),
517 forAll(patchDicts, patchi)
519 if (!patchDicts.set(patchi))
521 patchDicts.set(patchi,
new dictionary());
524 dictionary& dict = patchDicts[
patchi];
527 if (!dict.found(
"type"))
529 dict.add(
"type", patchTypes[patchi],
false);
531 else if (word(dict.lookup(
"type")) != patchTypes[patchi])
534 <<
"For patch " << patchNames[
patchi]
535 <<
" overriding type '" << patchTypes[
patchi]
536 <<
"' with '" << word(dict.lookup(
"type"))
537 <<
"' (read from boundary file)" 544 dict.set(
"neighbourPatch", nbrPatchNames[patchi]);
548 blockMeshPtr =
new polyMesh
553 meshDescription.time().constant(),
554 meshDescription.time(),
571 && blockMeshPtr->boundaryMesh().findPatchID(defaultPatchName) != -1
574 defaultPatchError(defaultPatchName, meshDescription);
577 else if (meshDescription.found(
"boundary"))
591 Info<<
nl <<
"Creating block mesh topology" <<
endl;
594 createCellShapes(tmpBlockCells);
596 blockMeshPtr =
new polyMesh
601 meshDescription.time().constant(),
602 meshDescription.time(),
619 && blockMeshPtr->boundaryMesh().findPatchID(defaultPatchName) != -1
622 defaultPatchError(defaultPatchName, meshDescription);
626 check(*blockMeshPtr, meshDescription);
List< faceList > faceListList
#define forAll(list, i)
Loop across all elements in list.
const blockFaceList & faces() const
Return the curved faces.
FvWallInfoData< WallInfo, label > 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.
blockMesh(const IOdictionary &, const word ®ionName)
Construct from IOdictionary.
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.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Mesh consisting of general polyhedral cells.
wordList patchNames() const
Return patch names.