diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options index 89496232cc..3ce62891e7 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options @@ -17,7 +17,6 @@ EXE_INC = \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ @@ -27,7 +26,6 @@ EXE_INC = \ LIB_LIBS = \ ${CGAL_LIBS} \ -lmeshTools \ - -lsampling \ -ldecompose \ -ldynamicMesh \ -lsnappyHexMesh diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C index 06411f24bb..1dc246e7d7 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C @@ -26,7 +26,7 @@ License #include "automatic.H" #include "addToRunTimeSelectionTable.H" #include "triSurfaceMesh.H" -#include "vtkSurfaceWriter.H" +#include "foamVtkSurfaceWriter.H" #include "primitivePatchInterpolation.H" #include "Time.H" @@ -288,20 +288,23 @@ Foam::tmp Foam::automatic::load() faces[fI] = surface_.triSurface::operator[](fI); } - vtkSurfaceWriter().write + vtk::surfaceWriter vtkWriter ( - surface_.searchableSurface::time().constant()/"triSurface", - surfaceName_.nameLessExt(), - meshedSurfRef + surface_.points(), + faces, ( - surface_.points(), - faces - ), - "cellSize", - pointCellSize, - true, - true + surface_.searchableSurface::time().constant() + / "triSurface" + / surfaceName_.nameLessExt() + "_cellSize" + ) ); + + + vtkWriter.writeGeometry(); + + vtkWriter.beginPointData(1); + + vtkWriter.write("cellSize", pointCellSize); } return tPointCellSize; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options index 3fe4af45fb..e71aedddb0 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options @@ -14,7 +14,6 @@ EXE_INC = \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I../vectorTools @@ -25,6 +24,5 @@ EXE_LIBS = \ -ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \ -ldecompose \ -lmeshTools \ - -lsampling \ -ldynamicMesh \ -lfiniteVolume diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index 0364c17774..92b465c619 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -41,7 +41,7 @@ Description #include "cellShape.H" #include "DynamicField.H" #include "isoSurfaceCell.H" -#include "vtkSurfaceWriter.H" +#include "foamVtkSurfaceWriter.H" #include "syncTools.H" #include "decompositionModel.H" @@ -739,14 +739,18 @@ int main(int argc, char *argv[]) pointMergeMap ); - vtkSurfaceWriter writer; - writer.write - ( - runTime.path(), - "iso", - mergedPoints, - mergedFaces - ); + if (Pstream::master()) + { + vtk::surfaceWriter writer + ( + mergedPoints, + mergedFaces, + (runTime.path() / "iso"), + false // serial only + ); + + writer.writeGeometry(); + } Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options index 79021d1a46..51b2faebcf 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/Make/options @@ -1,12 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude \ - -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ -ldynamicFvMesh \ -lmeshTools \ - -lsampling \ -ldynamicMesh diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index b0a0cc890a..531721b32d 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -36,9 +36,9 @@ Description #include "Time.H" #include "dynamicFvMesh.H" #include "pimpleControl.H" -#include "vtkSurfaceWriter.H" #include "cyclicAMIPolyPatch.H" #include "PatchTools.H" +#include "foamVtkSurfaceWriter.H" #include "functionObject.H" using namespace Foam; @@ -53,11 +53,9 @@ void writeWeights const primitivePatch& patch, const fileName& directory, const fileName& prefix, - const word& timeName + const Time& runTime ) { - vtkSurfaceWriter writer; - // Collect geometry labelList pointToGlobal; labelList uniqueMeshPointLabels; @@ -94,37 +92,36 @@ void writeWeights mergedWeights ); + instant inst(runTime.value(), runTime.timeName()); + if (Pstream::master()) { - writer.write + vtk::surfaceWriter writer ( - directory, - prefix + "_" + timeName, - meshedSurfRef - ( - mergedPoints, - mergedFaces - ), - "weightsSum", - mergedWeights, - false + mergedPoints, + mergedFaces, + (directory/prefix + "_" + inst.name()), + false // serial: master-only ); + + writer.setTime(inst); + writer.writeTimeValue(); + writer.writeGeometry(); + + writer.beginCellData(1); + writer.write("weightsSum", mergedWeights); } } void writeWeights(const polyMesh& mesh) { - const polyBoundaryMesh& pbm = mesh.boundaryMesh(); - - const word tmName(mesh.time().timeName()); - - forAll(pbm, patchi) + for (const polyPatch& pp : mesh.boundaryMesh()) { - if (isA(pbm[patchi])) + if (isA(pp)) { const cyclicAMIPolyPatch& cpp = - refCast(pbm[patchi]); + refCast(pp); if (cpp.owner()) { @@ -142,7 +139,7 @@ void writeWeights(const polyMesh& mesh) cpp.neighbPatch(), functionObject::outputPrefix, "tgt", - tmName + mesh.time() ); writeWeights ( @@ -151,7 +148,7 @@ void writeWeights(const polyMesh& mesh) cpp, functionObject::outputPrefix, "src", - tmName + mesh.time() ); } } diff --git a/applications/utilities/surface/surfaceFeatureExtract/Make/options b/applications/utilities/surface/surfaceFeatureExtract/Make/options index b79e3e27c5..dc149a902d 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/Make/options +++ b/applications/utilities/surface/surfaceFeatureExtract/Make/options @@ -1,11 +1,9 @@ EXE_INC = \ -IextractionMethod/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lsurfaceFeatureExtract \ - -lmeshTools \ - -lsampling + -lmeshTools diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 2d1d725d14..0c2f9c06fb 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -193,7 +193,7 @@ Note #include "meshTools.H" #include "OBJstream.H" #include "triSurfaceMesh.H" -#include "vtkSurfaceWriter.H" +#include "foamVtkSurfaceWriter.H" #include "unitConversion.H" #include "plane.H" #include "point.H" @@ -656,8 +656,55 @@ int main(int argc, char *argv[]) bfeMesh.regIOobject::write(); } + + // Output information + + const bool optCloseness = + surfaceDict.lookupOrDefault("closeness", false); + + const bool optProximity = + surfaceDict.lookupOrDefault("featureProximity", false); + + const bool optCurvature = + surfaceDict.lookupOrDefault("curvature", false); + + + // For VTK legacy format, we would need an a priori count of + // CellData and PointData fields. + // For convenience, we therefore only use the XML formats + + autoPtr vtkWriter; + + if (optCloseness || optProximity || optCurvature) + { + if (writeVTK) + { + vtkWriter.reset + ( + new vtk::surfaceWriter + ( + surf.points(), + faces, + (vtkOutputDir / outputName), + false // serial only + ) + ); + + vtkWriter->writeGeometry(); + + Info<< "Writing VTK to " + << ((vtkOutputDir/outputName).ext(vtkWriter->ext())) + .relative(runTime.globalPath()) << nl; + } + } + else + { + continue; // Nothing to output + } + + // Option: "closeness" - if (surfaceDict.lookupOrDefault("closeness", false)) + if (optCloseness) { Pair> tcloseness = triSurfaceTools::writeCloseness @@ -669,73 +716,20 @@ int main(int argc, char *argv[]) 10 // externalAngleTolerance ); - if (writeVTK) + if (vtkWriter.valid()) { - vtkSurfaceWriter().write - ( - vtkOutputDir, - outputName, - meshedSurfRef - ( - surf.points(), - faces - ), - "internalCloseness", // fieldName - tcloseness[0](), - false, // isNodeValues - true // verbose - ); - - vtkSurfaceWriter().write - ( - vtkOutputDir, - outputName, - meshedSurfRef - ( - surf.points(), - faces - ), - "externalCloseness", // fieldName - tcloseness[1](), - false, // isNodeValues - true // verbose - ); - } - } - - // Option: "curvature" - if (surfaceDict.lookupOrDefault("curvature", false)) - { - tmp tcurvatureField = - triSurfaceTools::writeCurvature - ( - runTime, - outputName, - surf - ); - - if (writeVTK) - { - vtkSurfaceWriter().write - ( - vtkOutputDir, - outputName, - meshedSurfRef - ( - surf.points(), - faces - ), - "curvature", // fieldName - tcurvatureField(), - true, // isNodeValues - true // verbose - ); + vtkWriter->beginCellData(); + vtkWriter->write("internalCloseness", tcloseness[0]()); + vtkWriter->write("externalCloseness", tcloseness[1]()); } } // Option: "featureProximity" - if (surfaceDict.lookupOrDefault("featureProximity", false)) + if (optCloseness) { + const scalar maxProximity = + surfaceDict.lookupOrDefault("maxFeatureProximity", 1); + tmp tproximity = edgeMeshTools::writeFeatureProximity ( @@ -743,25 +737,31 @@ int main(int argc, char *argv[]) outputName, feMesh, surf, - surfaceDict.get("maxFeatureProximity") + maxProximity ); - if (writeVTK) + if (vtkWriter.valid()) { - vtkSurfaceWriter().write + vtkWriter->beginCellData(); + vtkWriter->write("featureProximity", tproximity()); + } + } + + // Option: "curvature" + if (optCurvature) + { + tmp tcurvature = + triSurfaceTools::writeCurvature ( - vtkOutputDir, + runTime, outputName, - meshedSurfRef - ( - surf.points(), - faces - ), - "featureProximity", // fieldName - tproximity(), - false, // isNodeValues - true // verbose + surf ); + + if (vtkWriter.valid()) + { + vtkWriter->beginPointData(); + vtkWriter->write("curvature", tcurvature()); } } diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict index 3d82bb458f..89885ac38f 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict @@ -34,7 +34,7 @@ surface1.stl // Tolerance for surface intersections // tolerance 1e-3; - // Output options: +// Output options: // Write features to obj format for postprocessing writeObj yes; @@ -59,7 +59,7 @@ outputName1 // Tolerance for surface intersections // tolerance 1e-3; - // Output options: +// Output options: // Write features to OBJ format for postprocessing writeObj yes; @@ -117,7 +117,7 @@ surface2.nas // Tolerance for surface intersections // tolerance 1e-3; - // Output options: +// Output options: // Output the closeness of surface elements to other surface elements. closeness no; @@ -128,7 +128,7 @@ surface2.nas // Output the proximity of feature points and edges to another featureProximity no; - // The maximum search distance when checking feature proximity + // Maximum search distance when checking feature proximity (default: 1m) maxFeatureProximity 1; // Write features to OBJ format for postprocessing diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C index a3e614313d..9cf960a22c 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C @@ -30,8 +30,10 @@ License #include "OBJstream.H" #include "PatchTools.H" #include "Time.H" -//Note: cannot use vtkSurfaceWriter here - circular linkage -//#include "vtkSurfaceWriter.H" +// Note: cannot use vtkSurfaceWriter here - circular linkage +// but foamVtkSurfaceWriter (vtk::surfaceWriter) would be okay. +// +// #include "foamVtkSurfaceWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/system/surfaceFeatureExtractDictDefaults b/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/system/surfaceFeatureExtractDictDefaults index c3305713f8..eaaecde6c9 100644 --- a/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/system/surfaceFeatureExtractDictDefaults +++ b/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/system/surfaceFeatureExtractDictDefaults @@ -26,4 +26,13 @@ trimFeatures writeObj yes; // writes out .obj files to view features +writeVTK no; // writes vtk files to view features + +// Output items +/* +closeness yes; +curvature yes; +featureProxmity yes; +*/ + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //