33 bool Foam::blockMesh::blockLabelsOK
35 const label blockLabel,
37 const cellShape& blockShape
44 if (blockShape[blockI] < 0)
50 "bool Foam::blockMesh::blockLabelsOK"
51 "(const label blockLabel, const pointField& points, "
52 "const cellShape& blockShape)"
53 ) <<
"block " << blockLabel
54 <<
" point label " << blockShape[blockI]
55 <<
" less than zero" <<
endl;
57 else if (blockShape[blockI] >= points.size())
63 "bool Foam::blockMesh::blockLabelsOK"
64 "(const label blockLabel, const pointField& points, "
65 "const cellShape& blockShape)"
66 ) <<
"block " << blockLabel
67 <<
" point label " << blockShape[blockI]
68 <<
" larger than " << points.size() - 1
69 <<
" the largest defined point label" <<
endl;
77 bool Foam::blockMesh::patchLabelsOK
79 const label patchLabel,
98 "bool Foam::blockMesh::patchLabelsOK(...)"
99 ) <<
"patch " << patchLabel
101 <<
" point label " << f[fp]
102 <<
" less than zero" <<
endl;
104 else if (f[fp] >= points.size())
110 "bool Foam::blockMesh::patchLabelsOK(...)"
111 ) <<
"patch " << patchLabel
113 <<
" point label " << f[fp]
114 <<
" larger than " << points.size() - 1
115 <<
" the largest defined point label" <<
endl;
126 Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
128 bool topologyOK =
true;
130 blockMesh& blocks = *
this;
132 word defaultPatchName =
"defaultFaces";
133 word defaultPatchType = emptyPolyPatch::typeName;
138 if (
const dictionary* dictPtr = meshDescription.subDictPtr(
"defaultPatch"))
140 dictPtr->readIfPresent(
"name", defaultPatchName);
141 dictPtr->readIfPresent(
"type", defaultPatchType);
147 pointField tmpBlockPoints(meshDescription.lookup(
"vertices"));
149 if (meshDescription.found(
"edges"))
154 ITstream& edgesStream(meshDescription.lookup(
"edges"));
158 token firstToken(edgesStream);
160 if (firstToken.isLabel())
162 nEdges = firstToken.labelToken();
163 edges_.setSize(nEdges);
167 edgesStream.putBack(firstToken);
171 edgesStream.readBegin(
"edges");
175 token lastToken(edgesStream);
179 lastToken.isPunctuation()
184 if (edges_.size() <= nEdges)
186 edges_.setSize(nEdges + 1);
189 edgesStream.putBack(lastToken);
199 edgesStream >> lastToken;
201 edgesStream.putBack(lastToken);
204 edgesStream.readEnd(
"edges");
208 Info<<
nl <<
"There are no non-linear edges" <<
endl;
214 ITstream& blockDescriptorStream(meshDescription.lookup(
"blocks"));
219 token firstToken(blockDescriptorStream);
221 if (firstToken.isLabel())
223 nBlocks = firstToken.labelToken();
224 blocks.setSize(nBlocks);
228 blockDescriptorStream.putBack(firstToken);
232 blockDescriptorStream.readBegin(
"blocks");
236 token lastToken(blockDescriptorStream);
240 lastToken.isPunctuation()
245 if (blocks.size() <= nBlocks)
247 blocks.setSize(nBlocks + 1);
250 blockDescriptorStream.putBack(lastToken);
261 blockDescriptorStream
266 topologyOK = topologyOK && blockLabelsOK
270 blocks[nBlocks].blockDef().blockShape()
275 blockDescriptorStream >> lastToken;
277 blockDescriptorStream.putBack(lastToken);
280 blockDescriptorStream.readEnd(
"blocks");
291 ITstream& patchStream(meshDescription.lookup(
"patches"));
296 token firstToken(patchStream);
298 if (firstToken.isLabel())
300 nPatches = firstToken.labelToken();
302 tmpBlocksPatches.setSize(nPatches);
303 patchNames.setSize(nPatches);
304 patchTypes.setSize(nPatches);
308 patchStream.putBack(firstToken);
312 patchStream.readBegin(
"patches");
316 token lastToken(patchStream);
320 lastToken.isPunctuation()
325 if (tmpBlocksPatches.size() <=
nPatches)
327 tmpBlocksPatches.setSize(nPatches + 1);
328 patchNames.setSize(nPatches + 1);
329 patchTypes.setSize(nPatches + 1);
332 patchStream.putBack(lastToken);
341 for (label i = 0; i <
nPatches; i++)
343 if (patchNames[nPatches] == patchNames[i])
347 "blockMesh::createTopology(IOdictionary&)"
348 ) <<
"Duplicate patch " << patchNames[
nPatches]
349 <<
" at line " << patchStream.lineNumber()
350 <<
". Exiting !" <<
nl
355 topologyOK = topologyOK && patchLabelsOK
359 tmpBlocksPatches[nPatches]
364 patchStream >> lastToken;
366 patchStream.putBack(lastToken);
369 patchStream.readEnd(
"patches");
375 FatalErrorIn(
"blockMesh::createTopology(IOdictionary&)")
376 <<
"Cannot create mesh due to errors in topology, exiting !" <<
nl
381 Info<<
nl <<
"Creating block mesh topology" <<
endl;
383 PtrList<cellShape> tmpBlockCells(blocks.size());
384 forAll(blocks, blockLabel)
389 new cellShape(blocks[blockLabel].blockDef().blockShape())
392 if (tmpBlockCells[blockLabel].
mag(tmpBlockPoints) < 0.0)
396 "blockMesh::createTopology(IOdictionary&)"
397 ) <<
"negative volume block : " << blockLabel
398 <<
", probably defined inside-out" <<
endl;
406 meshDescription.time(),
407 meshDescription.time().constant(),
416 polyMesh* blockMeshPtr =
new polyMesh
421 meshDescription.time().constant(),
422 meshDescription.time(),
437 checkBlockMesh(*blockMeshPtr);