Commit 7325e3ac authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: topoSetSource::SUBTRACT enum action (#1060)

- old 'DELETE' enum was easily confused with 'REMOVE', which removes
  the set, not the elements from the set.

- provide corresponding subtractSet() method

STYLE: HashSet set/unset instead of insert/erase methods in topoSetSource

- simplifies switching to/from bitSet storage
parent 9b638f9a
......@@ -132,9 +132,9 @@ void printHelp(Ostream& os)
<< " clear - clears the set" << nl
<< " invert - inverts the set" << nl
<< " remove - remove the set" << nl
<< " new <source> - sets to set to the source set" << nl
<< " new <source> - use all elements from the source set" << nl
<< " add <source> - adds all elements from the source set" << nl
<< " delete <source> - deletes ,," << nl
<< " subtract <source> - subtract the source set elements" << nl
<< " subset <source> - combines current set with the source set"
<< nl
<< nl
......
......@@ -247,8 +247,8 @@ int main(int argc, char *argv[])
autoPtr<topoSet> currentSet;
if
(
(action == topoSetSource::NEW)
|| (action == topoSetSource::CLEAR)
action == topoSetSource::NEW
|| action == topoSetSource::CLEAR
)
{
currentSet = topoSet::New(setType, mesh, setName, 10000);
......@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{
case topoSetSource::NEW:
case topoSetSource::ADD:
case topoSetSource::DELETE:
case topoSetSource::SUBTRACT:
{
const word sourceName(dict.get<word>("source"));
......
......@@ -114,12 +114,12 @@ void Foam::badQualityToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding bad-quality cells" << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing bad-quality cells" << endl;
combine(set, false);
......
......@@ -110,12 +110,12 @@ void Foam::badQualityToFace::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding bad-quality faces" << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing bad-quality faces" << endl;
combine(set, false);
......
......@@ -142,15 +142,15 @@ void Foam::boxToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with center within boxes " << bbs_ << endl;
Info<< " Adding cells with centre within boxes " << bbs_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with center within boxes " << bbs_ << endl;
Info<< " Removing cells with centre within boxes " << bbs_ << endl;
combine(set, false);
}
......
......@@ -94,7 +94,7 @@ void Foam::cellToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all elements of cellSet " << setName_ << " ..."
<< endl;
......@@ -104,7 +104,7 @@ void Foam::cellToCell::applyToSet
set.addSet(loadedSet);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all elements of cellSet " << setName_ << " ..."
<< endl;
......@@ -112,7 +112,7 @@ void Foam::cellToCell::applyToSet
// Load the set
cellSet loadedSet(mesh_, setName_);
set.deleteSet(loadedSet);
set.subtractSet(loadedSet);
}
}
......
......@@ -158,7 +158,7 @@ void Foam::cylinderAnnulusToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within cylinder annulus,"
<< " with p1 = "
......@@ -168,7 +168,7 @@ void Foam::cylinderAnnulusToCell::applyToSet
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within cylinder annulus,"
<< " with p1 = "
......
......@@ -142,7 +142,7 @@ void Foam::cylinderToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
......@@ -150,7 +150,7 @@ void Foam::cylinderToCell::applyToSet
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
......
......@@ -176,14 +176,14 @@ void Foam::faceToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells according to faceSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells according to faceSet " << setName_
<< " ..." << endl;
......
......@@ -159,7 +159,7 @@ void Foam::faceZoneToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of face zones "
......@@ -167,7 +167,7 @@ void Foam::faceZoneToCell::applyToSet
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of face zones "
......
......@@ -74,10 +74,9 @@ void Foam::fieldToCell::applyToSet
topoSet& set
) const
{
Info<< " Field min:" << min(field)
<< " max:" << max(field) << endl;
Info<< " Field min:" << min(field) << " max:" << max(field) << endl;
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
......@@ -86,11 +85,11 @@ void Foam::fieldToCell::applyToSet
{
if (field[celli] >= min_ && field[celli] <= max_)
{
set.insert(celli);
set.set(celli);
}
}
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
......@@ -99,7 +98,7 @@ void Foam::fieldToCell::applyToSet
{
if (field[celli] >= min_ && field[celli] <= max_)
{
set.erase(celli);
set.unset(celli);
}
}
}
......
......@@ -116,13 +116,13 @@ void Foam::labelToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells mentioned in dictionary" << " ..." << endl;
addOrDelete(set, labels_, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells mentioned in dictionary" << " ..." << endl;
......
......@@ -151,14 +151,14 @@ void Foam::nbrToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
......
......@@ -152,13 +152,13 @@ void Foam::nearestToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells nearest to " << points_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells nearest to " << points_ << endl;
......
......@@ -159,14 +159,14 @@ void Foam::pointToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells according to pointSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells according to pointSet " << setName_
<< " ..." << endl;
......
......@@ -432,14 +432,14 @@ void Foam::regionToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
......
......@@ -176,15 +176,15 @@ void Foam::rotatedBoxToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with center within rotated box " << endl;
Info<< " Adding cells with centre within rotated box " << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with center within rotated box " << endl;
Info<< " Removing cells with centre within rotated box " << endl;
combine(set, false);
}
......
......@@ -142,13 +142,13 @@ void Foam::shapeToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells of type " << type_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells of type " << type_ << " ..." << endl;
......
......@@ -129,14 +129,14 @@ void Foam::sphereToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
......
......@@ -487,14 +487,14 @@ void Foam::surfaceToCell::applyToSet
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells in relation to surface " << surfName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells in relation to surface " << surfName_
<< " ..." << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment