From ae3d2f4d5757aa76220331966c5c087ed1ed4d72 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 16 Nov 2016 14:58:46 +0000 Subject: [PATCH] ENH: topoSet: clear sets upon writing modified mesh. Fixes #129. --- .../utilities/mesh/advanced/PDRMesh/PDRMesh.C | 97 +++++++++++++++- .../advanced/combinePatchFaces/Make/options | 2 + .../combinePatchFaces/combinePatchFaces.C | 6 +- .../mesh/advanced/modifyMesh/Make/options | 3 + .../mesh/advanced/modifyMesh/modifyMesh.C | 10 +- .../mesh/advanced/refineHexMesh/Make/options | 5 +- .../advanced/refineHexMesh/refineHexMesh.C | 5 +- .../advanced/refineWallLayer/Make/options | 3 + .../refineWallLayer/refineWallLayer.C | 5 +- .../mesh/advanced/removeFaces/Make/options | 2 + .../mesh/advanced/removeFaces/removeFaces.C | 5 +- .../extrude/extrudeMesh/Make/options | 2 + .../extrude/extrudeMesh/extrudeMesh.C | 5 +- .../extrude/extrudeToRegionMesh/Make/options | 2 + .../extrudeToRegionMesh/extrudeToRegionMesh.C | 7 +- .../generation/extrude2DMesh/Make/options | 3 + .../extrude2DMesh/extrude2DMeshApp.C | 6 +- .../generation/snappyHexMesh/Make/options | 2 + .../generation/snappyHexMesh/snappyHexMesh.C | 6 + .../manipulation/createBaffles/Make/options | 2 + .../createBaffles/createBaffles.C | 6 +- .../manipulation/createPatch/Make/options | 3 + .../manipulation/createPatch/createPatch.C | 5 +- .../manipulation/mergeMeshes/Make/options | 7 +- .../manipulation/mergeMeshes/mergeMeshes.C | 6 +- .../mergeOrSplitBaffles/Make/options | 4 +- .../mergeOrSplitBaffles/mergeOrSplitBaffles.C | 5 +- .../manipulation/polyDualMesh/Make/options | 2 + .../polyDualMesh/polyDualMeshApp.C | 6 +- .../manipulation/renumberMesh/renumberMesh.C | 75 +++---------- .../renumberMesh/renumberMeshDict | 3 - .../mesh/manipulation/splitMesh/Make/options | 3 + .../mesh/manipulation/splitMesh/splitMesh.C | 6 +- .../splitMeshRegions/Make/options | 6 +- .../splitMeshRegions/splitMeshRegions.C | 5 +- .../mesh/manipulation/subsetMesh/Make/options | 5 +- .../mesh/manipulation/subsetMesh/subsetMesh.C | 105 +++++++++++++++++- .../reconstructParMesh/reconstructParMesh.C | 4 +- .../redistributePar/redistributePar.C | 52 +++++++++ src/meshTools/sets/topoSets/cellSet.C | 34 +++++- src/meshTools/sets/topoSets/cellSet.H | 7 +- src/meshTools/sets/topoSets/faceSet.C | 34 +++++- src/meshTools/sets/topoSets/faceSet.H | 5 +- src/meshTools/sets/topoSets/pointSet.C | 34 +++++- src/meshTools/sets/topoSets/pointSet.H | 5 +- src/meshTools/sets/topoSets/topoSet.C | 22 +++- src/meshTools/sets/topoSets/topoSet.H | 29 ++++- .../sets/topoSets/topoSetTemplates.C | 59 ++++++++++ .../reconstruct/reconstruct/processorMeshes.C | 58 +++++++++- .../reconstruct/reconstruct/processorMeshes.H | 9 +- 50 files changed, 674 insertions(+), 108 deletions(-) create mode 100644 src/meshTools/sets/topoSets/topoSetTemplates.C diff --git a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C index 25c536e103..a8e1b3d89d 100644 --- a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C +++ b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,9 @@ Description #include "mapPolyMesh.H" #include "faceSet.H" #include "cellSet.H" +#include "pointSet.H" #include "syncTools.H" +#include "ReadFields.H" #include "polyTopoChange.H" #include "polyModifyFace.H" #include "polyAddFace.H" @@ -315,6 +317,59 @@ void initCreatedPatches } +template +void subsetTopoSets +( + const fvMesh& mesh, + const IOobjectList& objectsList, + const labelList& map, + const fvMesh& subMesh, + PtrList& subSets +) +{ + // Read original sets + PtrList sets; + ReadFields(objectsList, sets); + + subSets.setSize(sets.size()); + forAll(sets, i) + { + TopoSet& set = sets[i]; + + Info<< "Subsetting " << set.type() << " " << set.name() << endl; + + // Map the data + PackedBoolList isSet(set.maxSize(mesh)); + forAllConstIter(labelHashSet, set, iter) + { + isSet[iter.key()] = true; + } + label nSet = 0; + forAll(map, i) + { + if (isSet[map[i]]) + { + nSet++; + } + } + + subSets.set + ( + i, + new TopoSet(subMesh, set.name(), nSet, IOobject::AUTO_WRITE) + ); + TopoSet& subSet = subSets[i]; + forAll(map, i) + { + if (isSet[map[i]]) + { + subSet.insert(i); + } + } + } +} + + void createCoupledBaffles ( fvMesh& mesh, @@ -923,6 +978,41 @@ int main(int argc, char *argv[]) surfTensorFlds ); + + // Set handling + PtrList cellSets; + PtrList faceSets; + PtrList pointSets; + { + IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets"); + subsetTopoSets + ( + mesh, + objects, + subsetter.cellMap(), + subsetter.subMesh(), + cellSets + ); + subsetTopoSets + ( + mesh, + objects, + subsetter.faceMap(), + subsetter.subMesh(), + faceSets + ); + subsetTopoSets + ( + mesh, + objects, + subsetter.pointMap(), + subsetter.subMesh(), + pointSets + ); + } + + + if (!overwrite) { runTime++; @@ -1134,6 +1224,11 @@ int main(int argc, char *argv[]) Zero ); + // Update numbering of topoSets + topoSet::updateMesh(subsetter.subMesh().facesInstance(), map, cellSets); + topoSet::updateMesh(subsetter.subMesh().facesInstance(), map, faceSets); + topoSet::updateMesh(subsetter.subMesh().facesInstance(), map, pointSets); + // Move mesh (since morphing might not do this) if (map().hasMotionPoints()) diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/Make/options b/applications/utilities/mesh/advanced/combinePatchFaces/Make/options index 3da3443a27..ff07063590 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/Make/options +++ b/applications/utilities/mesh/advanced/combinePatchFaces/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ EXE_LIBS = \ -lfiniteVolume \ + -lreconstruct \ -ldynamicMesh diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 2666d4c9de..66cb396c81 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,6 +60,8 @@ Description #include "mapPolyMesh.H" #include "unitConversion.H" #include "motionSmoother.H" +#include "topoSet.H" +#include "processorMeshes.H" using namespace Foam; @@ -450,6 +452,8 @@ int main(int argc, char *argv[]) Info<< "Writing morphed mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); } else { diff --git a/applications/utilities/mesh/advanced/modifyMesh/Make/options b/applications/utilities/mesh/advanced/modifyMesh/Make/options index 70c838b774..4e67ae71f1 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/Make/options +++ b/applications/utilities/mesh/advanced/modifyMesh/Make/options @@ -1,7 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -lmeshTools \ + -lreconstruct \ -ldynamicMesh diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C index 661811afa8..f9b0e4ef2d 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,6 +62,8 @@ Description #include "meshTools.H" #include "Pair.H" #include "globalIndex.H" +#include "topoSet.H" +#include "processorMeshes.H" using namespace Foam; @@ -567,6 +569,8 @@ int main(int argc, char *argv[]) // Write resulting mesh Info<< "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); } else if (edgeToPos.size()) { @@ -641,6 +645,8 @@ int main(int argc, char *argv[]) // Write resulting mesh Info<< "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); } else { @@ -684,6 +690,8 @@ int main(int argc, char *argv[]) // Write resulting mesh Info<< "Writing modified mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); } diff --git a/applications/utilities/mesh/advanced/refineHexMesh/Make/options b/applications/utilities/mesh/advanced/refineHexMesh/Make/options index baa7b45f00..554d59b25d 100644 --- a/applications/utilities/mesh/advanced/refineHexMesh/Make/options +++ b/applications/utilities/mesh/advanced/refineHexMesh/Make/options @@ -1,11 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude - EXE_LIBS = \ + -lreconstruct \ -ldynamicMesh \ - -lmeshTools \ - -lfiniteVolume \ -lgenericPatchFields diff --git a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C index fcdd7ec8f1..bfa6dadce6 100644 --- a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C +++ b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,6 +49,7 @@ Description #include "surfaceFields.H" #include "pointFields.H" #include "ReadFields.H" +#include "processorMeshes.H" using namespace Foam; @@ -197,6 +198,8 @@ int main(int argc, char *argv[]) mesh.write(); meshCutter.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/advanced/refineWallLayer/Make/options b/applications/utilities/mesh/advanced/refineWallLayer/Make/options index 7349856cab..19716ca4ec 100644 --- a/applications/utilities/mesh/advanced/refineWallLayer/Make/options +++ b/applications/utilities/mesh/advanced/refineWallLayer/Make/options @@ -1,7 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -ldynamicMesh \ + -lreconstruct \ -lmeshTools diff --git a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C index 2fc8f5ec3e..e8d84ab180 100644 --- a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C +++ b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,6 +53,7 @@ Description #include "cellCuts.H" #include "cellSet.H" #include "meshCutter.H" +#include "processorMeshes.H" using namespace Foam; @@ -257,6 +258,8 @@ int main(int argc, char *argv[]) Info<< "Writing refined mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/advanced/removeFaces/Make/options b/applications/utilities/mesh/advanced/removeFaces/Make/options index 63c5dc5d78..b23c26cceb 100644 --- a/applications/utilities/mesh/advanced/removeFaces/Make/options +++ b/applications/utilities/mesh/advanced/removeFaces/Make/options @@ -1,10 +1,12 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ -lmeshTools \ -ldynamicMesh \ -lfiniteVolume \ + -lreconstruct \ -lgenericPatchFields diff --git a/applications/utilities/mesh/advanced/removeFaces/removeFaces.C b/applications/utilities/mesh/advanced/removeFaces/removeFaces.C index ca82886601..31989eca13 100644 --- a/applications/utilities/mesh/advanced/removeFaces/removeFaces.C +++ b/applications/utilities/mesh/advanced/removeFaces/removeFaces.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,6 +44,7 @@ Description #include "ReadFields.H" #include "volFields.H" #include "surfaceFields.H" +#include "processorMeshes.H" using namespace Foam; @@ -179,6 +180,8 @@ int main(int argc, char *argv[]) // Take over refinement levels and write to new time directory. Pout<< "Writing mesh to time " << runTime.timeName() << endl; mesh.write(); + topoSet::removeFiles(mesh); + processorMeshes::removeFiles(mesh); Pout<< "End\n" << endl; diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options index 94b355be3c..517a98473f 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options @@ -4,6 +4,7 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \ -I$(LIB_SRC)/mesh/extrudeModel/lnInclude EXE_LIBS = \ @@ -11,4 +12,5 @@ EXE_LIBS = \ -lsurfMesh \ -lmeshTools \ -ldynamicMesh \ + -lreconstruct \ -lextrudeModel diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index f4a01a7f89..c1d35e4a51 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,6 +56,7 @@ Description #include "wedgePolyPatch.H" #include "planeExtrusion.H" #include "emptyPolyPatch.H" +#include "processorMeshes.H" using namespace Foam; @@ -1058,6 +1059,8 @@ int main(int argc, char *argv[]) FatalErrorInFunction << exit(FatalError); } + // Remove any left-over files + processorMeshes::removeFiles(mesh); // Need writing cellSet label nAdded = returnReduce(addedCellsSet.size(), sumOp