diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 8f368f1b3f..c05958e4e9 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -33,9 +33,6 @@ Description #include "Time.H" #include "polyMesh.H" #include "topoSetSource.H" -#include "cellSet.H" -#include "faceSet.H" -#include "pointSet.H" #include "globalMeshData.H" #include "timeSelector.H" #include "IOobjectList.H" diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 5f0e5c0b39..e257d7d8c4 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -342,8 +342,12 @@ FoamFile // // cellZoneSet // ~~~~~~~~~~~ -// (mirrors operations on a cellSet into a cellZone) +// Manipulates a cellZone (as well as a cellSet) +// Takes any cellSet source. The difference with a cellSet is +// - reads the cells from the cellZone, not the cellSet +// - write to the cellZone as well as the cellSet // +// For backwards compatibility: // // Select based on cellSet // source setToCellZone; // sourceInfo @@ -355,6 +359,9 @@ FoamFile // // faceZoneSet // ~~~~~~~~~~~ +// Manipulates a faceZone (as well as a faceSet). It can only be used +// with two special sources: +// // // Select based on faceSet without orientation // source setToFaceZone; // sourceInfo @@ -391,17 +398,19 @@ FoamFile // // pointZoneSet // ~~~~~~~~~~~~ -// (mirrors operations on a pointSet into a pointZone) +// Manipulates a pointZone (as well as a pointSet) +// Takes any pointSet source. The difference with a pointSet is +// - reads the cells from the pointZone, not the pointSet +// - write to the pointZone as well as the pointSet // +// For backwards compatibility: // // Select based on pointSet // source setToPointZone; // sourceInfo // { // set p0; // name of pointSet // } -// -// -// + actions ( @@ -413,7 +422,7 @@ actions name c0; type cellSet; action new; - source labelToCell; + source labelToCell; sourceInfo { value (12 13 56); @@ -462,6 +471,19 @@ actions option all; } } + + + // Example: create cellZone from geometric region + { + name c0; + type cellZoneSet; + action new; + source boxToCell; + sourceInfo + { + box (0.04 0 0)(0.06 100 100); + } + } ); // ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/cellZoneSet.C b/src/meshTools/sets/topoSets/cellZoneSet.C index 5fc39bf142..9551827c29 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.C +++ b/src/meshTools/sets/topoSets/cellZoneSet.C @@ -229,7 +229,13 @@ void cellZoneSet::deleteSet(const topoSet& set) void cellZoneSet::sync(const polyMesh& mesh) -{} +{ + cellSet::sync(mesh); + + // Take over contents of cellSet into addressing. + addressing_ = sortedToc(); + updateSet(); +} label cellZoneSet::maxSize(const polyMesh& mesh) const diff --git a/src/meshTools/sets/topoSets/cellZoneSet.H b/src/meshTools/sets/topoSets/cellZoneSet.H index d3dfe2e63b..ee7a3ebb63 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.H +++ b/src/meshTools/sets/topoSets/cellZoneSet.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Class Foam::cellZoneSet Description - Like cellSet but updates cellZone when writing. + Like cellSet but -reads data from cellZone -updates cellZone when writing. SourceFiles cellZone.C @@ -126,7 +126,7 @@ public: //- Delete elements present in set. virtual void deleteSet(const topoSet& set); - //- Sync cellZoneSet across coupled patches. + //- Sync cellSet across coupled patches; update cellZone from cellSet virtual void sync(const polyMesh& mesh); //- Write maxLen items with label and coordinates. @@ -150,10 +150,6 @@ public: //- Return max index+1. virtual label maxSize(const polyMesh& mesh) const; - - - - }; diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C index cbd882d76c..608109f7d5 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.C +++ b/src/meshTools/sets/topoSets/faceZoneSet.C @@ -26,6 +26,9 @@ License #include "faceZoneSet.H" #include "mapPolyMesh.H" #include "polyMesh.H" +#include "setToFaceZone.H" +#include "setsToFaceZone.H" +#include "syncTools.H" #include "addToRunTimeSelectionTable.H" @@ -322,7 +325,132 @@ void faceZoneSet::deleteSet(const topoSet& set) void faceZoneSet::sync(const polyMesh& mesh) -{} +{ + // Make sure that the faceZone is consistent with the faceSet + { + const labelHashSet zoneSet(addressing_); + + // Get elements that are in zone but not faceSet + labelHashSet badSet(zoneSet); + badSet -= *this; + + // Add elements that are in faceSet but not in zone + labelHashSet fSet(*this); + fSet -= zoneSet; + + badSet += fSet; + + label nBad = returnReduce(badSet.size(), sumOp