Skip to content
Snippets Groups Projects
Commit fec5093c authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: add blockMesh -write-vtk option

- generates a vtk file in an ASCII, XML format (blockTopology.vtu).

  More information than the equivalent obj file since it includes
  connectivity, cell shapes and cell IDs (equivalent to the block
  numbers).
parent 11ff01f4
Branches
Tags
No related merge requests found
......@@ -46,6 +46,9 @@ Usage
- \par -write-obj
Write topology as a set of edges in OBJ format and exit.
- \par -write-vtk
Write topology as VTK file (xml, ascii) and exit.
- \par -merge-points
Merge points instead of default topological merge
......@@ -71,6 +74,7 @@ Usage
#include "IOPtrList.H"
#include "blockMesh.H"
#include "foamVtkInternalMeshWriter.H"
#include "attachPolyTopoChanger.H"
#include "polyTopoChange.H"
#include "emptyPolyPatch.H"
......@@ -122,6 +126,12 @@ int main(int argc, char *argv[])
);
argList::addOptionCompat("write-obj", {"blockTopology", 1912});
argList::addBoolOption
(
"write-vtk",
"Write topology as VTK file and exit"
);
argList::addBoolOption
(
"merge-points",
......@@ -226,7 +236,7 @@ int main(int argc, char *argv[])
{
OFstream os(runTime.path()/"blockTopology.obj");
Info<< "Writing block structure as obj format: "
Info<< "Writing block structure in obj format: "
<< os.name().name() << endl;
blocks.writeTopology(os);
......@@ -236,7 +246,7 @@ int main(int argc, char *argv[])
{
OFstream os(runTime.path()/"blockCentres.obj");
Info<< "Writing block centres as obj format: "
Info<< "Writing block centres in obj format: "
<< os.name().name() << endl;
for (const point& cc : blocks.topology().cellCentres())
......@@ -246,6 +256,35 @@ int main(int argc, char *argv[])
}
}
if (args.found("write-vtk"))
{
quickExit = true;
// non-legacy and ASCII (mesh is small, want readable output)
const vtk::outputOptions writeOpts = vtk::formatType::INLINE_ASCII;
Info<< nl;
const polyMesh& topoMesh = blocks.topology();
const vtk::vtuCells topoCells(topoMesh, writeOpts);
vtk::internalMeshWriter writer
(
topoMesh,
topoCells,
writeOpts,
runTime.path()/"blockTopology"
);
Info<< "Writing block topology in vtk format: "
<< args.relativePath(writer.output()).c_str() << endl;
writer.writeGeometry();
writer.beginCellData();
writer.writeCellIDs();
}
if (quickExit)
{
Info<< "\nEnd\n" << endl;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment