mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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).
This commit is contained in:
@ -46,6 +46,9 @@ Usage
|
|||||||
- \par -write-obj
|
- \par -write-obj
|
||||||
Write topology as a set of edges in OBJ format and exit.
|
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
|
- \par -merge-points
|
||||||
Merge points instead of default topological merge
|
Merge points instead of default topological merge
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ Usage
|
|||||||
#include "IOPtrList.H"
|
#include "IOPtrList.H"
|
||||||
|
|
||||||
#include "blockMesh.H"
|
#include "blockMesh.H"
|
||||||
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
#include "attachPolyTopoChanger.H"
|
#include "attachPolyTopoChanger.H"
|
||||||
#include "polyTopoChange.H"
|
#include "polyTopoChange.H"
|
||||||
#include "emptyPolyPatch.H"
|
#include "emptyPolyPatch.H"
|
||||||
@ -122,6 +126,12 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
argList::addOptionCompat("write-obj", {"blockTopology", 1912});
|
argList::addOptionCompat("write-obj", {"blockTopology", 1912});
|
||||||
|
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"write-vtk",
|
||||||
|
"Write topology as VTK file and exit"
|
||||||
|
);
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"merge-points",
|
"merge-points",
|
||||||
@ -226,7 +236,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
OFstream os(runTime.path()/"blockTopology.obj");
|
OFstream os(runTime.path()/"blockTopology.obj");
|
||||||
|
|
||||||
Info<< "Writing block structure as obj format: "
|
Info<< "Writing block structure in obj format: "
|
||||||
<< os.name().name() << endl;
|
<< os.name().name() << endl;
|
||||||
|
|
||||||
blocks.writeTopology(os);
|
blocks.writeTopology(os);
|
||||||
@ -236,7 +246,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
OFstream os(runTime.path()/"blockCentres.obj");
|
OFstream os(runTime.path()/"blockCentres.obj");
|
||||||
|
|
||||||
Info<< "Writing block centres as obj format: "
|
Info<< "Writing block centres in obj format: "
|
||||||
<< os.name().name() << endl;
|
<< os.name().name() << endl;
|
||||||
|
|
||||||
for (const point& cc : blocks.topology().cellCentres())
|
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)
|
if (quickExit)
|
||||||
{
|
{
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user