ENH: add blockFaces.vtp output for blockMesh -write-vtk

This commit is contained in:
Mark Olesen 2021-11-25 19:57:35 +01:00
parent f459b11e24
commit f078643f8c
4 changed files with 79 additions and 10 deletions

View File

@ -75,6 +75,7 @@ Usage
#include "blockMesh.H" #include "blockMesh.H"
#include "foamVtkInternalMeshWriter.H" #include "foamVtkInternalMeshWriter.H"
#include "foamVtkSurfaceWriter.H"
#include "attachPolyTopoChanger.H" #include "attachPolyTopoChanger.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "cyclicPolyPatch.H" #include "cyclicPolyPatch.H"

View File

@ -13,22 +13,25 @@ License
Description Description
VTK output of blockMesh topology blocks VTK output of blockMesh topology blocks
Always write in ASCII since the mesh is small and we want easily
readable output for inspection.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
{ // Common
// Non-legacy and ASCII (mesh is small, want readable output)
const vtk::outputOptions writeOpts = vtk::formatType::INLINE_ASCII;
refPtr<polyMesh> topoMeshPtr(blocks.topology(true)); refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
const polyMesh& topoMesh = topoMeshPtr(); const polyMesh& topoMesh = topoMeshPtr();
const vtk::vtuCells topoCells(topoMesh, writeOpts); // Internal mesh - ie, the blocks
{
const vtk::vtuCells topoCells(topoMesh, vtk::formatType::INLINE_ASCII);
vtk::internalMeshWriter writer vtk::internalMeshWriter writer
( (
topoMesh, topoMesh,
topoCells, topoCells,
writeOpts, vtk::formatType::INLINE_ASCII,
runTime.path()/"blockTopology" runTime.path()/"blockTopology"
); );
@ -99,4 +102,64 @@ Description
} }
// Block boundary faces
{
const label nIntFaces = topoMesh.nInternalFaces();
const label nBndFaces = topoMesh.nBoundaryFaces();
faceList bndFaces
(
faceList::subList(topoMesh.faces(), nBndFaces, nIntFaces)
);
vtk::surfaceWriter writer
(
topoMesh.points(),
bndFaces,
vtk::formatType::INLINE_ASCII,
runTime.path()/"blockFaces"
);
labelList blockIds(nBndFaces, -1);
labelList cellFaceIds(nBndFaces, -1);
labelList patchIds(nBndFaces, -1);
{
const labelList& own = topoMesh.faceOwner();
const cellList& cells = topoMesh.cells();
const polyPatchList& patches = topoMesh.boundaryMesh();
for (const polyPatch& pp : patches)
{
label bndFacei = pp.start() - nIntFaces;
label meshFacei = pp.start();
forAll(pp, bfacei)
{
const label celli = own[meshFacei];
const label cellFacei = cells[celli].find(meshFacei);
blockIds[bndFacei] = celli;
cellFaceIds[bndFacei] = cellFacei;
patchIds[bndFacei] = pp.index();
++bndFacei;
++meshFacei;
}
}
}
Info<< "Writing block boundary faces in vtk format: "
<< args.relativePath(writer.output()).c_str() << endl;
writer.writeGeometry();
writer.beginCellData();
writer.writeCellData("block", blockIds);
writer.writeCellData("face", cellFaceIds);
writer.writeCellData("patch", patchIds);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -123,7 +123,7 @@ cleanCase()
rm -rf system/machines rm -rf system/machines
# Possible blockMesh output # Possible blockMesh output
rm -f blockTopology.vtu blockTopology.obj blockCentres.obj rm -f blockTopology.vtu blockFaces.vtp blockTopology.obj blockCentres.obj
# From mpirunDebug # From mpirunDebug
rm -f gdbCommands mpirun.schema rm -f gdbCommands mpirun.schema

View File

@ -271,7 +271,12 @@ Foam::blockMesh::blockMesh
{ {
// Command-line options have precedence over dictionary setting // Command-line options have precedence over dictionary setting
if (!verbose_) if (verbose_ < 0)
{
// Forced as 'off'
verbose_ = 0;
}
else if (!verbose_)
{ {
verbose_ = meshDict_.getOrDefault("verbose", verboseOutput); verbose_ = meshDict_.getOrDefault("verbose", verboseOutput);
} }