65 int main(
int argc,
char *argv[])
73 "write block edges and centres as .obj files"
78 "keep the existing files in the polyMesh"
85 " For a given block, the correspondence between the ordering of\n"
86 " vertex labels and face labels is shown below.\n"
87 " For vertex numbering in the sequence 0 to 7 (block, centre):\n"
88 " faces 0 (f0) and 1 are left and right, respectively;\n"
89 " faces 2 and 3 are front and back; \n"
90 " and faces 4 and 5 are bottom and top::\n"
109 const word dictName(
"blockMeshDict");
130 if (
exists(polyMeshPath/dictName))
132 Info<<
"Not deleting polyMesh directory " <<
nl
133 <<
" " << polyMeshPath <<
nl
134 <<
" because it contains " << dictName <<
endl;
138 Info<<
"Deleting polyMesh directory" <<
nl
139 <<
" " << polyMeshPath <<
endl;
150 if (!meshDictIO.headerOk())
153 <<
"Cannot find file " << meshDictIO.relativeObjectPath()
158 Info<<
"Creating block mesh from\n "
159 << meshDictIO.relativeObjectPath() <<
endl;
169 fileName objMeshFile(
"blockTopology.obj");
171 OFstream str(runTime.path()/objMeshFile);
173 Info<<
nl <<
"Dumping block structure as Lightwave obj format"
174 <<
" to " << objMeshFile <<
endl;
176 blocks.writeTopology(str);
181 fileName objCcFile(
"blockCentres.obj");
183 OFstream str(runTime.path()/objCcFile);
185 Info<<
nl <<
"Dumping block centres as Lightwave obj format"
186 <<
" to " << objCcFile <<
endl;
188 const polyMesh& topo = blocks.topology();
192 forAll(cellCentres, celli)
195 const point& cc = cellCentres[celli];
197 str <<
"v " << cc.
x() <<
' ' << cc.
y() <<
' ' << cc.
z() <<
nl;
207 Info<<
nl <<
"Creating polyMesh from blockMesh" <<
endl;
219 clone(blocks.points()),
230 if (meshDict.found(
"mergePatchPairs"))
234 meshDict.lookup(
"mergePatchPairs")
237 if (patchPairNames.size())
239 const word oldInstance = mesh.pointsInstance();
241 mesh.setInstance(oldInstance);
246 Info<<
nl <<
"No patch pairs to merge" <<
endl;
249 label nZones = blocks.numZonedBlocks();
269 const block&
b = blocks[blockI];
271 const word& zoneName =
b.zoneName();
279 if (iter == zoneMap.end())
283 Info<<
" " << zoneI <<
'\t' << zoneName <<
endl;
285 zoneMap.insert(zoneName, zoneI);
294 zoneCells[zoneI].append(celli++);
299 celli += blockCells.
size();
308 label zoneI = iter();
313 zoneCells[zoneI].
shrink(),
318 mesh.pointZones().setSize(0);
319 mesh.faceZones().setSize(0);
320 mesh.cellZones().setSize(0);
328 bool hasCyclic =
false;
340 Info<<
nl <<
"Detected cyclic patches; ordering boundary faces"
342 const word oldInstance = mesh.instance();
344 meshMod.changeMesh(mesh);
345 mesh.setInstance(oldInstance);
358 <<
"Failed writing polyMesh."
367 Info<<
"----------------" <<
nl
368 <<
"Mesh Information" <<
nl
369 <<
"----------------" <<
nl
370 <<
" " <<
"boundingBox: " <<
boundBox(mesh.points()) <<
nl
371 <<
" " <<
"nPoints: " << mesh.nPoints() <<
nl
372 <<
" " <<
"nCells: " << mesh.nCells() <<
nl
373 <<
" " <<
"nFaces: " << mesh.nFaces() <<
nl
374 <<
" " <<
"nInternalFaces: " << mesh.nInternalFaces() <<
nl;
376 Info<<
"----------------" <<
nl
378 <<
"----------------" <<
nl;
385 <<
" (start: " <<
p.start()
386 <<
" size: " <<
p.
size()
387 <<
") name: " <<
p.
name()
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
void shrink()
Shrink the allocated table to approx. twice number of elements.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
static unsigned int defaultPrecision()
Return the default precision.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
static void noParallel()
Remove the parallel options.
static void removeOption(const word &opt)
Remove option from validOptions and from optionUsage.
A multi-block mesh generator.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
A bounding box defined in terms of the points at its extremities.
A class for handling file names.
Class to stitch mesh by merging patch-pairs.
Mesh consisting of general polyhedral cells.
static word defaultRegion
Return the default region name.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
A patch is a list of labels that address the faces in the global face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const vectorField & cellCentres() const
Templated form of IOobject providing type information for file reading and header type checking.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
const fvPatchList & patches
errorManipArg< error, int > exit(error &err, const int errNo=1)
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)
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
IOobject systemDictIO(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
bool rmDir(const fileName &)
Remove a directory and its contents.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Foam::argList args(argc, argv)