38 template<
class Source>
39 void Foam::blockMesh::checkPatchLabels
42 const word& patchName,
49 face&
f = patchFaces[facei];
55 const label bi =
f[0];
56 const label fi =
f[1];
61 <<
"Block index out of range for patch face " <<
f <<
nl
62 <<
" Number of blocks = " << size()
63 <<
", index = " <<
f[0] <<
nl
64 <<
" on patch " << patchName <<
", face " << facei
67 else if (fi >=
operator[](bi).blockShape().
faces().size())
70 <<
"Block face index out of range for patch face " <<
f
72 <<
" Number of block faces = "
73 << operator[](bi).blockShape().faces().size()
74 <<
", index = " <<
f[1] <<
nl
75 <<
" on patch " << patchName <<
", face " << facei
80 f = operator[](bi).blockShape().faces()[fi];
85 for (
const label pointi :
f)
87 if (pointi < 0 || pointi >=
points.size())
90 <<
"Point label " << pointi
91 <<
" out of range 0.." <<
points.size() - 1 <<
nl
92 <<
" on patch " << patchName <<
", face " << facei
101 void Foam::blockMesh::readPatches
103 const dictionary& meshDescription,
111 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
112 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
115 ITstream& patchStream(meshDescription.lookup(
"patches"));
120 token firstToken(patchStream);
122 if (firstToken.isLabel())
133 patchStream.putBack(firstToken);
137 patchStream.readBegin(
"patches");
141 token lastToken(patchStream);
145 lastToken.isPunctuation()
150 if (tmpBlocksPatches.size() <=
nPatches)
152 tmpBlocksPatches.setSize(
nPatches + 1);
155 nbrPatchNames.setSize(
nPatches + 1);
158 patchStream.putBack(lastToken);
165 tmpBlocksPatches[
nPatches] = blockMeshTools::read<face>
173 for (label i = 0; i <
nPatches; i++)
179 <<
" at line " << patchStream.lineNumber()
203 <<
"Old-style cyclic definition."
204 <<
" Splitting patch "
206 << halfA <<
" and " << halfB <<
endl
207 <<
" Alternatively use new 'boundary' dictionary syntax."
211 if (tmpBlocksPatches.size() <=
nPatches)
213 tmpBlocksPatches.setSize(
nPatches + 1);
216 nbrPatchNames.setSize(
nPatches + 1);
229 if ((tmpBlocksPatches[
nPatches-1].size() % 2) != 0)
232 <<
"Size of cyclic faces is not a multiple of 2 :"
236 label sz = tmpBlocksPatches[
nPatches-1].size()/2;
240 SubList<face>(unsplitFaces, sz)
244 SubList<face>(unsplitFaces, sz, sz)
250 patchStream >> lastToken;
252 patchStream.putBack(lastToken);
255 patchStream.readEnd(
"patches");
259 void Foam::blockMesh::readBoundary
261 const dictionary& meshDescription,
268 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
269 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
273 const PtrList<entry> patchesInfo
275 meshDescription.lookup(
"boundary")
279 tmpBlocksPatches.setSize(patchesInfo.size());
282 forAll(tmpBlocksPatches, patchi)
284 const entry& patchInfo = patchesInfo[patchi];
286 if (!patchInfo.isDict())
289 <<
"Entry " << patchInfo <<
" in boundary section is not a"
290 <<
" valid dictionary."
297 patchDicts.set(patchi,
new dictionary(patchInfo.dict()));
300 tmpBlocksPatches[patchi] = blockMeshTools::read<face>
312 tmpBlocksPatches[patchi]
318 void Foam::blockMesh::createCellShapes
323 const blockMesh& blocks = *
this;
325 tmpBlockCells.setSize(blocks.size());
328 tmpBlockCells[blocki] = blocks[blocki].blockShape();
337 const IOdictionary& meshDescription,
343 word defaultPatchName =
"defaultFaces";
344 word defaultPatchType = emptyPolyPatch::typeName;
349 if (
const dictionary* dictPtr = meshDescription.findDict(
"defaultPatch"))
351 dictPtr->readIfPresent(
"name", defaultPatchName);
352 dictPtr->readIfPresent(
"type", defaultPatchType);
356 meshDescription.readIfPresentCompat
359 {{
"convertToMeters", 1012}},
364 if (scaleFactor_ <= 0)
370 if (meshDescription.found(
"edges"))
374 Info<<
"Creating block edges" <<
endl;
379 meshDescription.lookup(
"edges"),
380 blockEdge::iNew(meshDescription, geometry_, vertices_)
387 Info<<
"No non-linear block edges defined" <<
endl;
392 if (meshDescription.found(
"faces"))
396 Info<<
"Creating block faces" <<
endl;
401 meshDescription.lookup(
"faces"),
402 blockFace::iNew(meshDescription, geometry_)
409 Info<<
"No non-planar block faces defined" <<
endl;
416 Info<<
"Creating topology blocks" <<
endl;
421 meshDescription.lookup(
"blocks"),
422 block::iNew(meshDescription, vertices_, edges_, faces_)
429 autoPtr<polyMesh> blockMeshPtr;
435 Info<<
"Creating topology patches" <<
endl;
438 if (meshDescription.found(
"patches"))
440 Info<<
nl <<
"Reading patches section" <<
endl;
456 Info<<
nl <<
"Creating block mesh topology" <<
endl;
459 createCellShapes(tmpBlockCells);
462 Info<<
nl <<
"Reading physicalType from existing boundary file" <<
endl;
469 meshDescription.time(),
470 meshDescription.time().constant(),
499 <<
"' with '" <<
dict.
get<word>(
"type")
500 <<
"' (read from boundary file)"
507 dict.
set(
"neighbourPatch", nbrPatchNames[patchi]);
516 meshDescription.time().constant(),
517 meshDescription.time(),
531 else if (meshDescription.found(
"boundary"))
545 Info<<
nl <<
"Creating block mesh topology" <<
endl;
548 createCellShapes(tmpBlockCells);
555 meshDescription.time().constant(),
556 meshDescription.time(),
571 check(*blockMeshPtr, meshDescription);