Commit b3156b0d authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: allow changing verbosity of topoSetSource (#1060)

- make topoSet set/unset methods virtual to allow overloading
parent 7325e3ac
......@@ -116,12 +116,20 @@ void Foam::badQualityToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding bad-quality cells" << endl;
if (verbose_)
{
Info<< " Adding bad-quality cells" << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing bad-quality cells" << endl;
if (verbose_)
{
Info<< " Removing bad-quality cells" << endl;
}
combine(set, false);
}
}
......
......@@ -112,12 +112,20 @@ void Foam::badQualityToFace::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding bad-quality faces" << endl;
if (verbose_)
{
Info<< " Adding bad-quality faces" << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing bad-quality faces" << endl;
if (verbose_)
{
Info<< " Removing bad-quality faces" << endl;
}
combine(set, false);
}
}
......
......@@ -144,13 +144,21 @@ void Foam::boxToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within boxes " << bbs_ << endl;
if (verbose_)
{
Info<< " Adding cells with centre within boxes "
<< bbs_ << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within boxes " << bbs_ << endl;
if (verbose_)
{
Info<< " Removing cells with centre within boxes "
<< bbs_ << endl;
}
combine(set, false);
}
......
......@@ -96,8 +96,11 @@ void Foam::cellToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all elements of cellSet " << setName_ << " ..."
<< endl;
if (verbose_)
{
Info<< " Adding all elements of cellSet " << setName_
<< " ..." << endl;
}
// Load the set
cellSet loadedSet(mesh_, setName_);
......@@ -106,8 +109,11 @@ void Foam::cellToCell::applyToSet
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all elements of cellSet " << setName_ << " ..."
<< endl;
if (verbose_)
{
Info<< " Removing all elements of cellSet " << setName_
<< " ..." << endl;
}
// Load the set
cellSet loadedSet(mesh_, setName_);
......
......@@ -160,21 +160,27 @@ void Foam::cylinderAnnulusToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within cylinder annulus,"
<< " with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
if (verbose_)
{
Info<< " Adding cells with centre within cylinder annulus,"
<< " with p1 = " << point1_ << ", p2 = " << point2_
<< ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within cylinder annulus,"
<< " with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
if (verbose_)
{
Info<< " Removing cells with centre within cylinder annulus,"
<< " with p1 = " << point1_ << ", p2 = " << point2_
<< ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, false);
}
......
......@@ -144,17 +144,23 @@ void Foam::cylinderToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
if (verbose_)
{
Info<< " Adding cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
if (verbose_)
{
Info<< " Removing cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, false);
}
......
......@@ -178,15 +178,21 @@ void Foam::faceToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells according to faceSet " << setName_
<< " ..." << endl;
if (verbose_)
{
Info<< " Adding cells according to faceSet " << setName_
<< " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells according to faceSet " << setName_
<< " ..." << endl;
if (verbose_)
{
Info<< " Removing cells according to faceSet " << setName_
<< " ..." << endl;
}
combine(set, false);
}
......
......@@ -78,9 +78,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
: zone.slaveCells()
);
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells on "
<< faceActionNames_[option_] << " side" << endl;
if (verbose_)
{
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells on "
<< faceActionNames_[option_] << " side" << endl;
}
for (const label celli : cellLabels)
{
......@@ -161,17 +164,23 @@ void Foam::faceZoneToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
if (verbose_)
{
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
if (verbose_)
{
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, false);
}
......
......@@ -74,12 +74,18 @@ void Foam::fieldToCell::applyToSet
topoSet& set
) const
{
Info<< " Field min:" << min(field) << " max:" << max(field) << endl;
if (verbose_)
{
Info << " Field min:" << min(field) << " max:" << max(field) << nl;
}
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
if (verbose_)
{
Info<< " Adding all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
}
forAll(field, celli)
{
......@@ -91,8 +97,11 @@ void Foam::fieldToCell::applyToSet
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
if (verbose_)
{
Info<< " Removing all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
}
forAll(field, celli)
{
......
......@@ -118,13 +118,21 @@ void Foam::labelToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells mentioned in dictionary" << " ..." << endl;
if (verbose_)
{
Info<< " Adding cells mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells mentioned in dictionary" << " ..." << endl;
if (verbose_)
{
Info<< " Removing cells mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, false);
}
......
......@@ -153,15 +153,21 @@ void Foam::nbrToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
if (verbose_)
{
Info<< " Adding cells with only " << minNbrs_
<< " or fewer neighbouring cells" << " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
if (verbose_)
{
Info<< " Removing cells with only " << minNbrs_
<< " or fewer neighbouring cells" << " ..." << endl;
}
combine(set, false);
}
......
......@@ -154,13 +154,19 @@ void Foam::nearestToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells nearest to " << points_ << endl;
if (verbose_)
{
Info<< " Adding cells nearest to " << points_ << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells nearest to " << points_ << endl;
if (verbose_)
{
Info<< " Removing cells nearest to " << points_ << endl;
}
combine(set, false);
}
......
......@@ -161,15 +161,21 @@ void Foam::pointToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells according to pointSet " << setName_
<< " ..." << endl;
if (verbose_)
{
Info<< " Adding cells according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells according to pointSet " << setName_
<< " ..." << endl;
if (verbose_)
{
Info<< " Removing cells according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, false);
}
......
......@@ -157,7 +157,7 @@ void Foam::regionToCell::unselectOutsideRegions
regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints_
boolList keepRegion(findRegions(true, cellRegion));
boolList keepRegion(findRegions(verbose_, cellRegion));
// Go back to bool per cell
forAll(cellRegion, celli)
......@@ -268,7 +268,7 @@ void Foam::regionToCell::erode
regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints
boolList keepRegion(findRegions(true, cellRegion));
boolList keepRegion(findRegions(verbose_, cellRegion));
// Extract cells in regions that are not to be kept.
......@@ -434,15 +434,23 @@ void Foam::regionToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
if (verbose_)
{
Info<< " Adding all cells of connected region "
<< "containing points "
<< insidePoints_ << " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
if (verbose_)
{
Info<< " Removing all cells of connected region "
<< "containing points "
<< insidePoints_ << " ..." << endl;
}
combine(set, false);
}
......
......@@ -178,13 +178,21 @@ void Foam::rotatedBoxToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells with centre within rotated box " << endl;
if (verbose_)
{
Info<< " Adding cells with centre within rotated box"
<< endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells with centre within rotated box " << endl;
if (verbose_)
{
Info<< " Removing cells with centre within rotated box"
<< endl;
}
combine(set, false);
}
......
......@@ -144,13 +144,21 @@ void Foam::shapeToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding all cells of type " << type_ << " ..." << endl;
if (verbose_)
{
Info<< " Adding all cells of type " << type_
<< " ..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing all cells of type " << type_ << " ..." << endl;
if (verbose_)
{
Info<< " Removing all cells of type " << type_
<< " ..." << endl;
}
combine(set, false);
}
......
......@@ -131,15 +131,21 @@ void Foam::sphereToCell::applyToSet
{
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
Info<< " Adding cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
if (verbose_)
{
Info<< " Adding cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
Info<< " Removing cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
if (verbose_)
{
Info<< " Removing cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
}
combine(set, false);
}
......
......@@ -154,8 +154,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
//- Calculate for each searchPoint inside/outside status.
boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
Info<< " Marked inside/outside using surface orientation in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
if (verbose_)
{
Info<< " Marked inside/outside using surface orientation in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
forAll(isInside, celli)
{
......@@ -206,8 +209,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
);
Info<< " Marked inside/outside using surface intersection in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
if (verbose_)
{
Info<< " Marked inside/outside using surface intersection in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
//- Add/remove cells using set
forAll(cellType, celli)
......@@ -250,8 +256,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
if (curvature_ < -1)
{
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface" << endl;
if (verbose_)
{
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface" << endl;
}
// No need to test curvature. Insert near cells into set.
......@@ -267,17 +276,22 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
}
}
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
if (verbose_)
{
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
}
else
{
// Test near cells for curvature
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface and curvature factor"
<< " less than " << curvature_ << endl;
if (verbose_)
{
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface and curvature factor"
<< " less than " << curvature_ << endl;
}
// Cache for nearest surface triangle for a point
Map<label> pointToNearest(mesh_.nCells()/10);
......@@ -307,8 +321,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
}
}
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
if (verbose_)
{
Info<< " Determined nearest surface point in = "