45 template<
class Source>
49 const word& patchName,
55 const label nBlocks = blocks.
size();
59 face&
f = patchFaces[facei];
65 const label bi =
f[0];
66 const label fi =
f[1];
68 if (bi < 0 || bi >= nBlocks)
71 <<
"Block index out of range." 72 <<
" Patch face (" << bi <<
' ' << fi <<
")\n" 73 <<
" Number of blocks = " << nBlocks
74 <<
", block index = " << bi <<
nl 75 <<
" on patch " << patchName <<
", face " << facei
78 else if (fi >= blocks[bi].blockShape().nFaces())
81 <<
"Block face index out of range." 82 <<
" Patch face (" << bi <<
' ' << fi <<
")\n" 83 <<
" Number of block faces = " 84 << blocks[bi].blockShape().nFaces()
85 <<
", face index = " << fi <<
nl 86 <<
" on patch " << patchName <<
", face " << facei
91 f = blocks[bi].blockShape().face(fi);
96 for (
const label pointi :
f)
98 if (pointi < 0 || pointi >=
nPoints)
101 <<
"Point label " << pointi
102 <<
" out of range 0.." << (
nPoints - 1) <<
nl 103 <<
" on patch " << patchName <<
", face " << facei
116 void Foam::blockMesh::readPatches
118 const dictionary& meshDescription,
126 dictionary varDict(meshDescription.subOrEmptyDict(
"namedVertices"));
127 varDict.merge(meshDescription.subOrEmptyDict(
"namedBlocks"));
130 ITstream& patchStream = meshDescription.lookup(
"patches");
135 if (patchStream.peek().isLabel())
146 patchStream.readBegin(
"patches");
150 token lastToken(patchStream);
153 if (tmpBlocksPatches.size() <=
nPatches)
155 tmpBlocksPatches.setSize(
nPatches + 1);
158 nbrPatchNames.setSize(
nPatches + 1);
161 patchStream.putBack(lastToken);
168 tmpBlocksPatches[
nPatches] = blockMeshTools::read<face>
176 for (label i = 0; i <
nPatches; i++)
182 <<
" 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);
236 <<
"Size of cyclic faces is not a multiple of 2 :" 240 label sz = tmpBlocksPatches[
nPatches-1].size()/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.lookup(
"boundary")
283 tmpBlocksPatches.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." 304 tmpBlocksPatches[patchi] = blockMeshTools::read<face>
317 tmpBlocksPatches[patchi]
325 const blockMesh& blocks = *
this;
331 shapes[blocki] = blocks[blocki].blockShape();
341 Foam::blockMesh::createTopology
343 const IOdictionary& meshDescription,
347 word defaultPatchName =
"defaultFaces";
348 word defaultPatchType = emptyPolyPatch::typeName;
353 if (
const dictionary* dictptr = meshDescription.findDict(
"defaultPatch"))
355 dictptr->readIfPresent(
"name", defaultPatchName);
356 dictptr->readIfPresent(
"type", defaultPatchType);
361 readPointTransforms(meshDescription);
364 if (meshDescription.found(
"edges"))
368 Info<<
"Creating block edges" <<
endl;
373 meshDescription.lookup(
"edges"),
374 blockEdge::iNew(meshDescription, geometry_, vertices_)
384 Info<<
"No non-linear block edges defined" <<
endl;
390 if (meshDescription.found(
"faces"))
394 Info<<
"Creating block faces" <<
endl;
399 meshDescription.lookup(
"faces"),
400 blockFace::iNew(meshDescription, geometry_)
410 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_)
440 Info<<
nl <<
"Creating topology patches - ";
443 if (meshDescription.found(
"patches"))
447 Info<<
"from patches section" <<
endl;
465 <<
"Reading physicalType from existing boundary file" <<
endl;
472 meshDescription.time(),
473 meshDescription.time().constant(),
502 <<
"' with '" <<
dict.
get<word>(
"type")
503 <<
"' (read from boundary file)" 508 if (!nbrPatchNames[patchi].empty())
510 dict.
set(
"neighbourPatch", nbrPatchNames[patchi]);
514 else if (meshDescription.found(
"boundary"))
518 Info<<
"from boundary section" <<
endl;
533 Info<<
"with default boundary only!!" <<
endl;
540 Info<<
nl <<
"Creating block mesh topology";
541 if (hasPointTransforms())
543 Info<<
" - scaling/transform applied later";
553 meshDescription.time().constant(),
554 meshDescription.time(),
568 check(*blockMeshPtr, meshDescription);
wordList patchNames() const
Return the patch names.
List< faceList > faceListList
List of faceList.
void size(const label n)
Older name for setAddressableSize.
static void rewritePatchLabels(const Source &source, const word &patchName, const PtrList< block > &blocks, const label nPoints, faceList &patchFaces)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
PtrList< block > blockList
A PtrList of blocks.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cellShape > cellShapeList
List of cellShape.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
A class for handling words, derived from Foam::string.
label size() const noexcept
The number of entries in the list.
wordList patchNames(nPatches)
static void check(const int retVal, const char *what)
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.
List< word > wordList
List of word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
PtrList< dictionary > patchDicts
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Do not request registration (bool: false)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...