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