diff --git a/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C b/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C index f49d334e5b..bc35115335 100644 --- a/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C +++ b/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C @@ -31,12 +31,33 @@ Group grpSurfaceUtilities Description - Writes regions of triSurface to separate files. + Writes surface regions to separate files. + +Usage + \b surfaceSplitByPatch [OPTION] + + Options: + - \par -patches NAME | LIST + Specify single patch or multiple patches (name or regex) to extract + For example, + \verbatim + -patches top + -patches '( front \".*back\" )' + \endverbatim + + - \par -excludePatches NAME | LIST + Specify single or multiple patches (name or regex) not to extract. + For example, + \verbatim + -excludePatches '( inlet_1 inlet_2 "proc.*")' + \endverbatim \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "triSurface.H" +#include "MeshedSurfaces.H" +#include "stringListOps.H" +#include "geometricSurfacePatch.H" using namespace Foam; @@ -48,65 +69,103 @@ int main(int argc, char *argv[]) ( "Write surface mesh regions to separate files" ); - argList::noParallel(); + argList::addOption + ( + "patches", + "wordRes", + "Specify single patch or multiple patches to write\n" + "Eg, 'top' or '( front \".*back\" )'" + ); + argList::addOption + ( + "excludePatches", + "wordRes", + "Specify single patch or multiple patches to exclude from writing." + " Eg, 'outlet' or '( inlet \".*Wall\" )'" + ); + argList::addArgument("input", "The input surface file"); + argList args(argc, argv); const fileName surfName = args[1]; - Info<< "Reading surf from " << surfName << " ..." << nl << endl; + const fileName surfBase(surfName.lessExt()); - fileName surfBase = surfName.lessExt(); - - word extension = surfName.ext(); - - triSurface surf(surfName); - - Info<< "Writing regions to separate files ..." - << nl << endl; + const word extension(surfName.ext()); - const geometricSurfacePatchList& patches = surf.patches(); + Info<< nl + << "Read surface from " << surfName << " ..." << nl << endl; - forAll(patches, patchi) + meshedSurface surf(surfName); + + const surfZoneList& zones = surf.surfZones(); + + Info<< " " << surf.size() << " faces with " + << zones.size() << " zones" << nl << nl; + + + wordRes includePatches, excludePatches; + + if (args.readListIfPresent("patches", includePatches)) { - const geometricSurfacePatch& pp = patches[patchi]; + Info<< "Including patches " << flatOutput(includePatches) + << nl << endl; + } + if (args.readListIfPresent("excludePatches", excludePatches)) + { + Info<< "Excluding patches " << flatOutput(excludePatches) + << nl << endl; + } - word patchName(pp.name()); + // Identity if both whitelist and blacklist are empty + const labelList zoneIndices + ( + stringListOps::findMatching + ( + zones, + includePatches, + excludePatches, + nameOp() + ) + ); + + + Info<< "Writing regions to " + << zoneIndices.size() << " separate files ..." << nl << endl; + + + // Faces to subset + bitSet includeMap(surf.size()); + + for (const label zonei : zoneIndices) + { + const surfZone& zn = zones[zonei]; + + includeMap.reset(); + includeMap.set(zn.range()); + + word patchName(zn.name()); if (patchName.empty()) { - patchName = geometricSurfacePatch::defaultName(patchi); + // In case people expect the same names as with triSurface + patchName = geometricSurfacePatch::defaultName(zonei); } fileName outFile(surfBase + '_' + patchName + '.' + extension); - Info<< " Writing patch " << patchName << " to file " << outFile - << endl; + Info<< " Zone " << zonei << " (" << zn.size() << " faces) " + << patchName + << " to file " << outFile << nl; - - // Collect faces of region - boolList includeMap(surf.size(), false); - - forAll(surf, facei) - { - const labelledTri& f = surf[facei]; - - if (f.region() == patchi) - { - includeMap[facei] = true; - } - } - - // Subset triSurface - - triSurface subSurf(surf.subsetMesh(includeMap)); - - subSurf.write(outFile); + // Subset and write + surf.subsetMesh(includeMap).write(outFile); } - Info<< "End\n" << endl; + Info<< "\nEnd\n" << endl; return 0; } diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index 3050d05469..04031d3f04 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +36,8 @@ Description \*---------------------------------------------------------------------------*/ -#include "triSurface.H" #include "triSurfaceSearch.H" +#include "MeshedSurfaces.H" #include "argList.H" #include "Fstream.H" #include "IOdictionary.H" @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { argList::addNote ( - "A surface analysis tool that subsets the triSurface to choose a" + "A surface analysis tool that subsets the surface to choose a" " region of interest." ); @@ -71,7 +71,8 @@ int main(int argc, char *argv[]) dictionary meshSubsetDict(dictFile); Info<< "Reading surface " << args[2] << " ..." << endl; - triSurface surf1(args[2]); + + meshedSurface surf1(args[2]); const fileName outFileName(args[3]); @@ -101,134 +102,115 @@ int main(int argc, char *argv[]) meshSubsetDict.lookup("zone") ); - if (markedZone.size() && markedZone.size() != 2) + + boundBox zoneBb; + + if (markedZone.size()) { - FatalErrorInFunction - << "zone specification should be two points, min and max of " - << "the boundingbox" << endl - << "zone:" << markedZone - << exit(FatalError); + if (markedZone.size() != 2) + { + FatalErrorInFunction + << "zone specification should be two points, min and max of " + << "the boundingbox" << endl + << "zone:" << markedZone + << exit(FatalError); + } + + zoneBb.min() = markedZone[0]; + zoneBb.max() = markedZone[1]; + + if (!zoneBb.valid()) + { + WarningInFunction + << "Defined zone is invalid: " << zoneBb << nl; + } } + const bool addFaceNeighbours = meshSubsetDict.get("addFaceNeighbours"); const bool invertSelection = - meshSubsetDict.lookupOrDefault("invertSelection", false); + meshSubsetDict.getOrDefault("invertSelection", false); // Mark the cells for the subset // Faces to subset - boolList facesToSubset(surf1.size(), false); + bitSet facesToSubset(surf1.size(), false); // - // pick up faces connected to "localPoints" + // Faces connected to "localPoints" // if (markedPoints.size()) { Info<< "Found " << markedPoints.size() << " marked point(s)." << endl; - // pick up cells sharing the point - - forAll(markedPoints, pointi) + for (const label pointi : markedPoints) { - if - ( - markedPoints[pointi] < 0 - || markedPoints[pointi] >= surf1.nPoints() - ) + if (pointi < 0 || pointi >= surf1.nPoints()) { FatalErrorInFunction - << "localPoint label " << markedPoints[pointi] - << "out of range." - << " The mesh has got " - << surf1.nPoints() << " localPoints." + << "localPoint label " << pointi << "out of range." + << " Surface has " << surf1.nPoints() << " localPoints." << exit(FatalError); } - const labelList& curFaces = - surf1.pointFaces()[markedPoints[pointi]]; + const labelList& curFaces = surf1.pointFaces()[pointi]; - forAll(curFaces, i) - { - facesToSubset[curFaces[i]] = true; - } + facesToSubset.set(curFaces); } } - // - // pick up faces connected to "edges" + // Faces connected to "edges" // if (markedEdges.size()) { Info<< "Found " << markedEdges.size() << " marked edge(s)." << endl; - // pick up cells sharing the edge - - forAll(markedEdges, edgeI) + for (const label edgei : markedEdges) { - if - ( - markedEdges[edgeI] < 0 - || markedEdges[edgeI] >= surf1.nEdges() - ) + if (edgei < 0 || edgei >= surf1.nEdges()) { FatalErrorInFunction - << "edge label " << markedEdges[edgeI] - << "out of range." - << " The mesh has got " - << surf1.nEdges() << " edges." + << "edge label " << edgei << "out of range." + << " Surface has " << surf1.nEdges() << " edges." << exit(FatalError); } - const labelList& curFaces = surf1.edgeFaces()[markedEdges[edgeI]]; + const labelList& curFaces = surf1.edgeFaces()[edgei]; - forAll(curFaces, i) - { - facesToSubset[curFaces[i]] = true; - } + facesToSubset.set(curFaces); } } // - // pick up faces with centre inside "zone" + // Faces with centre inside "zone" // - if (markedZone.size() == 2) + if (zoneBb.valid()) { - const point& min = markedZone[0]; - const point& max = markedZone[1]; - - Info<< "Using zone min:" << min << " max:" << max << endl; + Info<< "Using zone " << zoneBb << endl; forAll(surf1, facei) { const point centre = surf1[facei].centre(surf1.points()); - if - ( - (centre.x() >= min.x()) - && (centre.y() >= min.y()) - && (centre.z() >= min.z()) - && (centre.x() <= max.x()) - && (centre.y() <= max.y()) - && (centre.z() <= max.z()) - ) + if (zoneBb.contains(centre)) { - facesToSubset[facei] = true; + facesToSubset.set(facei); } } } // - // pick up faces on certain side of surface + // Faces on certain side of surface // if (meshSubsetDict.found("surface")) @@ -237,18 +219,16 @@ int main(int argc, char *argv[]) const fileName surfName(surfDict.get("name")); - const bool outside(surfDict.get("outside")); + const volumeType::type volType = + ( + surfDict.getOrDefault("outside", false) + ? volumeType::OUTSIDE + : volumeType::INSIDE + ); - if (outside) - { - Info<< "Selecting all triangles with centre outside surface " - << surfName << endl; - } - else - { - Info<< "Selecting all triangles with centre inside surface " - << surfName << endl; - } + Info<< "Selecting faces with centre located " + << volumeType::names[volType] << " of surface " + << surfName << endl; // Read surface to select on triSurface selectSurf(surfName); @@ -264,22 +244,15 @@ int main(int argc, char *argv[]) searchSelectSurf.tree(); // Check if face (centre) is in outside or inside. - forAll(facesToSubset, facei) + forAll(surf1, facei) { if (!facesToSubset[facei]) { const point fc(surf1[facei].centre(surf1.points())); - volumeType t = selectTree.getVolumeType(fc); - - if - ( - outside - ? (t == volumeType::OUTSIDE) - : (t == volumeType::INSIDE) - ) + if (volType == selectTree.getVolumeType(fc)) { - facesToSubset[facei] = true; + facesToSubset.set(facei); } } } @@ -304,7 +277,7 @@ int main(int argc, char *argv[]) if (pl.distance(fc) < distance && mag(pl.normal() & nf) > cosAngle) { - facesToSubset[facei] = true; + facesToSubset.set(facei); } } } @@ -323,38 +296,29 @@ int main(int argc, char *argv[]) Info<< "Found " << markedFaces.size() << " marked face(s)." << endl; // Check and mark faces to pick up - forAll(markedFaces, facei) + for (const label facei : markedFaces) { - if - ( - markedFaces[facei] < 0 - || markedFaces[facei] >= surf1.size() - ) + if (facei < 0 || facei >= surf1.size()) { FatalErrorInFunction - << "Face label " << markedFaces[facei] << "out of range." - << " The mesh has got " - << surf1.size() << " faces." + << "Face label " << facei << "out of range." + << " Surface has " << surf1.size() << " faces." << exit(FatalError); } // Mark the face - facesToSubset[markedFaces[facei]] = true; + facesToSubset.set(facei); - // mark its neighbours if requested + // Mark its neighbours if requested if (addFaceNeighbours) { - const labelList& curFaces = - surf1.faceFaces()[markedFaces[facei]]; + const labelList& curFaces = surf1.faceFaces()[facei]; - forAll(curFaces, i) + for (const label neiFacei : curFaces) { - label facei = curFaces[i]; - - if (!facesToSubset[facei]) + if (facesToSubset.set(neiFacei)) { - facesToSubset[facei] = true; - nFaceNeighbours++; + ++nFaceNeighbours; } } } @@ -372,15 +336,12 @@ int main(int argc, char *argv[]) { Info<< "Inverting selection." << endl; - forAll(facesToSubset, i) - { - facesToSubset[i] = facesToSubset[i] ? false : true; - } + facesToSubset.flip(); } // Create subsetted surface - triSurface surf2(surf1.subsetMesh(facesToSubset)); + meshedSurface surf2(surf1.subsetMesh(facesToSubset)); Info<< "Subset:" << endl; surf2.writeStats(Info); diff --git a/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg b/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg index c88ad8b986..01737a7f2d 100644 --- a/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg +++ b/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Version: v1912 + \\ / O peration | Version: v2006 \\ / A nd | Website: www.openfoam.com \\/ M anipulation | \*---------------------------------------------------------------------------*/ @@ -14,7 +14,7 @@ region1 sampledSurfaceDict { - type sampledTriSurfaceMesh; + type meshedSurface; regionType cells; interpolate true; surface $triSurface1; diff --git a/etc/caseDicts/postProcessing/surfaceFieldValue/triSurfaceRegion.cfg b/etc/caseDicts/postProcessing/surfaceFieldValue/triSurfaceRegion.cfg index 006d796c7b..538b9ed3b5 100644 --- a/etc/caseDicts/postProcessing/surfaceFieldValue/triSurfaceRegion.cfg +++ b/etc/caseDicts/postProcessing/surfaceFieldValue/triSurfaceRegion.cfg @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Version: v1912 + \\ / O peration | Version: v2006 \\ / A nd | Website: www.openfoam.com \\/ M anipulation | \*---------------------------------------------------------------------------*/ @@ -12,7 +12,7 @@ regionType sampledSurface; sampledSurfaceDict { - type sampledTriSurfaceMesh; + type meshedSurface; surface $triSurface; source cells; interpolate true; diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 3db3cb4159..75e7515fbb 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -47,97 +47,6 @@ Foam::word Foam::triSurfaceMesh::meshSubDir = "triSurface"; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::fileName Foam::triSurfaceMesh::checkFile -( - const IOobject& io, - const bool isGlobal -) -{ - const fileName fName - ( - isGlobal - ? io.globalFilePath(typeName) - : io.localFilePath(typeName) - ); - if (fName.empty()) - { - FatalErrorInFunction - << "Cannot find triSurfaceMesh starting from " - << io.objectPath() << exit(FatalError); - } - - return fName; -} - - -Foam::fileName Foam::triSurfaceMesh::relativeFilePath -( - const IOobject& io, - const fileName& f, - const bool isGlobal -) -{ - fileName fName(f); - fName.expand(); - if (!fName.isAbsolute()) - { - // Is the specified file: - // - local to the cwd? - // - local to the case dir? - // - or just another name? - fName = fileHandler().filePath - ( - isGlobal, - IOobject(io, fName), - word::null - ); - } - return fName; -} - -Foam::fileName Foam::triSurfaceMesh::checkFile -( - const IOobject& io, - const dictionary& dict, - const bool isGlobal -) -{ - fileName fName; - if (dict.readIfPresent("file", fName, keyType::LITERAL)) - { - const fileName rawFName(fName); - - fName = relativeFilePath(io, rawFName, isGlobal); - - if (!exists(fName)) - { - FatalErrorInFunction - << "Cannot find triSurfaceMesh " << rawFName - << " starting from " << io.objectPath() - << exit(FatalError); - } - } - else - { - fName = - ( - isGlobal - ? io.globalFilePath(typeName) - : io.localFilePath(typeName) - ); - - if (!exists(fName)) - { - FatalErrorInFunction - << "Cannot find triSurfaceMesh starting from " - << io.objectPath() << exit(FatalError); - } - } - - return fName; -} - - bool Foam::triSurfaceMesh::addFaceToEdge ( const edge& e, @@ -308,7 +217,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io) false // searchableSurface already registered under name ) ), - triSurface(checkFile(static_cast(*this), true)), + triSurface(static_cast(*this), dictionary::null), triSurfaceRegionSearch(static_cast(*this)), minQuality_(-1), surfaceClosed_(-1), @@ -341,19 +250,16 @@ Foam::triSurfaceMesh::triSurfaceMesh false // searchableSurface already registered under name ) ), - triSurface - ( - checkFile(static_cast(*this), dict, true) - ), + triSurface(static_cast(*this), dict), triSurfaceRegionSearch(static_cast(*this), dict), minQuality_(-1), surfaceClosed_(-1), outsideVolType_(volumeType::UNKNOWN) { - // Reading from supplied file name instead of objectPath/filePath + // Adjust to use supplied file name instead of objectPath/filePath if (dict.readIfPresent("file", fName_, keyType::LITERAL)) { - fName_ = relativeFilePath + fName_ = triSurface::relativeFilePath ( static_cast(*this), fName_, @@ -404,7 +310,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const readAction r) false // searchableSurface already registered under name ) ), - triSurface(), // construct null + triSurface(), triSurfaceRegionSearch(static_cast(*this)), minQuality_(-1), surfaceClosed_(-1), @@ -502,7 +408,7 @@ Foam::triSurfaceMesh::triSurfaceMesh false // searchableSurface already registered under name ) ), - triSurface(), // construct null + triSurface(), triSurfaceRegionSearch(static_cast(*this), dict), minQuality_(-1), surfaceClosed_(-1), diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H index 512d5bf230..c3e62014d1 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H @@ -106,26 +106,6 @@ protected: // Private Member Functions - //- Return fileName to load IOobject from - static fileName checkFile(const IOobject& io, const bool isGlobal); - - //- Return fileName. If fileName is relative gets treated local to - // IOobject - static fileName relativeFilePath - ( - const IOobject&, - const fileName&, - const bool isGlobal - ); - - //- Return fileName to load IOobject from. Optional override of fileName - static fileName checkFile - ( - const IOobject&, - const dictionary&, - const bool isGlobal - ); - //- Helper function for isSurfaceClosed static bool addFaceToEdge ( diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index dc75f2f80c..f0b9d40294 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -2557,7 +2557,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(const IOobject& io) bounds().reduce(); - const fileName actualFile(checkFile(io, true)); + const fileName actualFile(triSurfaceMesh::checkFile(io, true)); if ( @@ -2697,7 +2697,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh bounds().reduce(); - const fileName actualFile(checkFile(io, dict, true)); + const fileName actualFile(triSurfaceMesh::checkFile(io, dict, true)); if ( diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 7c2727ce53..2d2796dcca 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -44,11 +44,11 @@ sampledSurface/isoSurface/sampledIsoSurfaceTopo.C sampledSurface/distanceSurface/sampledDistanceSurface.C sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledCuttingSurface/sampledCuttingSurface.C +sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C +sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.C sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurface/sampledSurfaceRegister.C sampledSurface/sampledSurfaces/sampledSurfaces.C -sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C -sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C readers = sampledSurface/readers diff --git a/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C b/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C index 685d192af6..9e7975f40d 100644 --- a/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C +++ b/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -121,32 +122,34 @@ Foam::triSurfaceMeshPointSet::triSurfaceMeshPointSet ) : sampledSet(name, mesh, searchEngine, dict), - surface_(dict.get("surface")) + surfaceName_(dict.get("surface")) { - // Load surface. - if (mesh.time().foundObject(surface_)) + // Get or load surface + + const auto* surfPtr = + mesh.time().cfindObject(surfaceName_); + + if (surfPtr) { // Note: should use localPoints() instead of points() but assume // trisurface is compact. - sampleCoords_ = mesh.time().lookupObject - ( - surface_ - ).points(); + sampleCoords_ = surfPtr->points(); } else { - sampleCoords_ = triSurfaceMesh + sampleCoords_ = triSurface ( IOobject ( - surface_, + surfaceName_, mesh.time().constant(), // instance "triSurface", // local mesh.time(), IOobject::MUST_READ, IOobject::NO_WRITE, false - ) + ), + dictionary::null ).points(); } diff --git a/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.H b/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.H index 5d34a61fd2..c0aa558000 100644 --- a/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.H +++ b/src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.H @@ -60,10 +60,10 @@ class triSurfaceMeshPointSet : public sampledSet { - // Private data + // Private Data - //- Name of triSurfaceMesh - const word surface_; + //- The surface name + const word surfaceName_; //- Sampling points List sampleCoords_; diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C similarity index 53% rename from src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C rename to src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C index 14181bff0d..3198116b9f 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C @@ -26,23 +26,22 @@ License \*---------------------------------------------------------------------------*/ -#include "sampledTriSurfaceMesh.H" +#include "sampledMeshedSurface.H" #include "meshSearch.H" #include "Tuple2.H" #include "globalIndex.H" #include "treeDataCell.H" #include "treeDataFace.H" #include "meshTools.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::Enum < - Foam::sampledTriSurfaceMesh::samplingSource + Foam::sampledMeshedSurface::samplingSource > -Foam::sampledTriSurfaceMesh::samplingSourceNames_ +Foam::sampledMeshedSurface::samplingSourceNames_ ({ { samplingSource::cells, "cells" }, { samplingSource::insideCells, "insideCells" }, @@ -52,12 +51,22 @@ Foam::sampledTriSurfaceMesh::samplingSourceNames_ namespace Foam { - defineTypeNameAndDebug(sampledTriSurfaceMesh, 0); - addToRunTimeSelectionTable + defineTypeNameAndDebug(sampledMeshedSurface, 0); + // Use shorter name only + addNamedToRunTimeSelectionTable ( sampledSurface, - sampledTriSurfaceMesh, - word + sampledMeshedSurface, + word, + meshedSurface + ); + // Compatibility name (1912) + addNamedToRunTimeSelectionTable + ( + sampledSurface, + sampledMeshedSurface, + word, + sampledTriSurfaceMesh ); //- Private class for finding nearest @@ -78,53 +87,90 @@ namespace Foam } } }; + +} // End namespace Foam + + +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +namespace Foam +{ + +// The IOobject for reading +inline static IOobject selectReadIO(const word& name, const Time& runTime) +{ + return IOobject + ( + name, + runTime.constant(), // instance + "triSurface", // local + runTime, // registry + IOobject::MUST_READ, + IOobject::NO_WRITE, + false // no register + ); } +} // End namespace Foam -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -void Foam::sampledTriSurfaceMesh::setZoneMap -( - const surfZoneList& zoneLst, - labelList& zoneIds -) +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::sampledMeshedSurface::setZoneMap() { - label sz = 0; - for (const surfZone& zn : zoneLst) + // Ensure zoneIds_ are correctly populated + + const meshedSurface& s = static_cast(*this); + + const auto& zones = s.surfZones(); + + zoneIds_.resize(s.size()); + + // Trivial case + if (zoneIds_.empty() || zones.size() <= 1) { - sz += zn.size(); + zoneIds_ = 0; + return; } - zoneIds.setSize(sz); - forAll(zoneLst, zonei) + + label beg = 0; + + forAll(zones, zonei) { - const surfZone& zn = zoneLst[zonei]; + const label len = min(zones[zonei].size(), zoneIds_.size() - beg); // Assign sub-zone Ids - SubList