From 7fc943c178a36fcebdff05479d420239c32271c2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 12 Oct 2021 08:47:18 +0200 Subject: [PATCH] ENH: improvements for makeFaMesh, checkFaMesh - added -dry-run, -write-vtk options. Additional mesh information after creation. - add parallel reductions and more information for checkFaMesh ENH: minor cleanup of faPatch internals - align pointLabels and pointEdges creation more closely with coding patterns used in PrimitivePatch - use fileHandler when loading "S0" field. --- .../finiteArea/checkFaMesh/Make/options | 8 +- .../finiteArea/checkFaMesh/checkFaMesh.C | 54 +++--- .../finiteArea/checkFaMesh/faMeshWriteVTK.H | 47 +++++ .../finiteArea/checkFaMesh/printMeshSummary.H | 134 ++++++++++++++ .../finiteArea/makeFaMesh/Make/options | 2 + .../finiteArea/makeFaMesh/decomposeFaFields.H | 49 ++++- .../makeFaMesh/faMeshWriteEdgesOBJ.H | 11 +- .../finiteArea/makeFaMesh/faMeshWriteVTK.H | 47 +++++ .../finiteArea/makeFaMesh/makeFaMesh.C | 55 ++++-- .../finiteArea/makeFaMesh/printMeshSummary.H | 99 ++++++++++ .../faMesh/faBoundaryMesh/faBoundaryMesh.C | 9 +- src/finiteArea/faMesh/faMesh.C | 4 +- .../constraint/cyclic/cyclicFaPatch.C | 37 ++-- .../constraint/processor/processorFaPatch.C | 7 +- .../constraint/processor/processorFaPatch.H | 19 +- .../faMesh/faPatches/faPatch/faPatch.C | 172 +++++++++--------- .../faMesh/faPatches/faPatch/faPatch.H | 15 +- 17 files changed, 579 insertions(+), 190 deletions(-) create mode 100644 applications/utilities/finiteArea/checkFaMesh/faMeshWriteVTK.H create mode 100644 applications/utilities/finiteArea/checkFaMesh/printMeshSummary.H create mode 100644 applications/utilities/finiteArea/makeFaMesh/faMeshWriteVTK.H create mode 100644 applications/utilities/finiteArea/makeFaMesh/printMeshSummary.H diff --git a/applications/utilities/finiteArea/checkFaMesh/Make/options b/applications/utilities/finiteArea/checkFaMesh/Make/options index b69f32d758..2a0d2e96ce 100644 --- a/applications/utilities/finiteArea/checkFaMesh/Make/options +++ b/applications/utilities/finiteArea/checkFaMesh/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/finiteArea/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteArea \ - -lfiniteVolume \ + -lfileFormats \ + -lsurfMesh \ -lmeshTools diff --git a/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C b/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C index d83aaeb7f2..e15b830083 100644 --- a/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C +++ b/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,14 +30,22 @@ Application Description Check a finiteArea mesh -Author +Original Authors Zeljko Tukovic, FAMENA Hrvoje Jasak, Wikki Ltd. \*---------------------------------------------------------------------------*/ -#include "fvCFD.H" -#include "faCFD.H" +#include "Time.H" +#include "argList.H" +#include "faMesh.H" +#include "polyMesh.H" +#include "areaFaMesh.H" +#include "edgeFaMesh.H" +#include "areaFields.H" +#include "edgeFields.H" +#include "processorFaPatch.H" +#include "foamVtkUIndPatchWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,37 +60,32 @@ int main(int argc, char *argv[]) "Check a finiteArea mesh" ); - #include "addRegionOption.H" + argList::addBoolOption + ( + "write-vtk", + "Write mesh as a vtp (vtk) file for display or debugging" + ); + #include "addRegionOption.H" #include "setRootCase.H" #include "createTime.H" - #include "createNamedMesh.H" - #include "createFaMesh.H" + #include "createNamedPolyMesh.H" + + + // Create + faMesh aMesh(mesh); Info<< "Time = " << runTime.timeName() << nl << endl; - // General mesh statistics - Info<< "Number of points: " << aMesh.nPoints() << nl - << "Number of internal edges: " << aMesh.nInternalEdges() << nl - << "Number of edges: " << aMesh.nEdges() << nl - << "Number of faces: " << aMesh.nFaces() << nl - << endl; + #include "printMeshSummary.H" - // Check geometry - Info<< "Face area: min = " << min(aMesh.S().field()) - << " max = " << max(aMesh.S().field()) << nl - << "Internal edge length: min = " - << min(aMesh.magLe().internalField()) << nl - << " max = " << max(aMesh.magLe().internalField()) << nl - << "Edge length: min = " - << min(aMesh.magLe()).value() << nl - << " max = " << max(aMesh.magLe()).value() << nl - << "Face area normals: min = " << min(aMesh.faceAreaNormals().field()) - << " max = " << max(aMesh.faceAreaNormals().field()) << nl - << endl; + if (args.found("write-vtk")) + { + #include "faMeshWriteVTK.H" + } + Info<< "\nEnd\n" << endl; - Info << "\nEnd" << endl; return 0; } diff --git a/applications/utilities/finiteArea/checkFaMesh/faMeshWriteVTK.H b/applications/utilities/finiteArea/checkFaMesh/faMeshWriteVTK.H new file mode 100644 index 0000000000..1df8b4d312 --- /dev/null +++ b/applications/utilities/finiteArea/checkFaMesh/faMeshWriteVTK.H @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM, distributed under GPL-3.0-or-later. + +Description + VTK output of faMesh with some geometric or debug fields + +\*---------------------------------------------------------------------------*/ + +{ + // finiteArea + vtk::uindirectPatchWriter writer + ( + aMesh.patch(), + // vtk::formatType::INLINE_ASCII, + fileName + ( + aMesh.mesh().time().globalPath() / "finiteArea" + ) + ); + + writer.writeGeometry(); + + // CellData + writer.beginCellData(3); + writer.writeProcIDs(); + writer.write("area", aMesh.S().field()); + writer.write("normal", aMesh.faceAreaNormals()); + + // PointData + writer.beginPointData(1); + writer.write("normal", aMesh.pointAreaNormals()); + + Info<< nl + << "Wrote faMesh in vtk format: " << writer.output().name() << nl; +} + + +// ************************************************************************* // diff --git a/applications/utilities/finiteArea/checkFaMesh/printMeshSummary.H b/applications/utilities/finiteArea/checkFaMesh/printMeshSummary.H new file mode 100644 index 0000000000..256d2b1371 --- /dev/null +++ b/applications/utilities/finiteArea/checkFaMesh/printMeshSummary.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM, distributed under GPL-3.0-or-later. + +Description + Summary of faMesh information + +\*---------------------------------------------------------------------------*/ + +{ + const faBoundaryMesh& patches = aMesh.boundary(); + const label nNonProcessor = patches.nNonProcessor(); + const label nPatches = patches.size(); + + Info<< "----------------" << nl + << "Mesh Information" << nl + << "----------------" << nl + << " " << "boundingBox: " << boundBox(aMesh.points()) << nl; + + Info<< " Number of points: " + << returnReduce(aMesh.nPoints(), sumOp