35 template<
class Source>
36 void Foam::blockMesh::checkPatchLabels
39 const word& patchName,
46 face&
f = patchFaces[facei];
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
94 <<
"Point label " <<
f[fp]
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())
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);
159 nbrPatchNames.setSize(
nPatches + 1);
162 patchStream.putBack(lastToken);
169 tmpBlocksPatches[
nPatches] = blockMeshTools::read<face>
183 <<
" at line " << patchStream.lineNumber()
207 <<
"Old-style cyclic definition."
208 <<
" Splitting patch "
210 << halfA <<
" and " << halfB <<
endl
211 <<
" Alternatively use new 'boundary' dictionary syntax."
215 if (tmpBlocksPatches.size() <=
nPatches)
217 tmpBlocksPatches.setSize(
nPatches + 1);
220 nbrPatchNames.setSize(
nPatches + 1);
233 if ((tmpBlocksPatches[
nPatches-1].size() % 2) != 0)
236 <<
"Size of cyclic faces is not a multiple of 2 :"
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,
272 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
273 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
277 const PtrList<entry> patchesInfo
279 meshDescription.lookupOrDefault(
"boundary", PtrList<entry>())
283 tmpBlocksPatches.setSize(patchesInfo.size());
288 const entry& patchInfo = patchesInfo[
patchi];
290 if (!patchInfo.isDict())
293 <<
"Entry " << patchInfo <<
" in boundary section is not a"
294 <<
" valid dictionary."
304 tmpBlocksPatches[
patchi] = blockMeshTools::read<face>
322 void Foam::blockMesh::createCellShapes
327 const blockMesh& blocks = *
this;
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,
375 checkBlockFaceOrientation = meshDescription.lookupOrDefault<Switch>
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_)
417 edges_.transfer(edges);
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_)
439 faces_.transfer(faces);
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;
507 meshDescription.time(),
508 meshDescription.time().constant(),
537 <<
"' (read from boundary file)"
548 blockMeshPtr =
new polyMesh
553 meshDescription.time().constant(),
554 meshDescription.time(),
571 && blockMeshPtr->boundaryMesh().findIndex(defaultPatchName) != -1
574 defaultPatchError(defaultPatchName, meshDescription);
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().findIndex(defaultPatchName) != -1
622 defaultPatchError(defaultPatchName, meshDescription);
626 check(*blockMeshPtr, meshDescription);
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
label size() const
Return the number of elements in the UPtrList.
const T & operator[](const label) const
Return element const reference.
const blockFaceList & faces() const
Return the curved faces.
const pointField & points() const
The points for the entire mesh.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void set(entry *)
Assign a new entry, overwrite any existing entry.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Mesh consisting of general polyhedral cells.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static const word null
An empty word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
List< word > wordList
A List of words.
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const word & regionName(const solver ®ion)
vectorField pointField
pointField is a vectorField.
PtrList< block > blockList
A PtrList of blocks.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
List< faceList > faceListList
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.
wordList patchTypes(nPatches)
wordList patchNames(nPatches)
PtrList< dictionary > patchDicts