diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index fc99cc81e5d42dda61bce5fbe20df5052e4cbb75..5141980c3d4e1fa7c9b6b4eb1bd16873eef531f4 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -384,7 +384,7 @@ bool doCommand try { topoSetSource::setAction action = - topoSetSource::toAction(actionName); + topoSetSource::actionNames[actionName]; IOobject::readOption r; @@ -713,26 +713,11 @@ commandStatus parseType commandStatus parseAction(const word& actionName) { - commandStatus stat = INVALID; - - if (actionName.size()) - { - try - { - (void)topoSetSource::toAction(actionName); - - stat = VALIDSETCMD; - } - catch (Foam::IOerror& fIOErr) - { - stat = INVALID; - } - catch (Foam::error& fErr) - { - stat = INVALID; - } - } - return stat; + return + ( + actionName.size() && topoSetSource::actionNames.found(actionName) + ? VALIDSETCMD : INVALID + ); } diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 04c54e25472bf84f69b8cf1f11451442c99d0eb5..a0ad8a715f4137b7d6b82edc0d3444130662b1b6 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) const word dictName("topoSetDict"); #include "setSystemMeshDictionaryIO.H" - Info<< "Reading " << dictName << "\n" << endl; + Info<< "Reading " << dictName << nl << endl; IOdictionary topoSetDict(dictIO); @@ -238,19 +238,13 @@ int main(int argc, char *argv[]) meshReadUpdate(mesh); // Execute all actions - forAll(actions, i) + for (const dictionary& dict : actions) { - const dictionary& dict = actions[i]; + const word setName(dict.get<word>("name")); + const word setType(dict.get<word>("type")); - const word setName(dict.lookup("name")); - const word actionName(dict.lookup("action")); - const word setType(dict.lookup("type")); - - - topoSetSource::setAction action = topoSetSource::toAction - ( - actionName - ); + const topoSetSource::setAction action = + topoSetSource::actionNames.lookup("action", dict); autoPtr<topoSet> currentSet; if @@ -283,20 +277,20 @@ int main(int argc, char *argv[]) } - - // Handle special actions (clear, invert) locally, rest through - // sources. + // Handle special actions (clear, invert) locally, + // the other actions through sources. switch (action) { case topoSetSource::NEW: case topoSetSource::ADD: case topoSetSource::DELETE: { - Info<< " Applying source " << word(dict.lookup("source")) - << endl; + const word sourceName(dict.get<word>("source")); + + Info<< " Applying source " << sourceName << endl; autoPtr<topoSetSource> source = topoSetSource::New ( - dict.lookup("source"), + sourceName, mesh, dict.subDict("sourceInfo") ); @@ -310,11 +304,12 @@ int main(int argc, char *argv[]) case topoSetSource::SUBSET: { - Info<< " Applying source " << word(dict.lookup("source")) - << endl; + const word sourceName(dict.get<word>("source")); + + Info<< " Applying source " << sourceName << endl; autoPtr<topoSetSource> source = topoSetSource::New ( - dict.lookup("source"), + sourceName, mesh, dict.subDict("sourceInfo") ); @@ -359,7 +354,6 @@ int main(int argc, char *argv[]) removeSet(mesh, setType, setName); break; - default: WarningInFunction << "Unhandled action " << action << endl; @@ -368,16 +362,16 @@ int main(int argc, char *argv[]) if (currentSet.valid()) { - Info<< " " << currentSet().type() << " " - << currentSet().name() - << " now size " + Info<< " " + << currentSet().type() << " " + << currentSet().name() << " now size " << returnReduce(currentSet().size(), sumOp<label>()) << endl; } } } - Info<< "End\n" << endl; + Info<< "\nEnd\n" << endl; return 0; } diff --git a/src/meshTools/output/foamVtkWriteCellSetFaces.C b/src/meshTools/output/foamVtkWriteCellSetFaces.C index 4815a375ddb4c5d85e950b34171177206d8061af..9a10c37e72d9fce91dc0c3b093991380bf6ae034 100644 --- a/src/meshTools/output/foamVtkWriteCellSetFaces.C +++ b/src/meshTools/output/foamVtkWriteCellSetFaces.C @@ -60,15 +60,12 @@ void Foam::vtk::writeCellSetFaces Map<label> cellFaces(2*set.size()); - forAllConstIters(set, iter) + for (const label celli : static_cast<const labelHashSet&>(set)) { - label celli = iter.key(); const cell& cFaces = mesh.cells()[celli]; - forAll(cFaces, i) + for (const label facei : cFaces) { - label facei = cFaces[i]; - if (mesh.isInternalFace(facei)) { label otherCelli = mesh.faceOwner()[facei]; @@ -90,7 +87,7 @@ void Foam::vtk::writeCellSetFaces } } - const labelList faceLabels = cellFaces.sortedToc(); + const labelList faceLabels(cellFaces.sortedToc()); labelList faceValues(cellFaces.size()); forAll(faceLabels, facei) diff --git a/src/meshTools/output/foamVtkWriteCellSetFaces.H b/src/meshTools/output/foamVtkWriteCellSetFaces.H index 765ff60807fd28dd7c127940d5b2ed2699076913..e4d15efc9e2ca9c09379a84354e05862aaaf9a66 100644 --- a/src/meshTools/output/foamVtkWriteCellSetFaces.H +++ b/src/meshTools/output/foamVtkWriteCellSetFaces.H @@ -45,6 +45,8 @@ SourceFiles namespace Foam { + +// Forward declarations class primitiveMesh; class cellSet; class fileName; diff --git a/src/meshTools/output/foamVtkWriteFaceSet.C b/src/meshTools/output/foamVtkWriteFaceSet.C index 81c54434a8d2489c7f7739ba1a8d9aa435eb7a01..f0f2a215211dffa010b5867c37733e2bc06d6c0f 100644 --- a/src/meshTools/output/foamVtkWriteFaceSet.C +++ b/src/meshTools/output/foamVtkWriteFaceSet.C @@ -57,7 +57,7 @@ void Foam::vtk::writeFaceSet //------------------------------------------------------------------------- // Faces of set with OpenFOAM faceID as value - const labelList faceLabels = set.sortedToc(); + const labelList faceLabels(set.sortedToc()); uindirectPrimitivePatch pp ( diff --git a/src/meshTools/output/foamVtkWriteFaceSet.H b/src/meshTools/output/foamVtkWriteFaceSet.H index 2469b45f3d3467b3559aa24048d46191bebda648..d556c91bdb741697d3870f8ffe77ee09cf415df1 100644 --- a/src/meshTools/output/foamVtkWriteFaceSet.H +++ b/src/meshTools/output/foamVtkWriteFaceSet.H @@ -42,6 +42,8 @@ SourceFiles namespace Foam { + +// Forward declarations class primitiveMesh; class faceSet; class fileName; diff --git a/src/meshTools/output/foamVtkWritePointSet.H b/src/meshTools/output/foamVtkWritePointSet.H index 830dfd304a1363dab4e7fe815f9ab6c606f5dae2..576f2ccb4d186eb7f8e5843dca0f254a07ae772d 100644 --- a/src/meshTools/output/foamVtkWritePointSet.H +++ b/src/meshTools/output/foamVtkWritePointSet.H @@ -42,6 +42,8 @@ SourceFiles namespace Foam { + +// Forward declarations class primitiveMesh; class pointSet; class fileName; diff --git a/src/meshTools/sets/cellSources/boxToCell/boxToCell.C b/src/meshTools/sets/cellSources/boxToCell/boxToCell.C index db3d7b14663b36a45636082815f0aee2f97340cd..e8e6db6aa4f305116fc4b2d0fb6a71b41e38c403 100644 --- a/src/meshTools/sets/cellSources/boxToCell/boxToCell.C +++ b/src/meshTools/sets/cellSources/boxToCell/boxToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,9 +53,9 @@ void Foam::boxToCell::combine(topoSet& set, const bool add) const forAll(ctrs, celli) { - forAll(bbs_, i) + for (const auto& bb : bbs_) { - if (bbs_[i].contains(ctrs[celli])) + if (bb.contains(ctrs[celli])) { addOrDelete(set, celli, add); break; @@ -110,12 +110,6 @@ Foam::boxToCell::boxToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::boxToCell::~boxToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::boxToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H index 24a8b482733b71d059367995f193e19a8d17819d..7360bd0e90a093fd81286819ec0e33d13b565721 100644 --- a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H +++ b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,16 @@ Class Description A topoSetSource to select cells based on cell centres inside box(es). + \heading Dictionary parameters + \table + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | + \endtable + +Note + Must specify either "box" or "boxes" + SourceFiles boxToCell.C @@ -56,7 +66,7 @@ class boxToCell //- Add usage string static addToUsageTable usage_; - //- Bounding box. + //- Bounding boxes treeBoundBoxList bbs_; @@ -80,22 +90,14 @@ public: ); //- Construct from dictionary - boxToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + boxToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - boxToCell - ( - const polyMesh& mesh, - Istream& - ); + boxToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~boxToCell(); + virtual ~boxToCell() = default; // Member Functions @@ -108,7 +110,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C index 4644f755af36014a92c59fff543e966d7c513c89..6761dab811bfcab957fd545fb60e7ab5ceee9c96 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::cellToCell::cellToCell ) : topoSetSource(mesh), - setName_(dict.lookup("set")) + setName_(dict.get<word>("set")) {} @@ -81,12 +81,6 @@ Foam::cellToCell::cellToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellToCell::~cellToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cellToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H index e3e0c1e032ccf3d67e4ff31bf73324a1fb5e4fd0..23fb8be3d83c68a6b0c8ccd964d378229b12dc4d 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select the cells from another cellSet. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The cell set name | yes | + \endtable + SourceFiles cellToCell.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - cellToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + cellToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cellToCell - ( - const polyMesh& mesh, - Istream& - ); + cellToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~cellToCell(); + virtual ~cellToCell() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C index a566caf656cf2a433500707287e8631750323e3a..6a88cfb80ea5f11e0292a726060d7ca7871bd899 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,7 +50,7 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderAnnulusToCell::usage_ void Foam::cylinderAnnulusToCell::combine(topoSet& set, const bool add) const { - const vector axis = p2_ - p1_; + const vector axis = (point2_ - point1_); const scalar orad2 = sqr(outerRadius_); const scalar irad2 = sqr(innerRadius_); const scalar magAxis2 = magSqr(axis); @@ -59,12 +59,12 @@ void Foam::cylinderAnnulusToCell::combine(topoSet& set, const bool add) const forAll(ctrs, celli) { - vector d = ctrs[celli] - p1_; - scalar magD = d & axis; + const vector d = ctrs[celli] - point1_; + const scalar magD = d & axis; if ((magD > 0) && (magD < magAxis2)) { - scalar d2 = (d & d) - sqr(magD)/magAxis2; + const scalar d2 = (d & d) - sqr(magD)/magAxis2; if ((d2 < orad2) && (d2 > irad2)) { addOrDelete(set, celli, add); @@ -79,15 +79,15 @@ void Foam::cylinderAnnulusToCell::combine(topoSet& set, const bool add) const Foam::cylinderAnnulusToCell::cylinderAnnulusToCell ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar outerRadius, const scalar innerRadius ) : topoSetSource(mesh), - p1_(p1), - p2_(p2), + point1_(point1), + point2_(point2), outerRadius_(outerRadius), innerRadius_(innerRadius) {} @@ -100,10 +100,10 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell ) : topoSetSource(mesh), - p1_(dict.lookup("p1")), - p2_(dict.lookup("p2")), - outerRadius_(readScalar(dict.lookup("outerRadius"))), - innerRadius_(readScalar(dict.lookup("innerRadius"))) + point1_(dict.get<point>("p1")), + point2_(dict.get<point>("p2")), + outerRadius_(dict.get<scalar>("outerRadius")), + innerRadius_(dict.get<scalar>("innerRadius")) {} @@ -114,19 +114,13 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell ) : topoSetSource(mesh), - p1_(checkIs(is)), - p2_(checkIs(is)), + point1_(checkIs(is)), + point2_(checkIs(is)), outerRadius_(readScalar(checkIs(is))), innerRadius_(readScalar(checkIs(is))) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cylinderAnnulusToCell::~cylinderAnnulusToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cylinderAnnulusToCell::applyToSet @@ -139,18 +133,19 @@ void Foam::cylinderAnnulusToCell::applyToSet { Info<< " Adding cells with centre within cylinder annulus," << " with p1 = " - << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_ - << " and inner radius = " << innerRadius_ - << endl; + << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { - Info<< " Removing cells with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_ - << " and inner radius " << innerRadius_ - << endl; + Info<< " Removing cells with centre within cylinder annulus," + << " with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; combine(set, false); } diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H index d5489872b216508bbb4435610a1f78d286555bcd..af8bd0bad239717cdbae0ea5f35d1d247bf56e07 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,15 @@ Description A topoSetSource to select cells based on cell centres inside a cylinder annulus. + \heading Dictionary parameters + \table + Property | Description | Required | Default + p1 | coordinate of endpoint | yes | + p2 | coordinate of endpoint | yes | + outerRadius | cylinder outer radius | yes | + innerRadius | cylinder inner radius | yes | + \endtable + SourceFiles cylinderAnnulusToCell.C @@ -58,10 +67,10 @@ class cylinderAnnulusToCell static addToUsageTable usage_; //- First point on cylinder axis - vector p1_; + point point1_; //- Second point on cylinder axis - vector p2_; + point point2_; //- Outer Radius scalar outerRadius_; @@ -87,29 +96,22 @@ public: cylinderAnnulusToCell ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar outerRadius, const scalar innerRadius ); //- Construct from dictionary - cylinderAnnulusToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + cylinderAnnulusToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cylinderAnnulusToCell - ( - const polyMesh& mesh, - Istream& - ); + cylinderAnnulusToCell(const polyMesh& mesh, Istream& is); + + //- Destructor + virtual ~cylinderAnnulusToCell() = default; - // Destructor - virtual ~cylinderAnnulusToCell(); // Member Functions @@ -121,7 +123,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C index 6094b9c02fc699aef9de7d87ef93d773d7d3ca47..a8ceeb408b61c62ddc32e38b5024df3a197ebafe 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,7 +49,7 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderToCell::usage_ void Foam::cylinderToCell::combine(topoSet& set, const bool add) const { - const vector axis = p2_ - p1_; + const vector axis = (point2_ - point1_); const scalar rad2 = sqr(radius_); const scalar magAxis2 = magSqr(axis); @@ -57,12 +57,12 @@ void Foam::cylinderToCell::combine(topoSet& set, const bool add) const forAll(ctrs, celli) { - vector d = ctrs[celli] - p1_; - scalar magD = d & axis; + const vector d = ctrs[celli] - point1_; + const scalar magD = d & axis; if ((magD > 0) && (magD < magAxis2)) { - scalar d2 = (d & d) - sqr(magD)/magAxis2; + const scalar d2 = (d & d) - sqr(magD)/magAxis2; if (d2 < rad2) { addOrDelete(set, celli, add); @@ -77,14 +77,14 @@ void Foam::cylinderToCell::combine(topoSet& set, const bool add) const Foam::cylinderToCell::cylinderToCell ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar radius ) : topoSetSource(mesh), - p1_(p1), - p2_(p2), + point1_(point1), + point2_(point2), radius_(radius) {} @@ -96,9 +96,9 @@ Foam::cylinderToCell::cylinderToCell ) : topoSetSource(mesh), - p1_(dict.lookup("p1")), - p2_(dict.lookup("p2")), - radius_(readScalar(dict.lookup("radius"))) + point1_(dict.get<point>("p1")), + point2_(dict.get<point>("p2")), + radius_(dict.get<scalar>("radius")) {} @@ -109,18 +109,12 @@ Foam::cylinderToCell::cylinderToCell ) : topoSetSource(mesh), - p1_(checkIs(is)), - p2_(checkIs(is)), + point1_(checkIs(is)), + point2_(checkIs(is)), radius_(readScalar(checkIs(is))) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cylinderToCell::~cylinderToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cylinderToCell::applyToSet @@ -132,14 +126,16 @@ void Foam::cylinderToCell::applyToSet if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { Info<< " Adding cells with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { Info<< " Removing cells with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; combine(set, false); } diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H index 820c10831457158174460b65a43da4223de5a7c3..0d3db7640a66de5304693bfe69b3e731dee14375 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description A topoSetSource to select cells based on cell centres inside a cylinder. + \heading Dictionary parameters + \table + Property | Description | Required | Default + p1 | coordinate of endpoint | yes | + p2 | coordinate of endpoint | yes | + radius | cylinder radius | yes | + \endtable + SourceFiles cylinderToCell.C @@ -57,10 +65,10 @@ class cylinderToCell static addToUsageTable usage_; //- First point on cylinder axis - vector p1_; + point point1_; //- Second point on cylinder axis - vector p2_; + point point2_; //- Radius scalar radius_; @@ -83,28 +91,20 @@ public: cylinderToCell ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar radius ); //- Construct from dictionary - cylinderToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + cylinderToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cylinderToCell - ( - const polyMesh& mesh, - Istream& - ); + cylinderToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~cylinderToCell(); + virtual ~cylinderToCell() = default; // Member Functions @@ -117,7 +117,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C index 5847c624dd29541cedc4808b6841dccfae870a42..9142f32ae0acebdd1f051ea9168a24ca85b3de76 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,10 +52,10 @@ const Foam::Enum > Foam::faceToCell::faceActionNames_ { - { faceAction::NEIGHBOUR, "neighbour" }, - { faceAction::OWNER, "owner" }, { faceAction::ANY, "any" }, { faceAction::ALL, "all" }, + { faceAction::OWNER, "owner" }, + { faceAction::NEIGHBOUR, "neighbour" }, }; @@ -66,12 +66,11 @@ void Foam::faceToCell::combine(topoSet& set, const bool add) const // Load the set faceSet loadedSet(mesh_, setName_); + const labelHashSet& faceLabels = loadedSet; // Handle owner/neighbour/any selection - forAllConstIter(faceSet, loadedSet, iter) + for (const label facei : faceLabels) { - const label facei = iter.key(); - if ((option_ == OWNER) || (option_ == ANY)) { const label celli = mesh_.faceOwner()[facei]; @@ -97,46 +96,26 @@ void Foam::faceToCell::combine(topoSet& set, const bool add) const Map<label> facesPerCell(loadedSet.size()); - forAllConstIter(faceSet, loadedSet, iter) + for (const label facei : faceLabels) { - const label facei = iter.key(); - const label own = mesh_.faceOwner()[facei]; - - Map<label>::iterator fndOwn = facesPerCell.find(own); - - if (fndOwn == facesPerCell.end()) - { - facesPerCell.insert(own, 1); - } - else - { - fndOwn()++; - } + // Count faces on owner + ++(facesPerCell(mesh_.faceOwner()[facei], 0)); if (mesh_.isInternalFace(facei)) { - label nei = mesh_.faceNeighbour()[facei]; - - Map<label>::iterator fndNei = facesPerCell.find(nei); - - if (fndNei == facesPerCell.end()) - { - facesPerCell.insert(nei, 1); - } - else - { - fndNei()++; - } + // Count faces on neighbour + ++(facesPerCell(mesh_.faceNeighbour()[facei], 0)); } } // Include cells that are referenced as many times as they have faces // -> all faces in set. - forAllConstIter(Map<label>, facesPerCell, iter) + forAllConstIters(facesPerCell, iter) { const label celli = iter.key(); + const label count = iter.object(); - if (iter() == mesh_.cells()[celli].size()) + if (count == mesh_.cells()[celli].size()) { addOrDelete(set, celli, add); } @@ -167,7 +146,7 @@ Foam::faceToCell::faceToCell ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(faceActionNames_.lookup("option", dict)) {} @@ -184,12 +163,6 @@ Foam::faceToCell::faceToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceToCell::~faceToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H index 59564ac2a1edf07944474e284f6dd02922e59264..ced05a8f4ea52fde72e50eaab24db0c460830e21 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,14 @@ Class Foam::faceToCell Description - A topoSetSource to select cells based on usage in faces. + A topoSetSource to select cells based on usage in a face set. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The face set name to use | yes | + option | Selection type (all/any/owner/neighbour) | yes | + \endtable SourceFiles faceToCell.C @@ -55,10 +62,10 @@ public: //- Enumeration defining the valid options enum faceAction { - NEIGHBOUR, - OWNER, ANY, - ALL + ALL, + OWNER, + NEIGHBOUR }; private: @@ -99,22 +106,14 @@ public: ); //- Construct from dictionary - faceToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + faceToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - faceToCell - ( - const polyMesh& mesh, - Istream& - ); + faceToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~faceToCell(); + virtual ~faceToCell() = default; // Member Functions @@ -127,7 +126,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C index 96ddde1489176e6f6b4c0e4ffa6185d472b4f03f..8453e1a38767ee065009d93668bbf1aa60f603e8 100644 --- a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.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) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,12 +63,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const { bool hasMatched = false; - forAll(mesh_.faceZones(), i) + for (const faceZone& zone : mesh_.faceZones()) { - const faceZone& zone = mesh_.faceZones()[i]; - if (zoneName_.match(zone.name())) { + hasMatched = true; + const labelList& cellLabels = ( option_ == MASTER @@ -80,14 +80,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const << " with " << cellLabels.size() << " cells on selected side." << endl; - hasMatched = true; - - forAll(cellLabels, i) + for (const label celli : cellLabels) { // Only do active cells - if (cellLabels[i] >= 0 && cellLabels[i] < mesh_.nCells()) + if (celli >= 0 && celli < mesh_.nCells()) { - addOrDelete(set, cellLabels[i], add); + addOrDelete(set, celli, add); } } } @@ -96,8 +94,9 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any faceZone named " << zoneName_ << endl - << "Valid names are " << mesh_.faceZones().names() << endl; + << "Cannot find any faceZone named " << zoneName_ << nl + << "Valid names: " << flatOutput(mesh_.faceZones().names()) + << endl; } } @@ -124,7 +123,7 @@ Foam::faceZoneToCell::faceZoneToCell ) : topoSetSource(mesh), - zoneName_(dict.lookup("name")), + zoneName_(dict.get<wordRe>("name")), option_(faceActionNames_.lookup("option", dict)) {} @@ -141,12 +140,6 @@ Foam::faceZoneToCell::faceZoneToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceZoneToCell::~faceZoneToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceZoneToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H index 5c8dcb61a5b909e787fa29fc98a1567c90327498..3096d7ddf75fc0f1c16e3761709465e1855d0848 100644 --- a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select cells based on side of faceZone. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The face zone name or regex | yes | + option | Selection type (master / slave) | yes | + \endtable + SourceFiles faceZoneToCell.C @@ -96,22 +103,14 @@ public: ); //- Construct from dictionary - faceZoneToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + faceZoneToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - faceZoneToCell - ( - const polyMesh& mesh, - Istream& - ); + faceZoneToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~faceZoneToCell(); + virtual ~faceZoneToCell() = default; // Member Functions @@ -124,7 +123,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H b/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H index 6bb1ca1052dd753e988cac3ef9fedad94105c9a5..2ba6664c6301c076b6f10a1cf699c6257d4f3818 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H @@ -40,7 +40,6 @@ Description namespace Foam { - /*---------------------------------------------------------------------------*\ Class fieldDictionary Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C index c3914d5bb9f81013de8bd35ae62be9d6a97c2418..150eeb2ab978e5feb5bc29cfc38135fdec7fe589 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,6 @@ License #include "Time.H" #include "IFstream.H" #include "fieldDictionary.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -115,9 +114,9 @@ Foam::fieldToCell::fieldToCell ) : topoSetSource(mesh), - fieldName_(dict.lookup("field")), - min_(readScalar(dict.lookup("min"))), - max_(readScalar(dict.lookup("max"))) + fieldName_(dict.get<word>("field")), + min_(dict.get<scalar>("min")), + max_(dict.get<scalar>("max")) {} @@ -134,12 +133,6 @@ Foam::fieldToCell::fieldToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::fieldToCell::~fieldToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::fieldToCell::applyToSet @@ -170,22 +163,22 @@ void Foam::fieldToCell::applyToSet // Note: should use volScalarField::typeName instead below // but that would introduce linkage problems (finiteVolume needs // meshTools) - else if (fieldObject.headerClassName() == "volScalarField") + else if ("volScalarField" == fieldObject.headerClassName()) { IFstream str(typeFilePath<labelIOList>(fieldObject)); - // Read dictionary + // Read as dictionary fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName()); scalarField internalVals("internalField", fieldDict, mesh().nCells()); applyToSet(action, internalVals, set); } - else if (fieldObject.headerClassName() == "volVectorField") + else if ("volVectorField" == fieldObject.headerClassName()) { IFstream str(typeFilePath<labelIOList>(fieldObject)); - // Read dictionary + // Read as dictionary fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName()); vectorField internalVals("internalField", fieldDict, mesh().nCells()); diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H index fb5a98d2a9beb6757c0c2e22ed2bc7a1e921fc9b..c09e2773c815b5a7e02e7c85161c09e7dd8dfe58 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description A topoSetSource to select cells based on field values. + \heading Dictionary parameters + \table + Property | Description | Required | Default + field | The (scalar, vector) field to use | yes | + min | The min value for the subset | yes | + max | The max value for the subset | yes | + \endtable + SourceFiles fieldToCell.C @@ -58,13 +66,13 @@ class fieldToCell static addToUsageTable usage_; - //- Name of volScalarField + //- Name of volScalarField, volVectorField word fieldName_; //- Min to subset field values with scalar min_; - //- Max ,, + //- Max to subset field values with scalar max_; @@ -95,22 +103,14 @@ public: ); //- Construct from dictionary - fieldToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + fieldToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - fieldToCell - ( - const polyMesh& mesh, - Istream& - ); + fieldToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~fieldToCell(); + virtual ~fieldToCell() = default; // Member Functions @@ -123,7 +123,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/labelToCell/labelToCell.C b/src/meshTools/sets/cellSources/labelToCell/labelToCell.C index 2f71548cdeb4189c191005c19a9b21133a869d2d..13fda7b6d91ff993e137f4e1e787b943fd85e29c 100644 --- a/src/meshTools/sets/cellSources/labelToCell/labelToCell.C +++ b/src/meshTools/sets/cellSources/labelToCell/labelToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,17 +45,6 @@ Foam::topoSetSource::addToUsageTable Foam::labelToCell::usage_ ); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::labelToCell::combine(topoSet& set, const bool add) const -{ - forAll(labels_, labelI) - { - addOrDelete(set, labels_[labelI], add); - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::labelToCell::labelToCell @@ -76,7 +65,7 @@ Foam::labelToCell::labelToCell ) : topoSetSource(mesh), - labels_(dict.lookup("value")) + labels_(dict.get<labelList>("value")) {} @@ -88,13 +77,9 @@ Foam::labelToCell::labelToCell : topoSetSource(mesh), labels_(checkIs(is)) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::labelToCell::~labelToCell() -{} +{ + check(labels_, mesh.nCells()); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -109,13 +94,13 @@ void Foam::labelToCell::applyToSet { Info<< " Adding cells mentioned in dictionary" << " ..." << endl; - combine(set, true); + addOrDelete(set, labels_, true); } else if (action == topoSetSource::DELETE) { Info<< " Removing cells mentioned in dictionary" << " ..." << endl; - combine(set, false); + addOrDelete(set, labels_, false); } } diff --git a/src/meshTools/sets/cellSources/labelToCell/labelToCell.H b/src/meshTools/sets/cellSources/labelToCell/labelToCell.H index 2be415980c72caeee6ea8d19616336f2df915cef..ca9c12e1ff37552c1bc48d7fe667add09a54e728 100644 --- a/src/meshTools/sets/cellSources/labelToCell/labelToCell.H +++ b/src/meshTools/sets/cellSources/labelToCell/labelToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select cells based on explicitly given labels. + \heading Dictionary parameters + \table + Property | Description | Required | Default + value | The cell labels | yes | + \endtable + SourceFiles labelToCell.C @@ -60,11 +66,6 @@ class labelToCell labelList labels_; - // Private Member Functions - - void combine(topoSet& set, const bool add) const; - - public: //- Runtime type information @@ -80,22 +81,14 @@ public: ); //- Construct from dictionary - labelToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + labelToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - labelToCell - ( - const polyMesh& mesh, - Istream& - ); + labelToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~labelToCell(); + virtual ~labelToCell() = default; // Member Functions @@ -108,7 +101,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C index 85f5f494b356d295a7f2dd2db09d01e56418cb80..7aca426d575883630bfcc10cac322d819fe7f8a9 100644 --- a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C +++ b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,17 +54,15 @@ void Foam::nbrToCell::combine(topoSet& set, const bool add) const boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false); - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (pp.coupled()) { label facei = pp.start(); forAll(pp, i) { isCoupled[facei-mesh_.nInternalFaces()] = true; - facei++; + ++facei; } } } @@ -75,17 +73,15 @@ void Foam::nbrToCell::combine(topoSet& set, const bool add) const label nNbrCells = 0; - forAll(cFaces, i) + for (const label facei : cFaces) { - label facei = cFaces[i]; - if (mesh_.isInternalFace(facei)) { - nNbrCells++; + ++nNbrCells; } else if (isCoupled[facei-mesh_.nInternalFaces()]) { - nNbrCells++; + ++nNbrCells; } } @@ -117,7 +113,7 @@ Foam::nbrToCell::nbrToCell ) : topoSetSource(mesh), - minNbrs_(readLabel(dict.lookup("neighbours"))) + minNbrs_(dict.get<label>("neighbours")) {} @@ -132,12 +128,6 @@ Foam::nbrToCell::nbrToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::nbrToCell::~nbrToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::nbrToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H index e6ece736877b0f30ee2f1c6958e286999844aaf4..7bd4801bd0c5370d4f32da1ac86a5a0300cf3739 100644 --- a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H +++ b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,12 @@ Description A topoSetSource to select cells based on number of neighbouring cells (i.e. number of internal or coupled faces) + \heading Dictionary parameters + \table + Property | Description | Required | Default + neighbours | Number of neighbours | yes | + \endtable + SourceFiles nbrToCell.C @@ -71,6 +77,7 @@ public: //- Runtime type information TypeName("nbrToCell"); + // Constructors //- Construct from components @@ -81,22 +88,14 @@ public: ); //- Construct from dictionary - nbrToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + nbrToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - nbrToCell - ( - const polyMesh& mesh, - Istream& - ); + nbrToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~nbrToCell(); + virtual ~nbrToCell() = default; // Member Functions @@ -109,7 +108,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C index d7e2e11f8ff22197c79c5a13993d7609c6603928..03779fd61d923d56b2e32fb7b08e102729cb877f 100644 --- a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C +++ b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,8 +55,9 @@ void Foam::nearestToCell::combine(topoSet& set, const bool add) const forAll(points_, pointi) { - label celli = mesh_.findNearestCell(points_[pointi]); + const label celli = mesh_.findNearestCell(points_[pointi]); const point& cc = mesh_.cellCentres()[celli]; + nearest[pointi].first() = pointIndexHit(true, cc, celli); nearest[pointi].second() = Tuple2<scalar, label> ( @@ -68,11 +69,11 @@ void Foam::nearestToCell::combine(topoSet& set, const bool add) const Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp()); Pstream::listCombineScatter(nearest); - forAll(nearest, pointi) + for (const auto& near : nearest) { - if (nearest[pointi].second().second() == Pstream::myProcNo()) + if (near.second().second() == Pstream::myProcNo()) { - addOrDelete(set, nearest[pointi].first().index(), add); + addOrDelete(set, near.first().index(), add); } } } @@ -98,7 +99,7 @@ Foam::nearestToCell::nearestToCell ) : topoSetSource(mesh), - points_(dict.lookup("points")) + points_(dict.get<pointField>("points")) {} @@ -113,12 +114,6 @@ Foam::nearestToCell::nearestToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::nearestToCell::~nearestToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::nearestToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H index 0c6c664d7ff4d6a97c0ffc2dba2d0aa8de0290b4..e2b393f5e1ad80f3fd9726997fbaaf88917a69ed 100644 --- a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H +++ b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select cells nearest to points. + \heading Dictionary parameters + \table + Property | Description | Required | Default + points | List of selection points | yes | + \endtable + SourceFiles nearestToCell.C @@ -80,22 +86,14 @@ public: ); //- Construct from dictionary - nearestToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + nearestToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - nearestToCell - ( - const polyMesh& mesh, - Istream& - ); + nearestToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~nearestToCell(); + virtual ~nearestToCell() = default; // Member Functions @@ -108,7 +106,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C index 415969ad8adbeba0ff765eaffe1cfe7628fe484b..a11c7d739a3ebcb546b5d906374cc68525e3bdaa 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,31 +64,36 @@ void Foam::pointToCell::combine(topoSet& set, const bool add) const // Load the set pointSet loadedSet(mesh_, setName_); + const labelHashSet& pointLabels = loadedSet; // Handle any selection if (option_ == ANY) { - forAllConstIter(pointSet, loadedSet, iter) + for (const label pointi : pointLabels) { - const label pointi = iter.key(); const labelList& pCells = mesh_.pointCells()[pointi]; - forAll(pCells, pCelli) + for (const label celli : pCells) { - addOrDelete(set, pCells[pCelli], add); + addOrDelete(set, celli, add); } } } else if (option_ == EDGE) { const faceList& faces = mesh_.faces(); + forAll(faces, facei) { const face& f = faces[facei]; forAll(f, fp) { - if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp))) + if + ( + pointLabels.found(f[fp]) + && pointLabels.found(f.nextLabel(fp)) + ) { addOrDelete(set, mesh_.faceOwner()[facei], add); if (mesh_.isInternalFace(facei)) @@ -124,7 +129,7 @@ Foam::pointToCell::pointToCell ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(pointActionNames_.lookup("option", dict)) {} @@ -141,12 +146,6 @@ Foam::pointToCell::pointToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::pointToCell::~pointToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::pointToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H index 4be629c5d7bd90543a134f2f21a77950c109b38b..2778f134cd1fefd28429cd4a13fd01275a2803d6 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select cells based on usage of points. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The point set name | yes | + option | Selection type (any / edge) | yes | + \endtable + SourceFiles pointToCell.C @@ -96,22 +103,14 @@ public: ); //- Construct from dictionary - pointToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + pointToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - pointToCell - ( - const polyMesh& mesh, - Istream& - ); + pointToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~pointToCell(); + virtual ~pointToCell() = default; // Member Functions @@ -124,7 +123,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C index e0843a19ab0e8e3608cbf4e25ad8d7b6219e0f55..8cbd157bf7db66adfdbdb99ac84f5cd69a4d03be 100644 --- a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C +++ b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C @@ -232,7 +232,8 @@ void Foam::regionToCell::shrinkRegions } } } - Info<< " Eroded " << returnReduce(nChanged, sumOp<label>()) + Info<< " Eroded " + << returnReduce(nChanged, sumOp<label>()) << " cells." << endl; } @@ -257,7 +258,6 @@ void Foam::regionToCell::erode //generateField("shrunkSelectedCell", shrunkSelectedCell)().write(); - // Determine faces on the edge of shrunkSelectedCell boolList blockedFace(mesh_.nFaces(), false); markRegionFaces(shrunkSelectedCell, blockedFace); @@ -283,7 +283,6 @@ void Foam::regionToCell::erode //generateField("removeCell_before", removeCell)().write(); - // Grow removeCell for (label iter = 0; iter < nErode_; iter++) { @@ -345,8 +344,10 @@ void Foam::regionToCell::combine(topoSet& set, const bool add) const if (setName_.size() && setName_ != "none") { - Info<< " Loading subset " << setName_ << " to delimit search region." + Info<< " Loading subset " << setName_ + << " to delimit search region." << endl; + cellSet subSet(mesh_, setName_); selectedCell = false; @@ -402,11 +403,9 @@ Foam::regionToCell::regionToCell setName_(dict.lookupOrDefault<word>("set", "none")), insidePoints_ ( - dict.found("insidePoints") - ? dict.lookup("insidePoints") - : dict.lookup("insidePoint") + dict.getCompat<pointField>("insidePoints", {{ "insidePoint", 0 }}) ), - nErode_(dict.lookupOrDefault("nErode", 0)) + nErode_(dict.lookupOrDefault<label>("nErode", 0)) {} @@ -423,12 +422,6 @@ Foam::regionToCell::regionToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::regionToCell::~regionToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::regionToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/regionToCell/regionToCell.H b/src/meshTools/sets/cellSources/regionToCell/regionToCell.H index 4d740c0ca3096774c6d70a3b7c8952c589646fa3..7324aba1fac75112e281eea14db165a7978531d5 100644 --- a/src/meshTools/sets/cellSources/regionToCell/regionToCell.H +++ b/src/meshTools/sets/cellSources/regionToCell/regionToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,7 @@ Description (that contains given points) In dictionary input: - + \verbatim // optional name of cellSet delimiting search set c0; @@ -39,7 +39,15 @@ Description // points inside region to select insidePoints ((1 2 3)); + \endverbatim + \heading Dictionary parameters + \table + Property | Description | Required | Default + insidePoints | Points inside regions | yes | + nErode | Cell layers to erode to detect holes | no | 0 + set | Restrict to named cellSet | no | '' + \endtable SourceFiles regionToCell.C @@ -126,22 +134,14 @@ public: ); //- Construct from dictionary - regionToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + regionToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - regionToCell - ( - const polyMesh& mesh, - Istream& - ); + regionToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~regionToCell(); + virtual ~regionToCell() = default; // Member Functions @@ -151,8 +151,11 @@ public: return CELLSETSOURCE; } - virtual void applyToSet(const topoSetSource::setAction action, topoSet&) - const; + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& set + ) const; }; diff --git a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C index 799d4d5237d4c6155aea6cdb6fca6dc4f6966d23..8ab9e1ac9494dcbdd73f21a5a8b2eac50796c31b 100644 --- a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C +++ b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -136,10 +136,10 @@ Foam::rotatedBoxToCell::rotatedBoxToCell ) : topoSetSource(mesh), - origin_(dict.lookup("origin")), - i_(dict.lookup("i")), - j_(dict.lookup("j")), - k_(dict.lookup("k")) + origin_(dict.get<point>("origin")), + i_(dict.get<vector>("i")), + j_(dict.get<vector>("j")), + k_(dict.get<vector>("k")) {} @@ -153,12 +153,6 @@ Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::rotatedBoxToCell::~rotatedBoxToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::rotatedBoxToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H index 169b894a011e236cc11558fe83d9f84e1f23ab25..204e2175de69300d5d02bf6882ac25599bfe2997 100644 --- a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H +++ b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,15 @@ Description k ( 0.0 0.0 100); \endverbatim + \heading Dictionary parameters + \table + Property | Description | Required | Default + origin | The box centre | yes | + i | | yes | + j | | yes | + k | | yes | + \endtable + SourceFiles rotatedBoxToCell.C @@ -70,7 +79,7 @@ class rotatedBoxToCell //- Skewed box - const vector origin_; + const point origin_; const vector i_; const vector j_; const vector k_; @@ -102,11 +111,11 @@ public: rotatedBoxToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - rotatedBoxToCell(const polyMesh& mesh, Istream&); + rotatedBoxToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~rotatedBoxToCell(); + virtual ~rotatedBoxToCell() = default; // Member Functions @@ -119,7 +128,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C index 961c678708eea231331b0853959570c7962cf3d2..387eb29f48cbc5c98bae47842d87e4c0ffadd8a3 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,7 +59,7 @@ void Foam::shapeToCell::combine(topoSet& set, const bool add) const { if (type_ == "splitHex") { - for (label celli = 0; celli < mesh_.nCells(); celli++) + for (label celli = 0; celli < mesh_.nCells(); ++celli) { cellFeatures superCell(mesh_, featureCos, celli); @@ -91,11 +91,11 @@ void Foam::shapeToCell::combine(topoSet& set, const bool add) const Foam::shapeToCell::shapeToCell ( const polyMesh& mesh, - const word& type + const word& shapeName ) : topoSetSource(mesh), - type_(type) + type_(shapeName) { if (!cellModel::ptr(type_) && type_ != "splitHex") { @@ -112,7 +112,7 @@ Foam::shapeToCell::shapeToCell ) : topoSetSource(mesh), - type_(dict.lookup("type")) + type_(dict.get<word>("type")) { if (!cellModel::ptr(type_) && type_ != "splitHex") { @@ -139,12 +139,6 @@ Foam::shapeToCell::shapeToCell } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::shapeToCell::~shapeToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::shapeToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H index 82f2b97987ff63f4bc09e8b10aa15a6a686f092c..8476e013abe021c62e6270e0ba6dcbe81b6d268c 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,12 @@ Description Handles all known ones from static collection in cellModel and splitHex with 10 degrees feature angle. + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | The cell model type (hex, ..) | yes | + \endtable + SourceFiles shapeToCell.C @@ -62,6 +68,7 @@ class shapeToCell //- Name of cell type word type_; + // Private Member Functions //- Depending on cell type add to or delete from cellSet. @@ -79,32 +86,25 @@ public: //- Cos of feature angle for polyHedral to be splitHex static scalar featureCos; + // Constructors //- Construct from components shapeToCell ( const polyMesh& mesh, - const word& type + const word& shapeName ); //- Construct from dictionary - shapeToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + shapeToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - shapeToCell - ( - const polyMesh& mesh, - Istream& - ); + shapeToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~shapeToCell(); + virtual ~shapeToCell() = default; // Member Functions @@ -117,7 +117,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C index cd356da9057f6a02e0b80d4111dba6b5c24a6ef7..3f640426e112ed080c680d458805fab3fcbd8155 100644 --- a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C +++ b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,12 +51,11 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const { const pointField& ctrs = mesh_.cellCentres(); - const scalar radSquared = radius_*radius_; + const scalar rad2 = radius_*radius_; forAll(ctrs, celli) { - scalar offset = magSqr(centre_ - ctrs[celli]); - if (offset <= radSquared) + if (magSqr(ctrs[celli] - centre_) <= rad2) { addOrDelete(set, celli, add); } @@ -69,7 +68,7 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const Foam::sphereToCell::sphereToCell ( const polyMesh& mesh, - const vector& centre, + const point& centre, const scalar radius ) : @@ -86,8 +85,8 @@ Foam::sphereToCell::sphereToCell ) : topoSetSource(mesh), - centre_(dict.lookup("centre")), - radius_(readScalar(dict.lookup("radius"))) + centre_(dict.get<point>("centre")), + radius_(dict.get<scalar>("radius")) {} @@ -103,12 +102,6 @@ Foam::sphereToCell::sphereToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::sphereToCell::~sphereToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::sphereToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H index 506ffd371b2a994b3d03d872ad691b17bb8eb687..200b9f68b2ef14d056c4e1f0525af0b7fd2777b1 100644 --- a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H +++ b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select cells based on cell centres inside sphere. + \heading Dictionary parameters + \table + Property | Description | Required | Default + centre | The sphere centre | yes | + radius | The (outside) radius of sphere | yes | + \endtable + SourceFiles sphereToCell.C @@ -56,10 +63,10 @@ class sphereToCell //- Add usage string static addToUsageTable usage_; - //- Centre - vector centre_; + //- Centre point of the sphere + point centre_; - //- Radius + //- The outer radius of the sphere scalar radius_; @@ -80,27 +87,19 @@ public: sphereToCell ( const polyMesh& mesh, - const vector& centre, + const point& centre, const scalar radius ); //- Construct from dictionary - sphereToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + sphereToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - sphereToCell - ( - const polyMesh& mesh, - Istream& - ); + sphereToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~sphereToCell(); + virtual ~sphereToCell() = default; // Member Functions @@ -113,7 +112,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C index 6fcdee1b1ea12ef66793fe6724fe261337efc236..a2a26564ff443c02121fd8fda0203550a3917fb5 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -113,14 +113,12 @@ bool Foam::surfaceToCell::differingPointNormals const labelList& cFaces = mesh().cells()[celli]; - forAll(cFaces, cFacei) + for (const label facei : cFaces) { - const face& f = faces[cFaces[cFacei]]; + const face& f = faces[facei]; - forAll(f, fp) + for (const label pointi : f) { - label pointi = f[fp]; - label pointTriI = getNearest ( @@ -186,10 +184,8 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const // Check all 'outside' points - forAll(outsidePoints_, outsideI) + for (const point& outsidePoint : outsidePoints_) { - const point& outsidePoint = outsidePoints_[outsideI]; - // Find cell point is in. Linear search. label celli = queryMesh.findCell(outsidePoint, -1, false); if (returnReduce(celli, maxOp<label>()) == -1) @@ -424,17 +420,17 @@ Foam::surfaceToCell::surfaceToCell ) : topoSetSource(mesh), - surfName_(fileName(dict.lookup("file")).expand()), - outsidePoints_(dict.lookup("outsidePoints")), - includeCut_(readBool(dict.lookup("includeCut"))), - includeInside_(readBool(dict.lookup("includeInside"))), - includeOutside_(readBool(dict.lookup("includeOutside"))), + surfName_(dict.get<fileName>("file").expand()), + outsidePoints_(dict.get<pointField>("outsidePoints")), + includeCut_(dict.get<bool>("includeCut")), + includeInside_(dict.get<bool>("includeInside")), + includeOutside_(dict.get<bool>("includeOutside")), useSurfaceOrientation_ ( dict.lookupOrDefault("useSurfaceOrientation", false) ), - nearDist_(readScalar(dict.lookup("nearDistance"))), - curvature_(readScalar(dict.lookup("curvature"))), + nearDist_(dict.get<scalar>("nearDistance")), + curvature_(dict.get<scalar>("curvature")), surfPtr_ ( new triSurface diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H index 9e4784573a70635b461b5c98a7e4b69603a17a82..cf3fa9f2b8e2d2cc24cb1775d26db73dda56b1ee 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,6 +36,20 @@ Description at nearest point to centre and cell-corners differing by more than YYY (i.e., point of high curvature) + \heading Dictionary parameters + \table + Property | Description | Required | Default + file | The surface "filename" | yes | + scale | surface scaling factor | no | -1 + nearDistance | Near distance to the surface | yes | + curvature | surface curvature selection | yes | + outsidePoints| Points outside of surface | yes | + includeCut | Include cut cells (bool) | yes | + includeInside | Include inside cells (bool) | yes | + includeOutside | Include outside cells (bool) | yes | + useSurfaceOrientation | useSurfaceOrientation | no | false + \endtable + SourceFiles surfaceToCell.C @@ -183,18 +197,10 @@ public: ); //- Construct from dictionary - surfaceToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + surfaceToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - surfaceToCell - ( - const polyMesh& mesh, - Istream& - ); + surfaceToCell(const polyMesh& mesh, Istream& is); //- Destructor diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C index 4ab71b43d060536090b698a0fd1b5836de2abf0a..1e1c3f6d0d747ee2f881a105ac76ab002c595eb1 100644 --- a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,7 @@ License #include "polyMesh.H" #include "globalMeshData.H" #include "plane.H" +#include "bitSet.H" #include "cellSet.H" #include "addToRunTimeSelectionTable.H" @@ -57,13 +58,12 @@ Foam::scalar Foam::targetVolumeToCell::volumeOfSet { scalar sumVol = 0.0; - forAll(selected, celli) + // Loop over selected cells only + for (const label celli : selected) { - if (selected.test(celli)) - { - sumVol += mesh_.cellVolumes()[celli]; - } + sumVol += mesh_.cellVolumes()[celli]; } + return returnReduce(sumVol, sumOp<scalar>()); } @@ -84,12 +84,13 @@ Foam::label Foam::targetVolumeToCell::selectCells { const point& cc = mesh_.cellCentres()[celli]; - if (maskSet.test(celli) && ((cc&n_) < normalComp)) + if (maskSet.test(celli) && ((cc & normal_) < normalComp)) { selected.set(celli); - nSelected++; + ++nSelected; } } + return returnReduce(nSelected, sumOp<label>()); } @@ -114,10 +115,8 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const maskSet = false; cellSet subset(mesh_, maskSetName_); - forAllConstIter(cellSet, subset, iter) - { - maskSet.set(iter.key()); - } + const labelHashSet& cellLabels = subset; + maskSet.setMany(cellLabels.begin(), cellLabels.end()); nTotCells = returnReduce(subset.size(), sumOp<label>()); } @@ -139,7 +138,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const label maxPointi = -1; forAll(points, pointi) { - scalar c = (points[pointi]&n_); + scalar c = (points[pointi] & normal_); if (c > maxComp) { maxComp = c; @@ -160,7 +159,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const if (maxCells != nTotCells) { WarningInFunction - << "Plane " << plane(points[maxPointi], n_) + << "Plane " << plane(points[maxPointi], normal_) << " selects " << maxCells << " cells instead of all " << nTotCells << " cells. Results might be wrong." << endl; @@ -168,7 +167,6 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const } - // Bisection // ~~~~~~~~~ @@ -185,7 +183,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const while ((high-low) > tolerance) { - scalar mid = 0.5*(low + high); + const scalar mid = 0.5*(low + high); nSelected = selectCells(mid, maskSet, selected); selectedVol = volumeOfSet(selected); @@ -240,24 +238,23 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const WarningInFunction << "Did not converge onto plane. " << nl << "high plane:" - << plane(high*n_, n_) + << plane(high*normal_, normal_) << nl << "low plane :" - << plane(low*n_, n_) + << plane(low*normal_, normal_) << endl; } } - Info<< " Selected " << nSelected << " with actual volume " << selectedVol - << endl; + Info<< " Selected " << nSelected << " with actual volume " + << selectedVol << endl; - forAll(selected, celli) + + // Loop over selected cells only + for (const label celli : selected) { - if (selected.test(celli)) - { - addOrDelete(set, celli, add); - } + addOrDelete(set, celli, add); } } @@ -268,12 +265,12 @@ Foam::targetVolumeToCell::targetVolumeToCell ( const polyMesh& mesh, const scalar vol, - const vector& n + const vector& normal ) : topoSetSource(mesh), vol_(vol), - n_(n) + normal_(normal) {} @@ -284,8 +281,8 @@ Foam::targetVolumeToCell::targetVolumeToCell ) : topoSetSource(mesh), - vol_(readScalar(dict.lookup("volume"))), - n_(dict.lookup("normal")), + vol_(dict.get<scalar>("volume")), + normal_(dict.get<vector>("normal")), maskSetName_(dict.lookupOrDefault<word>("set", "")) {} @@ -298,12 +295,7 @@ Foam::targetVolumeToCell::targetVolumeToCell : topoSetSource(mesh), vol_(readScalar(checkIs(is))), - n_(checkIs(is)) -{} - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::targetVolumeToCell::~targetVolumeToCell() + normal_(checkIs(is)) {} diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H index ee350de5223e3c3a7bba941978781c2f101d2d97..d2fc080970bd8e3ac04eaa345e904ed87a0a9633 100644 --- a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,14 @@ Description A topoSetSource to select cells based on the wanted volume of selected cells. Adapts a plane until it has enough. + \heading Dictionary parameters + \table + Property | Description | Required | Default + volume | The target volume (m^3) | yes | + normal | The plane normal | yes | + set | Restrict to named cellSet | no | "" + \endtable + SourceFiles targetVolumeToCell.C @@ -37,13 +45,15 @@ SourceFiles #define targetVolumeToCell_H #include "topoSetSource.H" -#include "bitSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward declarations +class bitSet; + /*---------------------------------------------------------------------------*\ Class targetVolumeToCell Declaration \*---------------------------------------------------------------------------*/ @@ -62,7 +72,7 @@ class targetVolumeToCell const scalar vol_; //- Normal of plane to sweep - const vector n_; + const vector normal_; //- Optional name of cellSet to calculate volume in const word maskSetName_; @@ -70,7 +80,8 @@ class targetVolumeToCell // Private Member Functions - scalar volumeOfSet(const bitSet&) const; + //- The volume of the selected cells + scalar volumeOfSet(const bitSet& selected) const; label selectCells ( @@ -94,26 +105,18 @@ public: ( const polyMesh& mesh, const scalar vol, - const vector& + const vector& normal ); //- Construct from dictionary - targetVolumeToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + targetVolumeToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - targetVolumeToCell - ( - const polyMesh& mesh, - Istream& - ); + targetVolumeToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~targetVolumeToCell(); + virtual ~targetVolumeToCell() = default; // Member Functions @@ -126,7 +129,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C index 612da1e918833a89355ed58d48de55cf64bca3c4..ee3e616b251b04e6bf2f19bb32c4cf2fb52d4ff5 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,25 +52,23 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const { bool hasMatched = false; - forAll(mesh_.cellZones(), i) + for (const cellZone& zone : mesh_.cellZones()) { - const cellZone& zone = mesh_.cellZones()[i]; - if (zoneName_.match(zone.name())) { - const labelList& cellLabels = mesh_.cellZones()[i]; + hasMatched = true; + + const labelList& cellLabels = zone; Info<< " Found matching zone " << zone.name() << " with " << cellLabels.size() << " cells." << endl; - hasMatched = true; - - forAll(cellLabels, i) + for (const label celli : cellLabels) { // Only do active cells - if (cellLabels[i] < mesh_.nCells()) + if (celli >= 0 && celli < mesh_.nCells()) { - addOrDelete(set, cellLabels[i], add); + addOrDelete(set, celli, add); } } } @@ -79,8 +77,9 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any cellZone named " << zoneName_ << endl - << "Valid names are " << mesh_.cellZones().names() << endl; + << "Cannot find any cellZone named " << zoneName_ << nl + << "Valid names: " << flatOutput(mesh_.cellZones().names()) + << endl; } } @@ -105,7 +104,7 @@ Foam::zoneToCell::zoneToCell ) : topoSetSource(mesh), - zoneName_(dict.lookup("name")) + zoneName_(dict.get<wordRe>("name")) {} @@ -120,12 +119,6 @@ Foam::zoneToCell::zoneToCell {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::zoneToCell::~zoneToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::zoneToCell::applyToSet diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H index ac88dbc81c4f3271f983c4d2c7305cb22d4247b2..d687226798024f8c4aae241497d35f94fecd34bc 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,13 @@ Class Foam::zoneToCell Description - A topoSetSource to select faces based on cellZone. + A topoSetSource to select cells based on cellZone. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The cell zone name or regex | yes | + \endtable SourceFiles zoneToCell.C @@ -81,22 +87,14 @@ public: ); //- Construct from dictionary - zoneToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + zoneToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - zoneToCell - ( - const polyMesh& mesh, - Istream& - ); + zoneToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~zoneToCell(); + virtual ~zoneToCell() = default; // Member Functions @@ -109,7 +107,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C index db01c781693dd03bbc9b87b384de639e162ab756..9203ad8e394e35143176806697a69f4346872963 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::setToCellZone::setToCellZone ) : topoSetSource(mesh), - setName_(dict.lookup("set")) + setName_(dict.get<word>("set")) {} @@ -81,12 +81,6 @@ Foam::setToCellZone::setToCellZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::setToCellZone::~setToCellZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::setToCellZone::applyToSet diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H index 4d74ae3cdaec0ccb10fafd271685c2a763ef71ae..aadde9c799c7723df5357a8afbfc43cd1edadd06 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select cells based on usage in a cellSet. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The cell set name | yes | + \endtable + SourceFiles setToCellZone.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - setToCellZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + setToCellZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setToCellZone - ( - const polyMesh& mesh, - Istream& - ); + setToCellZone(const polyMesh& mesh, Istream& is ); //- Destructor - virtual ~setToCellZone(); + virtual ~setToCellZone() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C index a1085fdbf2af09cbae8a9410fe9785d4dd90de1d..280850f1fbd7319ca56d007d38e1dc35de69da7f 100644 --- a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C +++ b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +53,7 @@ void Foam::boundaryToFace::combine(topoSet& set, const bool add) const ( label facei = mesh().nInternalFaces(); facei < mesh().nFaces(); - facei++ + ++facei ) { addOrDelete(set, facei, add); @@ -69,7 +69,11 @@ Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh) {} -Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh, const dictionary&) +Foam::boundaryToFace::boundaryToFace +( + const polyMesh& mesh, + const dictionary& +) : topoSetSource(mesh) {} @@ -78,19 +82,13 @@ Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh, const dictionary&) Foam::boundaryToFace::boundaryToFace ( const polyMesh& mesh, - Istream& is + Istream& ) : topoSetSource(mesh) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::boundaryToFace::~boundaryToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::boundaryToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H index 5875ea2902025b13ccbb038ba66652991b6c16b9..e654485fb6c5bda4ffaa04cb821e63384f983b8d 100644 --- a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H +++ b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,9 @@ Class Description A topoSetSource to select all external (boundary) faces. + \heading Dictionary parameters + None + SourceFiles boundaryToFace.C @@ -69,25 +72,17 @@ public: // Constructors //- Construct from components - boundaryToFace(const polyMesh&); + boundaryToFace(const polyMesh& mesh); //- Construct from dictionary - boundaryToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + boundaryToFace(const polyMesh& mesh, const dictionary& unused); //- Construct from Istream - boundaryToFace - ( - const polyMesh& mesh, - Istream& - ); + boundaryToFace(const polyMesh& mesh, Istream& unused); //- Destructor - virtual ~boundaryToFace(); + virtual ~boundaryToFace() = default; // Member Functions @@ -100,7 +95,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/boxToFace/boxToFace.C b/src/meshTools/sets/faceSources/boxToFace/boxToFace.C index f9b276118f542c62f99a658c34b59df0c45b3470..236a0b7d93d1b15d918a63801f2de4c462c69289 100644 --- a/src/meshTools/sets/faceSources/boxToFace/boxToFace.C +++ b/src/meshTools/sets/faceSources/boxToFace/boxToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,9 +53,9 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const forAll(ctrs, facei) { - forAll(bbs_, i) + for (const auto& bb : bbs_) { - if (bbs_[i].contains(ctrs[facei])) + if (bb.contains(ctrs[facei])) { addOrDelete(set, facei, add); break; @@ -110,12 +110,6 @@ Foam::boxToFace::boxToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::boxToFace::~boxToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::boxToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/boxToFace/boxToFace.H b/src/meshTools/sets/faceSources/boxToFace/boxToFace.H index 2cde01e1f9850132bb6ef772af16e9472d516018..6a9bc01cea769e7f330464dd7ac64d49900a4311 100644 --- a/src/meshTools/sets/faceSources/boxToFace/boxToFace.H +++ b/src/meshTools/sets/faceSources/boxToFace/boxToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,16 @@ Class Description A topoSetSource to select faces based on face centres inside box. + \heading Dictionary parameters + \table + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | + \endtable + +Note + Must specify either "box" or "boxes" + SourceFiles boxToFace.C @@ -80,22 +90,14 @@ public: ); //- Construct from dictionary - boxToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + boxToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - boxToFace - ( - const polyMesh& mesh, - Istream& - ); + boxToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~boxToFace(); + virtual ~boxToFace() = default; // Member Functions @@ -108,7 +110,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C index 62912ef7f4bfa9fd9a147395177296a81d3a0f4b..e36dd88c1d4cdd9c1211cbcada278cc5b5ea8bbc 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,18 +71,18 @@ void Foam::cellToFace::combine(topoSet& set, const bool add) const } cellSet loadedSet(mesh_, setName_); + const labelHashSet& cellLabels = loadedSet; if (option_ == ALL) { // Add all faces from cell - forAllConstIter(cellSet, loadedSet, iter) + for (const label celli : cellLabels) { - const label celli = iter.key(); const labelList& cFaces = mesh_.cells()[celli]; - forAll(cFaces, cFacei) + for (const label facei : cFaces) { - addOrDelete(set, cFaces[cFacei], add); + addOrDelete(set, facei, add); } } } @@ -97,9 +97,9 @@ void Foam::cellToFace::combine(topoSet& set, const bool add) const // Check all internal faces - for (label facei = 0; facei < nInt; facei++) + for (label facei = 0; facei < nInt; ++facei) { - if (loadedSet.found(own[facei]) && loadedSet.found(nei[facei])) + if (cellLabels.found(own[facei]) && cellLabels.found(nei[facei])) { addOrDelete(set, facei, add); } @@ -109,17 +109,15 @@ void Foam::cellToFace::combine(topoSet& set, const bool add) const // Get coupled cell status boolList neiInSet(mesh_.nFaces()-nInt, false); - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (pp.coupled()) { label facei = pp.start(); forAll(pp, i) { - neiInSet[facei-nInt] = loadedSet.found(own[facei]); - facei++; + neiInSet[facei-nInt] = cellLabels.found(own[facei]); + ++facei; } } } @@ -127,20 +125,18 @@ void Foam::cellToFace::combine(topoSet& set, const bool add) const // Check all boundary faces - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (pp.coupled()) { label facei = pp.start(); forAll(pp, i) { - if (loadedSet.found(own[facei]) && neiInSet[facei-nInt]) + if (cellLabels.found(own[facei]) && neiInSet[facei-nInt]) { addOrDelete(set, facei, add); } - facei++; + ++facei; } } } @@ -170,7 +166,7 @@ Foam::cellToFace::cellToFace ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(cellActionNames_.lookup("option", dict)) {} @@ -187,12 +183,6 @@ Foam::cellToFace::cellToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellToFace::~cellToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cellToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.H b/src/meshTools/sets/faceSources/cellToFace/cellToFace.H index f0fcca37bf6530dbe060b163ee041c5d7da93998..842203c6d127da8498494eeb3c348be6d4cc4ce6 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.H +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,9 +27,18 @@ Class Description A topoSetSource to select a faceSet from cells. - Either all faces of cell or some other criterion. - See implementation. - Note: when picking up coupled faces uses cells on neighbouring processors. + Either use 'all' cell faces, or only faces that have cells + on 'both' sides. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | Name of input cellSet | yes | + option | Selection (all/both) | yes | + \endtable + +Note + When picking up coupled faces uses cells on neighbouring processors. SourceFiles cellToFace.C @@ -100,22 +109,14 @@ public: ); //- Construct from dictionary - cellToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + cellToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cellToFace - ( - const polyMesh& mesh, - Istream& - ); + cellToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~cellToFace(); + virtual ~cellToFace() = default; // Member Functions @@ -128,7 +129,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C index 0dbbe7c9ff90137c603c2e4fd7fb3c36023507ba..99ec5fc1a2bd495782dc1afe1ed61ce4d4b0648f 100644 --- a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C +++ b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,7 +50,7 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderAnnulusToFace::usage_ void Foam::cylinderAnnulusToFace::combine(topoSet& set, const bool add) const { - const vector axis = p2_ - p1_; + const vector axis = (point2_ - point1_); const scalar orad2 = sqr(outerRadius_); const scalar irad2 = sqr(innerRadius_); const scalar magAxis2 = magSqr(axis); @@ -59,12 +59,12 @@ void Foam::cylinderAnnulusToFace::combine(topoSet& set, const bool add) const forAll(ctrs, facei) { - vector d = ctrs[facei] - p1_; - scalar magD = d & axis; + const vector d = ctrs[facei] - point1_; + const scalar magD = d & axis; if ((magD > 0) && (magD < magAxis2)) { - scalar d2 = (d & d) - sqr(magD)/magAxis2; + const scalar d2 = (d & d) - sqr(magD)/magAxis2; if ((d2 < orad2) && (d2 > irad2)) { addOrDelete(set, facei, add); @@ -79,15 +79,15 @@ void Foam::cylinderAnnulusToFace::combine(topoSet& set, const bool add) const Foam::cylinderAnnulusToFace::cylinderAnnulusToFace ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar outerRadius, const scalar innerRadius ) : topoSetSource(mesh), - p1_(p1), - p2_(p2), + point1_(point1), + point2_(point2), outerRadius_(outerRadius), innerRadius_(innerRadius) {} @@ -100,10 +100,10 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace ) : topoSetSource(mesh), - p1_(dict.lookup("p1")), - p2_(dict.lookup("p2")), - outerRadius_(readScalar(dict.lookup("outerRadius"))), - innerRadius_(readScalar(dict.lookup("innerRadius"))) + point1_(dict.get<point>("p1")), + point2_(dict.get<point>("p2")), + outerRadius_(dict.get<scalar>("outerRadius")), + innerRadius_(dict.get<scalar>("innerRadius")) {} @@ -114,19 +114,13 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace ) : topoSetSource(mesh), - p1_(checkIs(is)), - p2_(checkIs(is)), + point1_(checkIs(is)), + point2_(checkIs(is)), outerRadius_(readScalar(checkIs(is))), innerRadius_(readScalar(checkIs(is))) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cylinderAnnulusToFace::~cylinderAnnulusToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cylinderAnnulusToFace::applyToSet @@ -139,18 +133,19 @@ void Foam::cylinderAnnulusToFace::applyToSet { Info<< " Adding faces with centre within cylinder annulus," << " with p1 = " - << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_ - << " and inner radius = " << innerRadius_ - << endl; + << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { - Info<< " Removing faces with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_ - << " and inner radius " << innerRadius_ - << endl; + Info<< " Removing faces with centre within cylinder annulus," + << " with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; combine(set, false); } diff --git a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H index 3149a60429c4b296354bbfab0d93420e405cca5d..842ac28053e94e0044c6eef0a4b9286411fc54ca 100644 --- a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H +++ b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,15 @@ Description A topoSetSource to select faces based on face centres inside a cylinder annulus. + \heading Dictionary parameters + \table + Property | Description | Required | Default + p1 | coordinate of endpoint | yes | + p2 | coordinate of endpoint | yes | + outerRadius | cylinder outer radius | yes | + innerRadius | cylinder inner radius | yes | + \endtable + SourceFiles cylinderAnnulusToFace.C @@ -58,10 +67,10 @@ class cylinderAnnulusToFace static addToUsageTable usage_; //- First point on cylinder axis - vector p1_; + point point1_; //- Second point on cylinder axis - vector p2_; + point point2_; //- Outer Radius scalar outerRadius_; @@ -87,29 +96,22 @@ public: cylinderAnnulusToFace ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar outerRadius, const scalar innerRadius ); //- Construct from dictionary - cylinderAnnulusToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + cylinderAnnulusToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cylinderAnnulusToFace - ( - const polyMesh& mesh, - Istream& - ); + cylinderAnnulusToFace(const polyMesh& mesh, Istream& is); + + //- Destructor + virtual ~cylinderAnnulusToFace() = default; - // Destructor - virtual ~cylinderAnnulusToFace(); // Member Functions diff --git a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C index a360e4f926c229a09af8b21f055f0411437ae4e4..0e82f1d94d6aabdaf3f18e9340d3c1f713a24fbf 100644 --- a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C +++ b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,7 +49,7 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderToFace::usage_ void Foam::cylinderToFace::combine(topoSet& set, const bool add) const { - const vector axis = p2_ - p1_; + const vector axis = (point2_ - point1_); const scalar rad2 = sqr(radius_); const scalar magAxis2 = magSqr(axis); @@ -57,12 +57,12 @@ void Foam::cylinderToFace::combine(topoSet& set, const bool add) const forAll(ctrs, facei) { - vector d = ctrs[facei] - p1_; - scalar magD = d & axis; + const vector d = ctrs[facei] - point1_; + const scalar magD = d & axis; if ((magD > 0) && (magD < magAxis2)) { - scalar d2 = (d & d) - sqr(magD)/magAxis2; + const scalar d2 = (d & d) - sqr(magD)/magAxis2; if (d2 < rad2) { addOrDelete(set, facei, add); @@ -77,14 +77,14 @@ void Foam::cylinderToFace::combine(topoSet& set, const bool add) const Foam::cylinderToFace::cylinderToFace ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar radius ) : topoSetSource(mesh), - p1_(p1), - p2_(p2), + point1_(point1), + point2_(point2), radius_(radius) {} @@ -96,9 +96,9 @@ Foam::cylinderToFace::cylinderToFace ) : topoSetSource(mesh), - p1_(dict.lookup("p1")), - p2_(dict.lookup("p2")), - radius_(readScalar(dict.lookup("radius"))) + point1_(dict.get<point>("p1")), + point2_(dict.get<point>("p2")), + radius_(dict.get<scalar>("radius")) {} @@ -109,18 +109,12 @@ Foam::cylinderToFace::cylinderToFace ) : topoSetSource(mesh), - p1_(checkIs(is)), - p2_(checkIs(is)), + point1_(checkIs(is)), + point2_(checkIs(is)), radius_(readScalar(checkIs(is))) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cylinderToFace::~cylinderToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cylinderToFace::applyToSet @@ -131,15 +125,17 @@ void Foam::cylinderToFace::applyToSet { if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { - Info<< " Adding faces with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + Info<< " Adding faces with centre within cylinder, with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { Info<< " Removing faces with centre within cylinder, with p1 = " - << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; combine(set, false); } diff --git a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H index b51083aebf562594711a61b9ea9d545930073388..6a2c4fe39e38171c006446efc54a05c01dc7b2b2 100644 --- a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H +++ b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description A topoSetSource to select faces based on face centres inside a cylinder. + \heading Dictionary parameters + \table + Property | Description | Required | Default + p1 | coordinate of endpoint | yes | + p2 | coordinate of endpoint | yes | + radius | cylinder radius | yes | + \endtable + SourceFiles cylinderToFace.C @@ -57,10 +65,10 @@ class cylinderToFace static addToUsageTable usage_; //- First point on cylinder axis - vector p1_; + point point1_; //- Second point on cylinder axis - vector p2_; + point point2_; //- Radius scalar radius_; @@ -83,28 +91,20 @@ public: cylinderToFace ( const polyMesh& mesh, - const vector& p1, - const vector& p2, + const point& point1, + const point& point2, const scalar radius ); //- Construct from dictionary - cylinderToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + cylinderToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cylinderToFace - ( - const polyMesh& mesh, - Istream& - ); + cylinderToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~cylinderToFace(); + virtual ~cylinderToFace() = default; // Member Functions @@ -117,7 +117,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/faceToFace/faceToFace.C b/src/meshTools/sets/faceSources/faceToFace/faceToFace.C index fb78cb52eda1c5bec397f8121bf6eace136346e9..e3ee6f8d60ac1667ca41473f63dacbfb8d757ca2 100644 --- a/src/meshTools/sets/faceSources/faceToFace/faceToFace.C +++ b/src/meshTools/sets/faceSources/faceToFace/faceToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::faceToFace::faceToFace ) : topoSetSource(mesh), - setName_(dict.lookup("set")) + setName_(dict.get<word>("set")) {} @@ -81,12 +81,6 @@ Foam::faceToFace::faceToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceToFace::~faceToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/faceToFace/faceToFace.H b/src/meshTools/sets/faceSources/faceToFace/faceToFace.H index 45de3e301b18bee506e0946b1d1c5a9297f8dd10..58ed57bedd34549cd499fa4fabe6b84629a8d4fa 100644 --- a/src/meshTools/sets/faceSources/faceToFace/faceToFace.H +++ b/src/meshTools/sets/faceSources/faceToFace/faceToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select faces based on usage in another faceSet. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | Name of the input faceSet | yes | + \endtable + SourceFiles faceToFace.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - faceToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + faceToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - faceToFace - ( - const polyMesh& mesh, - Istream& - ); + faceToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~faceToFace(); + virtual ~faceToFace() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/labelToFace/labelToFace.C b/src/meshTools/sets/faceSources/labelToFace/labelToFace.C index 9f7efd81e91a787acdcdef1cced0a96c7b1b9ef9..4ea83806cf57334c601906e329213af85ce2d14b 100644 --- a/src/meshTools/sets/faceSources/labelToFace/labelToFace.C +++ b/src/meshTools/sets/faceSources/labelToFace/labelToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,17 +45,6 @@ Foam::topoSetSource::addToUsageTable Foam::labelToFace::usage_ ); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::labelToFace::combine(topoSet& set, const bool add) const -{ - forAll(labels_, labelI) - { - addOrDelete(set, labels_[labelI], add); - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::labelToFace::labelToFace @@ -76,7 +65,7 @@ Foam::labelToFace::labelToFace ) : topoSetSource(mesh), - labels_(dict.lookup("value")) + labels_(dict.get<labelList>("value")) {} @@ -88,13 +77,9 @@ Foam::labelToFace::labelToFace : topoSetSource(mesh), labels_(checkIs(is)) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::labelToFace::~labelToFace() -{} +{ + check(labels_, mesh.nFaces()); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -109,13 +94,13 @@ void Foam::labelToFace::applyToSet { Info<< " Adding faces mentioned in dictionary" << " ..." << endl; - combine(set, true); + addOrDelete(set, labels_, true); } else if (action == topoSetSource::DELETE) { Info<< " Removing faces mentioned dictionary" << " ..." << endl; - combine(set, false); + addOrDelete(set, labels_, false); } } diff --git a/src/meshTools/sets/faceSources/labelToFace/labelToFace.H b/src/meshTools/sets/faceSources/labelToFace/labelToFace.H index e66ef132f2c1c2404cf00e385b0f58038bc299f0..53bc405a78e005c0dc87ff3acf782447ba167292 100644 --- a/src/meshTools/sets/faceSources/labelToFace/labelToFace.H +++ b/src/meshTools/sets/faceSources/labelToFace/labelToFace.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select faces given explicitly provided face labels. + \heading Dictionary parameters + \table + Property | Description | Required | Default + normal | The normal for selecting faces | yes | + cos | Tolerance angle (range -1, +1) | yes | + \endtable + SourceFiles labelToFace.C @@ -60,11 +67,6 @@ class labelToFace labelList labels_; - // Private Member Functions - - void combine(topoSet& set, const bool add) const; - - public: //- Runtime type information @@ -80,22 +82,14 @@ public: ); //- Construct from dictionary - labelToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + labelToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - labelToFace - ( - const polyMesh& mesh, - Istream& - ); + labelToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~labelToFace(); + virtual ~labelToFace() = default; // Member Functions @@ -108,7 +102,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/normalToFace/normalToFace.C b/src/meshTools/sets/faceSources/normalToFace/normalToFace.C index 19e0a1c1ac5a9e30a9799c8806987cbcc035821c..efc6d136ce7210e805f056d129142bf667ac79eb 100644 --- a/src/meshTools/sets/faceSources/normalToFace/normalToFace.C +++ b/src/meshTools/sets/faceSources/normalToFace/normalToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -84,8 +84,8 @@ Foam::normalToFace::normalToFace Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict) : topoSetSource(mesh), - normal_(dict.lookup("normal")), - tol_(readScalar(dict.lookup("cos"))) + normal_(dict.get<vector>("normal")), + tol_(dict.get<scalar>("cos")) { setNormal(); } @@ -101,12 +101,6 @@ Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is) } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::normalToFace::~normalToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::normalToFace::applyToSet @@ -136,7 +130,6 @@ void Foam::normalToFace::applyToSet Info<< " Removing faces according to normal being aligned with " << normal_ << " (to within " << tol_ << ") ..." << endl; - DynamicList<label> toBeRemoved(set.size()/10); forAllConstIter(topoSet, set, iter) diff --git a/src/meshTools/sets/faceSources/normalToFace/normalToFace.H b/src/meshTools/sets/faceSources/normalToFace/normalToFace.H index 9891680204523287aa28450eb349845c424989c9..c27635615306d2455a4396776881aee36d07e642 100644 --- a/src/meshTools/sets/faceSources/normalToFace/normalToFace.H +++ b/src/meshTools/sets/faceSources/normalToFace/normalToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select faces based on normal. + \heading Dictionary parameters + \table + Property | Description | Required | Default + normal | The normal for selecting faces | yes | + cos | Tolerance angle (range -1, +1) | yes | + \endtable + SourceFiles normalToFace.C @@ -92,7 +99,7 @@ public: //- Destructor - virtual ~normalToFace(); + virtual ~normalToFace() = default; // Member Functions @@ -105,7 +112,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C index 94d3170143a7cd0fe0b9366f7c0ee56e7fe557ac..9694a42fa4718d701df8f8b8cc3f495ac5312a1f 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C @@ -67,7 +67,7 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const ( label facei = pp.start(); facei < pp.start() + pp.size(); - facei++ + ++facei ) { addOrDelete(set, facei, add); @@ -103,7 +103,7 @@ Foam::patchToFace::patchToFace ) : topoSetSource(mesh), - patchName_(dict.lookup("name")) + patchName_(dict.get<wordRe>("name")) {} @@ -118,12 +118,6 @@ Foam::patchToFace::patchToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::patchToFace::~patchToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::patchToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.H b/src/meshTools/sets/faceSources/patchToFace/patchToFace.H index 17e4e5633f18899b2f81c4b110040c5c7fce9212..e956cc516cdedadd2f7e189e226f1a062ea0618b 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.H +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.H @@ -27,6 +27,12 @@ Class Description A topoSetSource to select faces based on usage in patches. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | Patch name or regex to select | yes | + \endtable + SourceFiles patchToFace.C @@ -81,22 +87,14 @@ public: ); //- Construct from dictionary - patchToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + patchToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - patchToFace - ( - const polyMesh& mesh, - Istream& - ); + patchToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~patchToFace(); + virtual ~patchToFace() = default; // Member Functions @@ -109,7 +107,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C index 2ecc19a91b72a6d3f3d87e5ac7a95e3b52c0496e..6da05cd63606ff55d60bba7933a0527a778a239e 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,17 +67,18 @@ void Foam::pointToFace::combine(topoSet& set, const bool add) const // Load the set pointSet loadedSet(mesh_, setName_); + const labelHashSet& pointLabels = loadedSet; + if (option_ == ANY) { // Add faces with any point in loadedSet - forAllConstIter(pointSet, loadedSet, iter) + for (const label pointi : pointLabels) { - const label pointi = iter.key(); const labelList& pFaces = mesh_.pointFaces()[pointi]; - forAll(pFaces, pFacei) + for (const label facei : pFaces) { - addOrDelete(set, pFaces[pFacei], add); + addOrDelete(set, facei, add); } } } @@ -86,38 +87,27 @@ void Foam::pointToFace::combine(topoSet& set, const bool add) const // Add all faces whose points are all in set. // Count number of points using face. - Map<label> numPoints(loadedSet.size()); + Map<label> numPoints(pointLabels.size()); - forAllConstIter(pointSet, loadedSet, iter) + for (const label pointi : pointLabels) { - const label pointi = iter.key(); const labelList& pFaces = mesh_.pointFaces()[pointi]; - forAll(pFaces, pFacei) + for (const label facei : pFaces) { - const label facei = pFaces[pFacei]; - - Map<label>::iterator fndFace = numPoints.find(facei); - - if (fndFace == numPoints.end()) - { - numPoints.insert(facei, 1); - } - else - { - fndFace()++; - } + ++(numPoints(facei, 0)); } } // Include faces that are referenced as many times as there are points // in face -> all points of face - forAllConstIter(Map<label>, numPoints, iter) + forAllConstIters(numPoints, iter) { const label facei = iter.key(); + const label count = iter.object(); - if (iter() == mesh_.faces()[facei].size()) + if (count == mesh_.faces()[facei].size()) { addOrDelete(set, facei, add); } @@ -126,13 +116,18 @@ void Foam::pointToFace::combine(topoSet& set, const bool add) const else if (option_ == EDGE) { const faceList& faces = mesh_.faces(); + forAll(faces, facei) { const face& f = faces[facei]; forAll(f, fp) { - if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp))) + if + ( + pointLabels.found(f[fp]) + && pointLabels.found(f.nextLabel(fp)) + ) { addOrDelete(set, facei, add); break; @@ -165,7 +160,7 @@ Foam::pointToFace::pointToFace ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(pointActionNames_.lookup("option", dict)) {} @@ -182,12 +177,6 @@ Foam::pointToFace::pointToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::pointToFace::~pointToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::pointToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H index 03e09a25ddbbf1c43e1d43509d17db4288313590..3e1ceb9f11162a735c7e3bef8ddbfec487914652 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select faces based on use of points. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The point set name to use | yes | + option | Selection type (all/any/edge) | yes | + \endtable + SourceFiles pointToFace.C @@ -99,22 +106,14 @@ public: ); //- Construct from dictionary - pointToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + pointToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - pointToFace - ( - const polyMesh& mesh, - Istream& - ); + pointToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~pointToFace(); + virtual ~pointToFace() = default; // Member Functions @@ -127,7 +126,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceSources/regionToFace/regionToFace.C b/src/meshTools/sets/faceSources/regionToFace/regionToFace.C index e9fbf00645eceb2bd5e97b3ab02d59f013c89d7c..4825c804c60124788ce934ee1643d766dc9d0c5b 100644 --- a/src/meshTools/sets/faceSources/regionToFace/regionToFace.C +++ b/src/meshTools/sets/faceSources/regionToFace/regionToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,9 +73,9 @@ void Foam::regionToFace::markZone if (Pstream::myProcNo() == proci) { const labelList& fEdges = patch.faceEdges()[facei]; - forAll(fEdges, i) + for (const label edgei : fEdges) { - changedEdges.append(fEdges[i]); + changedEdges.append(edgei); changedInfo.append(zoneI); } } @@ -108,8 +108,9 @@ void Foam::regionToFace::markZone void Foam::regionToFace::combine(topoSet& set, const bool add) const { - Info<< " Loading subset " << setName_ << " to delimit search region." - << endl; + Info<< " Loading subset " << setName_ + << " to delimit search region." << endl; + faceSet subSet(mesh_, setName_); indirectPrimitivePatch patch @@ -192,8 +193,8 @@ Foam::regionToFace::regionToFace ) : topoSetSource(mesh), - setName_(dict.lookup("set")), - nearPoint_(dict.lookup("nearPoint")) + setName_(dict.get<word>("set")), + nearPoint_(dict.get<point>("nearPoint")) {} @@ -209,12 +210,6 @@ Foam::regionToFace::regionToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::regionToFace::~regionToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::regionToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/regionToFace/regionToFace.H b/src/meshTools/sets/faceSources/regionToFace/regionToFace.H index e35f38b1062bdc8cb713c40430f7d100e725a67c..fedd9d86d07ef6a3477f136b6f78de00c9673f7c 100644 --- a/src/meshTools/sets/faceSources/regionToFace/regionToFace.H +++ b/src/meshTools/sets/faceSources/regionToFace/regionToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,13 @@ Description A topoSetSource to select faces belonging to topological connected region (that contains given point) + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The face set name to use | yes | + nearPoint | The point on/near to the region | yes | + \endtable + SourceFiles regionToFace.C @@ -37,7 +44,6 @@ SourceFiles #define regionToFace_H #include "topoSetSource.H" -#include "bitSet.H" #include "indirectPrimitivePatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,6 +70,7 @@ class regionToFace //- Coordinate that is nearest/on connected region point nearPoint_; + // Private Member Functions //- Walk edge-face-edge @@ -94,22 +101,14 @@ public: ); //- Construct from dictionary - regionToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + regionToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - regionToFace - ( - const polyMesh& mesh, - Istream& - ); + regionToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~regionToFace(); + virtual ~regionToFace() = default; // Member Functions diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C index 9285cc1e74203211b58b7b82fe2a1878d02993ff..ea9090c0562e8c4d002d1885005f28872fa57e05 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,25 +52,23 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const { bool hasMatched = false; - forAll(mesh_.faceZones(), i) + for (const faceZone& zone : mesh_.faceZones()) { - const faceZone& zone = mesh_.faceZones()[i]; - if (zoneName_.match(zone.name())) { - const labelList& faceLabels = mesh_.faceZones()[i]; + hasMatched = true; + + const labelList& faceLabels = zone; Info<< " Found matching zone " << zone.name() << " with " << faceLabels.size() << " faces." << endl; - hasMatched = true; - - forAll(faceLabels, i) + for (const label facei : faceLabels) { // Only do active faces - if (faceLabels[i] < mesh_.nFaces()) + if (facei >= 0 && facei < mesh_.nFaces()) { - addOrDelete(set, faceLabels[i], add); + addOrDelete(set, facei, add); } } } @@ -105,7 +103,7 @@ Foam::zoneToFace::zoneToFace ) : topoSetSource(mesh), - zoneName_(dict.lookup("name")) + zoneName_(dict.get<wordRe>("name")) {} @@ -120,12 +118,6 @@ Foam::zoneToFace::zoneToFace {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::zoneToFace::~zoneToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::zoneToFace::applyToSet diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H index c4c2c0573bd48161cf9be2e6ec247bd803754d98..35d9c23ebe0edc40180bb893f6b23a66e95a043b 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select faces based on faceZone. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The face zone name or regex | yes | + \endtable + SourceFiles zoneToFace.C @@ -57,7 +63,7 @@ class zoneToFace //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of cellZone + //- Name/regular expression of the faceZone wordRe zoneName_; @@ -81,22 +87,14 @@ public: ); //- Construct from dictionary - zoneToFace - ( - const polyMesh& mesh, - const dictionary& dict - ); + zoneToFace(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - zoneToFace - ( - const polyMesh& mesh, - Istream& - ); + zoneToFace(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~zoneToFace(); + virtual ~zoneToFace() = default; // Member Functions @@ -109,7 +107,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C index fe0ee3c5d25e8e36864b08856ec33b7c37b5ff09..dfd056ae0ad2034622a9aae9d4d2fb8ebec2e251 100644 --- a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone ) : topoSetSource(mesh), - setName_(dict.lookup("zone")) + setName_(dict.get<word>("zone")) {} @@ -81,12 +81,6 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceZoneToFaceZone::~faceZoneToFaceZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceZoneToFaceZone::applyToSet diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H index 019678aeef3ee56c9f8c2432863fbb894a3fe15d..22f4b36d5afea764b9035d7c26a212e032f2a4a1 100644 --- a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select faces based on usage in another faceSet. + \heading Dictionary parameters + \table + Property | Description | Required | Default + zone | Name of input face zone (no regex) | yes | + \endtable + SourceFiles faceZoneToFaceZone.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - faceZoneToFaceZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + faceZoneToFaceZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - faceZoneToFaceZone - ( - const polyMesh& mesh, - Istream& - ); + faceZoneToFaceZone(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~faceZoneToFaceZone(); + virtual ~faceZoneToFaceZone() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index 8739feb0657c6bc52b24503a136cad8cec5bb31e..173c852cd691b8626b248536a89209be449ff3a6 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,6 @@ License #include "searchableSurface.H" #include "syncTools.H" #include "Time.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -68,7 +67,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone ( searchableSurface::New ( - word(dict.lookup("surface")), + dict.get<word>("surface"), IOobject ( dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), @@ -128,10 +127,8 @@ void Foam::searchableSurfaceToFaceZone::applyToSet const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); - forAll(pbm, patchi) + for (const polyPatch& pp : pbm) { - const polyPatch& pp = pbm[patchi]; - if (pp.coupled()) { forAll(pp, i) diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H index 7269a3d38eea48c6a89a7556b2878715bf70dd74..a5507dd1faf36fe31069bb1fe34099c88656f029 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H @@ -28,6 +28,13 @@ Description A topoSetSource to select faces based on intersection (of cell-cell vector) with a surface. + \heading Dictionary parameters + \table + Property | Description | Required | Default + surface | The searchable surface type | yes | + name | Name for the IOobject | no | mesh-name + \endtable + SourceFiles searchableSurfaceToFaceZone.C @@ -90,7 +97,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C index baf34a3551998855fa5945990455e1e50a534a2d..391ba268250fbd0d06f9f8f5334c900e70fc48eb 100644 --- a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,20 +26,15 @@ License #include "setAndNormalToFaceZone.H" #include "polyMesh.H" #include "faceZoneSet.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -defineTypeNameAndDebug(setAndNormalToFaceZone, 0); - -addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, word); - -addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, istream); - + defineTypeNameAndDebug(setAndNormalToFaceZone, 0); + addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, word); + addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, istream); } @@ -73,8 +68,8 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone ) : topoSetSource(mesh), - setName_(dict.lookup("faceSet")), - normal_(dict.lookup("normal")) + setName_(dict.get<word>("faceSet")), + normal_(dict.get<vector>("normal")) {} @@ -90,12 +85,6 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::setAndNormalToFaceZone::~setAndNormalToFaceZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::setAndNormalToFaceZone::applyToSet @@ -119,7 +108,8 @@ void Foam::setAndNormalToFaceZone::applyToSet << " ..." << endl; // Load the sets - faceSet fSet(mesh_, setName_); + faceSet loadedSet(mesh_, setName_); + labelHashSet& faceIds = loadedSet; // Start off from copy DynamicList<label> newAddressing(fzSet.addressing()); @@ -128,10 +118,8 @@ void Foam::setAndNormalToFaceZone::applyToSet const faceList& faces = mesh_.faces(); const pointField& points = mesh_.points(); - forAllConstIter(faceSet, fSet, iter) + for (const label facei : faceIds) { - label facei = iter.key(); - if (!fzSet.found(facei)) { newAddressing.append(facei); diff --git a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H index 23c9c266fe46d3fab5e0509fa330dfd7a473dd5a..76a285865e060ad8dfeb2eaedad82c9805c45726 100644 --- a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,13 @@ Description A topoSetSource to select faces based on usage in a faceSet, where the normal vector is used to orient the faces. + \heading Dictionary parameters + \table + Property | Description | Required | Default + faceSet | Name of input faceSet | yes | + normal | The normal vector for orientation | yes | + \endtable + SourceFiles setAndNormalToFaceZone.C @@ -79,22 +86,14 @@ public: ); //- Construct from dictionary - setAndNormalToFaceZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + setAndNormalToFaceZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setAndNormalToFaceZone - ( - const polyMesh& mesh, - Istream& - ); + setAndNormalToFaceZone(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~setAndNormalToFaceZone(); + virtual ~setAndNormalToFaceZone() = default; // Member Functions @@ -107,7 +106,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C index b9b418f2f2598b59cf1d05cabf361f203f893801..3ed303102b5b2c44c094ca406cac2cea7b87bbde 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,7 +67,7 @@ Foam::setToFaceZone::setToFaceZone ) : topoSetSource(mesh), - setName_(dict.lookup("faceSet")) + setName_(dict.get<word>("faceSet")) {} @@ -82,12 +82,6 @@ Foam::setToFaceZone::setToFaceZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::setToFaceZone::~setToFaceZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::setToFaceZone::applyToSet @@ -111,16 +105,15 @@ void Foam::setToFaceZone::applyToSet << " ..." << endl; // Load the sets - faceSet fSet(mesh_, setName_); + faceSet loadedSet(mesh_, setName_); + const labelHashSet& faceLabels = loadedSet; // Start off from copy DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<bool> newFlipMap(fzSet.flipMap()); - forAllConstIter(faceSet, fSet, iter) + for (const label facei : faceLabels) { - label facei = iter.key(); - if (!fzSet.found(facei)) { newAddressing.append(facei); diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H index 41a6d91cdea574f60919ed20807ca81f39543abb..f82d796eeb0b5258c7ede09ea82b3e5099281c15 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,8 +25,19 @@ Class Foam::setToFaceZone Description - A topoSetSource to select faces based on usage in a faceSet. Sets flipMap - to true. + A topoSetSource to select faces based on usage in a faceSet. + Sets flipMap to true. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + faceSet | Name of input faceSet | yes | + \endtable + +Note + The use of keyword \c faceSet is consistent with the setsToFaceZone, + but inconsistent with setToCellZone and setToPointZone. + Both of which use \c set instead. SourceFiles setToFaceZone.C @@ -74,22 +85,14 @@ public: ); //- Construct from dictionary - setToFaceZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + setToFaceZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setToFaceZone - ( - const polyMesh& mesh, - Istream& - ); + setToFaceZone(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~setToFaceZone(); + virtual ~setToFaceZone() = default; // Member Functions @@ -102,7 +105,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C index 70892ab62f216213794f33f98e505bcaf88895f6..8c016ea7f6cf998c601cf2d321d71f6f18187f2e 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,6 @@ License #include "polyMesh.H" #include "faceZoneSet.H" #include "cellSet.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -56,7 +55,7 @@ Foam::setsToFaceZone::setsToFaceZone const polyMesh& mesh, const word& faceSetName, const word& cellSetName, - const Switch& flip + const bool flip ) : topoSetSource(mesh), @@ -73,8 +72,8 @@ Foam::setsToFaceZone::setsToFaceZone ) : topoSetSource(mesh), - faceSetName_(dict.lookup("faceSet")), - cellSetName_(dict.lookup("cellSet")), + faceSetName_(dict.get<word>("faceSet")), + cellSetName_(dict.get<word>("cellSet")), flip_(dict.lookupOrDefault("flip", false)) {} @@ -92,12 +91,6 @@ Foam::setsToFaceZone::setsToFaceZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::setsToFaceZone::~setsToFaceZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::setsToFaceZone::applyToSet @@ -136,8 +129,8 @@ void Foam::setsToFaceZone::applyToSet { bool flipFace = false; - label own = mesh_.faceOwner()[facei]; - bool ownFound = cSet.found(own); + const label own = mesh_.faceOwner()[facei]; + const bool ownFound = cSet.found(own); if (mesh_.isInternalFace(facei)) { diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H index 72d2f6501e1d8656b135553316ebb4e653be4275..81bd21094065f29c67faafcd0c8adfa27f97374d 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description A topoSetSource to select faces based on usage in a faceSet and cellSet + \heading Dictionary parameters + \table + Property | Description | Required | Default + cellSet | Name of input cellSet | yes | + faceSet | Name of input faceSet | yes | + flip | Force flip of faces | no | false + \endtable + SourceFiles setsToFaceZone.C @@ -36,7 +44,6 @@ SourceFiles #define setsToFaceZone_H #include "topoSetSource.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -63,7 +70,7 @@ class setsToFaceZone const word cellSetName_; //- Whether cellSet is slave cells or master cells - const Switch flip_; + const bool flip_; public: @@ -78,26 +85,18 @@ public: const polyMesh& mesh, const word& faceSetName, const word& cellSetName, - const Switch& flip + const bool flip ); //- Construct from dictionary - setsToFaceZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + setsToFaceZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setsToFaceZone - ( - const polyMesh& mesh, - Istream& - ); + setsToFaceZone(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~setsToFaceZone(); + virtual ~setsToFaceZone() = default; // Member Functions diff --git a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C index 25805bc61e40c77f26d3d3c95a81589229f22fe5..d080f110e014ec61c17b00df20eca4a15891ff6b 100644 --- a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C +++ b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,11 +53,12 @@ void Foam::boxToPoint::combine(topoSet& set, const bool add) const forAll(pts, pointi) { - forAll(bbs_, i) + for (const auto& bb : bbs_) { - if (bbs_[i].contains(pts[pointi])) + if (bb.contains(pts[pointi])) { addOrDelete(set, pointi, add); + break; } } } @@ -109,12 +110,6 @@ Foam::boxToPoint::boxToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::boxToPoint::~boxToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::boxToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H index 121b22017c06b838a9fb2c378ef9a727099676ac..474c1538ffc04ac9ff9138996a2c3bfe6bd80acb 100644 --- a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H +++ b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,16 @@ Class Description A topoSetSource to select points based on whether they are inside box. + \heading Dictionary parameters + \table + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | + \endtable + +Note + Must specify either "box" or "boxes" + SourceFiles boxToPoint.C @@ -57,7 +67,7 @@ class boxToPoint //- Add usage string static addToUsageTable usage_; - //- Bounding box. + //- Bounding boxes treeBoundBoxList bbs_; @@ -77,26 +87,18 @@ public: boxToPoint ( const polyMesh& mesh, - const treeBoundBoxList& bb + const treeBoundBoxList& bbs ); //- Construct from dictionary - boxToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + boxToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - boxToPoint - ( - const polyMesh& mesh, - Istream& - ); + boxToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~boxToPoint(); + virtual ~boxToPoint() = default; // Member Functions @@ -109,7 +111,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C index bd17ab30ebfe059bca68b0a9d3927d5b7bed1d7d..9db7bedc5ccf0d966b0eb35318bd1197fb219399 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,20 +61,20 @@ void Foam::cellToPoint::combine(topoSet& set, const bool add) const { // Load the set cellSet loadedSet(mesh_, setName_); + const labelHashSet& cellLabels = loadedSet; // Add all point from cells in loadedSet - forAllConstIter(cellSet, loadedSet, iter) + for (const label celli : cellLabels) { - const label celli = iter.key(); const labelList& cFaces = mesh_.cells()[celli]; - forAll(cFaces, cFacei) + for (const label facei : cFaces) { - const face& f = mesh_.faces()[cFaces[cFacei]]; + const face& f = mesh_.faces()[facei]; - forAll(f, fp) + for (const label pointi : f) { - addOrDelete(set, f[fp], add); + addOrDelete(set, pointi, add); } } } @@ -103,7 +103,7 @@ Foam::cellToPoint::cellToPoint ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(cellActionNames_.lookup("option", dict)) {} @@ -120,12 +120,6 @@ Foam::cellToPoint::cellToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellToPoint::~cellToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cellToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H index d19be4f1941fc24fd738c3ce834138fac9dd7698..7bf16ea8534b41b7ee11f9303306e298982fdb62 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select points based on usage in cells. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The input cellSet name | yes | + option | Selection type (all) | yes | + \endtable + SourceFiles cellToPoint.C @@ -95,22 +102,14 @@ public: ); //- Construct from dictionary - cellToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + cellToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - cellToPoint - ( - const polyMesh& mesh, - Istream& - ); + cellToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~cellToPoint(); + virtual ~cellToPoint() = default; // Member Functions @@ -123,7 +122,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C index 1010ae8000c166c6f5efc19ada3caed169e183f2..72e93bdb78ecc7237b4d79d62bde8cf354fd7770 100644 --- a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C +++ b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,15 +60,16 @@ void Foam::faceToPoint::combine(topoSet& set, const bool add) const { // Load the set faceSet loadedSet(mesh_, setName_); + const labelHashSet& faceLabels = loadedSet; // Add all points from faces in loadedSet - forAllConstIter(faceSet, loadedSet, iter) + for (const label facei : faceLabels) { - const face& f = mesh_.faces()[iter.key()]; + const face& f = mesh_.faces()[facei]; - forAll(f, fp) + for (const label pointi : f) { - addOrDelete(set, f[fp], add); + addOrDelete(set, pointi, add); } } } @@ -96,7 +97,7 @@ Foam::faceToPoint::faceToPoint ) : topoSetSource(mesh), - setName_(dict.lookup("set")), + setName_(dict.get<word>("set")), option_(faceActionNames_.lookup("option", dict)) {} @@ -113,12 +114,6 @@ Foam::faceToPoint::faceToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceToPoint::~faceToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H index 99c598e150ec7394e8da12ecb0cdca4d14ca2943..7a2f3918d3dd6e809f40fb51e24ed5fda4bde734 100644 --- a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H +++ b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,13 @@ Class Description A topoSetSource to select points based on usage in faces. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The input faceSet name | yes | + option | Selection type (all) | yes | + \endtable + SourceFiles faceToPoint.C @@ -95,22 +102,14 @@ public: ); //- Construct from dictionary - faceToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + faceToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - faceToPoint - ( - const polyMesh& mesh, - Istream& - ); + faceToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~faceToPoint(); + virtual ~faceToPoint() = default; // Member Functions @@ -123,7 +122,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C index 1eed08530889b06ac5f2aee8f7cfd0220ace9198..15e19a773b882f1bb1ffe46587f8ce8b1a2d547b 100644 --- a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C +++ b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,17 +45,6 @@ Foam::topoSetSource::addToUsageTable Foam::labelToPoint::usage_ ); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::labelToPoint::combine(topoSet& set, const bool add) const -{ - forAll(labels_, labelI) - { - addOrDelete(set, labels_[labelI], add); - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::labelToPoint::labelToPoint @@ -76,7 +65,7 @@ Foam::labelToPoint::labelToPoint ) : topoSetSource(mesh), - labels_(dict.lookup("value")) + labels_(dict.get<labelList>("value")) {} @@ -88,13 +77,9 @@ Foam::labelToPoint::labelToPoint : topoSetSource(mesh), labels_(checkIs(is)) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::labelToPoint::~labelToPoint() -{} +{ + check(labels_, mesh.nPoints()); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -109,14 +94,13 @@ void Foam::labelToPoint::applyToSet { Info<< " Adding points mentioned in dictionary" << " ..." << endl; - combine(set, true); + addOrDelete(set, labels_, true); } else if (action == topoSetSource::DELETE) { - Info<< " Removing points mentioned in dictionary" << " ..." - << endl; + Info<< " Removing points mentioned in dictionary" << " ..." << endl; - combine(set, false); + addOrDelete(set, labels_, false); } } diff --git a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H index 5604862f9dbc368d3f59b12f132e74efcfe05d7e..5670edcddf690f6fa1d04305029fdc5181833b13 100644 --- a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H +++ b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select points given explicitly provided labels. + \heading Dictionary parameters + \table + Property | Description | Required | Default + value | The point labels | yes | + \endtable + SourceFiles labelToPoint.C @@ -60,11 +66,6 @@ class labelToPoint labelList labels_; - // Private Member Functions - - void combine(topoSet& set, const bool add) const; - - public: //- Runtime type information @@ -72,7 +73,7 @@ public: // Constructors - //- Construct from components + //- Copy construct from components labelToPoint ( const polyMesh& mesh, @@ -80,22 +81,14 @@ public: ); //- Construct from dictionary - labelToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + labelToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - labelToPoint - ( - const polyMesh& mesh, - Istream& - ); + labelToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~labelToPoint(); + virtual ~labelToPoint() = default; // Member Functions @@ -108,7 +101,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C index 339c9fac7c2d55344babaf6c11c438ffce9416e9..95fc156c0438e789212e56eb10086d2caa271d16 100644 --- a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,11 +88,11 @@ void Foam::nearestToPoint::combine(topoSet& set, const bool add) const Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp()); Pstream::listCombineScatter(nearest); - forAll(nearest, pointi) + for (const auto& near : nearest) { - if (nearest[pointi].second().second() == Pstream::myProcNo()) + if (near.second().second() == Pstream::myProcNo()) { - addOrDelete(set, nearest[pointi].first().index(), add); + addOrDelete(set, near.first().index(), add); } } } @@ -118,7 +118,7 @@ Foam::nearestToPoint::nearestToPoint ) : topoSetSource(mesh), - points_(dict.lookup("points")) + points_(dict.get<pointField>("points")) {} @@ -133,12 +133,6 @@ Foam::nearestToPoint::nearestToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::nearestToPoint::~nearestToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::nearestToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H index ede08013b02a4a1e52cbefdfd0308b8299756fe4..ff224780ac4c7e4956bb403a3df9201018526b9c 100644 --- a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select points nearest to points. + \heading Dictionary parameters + \table + Property | Description | Required | Default + points | List of selection points | yes | + \endtable + SourceFiles nearestToPoint.C @@ -80,22 +86,14 @@ public: ); //- Construct from dictionary - nearestToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + nearestToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - nearestToPoint - ( - const polyMesh& mesh, - Istream& - ); + nearestToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~nearestToPoint(); + virtual ~nearestToPoint() = default; // Member Functions @@ -108,7 +106,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C index 3a72bdda6ce97430d5849a268e37756fcadb24c2..93a40e84e17446093de2f3bb181434a1d1e5b720 100644 --- a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C +++ b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::pointToPoint::pointToPoint ) : topoSetSource(mesh), - setName_(dict.lookup("set")) + setName_(dict.get<word>("set")) {} @@ -81,12 +81,6 @@ Foam::pointToPoint::pointToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::pointToPoint::~pointToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::pointToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H index fbe0c742bcefec4a340590a38dfc51342d97d72e..9257d3bea9ec3337b9cb026564308dbdba0e0c0a 100644 --- a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H +++ b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,13 @@ Class Foam::pointToPoint Description - A topoSetSource to select points based on usage in pointSet. + A topoSetSource to select the points from another pointSet. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | The point set name | yes | + \endtable SourceFiles pointToPoint.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - pointToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + pointToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - pointToPoint - ( - const polyMesh& mesh, - Istream& - ); + pointToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~pointToPoint(); + virtual ~pointToPoint() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C index 21f06de20f493f009217c8c40491c741d404c56e..da51f7a9d95ec9bba87b85d652723fd51847e7d0 100644 --- a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C +++ b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,7 +75,11 @@ void Foam::surfaceToPoint::combine(topoSet& set, const bool add) const { bool isInside = pointInside[pointi]; - if ((isInside && includeInside_) || (!isInside && includeOutside_)) + if + ( + (isInside && includeInside_) + || (!isInside && includeOutside_) + ) { addOrDelete(set, pointi, add); } @@ -147,11 +151,11 @@ Foam::surfaceToPoint::surfaceToPoint ) : topoSetSource(mesh), - surfName_(fileName(dict.lookup("file")).expand()), - scale_(dict.lookupOrDefault<scalar>("scale", 1.0)), - nearDist_(readScalar(dict.lookup("nearDistance"))), - includeInside_(readBool(dict.lookup("includeInside"))), - includeOutside_(readBool(dict.lookup("includeOutside"))) + surfName_(dict.get<fileName>("file").expand()), + scale_(dict.lookupOrDefault<scalar>("scale", -1)), + nearDist_(dict.get<scalar>("nearDistance")), + includeInside_(dict.get<bool>("includeInside")), + includeOutside_(dict.get<bool>("includeOutside")) { checkSettings(); } @@ -174,12 +178,6 @@ Foam::surfaceToPoint::surfaceToPoint } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::surfaceToPoint::~surfaceToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::surfaceToPoint::applyToSet @@ -188,7 +186,7 @@ void Foam::surfaceToPoint::applyToSet topoSet& set ) const { - if ( (action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { Info<< " Adding points in relation to surface " << surfName_ << " ..." << endl; diff --git a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H index d800574069c5abf7cae72d95cd8c8226bb497d64..0f6ed0d4e5e9c7429a9e4887b978d5772cc90fe3 100644 --- a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H +++ b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,6 +33,16 @@ Description (Uses normal of nearest surface triangle so requires valid surface topology!) + \heading Dictionary parameters + \table + Property | Description | Required | Default + file | The surface "filename" | yes | + scale | surface scaling factor | no | -1 + nearDistance | Near distance to the surface | yes | + includeInside | Include inside cells (bool) | yes | + includeOutside | Include outside cells (bool) | yes | + \endtable + SourceFiles surfaceToPoint.C @@ -42,12 +52,13 @@ SourceFiles #define surfaceToPoint_H #include "topoSetSource.H" -#include "Map.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { + +// Forward declarations class triSurfaceSearch; /*---------------------------------------------------------------------------*\ @@ -106,22 +117,14 @@ public: ); //- Construct from dictionary - surfaceToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + surfaceToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - surfaceToPoint - ( - const polyMesh& mesh, - Istream& - ); + surfaceToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~surfaceToPoint(); + virtual ~surfaceToPoint() = default; // Member Functions @@ -134,7 +137,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C index cdb7eb28d9919ea7413c393f36d324af44eefcb0..69d6ab31af340017e0abf1ed1aa07de44b5a112f 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,6 @@ License #include "zoneToPoint.H" #include "polyMesh.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -53,25 +52,23 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const { bool hasMatched = false; - forAll(mesh_.pointZones(), i) + for (const pointZone& zone : mesh_.pointZones()) { - const pointZone& zone = mesh_.pointZones()[i]; - if (zoneName_.match(zone.name())) { - const labelList& pointLabels = mesh_.pointZones()[i]; + hasMatched = true; + + const labelList& pointLabels = zone; Info<< " Found matching zone " << zone.name() << " with " << pointLabels.size() << " points." << endl; - hasMatched = true; - - forAll(pointLabels, i) + for (const label pointi : pointLabels) { // Only do active points - if (pointLabels[i] < mesh_.nPoints()) + if (pointi >= 0 && pointi < mesh_.nPoints()) { - addOrDelete(set, pointLabels[i], add); + addOrDelete(set, pointi, add); } } } @@ -80,8 +77,9 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any pointZone named " << zoneName_ << endl - << "Valid names are " << mesh_.pointZones().names() << endl; + << "Cannot find any pointZone named " << zoneName_ << nl + << "Valid names: " << flatOutput(mesh_.pointZones().names()) + << endl; } } @@ -106,7 +104,7 @@ Foam::zoneToPoint::zoneToPoint ) : topoSetSource(mesh), - zoneName_(dict.lookup("name")) + zoneName_(dict.get<wordRe>("name")) {} @@ -121,12 +119,6 @@ Foam::zoneToPoint::zoneToPoint {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::zoneToPoint::~zoneToPoint() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::zoneToPoint::applyToSet diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H index 233fc879ce47d199111e2631aa6bdcb97258b2c5..ea7c0eaee13711f0836b875f5854bdd590efc4e1 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select points based on pointZone. + \heading Dictionary parameters + \table + Property | Description | Required | Default + name | The point zone name or regex | yes | + \endtable + SourceFiles zoneToPoint.C @@ -81,22 +87,14 @@ public: ); //- Construct from dictionary - zoneToPoint - ( - const polyMesh& mesh, - const dictionary& dict - ); + zoneToPoint(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - zoneToPoint - ( - const polyMesh& mesh, - Istream& - ); + zoneToPoint(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~zoneToPoint(); + virtual ~zoneToPoint() = default; // Member Functions @@ -109,7 +107,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C index b44321f048a349eafccc227c449fa15a7697a675..fd714d51fa247fe61e1d5dd9d27d6c4b6f9d52d5 100644 --- a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::setToPointZone::setToPointZone ) : topoSetSource(mesh), - setName_(dict.lookup("set")) + setName_(dict.get<word>("set")) {} @@ -81,12 +81,6 @@ Foam::setToPointZone::setToPointZone {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::setToPointZone::~setToPointZone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::setToPointZone::applyToSet @@ -110,15 +104,14 @@ void Foam::setToPointZone::applyToSet << " ..." << endl; // Load the sets - pointSet fSet(mesh_, setName_); + pointSet loadedSet(mesh_, setName_); + const labelHashSet& pointLabels = loadedSet; // Start off from copy DynamicList<label> newAddressing(fzSet.addressing()); - forAllConstIter(pointSet, fSet, iter) + for (const label pointi : pointLabels) { - label pointi = iter.key(); - if (!fzSet.found(pointi)) { newAddressing.append(pointi); diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H index e3faf596037b4d37fad2e9b939598fa636792c3b..f1396ac8d9a3d53a1d3010ff2bda1b941cd79a80 100644 --- a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,12 @@ Class Description A topoSetSource to select points based on usage in a pointSet. + \heading Dictionary parameters + \table + Property | Description | Required | Default + set | Name of input pointSet | yes | + \endtable + SourceFiles setToPointZone.C @@ -73,22 +79,14 @@ public: ); //- Construct from dictionary - setToPointZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + setToPointZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setToPointZone - ( - const polyMesh& mesh, - Istream& - ); + setToPointZone(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~setToPointZone(); + virtual ~setToPointZone() = default; // Member Functions @@ -101,7 +99,7 @@ public: virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.C b/src/meshTools/sets/topoSetSource/topoSetSource.C index 40c20d21de95516e5e18a8a3ae3bb07a0ac324c8..801190f5217c958a7680735c618e8b0e22df5ee1 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.C +++ b/src/meshTools/sets/topoSetSource/topoSetSource.C @@ -44,7 +44,7 @@ const Foam::Enum < Foam::topoSetSource::setAction > -Foam::topoSetSource::actionNames_ +Foam::topoSetSource::actionNames { { setAction::CLEAR, "clear" }, { setAction::NEW, "new" }, @@ -63,6 +63,40 @@ const Foam::string Foam::topoSetSource::illegalSource_ ); +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool Foam::topoSetSource::check(labelList& list, const label maxLabel) +{ + const label len = list.size(); + + label nGood = 0; + + for (label i=0; i < len; ++i) + { + const label val = list[i]; + + if (val >= 0 && val < maxLabel) + { + if (nGood != i) + { + list[nGood] = val; + } + ++nGood; + } + } + + const label nReject = (len - nGood); + + if (nReject) + { + list.resize(nGood); + + // Report? + } + + return !nReject; +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -122,9 +156,9 @@ Foam::Istream& Foam::topoSetSource::checkIs(Istream& is) { FatalErrorInFunction << exit(FatalError); - - return is; } + + return is; } @@ -133,17 +167,35 @@ Foam::Istream& Foam::topoSetSource::checkIs(Istream& is) void Foam::topoSetSource::addOrDelete ( topoSet& set, - const label celli, + const label id, const bool add ) const { if (add) { - set.insert(celli); + set.insert(id); } else { - set.erase(celli); + set.erase(id); + } +} + + +void Foam::topoSetSource::addOrDelete +( + topoSet& set, + const labelUList& labels, + const bool add +) const +{ + if (add) + { + set.insert(labels); + } + else + { + set.erase(labels); } } @@ -156,10 +208,4 @@ Foam::topoSetSource::topoSetSource(const polyMesh& mesh) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::topoSetSource::~topoSetSource() -{} - - // ************************************************************************* // diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.H b/src/meshTools/sets/topoSetSource/topoSetSource.H index 46042fe3496d9be6929e55554003076d2cf9547c..4dfacfe3c4f4f82e1187420983e61925b00d7250 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.H +++ b/src/meshTools/sets/topoSetSource/topoSetSource.H @@ -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) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +53,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class polyMesh; class topoSet; @@ -92,6 +92,10 @@ public: REMOVE }; + //- The setActions text representations + static const Enum<setAction> actionNames; + + protected: //- A table of usage strings @@ -124,15 +128,29 @@ protected: // Protected data + //- Reference to the mesh const polyMesh& mesh_; - //- Add (if bool) celli to set or delete celli from set. - void addOrDelete(topoSet& set, const label celli, const bool) const; + // Protected Member Functions + + //- Detect and remove any values less than 0 or ge maxLabel. + // \return false if invalid elements were detected (and removed) + static bool check(labelList& list, const label maxLabel); + + //- Add or delete id from set. Add when 'add' is true + void addOrDelete(topoSet& set, const label id, const bool add) const; + + //- Add or delete labels from set. Add when 'add' is true + void addOrDelete + ( + topoSet& set, + const labelUList& labels, + const bool add + ) const; -private: - static const Enum<setAction> actionNames_; +private: static const string illegalSource_; @@ -155,14 +173,16 @@ public: // Static Functions //- Convert string to action + // \deprecated use direct access to actionNames (JUL-2018) static setAction toAction(const word& actionName) { - return actionNames_[actionName]; + return actionNames[actionName]; } //- Check state of stream. static Istream& checkIs(Istream& is); + // Declare run-time constructor selection table // For the dictionary constructor @@ -207,9 +227,9 @@ public: autoPtr<topoSetSource> operator()(Istream& is) const { - word topoSetSourceType(is); + const word sourceTypeName(is); dictionary dict(is); - return topoSetSource::New(topoSetSourceType, mesh_, dict); + return topoSetSource::New(sourceTypeName, mesh_, dict); } }; @@ -221,25 +241,16 @@ public: usageTablePtr_ = new HashTable<string>(); } - const HashTable<string>& usageTable = *usageTablePtr_; - - if (usageTable.found(name)) - { - return usageTable[name]; - } - else - { - return illegalSource_; - } + return usageTablePtr_->lookup(name, illegalSource_); } // Constructors //- Construct from components - topoSetSource(const polyMesh& mesh); + explicit topoSetSource(const polyMesh& mesh); - //- Clone + //- Clone (disallowed) autoPtr<topoSetSource> clone() const { NotImplemented; @@ -267,11 +278,12 @@ public: //- Destructor - virtual ~topoSetSource(); + virtual ~topoSetSource() = default; // Member Functions + //- Reference to the mesh const polyMesh& mesh() const { return mesh_; @@ -280,9 +292,11 @@ public: // Member Functions + //- The type of set being used by the source virtual sourceType setType() const = 0; - virtual void applyToSet(const setAction action, topoSet&) const = 0; + //- Apply specified action to the topoSet + virtual void applyToSet(const setAction action, topoSet& set) const = 0; }; diff --git a/src/meshTools/sets/topoSets/cellSet.C b/src/meshTools/sets/topoSets/cellSet.C index d98ab34dfeacb47589ba090f1d8ff5e4749c8131..df5704da16d46ddb1e747ce0196d72e50c0a2699 100644 --- a/src/meshTools/sets/topoSets/cellSet.C +++ b/src/meshTools/sets/topoSets/cellSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,8 @@ addToRunTimeSelectionTable(topoSet, cellSet, size); addToRunTimeSelectionTable(topoSet, cellSet, set); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellSet::cellSet(const IOobject& obj) : @@ -92,11 +93,11 @@ Foam::cellSet::cellSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, labels, w) {} @@ -104,11 +105,23 @@ Foam::cellSet::cellSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, std::move(labels), w) +{} + + +Foam::cellSet::cellSet +( + const polyMesh& mesh, + const word& name, + const labelUList& labels, + writeOption w +) +: + topoSet(mesh, name, labels, w) {} @@ -149,24 +162,18 @@ Foam::cellSet::cellSet ( const Time& runTime, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w ) : topoSet ( findIOobject(runTime, name, IOobject::NO_READ, w), - set + labels ) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellSet::~cellSet() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::cellSet::maxSize(const polyMesh& mesh) const @@ -184,10 +191,14 @@ void Foam::cellSet::updateMesh(const mapPolyMesh& morphMap) void Foam::cellSet::distribute(const mapDistributePolyMesh& map) { boolList inSet(map.nOldCells()); - forAllConstIter(cellSet, *this, iter) + + const labelHashSet& labels = *this; + + for (const label celli : labels) { - inSet[iter.key()] = true; + inSet[celli] = true; } + map.distributeCellData(inSet); // Count @@ -196,7 +207,7 @@ void Foam::cellSet::distribute(const mapDistributePolyMesh& map) { if (inSet[celli]) { - n++; + ++n; } } diff --git a/src/meshTools/sets/topoSets/cellSet.H b/src/meshTools/sets/topoSets/cellSet.H index 7d47e9ec01739f17c6c5e227b9797eec48feb9b4..dc00df9c4436444a4f8739b8b823bf64bca84a51 100644 --- a/src/meshTools/sets/topoSets/cellSet.H +++ b/src/meshTools/sets/topoSets/cellSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,7 +76,7 @@ public: writeOption w=NO_WRITE ); - //- Construct empty from size of labelHashSet + //- Construct empty with initial size for labelHashSet cellSet ( const polyMesh& mesh, @@ -94,21 +94,30 @@ public: writeOption w=NO_WRITE ); - //- Construct from labelHashSet + //- Construct (no-read) with copy of labelHashSet cellSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w=NO_WRITE ); - //- Construct from additional list of labels for the labelHashSet + //- Construct (no-read) with moving labelHashSet cellSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, + writeOption w=NO_WRITE + ); + + //- Construct (no-read) with copy labels + cellSet + ( + const polyMesh& mesh, + const word& name, + const labelUList& labels, writeOption w=NO_WRITE ); @@ -138,13 +147,13 @@ public: ( const Time&, const word& name, - const labelHashSet&, + const labelHashSet& labels, writeOption w=NO_WRITE ); //- Destructor - virtual ~cellSet(); + virtual ~cellSet() = default; // Member functions @@ -160,7 +169,7 @@ public: virtual void updateMesh(const mapPolyMesh& morphMap); //- Update any stored data for mesh redistribution. - virtual void distribute(const mapDistributePolyMesh&); + virtual void distribute(const mapDistributePolyMesh& map); //- Write maxLen items with label and coordinates. virtual void writeDebug diff --git a/src/meshTools/sets/topoSets/cellZoneSet.C b/src/meshTools/sets/topoSets/cellZoneSet.C index 2e08f62348bf4f6d5f2cfd415ee8354ce1395b7a..4168af394a85392f475992183eb3458656b153cd 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.C +++ b/src/meshTools/sets/topoSets/cellZoneSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,11 +33,10 @@ License namespace Foam { -defineTypeNameAndDebug(cellZoneSet, 0); - -addToRunTimeSelectionTable(topoSet, cellZoneSet, word); -addToRunTimeSelectionTable(topoSet, cellZoneSet, size); -addToRunTimeSelectionTable(topoSet, cellZoneSet, set); + defineTypeNameAndDebug(cellZoneSet, 0); + addToRunTimeSelectionTable(topoSet, cellZoneSet, word); + addToRunTimeSelectionTable(topoSet, cellZoneSet, size); + addToRunTimeSelectionTable(topoSet, cellZoneSet, set); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -50,10 +49,7 @@ void Foam::cellZoneSet::updateSet() cellSet::clearStorage(); cellSet::resize(2*addressing_.size()); - forAll(addressing_, i) - { - cellSet::insert(addressing_[i]); - } + cellSet::insert(addressing_); } @@ -67,9 +63,9 @@ Foam::cellZoneSet::cellZoneSet writeOption w ) : - cellSet(mesh, name, 1000), // do not read cellSet + cellSet(mesh, name, 1024), // do not read cellSet mesh_(mesh), - addressing_(0) + addressing_() { const cellZoneMesh& cellZones = mesh.cellZones(); label zoneID = cellZones.findZoneID(name); @@ -101,7 +97,7 @@ Foam::cellZoneSet::cellZoneSet : cellSet(mesh, name, size, w), mesh_(mesh), - addressing_(0) + addressing_() { updateSet(); } @@ -123,12 +119,6 @@ Foam::cellZoneSet::cellZoneSet } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellZoneSet::~cellZoneSet() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::cellZoneSet::invert(const label maxLen) @@ -136,11 +126,11 @@ void Foam::cellZoneSet::invert(const label maxLen) // Count label n = 0; - for (label celli = 0; celli < maxLen; celli++) + for (label celli = 0; celli < maxLen; ++celli) { if (!found(celli)) { - n++; + ++n; } } @@ -148,12 +138,12 @@ void Foam::cellZoneSet::invert(const label maxLen) addressing_.setSize(n); n = 0; - for (label celli = 0; celli < maxLen; celli++) + for (label celli = 0; celli < maxLen; ++celli) { if (!found(celli)) { addressing_[n] = celli; - n++; + ++n; } } @@ -165,12 +155,10 @@ void Foam::cellZoneSet::subset(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); - const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + const cellZoneSet& zoneSet = refCast<const cellZoneSet>(set); - forAll(fSet.addressing(), i) + for (const label celli : zoneSet.addressing()) { - label celli = fSet.addressing()[i]; - if (found(celli)) { newAddressing.append(celli); @@ -186,12 +174,10 @@ void Foam::cellZoneSet::addSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_); - const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + const cellZoneSet& zoneSet = refCast<const cellZoneSet>(set); - forAll(fSet.addressing(), i) + for (const label celli : zoneSet.addressing()) { - label celli = fSet.addressing()[i]; - if (!found(celli)) { newAddressing.append(celli); @@ -207,15 +193,13 @@ void Foam::cellZoneSet::deleteSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); - const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + const cellZoneSet& zoneSet = refCast<const cellZoneSet>(set); - forAll(addressing_, i) + for (const label celli : addressing_) { - label celli = addressing_[i]; - - if (!fSet.found(celli)) + if (!zoneSet.found(celli)) { - // Not found in fSet so add + // Not found in zoneSet so add newAddressing.append(celli); } } @@ -299,7 +283,7 @@ void Foam::cellZoneSet::updateMesh(const mapPolyMesh& morphMap) if (newCelli >= 0) { newAddressing[n] = newCelli; - n++; + ++n; } } newAddressing.setSize(n); diff --git a/src/meshTools/sets/topoSets/cellZoneSet.H b/src/meshTools/sets/topoSets/cellZoneSet.H index 9df3c0c4db45e3700a29cee42243998ccb99b057..8e21178a5e9cb1ba829c14d6f28b98f54f5da47f 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.H +++ b/src/meshTools/sets/topoSets/cellZoneSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,6 @@ SourceFiles #define cellZoneSet_H #include "cellSet.H" -#include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -74,28 +73,28 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional size of labelHashSet + //- Construct from initial size for labelHashSet cellZoneSet ( const polyMesh& mesh, const word& name, - const label, + const label size, writeOption w=NO_WRITE ); - //- Construct from existing set + //- Copy construct from existing set cellZoneSet ( const polyMesh& mesh, const word& name, - const topoSet&, + const topoSet& set, writeOption w=NO_WRITE ); //- Destructor - virtual ~cellZoneSet(); + virtual ~cellZoneSet() = default; // Member functions @@ -113,8 +112,8 @@ public: //- Sort addressing and make cellSet part consistent with addressing void updateSet(); - //- Invert contents. (insert all members 0..maxLen-1 which were not in - // set) + //- Invert contents. + // Insert all members [0,maxLen) which were not in set virtual void invert(const label maxLen); //- Subset contents. Only elements present in both sets remain. diff --git a/src/meshTools/sets/topoSets/faceSet.C b/src/meshTools/sets/topoSets/faceSet.C index afeebccbf4909ef13746be72bd66af1c3aa50f23..2de0053c38ebfae4447587d056747cf2b9d1a7ae 100644 --- a/src/meshTools/sets/topoSets/faceSet.C +++ b/src/meshTools/sets/topoSets/faceSet.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) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,18 +28,16 @@ License #include "polyMesh.H" #include "syncTools.H" #include "mapDistributePolyMesh.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { -defineTypeNameAndDebug(faceSet, 0); - -addToRunTimeSelectionTable(topoSet, faceSet, word); -addToRunTimeSelectionTable(topoSet, faceSet, size); -addToRunTimeSelectionTable(topoSet, faceSet, set); + defineTypeNameAndDebug(faceSet, 0); + addToRunTimeSelectionTable(topoSet, faceSet, word); + addToRunTimeSelectionTable(topoSet, faceSet, size); + addToRunTimeSelectionTable(topoSet, faceSet, set); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -92,11 +90,11 @@ Foam::faceSet::faceSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, labels, w) {} @@ -104,17 +102,23 @@ Foam::faceSet::faceSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, std::move(labels), w) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceSet::~faceSet() +Foam::faceSet::faceSet +( + const polyMesh& mesh, + const word& name, + const labelUList& labels, + writeOption w +) +: + topoSet(mesh, name, labels, w) {} @@ -124,10 +128,13 @@ void Foam::faceSet::sync(const polyMesh& mesh) { boolList set(mesh.nFaces(), false); - forAllConstIter(faceSet, *this, iter) + const labelHashSet& labels = *this; + + for (const label facei : labels) { - set[iter.key()] = true; + set[facei] = true; } + syncTools::syncFaceList(mesh, set, orEqOp<bool>()); label nAdded = 0; @@ -138,7 +145,7 @@ void Foam::faceSet::sync(const polyMesh& mesh) { if (insert(facei)) { - nAdded++; + ++nAdded; } } else if (found(facei)) @@ -174,10 +181,14 @@ void Foam::faceSet::updateMesh(const mapPolyMesh& morphMap) void Foam::faceSet::distribute(const mapDistributePolyMesh& map) { boolList inSet(map.nOldFaces()); - forAllConstIter(faceSet, *this, iter) + + const labelHashSet& labels = *this; + + for (const label facei : labels) { - inSet[iter.key()] = true; + inSet[facei] = true; } + map.distributeFaceData(inSet); // Count @@ -186,7 +197,7 @@ void Foam::faceSet::distribute(const mapDistributePolyMesh& map) { if (inSet[facei]) { - n++; + ++n; } } diff --git a/src/meshTools/sets/topoSets/faceSet.H b/src/meshTools/sets/topoSets/faceSet.H index 02d9f42331989ade3a5101e742654c040e617efe..b3e401c0fba2b9e0db8d67376d5bf8188a1eca29 100644 --- a/src/meshTools/sets/topoSets/faceSet.H +++ b/src/meshTools/sets/topoSets/faceSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional size of labelHashSet + //- Construct empty with initial size for labelHashSet faceSet ( const polyMesh& mesh, @@ -89,27 +89,36 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional labelHashSet + //- Construct (no-read) with copy of labelHashSet faceSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w=NO_WRITE ); - //- Construct from additional list of labels for the labelHashSet + //- Construct (no-read) with moving labelHashSet faceSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, + writeOption w=NO_WRITE + ); + + //- Construct (no-read) with copy of labels + faceSet + ( + const polyMesh& mesh, + const word& name, + const labelUList& labels, writeOption w=NO_WRITE ); //- Destructor - virtual ~faceSet(); + virtual ~faceSet() = default; // Member functions @@ -124,7 +133,7 @@ public: virtual void updateMesh(const mapPolyMesh& morphMap); //- Update any stored data for mesh redistribution. - virtual void distribute(const mapDistributePolyMesh&); + virtual void distribute(const mapDistributePolyMesh& map); //- Write maxLen items with label and coordinates. virtual void writeDebug diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C index 2227813dd23435f8be65913f8236f125d6bd421e..e0716e858a2cbf8b5170b1e815c87e7dbef08d52 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.C +++ b/src/meshTools/sets/topoSets/faceZoneSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,13 +36,13 @@ License namespace Foam { -defineTypeNameAndDebug(faceZoneSet, 0); - -addToRunTimeSelectionTable(topoSet, faceZoneSet, word); -addToRunTimeSelectionTable(topoSet, faceZoneSet, size); -addToRunTimeSelectionTable(topoSet, faceZoneSet, set); + defineTypeNameAndDebug(faceZoneSet, 0); + addToRunTimeSelectionTable(topoSet, faceZoneSet, word); + addToRunTimeSelectionTable(topoSet, faceZoneSet, size); + addToRunTimeSelectionTable(topoSet, faceZoneSet, set); } + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::faceZoneSet::updateSet() @@ -54,10 +54,7 @@ void Foam::faceZoneSet::updateSet() faceSet::clearStorage(); faceSet::resize(2*addressing_.size()); - forAll(addressing_, i) - { - faceSet::insert(addressing_[i]); - } + faceSet::insert(addressing_); } @@ -71,10 +68,10 @@ Foam::faceZoneSet::faceZoneSet writeOption w ) : - faceSet(mesh, name, 1000), // do not read faceSet + faceSet(mesh, name, 1024), // do not read faceSet mesh_(mesh), - addressing_(0), - flipMap_(0) + addressing_(), + flipMap_() { const faceZoneMesh& faceZones = mesh.faceZones(); label zoneID = faceZones.findZoneID(name); @@ -107,8 +104,8 @@ Foam::faceZoneSet::faceZoneSet : faceSet(mesh, name, size, w), mesh_(mesh), - addressing_(0), - flipMap_(0) + addressing_(), + flipMap_() { updateSet(); } @@ -131,12 +128,6 @@ Foam::faceZoneSet::faceZoneSet } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::faceZoneSet::~faceZoneSet() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::faceZoneSet::invert(const label maxLen) @@ -144,11 +135,11 @@ void Foam::faceZoneSet::invert(const label maxLen) // Count label n = 0; - for (label facei = 0; facei < maxLen; facei++) + for (label facei = 0; facei < maxLen; ++facei) { if (!found(facei)) { - n++; + ++n; } } @@ -157,13 +148,13 @@ void Foam::faceZoneSet::invert(const label maxLen) flipMap_.setSize(n); n = 0; - for (label facei = 0; facei < maxLen; facei++) + for (label facei = 0; facei < maxLen; ++facei) { if (!found(facei)) { addressing_[n] = facei; flipMap_[n] = false; //? or true? - n++; + ++n; } } updateSet(); @@ -183,21 +174,21 @@ void Foam::faceZoneSet::subset(const topoSet& set) faceToIndex.insert(addressing_[i], i); } - const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + const faceZoneSet& zoneSet = refCast<const faceZoneSet>(set); - forAll(fSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - label facei = fSet.addressing()[i]; + const label facei = zoneSet.addressing()[i]; - Map<label>::const_iterator iter = faceToIndex.find(facei); + const auto iter = faceToIndex.cfind(facei); - if (iter != faceToIndex.end()) + if (iter.found()) { - label index = iter(); + const label index = *iter; - if (fSet.flipMap()[i] != flipMap_[index]) + if (zoneSet.flipMap()[i] != flipMap_[index]) { - nConflict++; + ++nConflict; } newAddressing.append(facei); newFlipMap.append(flipMap_[index]); @@ -231,27 +222,27 @@ void Foam::faceZoneSet::addSet(const topoSet& set) faceToIndex.insert(addressing_[i], i); } - const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + const faceZoneSet& zoneSet = refCast<const faceZoneSet>(set); - forAll(fSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - label facei = fSet.addressing()[i]; + label facei = zoneSet.addressing()[i]; - Map<label>::const_iterator iter = faceToIndex.find(facei); + const auto iter = faceToIndex.cfind(facei); - if (iter != faceToIndex.end()) + if (iter.found()) { - label index = iter(); + const label index = *iter; - if (fSet.flipMap()[i] != flipMap_[index]) + if (zoneSet.flipMap()[i] != flipMap_[index]) { - nConflict++; + ++nConflict; } } else { newAddressing.append(facei); - newFlipMap.append(fSet.flipMap()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } @@ -276,34 +267,34 @@ void Foam::faceZoneSet::deleteSet(const topoSet& set) DynamicList<label> newAddressing(addressing_.size()); DynamicList<bool> newFlipMap(flipMap_.size()); - const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + const faceZoneSet& zoneSet = refCast<const faceZoneSet>(set); - Map<label> faceToIndex(fSet.addressing().size()); - forAll(fSet.addressing(), i) + Map<label> faceToIndex(zoneSet.addressing().size()); + forAll(zoneSet.addressing(), i) { - faceToIndex.insert(fSet.addressing()[i], i); + faceToIndex.insert(zoneSet.addressing()[i], i); } forAll(addressing_, i) { - label facei = addressing_[i]; + const label facei = addressing_[i]; - Map<label>::const_iterator iter = faceToIndex.find(facei); + const auto iter = faceToIndex.cfind(facei); - if (iter != faceToIndex.end()) + if (iter.found()) { - label index = iter(); + const label index = *iter; - if (fSet.flipMap()[index] != flipMap_[i]) + if (zoneSet.flipMap()[index] != flipMap_[i]) { - nConflict++; + ++nConflict; } } else { - // Not found in fSet so add + // Not found in zoneSet so add newAddressing.append(facei); - newFlipMap.append(fSet.flipMap()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } @@ -364,7 +355,7 @@ void Foam::faceZoneSet::sync(const polyMesh& mesh) forAll(addressing_, i) { - label bFacei = addressing_[i]-mesh.nInternalFaces(); + const label bFacei = addressing_[i]-mesh.nInternalFaces(); if (bFacei >= 0) { @@ -394,7 +385,7 @@ void Foam::faceZoneSet::sync(const polyMesh& mesh) forAll(addressing_, i) { - label facei = addressing_[i]; + const label facei = addressing_[i]; if (facei < mesh.nInternalFaces()) { newAddressing.append(facei); diff --git a/src/meshTools/sets/topoSets/faceZoneSet.H b/src/meshTools/sets/topoSets/faceZoneSet.H index 375d0b96938ab378f2f21d53274f4464bf5fb3ea..c8c0014906705df414fc326c3b377aadfa797ae8 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.H +++ b/src/meshTools/sets/topoSets/faceZoneSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,8 +59,6 @@ class faceZoneSet boolList flipMap_; - // Private Member Functions - public: @@ -79,28 +77,27 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional size of labelHashSet + //- Construct with initial size for labelHashSet faceZoneSet ( const polyMesh& mesh, const word& name, - const label, + const label size, writeOption w=NO_WRITE ); - //- Construct from existing set + //- Copy construct from existing set faceZoneSet ( const polyMesh& mesh, const word& name, - const topoSet&, + const topoSet& set, writeOption w=NO_WRITE ); - //- Destructor - virtual ~faceZoneSet(); + virtual ~faceZoneSet() = default; // Member functions @@ -130,8 +127,8 @@ public: //- Sort addressing and make faceSet part consistent with addressing void updateSet(); - //- Invert contents. (insert all members 0..maxLen-1 which were not in - // set) + //- Invert contents. + // Insert all members [0,maxLen) which were not in set. virtual void invert(const label maxLen); //- Subset contents. Only elements present in both sets remain. diff --git a/src/meshTools/sets/topoSets/pointSet.C b/src/meshTools/sets/topoSets/pointSet.C index 01ffabfca27c5ae90722b75825e2f544188a5fcc..ed4347a59d845decc6d7ec780879d102bd0e37da 100644 --- a/src/meshTools/sets/topoSets/pointSet.C +++ b/src/meshTools/sets/topoSets/pointSet.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) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,11 +34,10 @@ License namespace Foam { -defineTypeNameAndDebug(pointSet, 0); - -addToRunTimeSelectionTable(topoSet, pointSet, word); -addToRunTimeSelectionTable(topoSet, pointSet, size); -addToRunTimeSelectionTable(topoSet, pointSet, set); + defineTypeNameAndDebug(pointSet, 0); + addToRunTimeSelectionTable(topoSet, pointSet, word); + addToRunTimeSelectionTable(topoSet, pointSet, size); + addToRunTimeSelectionTable(topoSet, pointSet, set); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -91,11 +90,11 @@ Foam::pointSet::pointSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, labels, w) {} @@ -103,17 +102,23 @@ Foam::pointSet::pointSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, writeOption w ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, std::move(labels), w) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::pointSet::~pointSet() +Foam::pointSet::pointSet +( + const polyMesh& mesh, + const word& name, + const labelUList& labels, + writeOption w +) +: + topoSet(mesh, name, labels, w) {} @@ -125,10 +130,13 @@ void Foam::pointSet::sync(const polyMesh& mesh) boolList contents(mesh.nPoints(), false); - forAllConstIter(pointSet, *this, iter) + const labelHashSet& labels = *this; + + for (const label pointi : labels) { - contents[iter.key()] = true; + contents[pointi] = true; } + syncTools::syncPointList ( mesh, @@ -168,10 +176,14 @@ void Foam::pointSet::updateMesh(const mapPolyMesh& morphMap) void Foam::pointSet::distribute(const mapDistributePolyMesh& map) { boolList inSet(map.nOldPoints()); - forAllConstIter(pointSet, *this, iter) + + const labelHashSet& labels = *this; + + for (const label pointi : labels) { - inSet[iter.key()] = true; + inSet[pointi] = true; } + map.distributePointData(inSet); // Count @@ -180,7 +192,7 @@ void Foam::pointSet::distribute(const mapDistributePolyMesh& map) { if (inSet[pointi]) { - n++; + ++n; } } diff --git a/src/meshTools/sets/topoSets/pointSet.H b/src/meshTools/sets/topoSets/pointSet.H index d9909ed34dc213fe3168ea4e703b1c26c09ac876..89f1009d2908f828fbf6907cc05b3e8d11c8e1be 100644 --- a/src/meshTools/sets/topoSets/pointSet.H +++ b/src/meshTools/sets/topoSets/pointSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,8 +50,6 @@ class pointSet : public topoSet { - - public: //- Runtime type information @@ -72,7 +70,7 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional size of labelHashSet + //- Construct empty with initial size for labelHashSet pointSet ( const polyMesh& mesh, @@ -90,27 +88,36 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional labelHashSet + //- Construct (no-read) with copy of labelHashSet + pointSet + ( + const polyMesh& mesh, + const word& name, + const labelHashSet& labels, + writeOption w=NO_WRITE + ); + + //- Construct (no-read) with moving labelHashSet pointSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + labelHashSet&& labels, writeOption w=NO_WRITE ); - //- Construct from additional list of labels for the labelHashSet + //- Construct (no-read) with copy of labels pointSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + const labelUList& labels, writeOption w=NO_WRITE ); //- Destructor - virtual ~pointSet(); + virtual ~pointSet() = default; // Member functions diff --git a/src/meshTools/sets/topoSets/pointZoneSet.C b/src/meshTools/sets/topoSets/pointZoneSet.C index 91675d815572bf6c7d92fdc061155b0206aee632..06b8eba119f18f2a00a398c1568a56cd20fd7f7d 100644 --- a/src/meshTools/sets/topoSets/pointZoneSet.C +++ b/src/meshTools/sets/topoSets/pointZoneSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,18 +28,16 @@ License #include "polyMesh.H" #include "processorPolyPatch.H" #include "cyclicPolyPatch.H" - #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { -defineTypeNameAndDebug(pointZoneSet, 0); - -addToRunTimeSelectionTable(topoSet, pointZoneSet, word); -addToRunTimeSelectionTable(topoSet, pointZoneSet, size); -addToRunTimeSelectionTable(topoSet, pointZoneSet, set); + defineTypeNameAndDebug(pointZoneSet, 0); + addToRunTimeSelectionTable(topoSet, pointZoneSet, word); + addToRunTimeSelectionTable(topoSet, pointZoneSet, size); + addToRunTimeSelectionTable(topoSet, pointZoneSet, set); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -52,10 +50,7 @@ void Foam::pointZoneSet::updateSet() pointSet::clearStorage(); pointSet::resize(2*addressing_.size()); - forAll(addressing_, i) - { - pointSet::insert(addressing_[i]); - } + pointSet::insert(addressing_); } @@ -69,9 +64,9 @@ Foam::pointZoneSet::pointZoneSet writeOption w ) : - pointSet(mesh, name, 1000), // do not read pointSet + pointSet(mesh, name, 1024), // do not read pointSet mesh_(mesh), - addressing_(0) + addressing_() { const pointZoneMesh& pointZones = mesh.pointZones(); label zoneID = pointZones.findZoneID(name); @@ -103,7 +98,7 @@ Foam::pointZoneSet::pointZoneSet : pointSet(mesh, name, size, w), mesh_(mesh), - addressing_(0) + addressing_() { updateSet(); } @@ -125,12 +120,6 @@ Foam::pointZoneSet::pointZoneSet } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::pointZoneSet::~pointZoneSet() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::pointZoneSet::invert(const label maxLen) @@ -138,11 +127,11 @@ void Foam::pointZoneSet::invert(const label maxLen) // Count label n = 0; - for (label pointi = 0; pointi < maxLen; pointi++) + for (label pointi = 0; pointi < maxLen; ++pointi) { if (!found(pointi)) { - n++; + ++n; } } @@ -150,12 +139,12 @@ void Foam::pointZoneSet::invert(const label maxLen) addressing_.setSize(n); n = 0; - for (label pointi = 0; pointi < maxLen; pointi++) + for (label pointi = 0; pointi < maxLen; ++pointi) { if (!found(pointi)) { addressing_[n] = pointi; - n++; + ++n; } } updateSet(); @@ -166,12 +155,10 @@ void Foam::pointZoneSet::subset(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); - const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + const pointZoneSet& zoneSet = refCast<const pointZoneSet>(set); - forAll(fSet.addressing(), i) + for (const label pointi : zoneSet.addressing()) { - label pointi = fSet.addressing()[i]; - if (found(pointi)) { newAddressing.append(pointi); @@ -187,12 +174,10 @@ void Foam::pointZoneSet::addSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_); - const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + const pointZoneSet& zoneSet = refCast<const pointZoneSet>(set); - forAll(fSet.addressing(), i) + for (const label pointi : zoneSet.addressing()) { - label pointi = fSet.addressing()[i]; - if (!found(pointi)) { newAddressing.append(pointi); @@ -208,15 +193,13 @@ void Foam::pointZoneSet::deleteSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); - const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + const pointZoneSet& zoneSet = refCast<const pointZoneSet>(set); - forAll(addressing_, i) + for (label pointi : addressing_) { - label pointi = addressing_[i]; - - if (!fSet.found(pointi)) + if (!zoneSet.found(pointi)) { - // Not found in fSet so add + // Not found in zoneSet so add newAddressing.append(pointi); } } @@ -300,7 +283,7 @@ void Foam::pointZoneSet::updateMesh(const mapPolyMesh& morphMap) if (newPointi >= 0) { newAddressing[n] = newPointi; - n++; + ++n; } } newAddressing.setSize(n); diff --git a/src/meshTools/sets/topoSets/pointZoneSet.H b/src/meshTools/sets/topoSets/pointZoneSet.H index 47823e2dee565e651b340dde6ba45fc11bdc6572..f32db072d9cff80930a8f6446e0e206ee110bcaa 100644 --- a/src/meshTools/sets/topoSets/pointZoneSet.H +++ b/src/meshTools/sets/topoSets/pointZoneSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,6 @@ SourceFiles #define pointZoneSet_H #include "pointSet.H" -#include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class pointZoneSet Declaration + Class pointZoneSet Declaration \*---------------------------------------------------------------------------*/ class pointZoneSet @@ -58,8 +57,6 @@ class pointZoneSet labelList addressing_; - // Private Member Functions - public: @@ -78,28 +75,27 @@ public: writeOption w=NO_WRITE ); - //- Construct from additional size of labelHashSet + //- Construct empty with initial size for labelHashSet pointZoneSet ( const polyMesh& mesh, const word& name, - const label, + const label size, writeOption w=NO_WRITE ); - //- Construct from existing set + //- Copy construct from existing set pointZoneSet ( const polyMesh& mesh, const word& name, - const topoSet&, + const topoSet& set, writeOption w=NO_WRITE ); - //- Destructor - virtual ~pointZoneSet(); + virtual ~pointZoneSet() = default; // Member functions @@ -117,8 +113,8 @@ public: //- Sort addressing and make pointSet part consistent with addressing void updateSet(); - //- Invert contents. (insert all members 0..maxLen-1 which were not in - // set) + //- Invert contents. + // Insert all members [0,maxLen) which were not in set virtual void invert(const label maxLen); //- Subset contents. Only elements present in both sets remain. diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index 754100d1dc2fdffd1b97a5dcc47a43bfe3b6626c..c69ffa92ebba10322a1170f6339469e1cf3f7cc2 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -212,11 +212,11 @@ void Foam::topoSet::writeDebug { label n = 0; - for (; (iter != end()) && (n < maxElem); ++iter) + for (; (iter != cend()) && (n < maxElem); ++iter) { if (n && ((n % 10) == 0)) { - os << endl; + os << nl; } os << iter.key() << ' '; @@ -238,11 +238,11 @@ void Foam::topoSet::writeDebug { label n = 0; - for (; (iter != end()) && (n < maxElem); ++iter) + for (; (iter != cend()) && (n < maxElem); ++iter) { if (n && ((n % 3) == 0)) { - os << endl; + os << nl; } os << iter.key() << coords[iter.key()] << ' '; @@ -263,11 +263,11 @@ void Foam::topoSet::writeDebug boundBox bb(pointField(coords, toc()), true); os << "Set bounding box: min = " - << bb.min() << " max = " << bb.max() << " metres. " << endl << endl; + << bb.min() << " max = " << bb.max() << " metres." << nl << endl; label n = 0; - topoSet::const_iterator iter = begin(); + topoSet::const_iterator iter = this->cbegin(); if (size() <= maxLen) { @@ -278,7 +278,7 @@ void Foam::topoSet::writeDebug label halfLen = maxLen/2; os << "Size larger than " << maxLen << ". Printing first and last " - << halfLen << " elements:" << endl << endl; + << halfLen << " elements:" << nl << endl; writeDebug(os, coords, halfLen, iter, n); @@ -433,12 +433,12 @@ Foam::topoSet::topoSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + const labelHashSet& labels, writeOption w ) : regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), - labelHashSet(set) + labelHashSet(labels) {} @@ -446,33 +446,46 @@ Foam::topoSet::topoSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + labelHashSet&& labels, writeOption w ) : regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), - labelHashSet(set) + labelHashSet(std::move(labels)) {} -Foam::topoSet::topoSet(const IOobject& obj, const label size) +Foam::topoSet::topoSet +( + const polyMesh& mesh, + const word& name, + const labelUList& labels, + writeOption w +) : - regIOobject(obj), - labelHashSet(size) + regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), + labelHashSet(labels) {} -Foam::topoSet::topoSet(const IOobject& obj, const labelHashSet& set) +Foam::topoSet::topoSet(const IOobject& io, const label size) : - regIOobject(obj), - labelHashSet(set) + regIOobject(io), + labelHashSet(size) {} +Foam::topoSet::topoSet(const IOobject& io, const labelHashSet& labels) +: + regIOobject(io), + labelHashSet(labels) +{} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::topoSet::~topoSet() +Foam::topoSet::topoSet(const IOobject& io, labelHashSet&& labels) +: + regIOobject(io), + labelHashSet(std::move(labels)) {} @@ -480,17 +493,20 @@ Foam::topoSet::~topoSet() void Foam::topoSet::invert(const label maxLen) { - // Keep copy of current set. - labelHashSet currentSet(*this); + // Retain a copy of the original (current) set. + labelHashSet original + ( + std::move(static_cast<labelHashSet&>(*this)) + ); - clear(); - resize(2*(maxLen - currentSet.size())); + clear(); // Maybe don't trust the previous move operation + resize(2*max(64, (maxLen - original.size()))); - for (label celli = 0; celli < maxLen; celli++) + for (label id=0; id < maxLen; ++id) { - if (!currentSet.found(celli)) + if (!original.found(id)) { - insert(celli); + insert(id); } } } @@ -498,40 +514,22 @@ void Foam::topoSet::invert(const label maxLen) void Foam::topoSet::subset(const topoSet& set) { - // Keep copy of current set. - labelHashSet currentSet(*this); - - clear(); - resize(2*min(currentSet.size(), set.size())); - - for (const label currId : currentSet) - { - if (set.found(currId)) - { - // element present in both currentSet and set. - insert(currId); - } - } + // Only retain entries found in both HashSets + static_cast<labelHashSet&>(*this) &= set; } void Foam::topoSet::addSet(const topoSet& set) { - const labelHashSet& labels = set; - for (const label id : labels) - { - insert(id); - } + // Add entries to the HashSet + static_cast<labelHashSet&>(*this) += set; } void Foam::topoSet::deleteSet(const topoSet& set) { - const labelHashSet& labels = set; - for (const label id : labels) - { - erase(id); - } + // Remove entries from the HashSet + static_cast<labelHashSet&>(*this) -= set; } @@ -545,7 +543,7 @@ void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const { label n = 0; - topoSet::const_iterator iter = begin(); + topoSet::const_iterator iter = this->cbegin(); if (size() <= maxLen) { @@ -556,7 +554,7 @@ void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const label halfLen = maxLen/2; os << "Size larger than " << maxLen << ". Printing first and last " - << halfLen << " elements:" << endl << endl; + << halfLen << " elements:" << nl << endl; writeDebug(os, halfLen, iter, n); diff --git a/src/meshTools/sets/topoSets/topoSet.H b/src/meshTools/sets/topoSets/topoSet.H index 55bd7941cf722dabd57fa15a01c1385fbd3ee693..7255caecbba7fa81027586c74780b9c30c56944b 100644 --- a/src/meshTools/sets/topoSets/topoSet.H +++ b/src/meshTools/sets/topoSets/topoSet.H @@ -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) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,6 +51,7 @@ SourceFiles namespace Foam { +// Forward declarations class mapPolyMesh; class polyMesh; class primitiveMesh; @@ -196,13 +197,13 @@ public: // Constructors - //- Construct from IOobject as explicitly passed type. // Can't use typeName info here since subclasses not yet instantiated topoSet(const IOobject& obj, const word& wantedType); - //- Construct from polyMesh and name. Searches for a polyMesh/sets - // directory but not beyond mesh.facesInstance. + //- Construct from polyMesh and name. + // Searches for a polyMesh/sets directory but not beyond the + // mesh.facesInstance(). topoSet ( const polyMesh& mesh, @@ -213,8 +214,8 @@ public: ); //- Construct empty from additional size of labelHashSet. - // Searches for a polyMesh/sets - // directory but not beyond mesh.facesInstance. + // Searches for a polyMesh/sets directory but not beyond the + // mesh.facesInstance(). topoSet ( const polyMesh& mesh, @@ -223,34 +224,47 @@ public: writeOption w=NO_WRITE ); - //- Construct empty from additional labelHashSet - // Searches for a polyMesh/sets - // directory but not beyond mesh.facesInstance. + //- Construct (no-read) with copy of labelHashSet + // Searches for a polyMesh/sets directory but not beyond the + // mesh.facesInstance(). + topoSet + ( + const polyMesh& mesh, + const word& name, + const labelHashSet& labels, + writeOption w=NO_WRITE + ); + + //- Construct (no-read) with moving labelHashSet + // Searches for a polyMesh/sets directory but not beyond the + // mesh.facesInstance(). topoSet ( const polyMesh& mesh, const word& name, - const labelHashSet& set, + labelHashSet&& labels, writeOption w=NO_WRITE ); - //- Construct empty from additional labelHashSet - // Searches for a polyMesh/sets - // directory but not beyond mesh.facesInstance. + //- Construct (no-read) with copy of labels + // Searches for a polyMesh/sets directory but not beyond the + // mesh.facesInstance(). topoSet ( const polyMesh& mesh, const word& name, - const labelUList& set, + const labelUList& labels, writeOption w=NO_WRITE ); - //- Construct empty from IOobject and size. - topoSet(const IOobject&, const label size); + //- Construct empty from IOobject and HashSet size. + topoSet(const IOobject& io, const label size); - //- Construct from IOobject and labelHashSet. - topoSet(const IOobject&, const labelHashSet&); + //- Construct from IOobject and copy of labelHashSet. + topoSet(const IOobject& io, const labelHashSet& labels); + //- Construct from IOobject and move labelHashSet. + topoSet(const IOobject& io, labelHashSet&& labels); //- Clone @@ -295,13 +309,13 @@ public: //- Destructor - virtual ~topoSet(); + virtual ~topoSet() = default; // Member functions - //- Invert contents. (insert all members 0..maxLen-1 which were not in - // set) + //- Invert contents. + // Insert all members [0,maxLen) which were not in set. virtual void invert(const label maxLen); //- Subset contents. Only elements present in both sets remain. @@ -320,7 +334,7 @@ public: virtual void writeDebug(Ostream& os, const label maxLen) const; //- Like above but also writes mesh related quantity - // (usually coordinate). + //- (usually coordinate). virtual void writeDebug ( Ostream& os,