diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index bc800b920aee19d401b79881caa4a5a4d8de8e14..fa48186c90c275c9e013fa709c0ea2831858e110 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -132,9 +132,9 @@ void printHelp(Ostream& os) << " clear - clears the set" << nl << " invert - inverts the set" << nl << " remove - remove the set" << nl - << " new <source> - sets to set to the source set" << nl + << " new <source> - use all elements from the source set" << nl << " add <source> - adds all elements from the source set" << nl - << " delete <source> - deletes ,," << nl + << " subtract <source> - subtract the source set elements" << nl << " subset <source> - combines current set with the source set" << nl << nl diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index f08ea7516908b193a27045bae629c8170b8abac3..a9cd056c58f8817cc2062ee2210cd752834a8011 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -247,8 +247,8 @@ int main(int argc, char *argv[]) autoPtr<topoSet> currentSet; if ( - (action == topoSetSource::NEW) - || (action == topoSetSource::CLEAR) + action == topoSetSource::NEW + || action == topoSetSource::CLEAR ) { currentSet = topoSet::New(setType, mesh, setName, 10000); @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) { case topoSetSource::NEW: case topoSetSource::ADD: - case topoSetSource::DELETE: + case topoSetSource::SUBTRACT: { const word sourceName(dict.get<word>("source")); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 66302acdfa8c224179b14bfd6168742cd13a790c..cc78c310905aee5b334c95391a5d8122591a2fb6 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -63,7 +63,9 @@ FoamFile // source faceZoneToCell; // sourceInfo // { -// name ".*Zone"; // Name of faceZone, regular expressions allowed +// zones (".*Zone"); // Name of faceZone, regular expressions allowed +// // OR zone ".*Zone"; // Name of faceZone, regular expressions allowed +// // OR name ".*Zone"; // Name of faceZone, regular expressions allowed // option master; // master/slave // } // @@ -127,7 +129,7 @@ FoamFile // source sphereToCell; // sourceInfo // { -// centre (0.2 0.2 -10); +// origin (0.2 0.2 -10); // radius 5.0; // } // @@ -392,7 +394,7 @@ FoamFile // sourceInfo // { // surface searchableSphere; -// centre (0.05 0.05 0.005); +// origin (0.05 0.05 0.005); // radius 0.025; // //name sphere.stl; // Optional name if surface triSurfaceMesh // } diff --git a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C index 37bc94df278e2faa01a9a1723af6dac6a6055af5..44001f4dd8e87853e5d403565aa87a1969ca4378 100644 --- a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C +++ b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) ( shapeSelector::shapeTypeNames.get("type", dict) ); - const vector centre(dict.get<vector>("centre")); + const vector origin(dict.getCompat<vector>("origin", {{"centre", 1806}})); const word fieldName(dict.get<word>("field")); Info<< "Reading field " << fieldName << "\n" << endl; @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) mesh ); - scalar f0 = 0.0; + scalar f0 = 0; scalarField f(mesh.points().size()); Info<< "Processing type '" << shapeSelector::shapeTypeNames[surfType] @@ -126,15 +126,15 @@ int main(int argc, char *argv[]) { const vector direction(dict.get<vector>("direction")); - f = -(mesh.points() - centre) & (direction/mag(direction)); - f0 = 0.0; + f = -(mesh.points() - origin) & (direction/mag(direction)); + f0 = 0; break; } case shapeSelector::shapeType::SPHERE: { const scalar radius(dict.get<scalar>("radius")); - f = -mag(mesh.points() - centre); + f = -mag(mesh.points() - origin); f0 = -radius; break; } @@ -145,8 +145,8 @@ int main(int argc, char *argv[]) f = -sqrt ( - sqr(mag(mesh.points() - centre)) - - sqr(mag((mesh.points() - centre) & direction)) + sqr(mag(mesh.points() - origin)) + - sqr(mag((mesh.points() - origin) & direction)) ); f0 = -radius; break; @@ -160,9 +160,9 @@ int main(int argc, char *argv[]) const scalarField xx ( - (mesh.points() - centre) & direction/mag(direction) + (mesh.points() - origin) & direction/mag(direction) ); - const scalarField zz((mesh.points() - centre) & up/mag(up)); + const scalarField zz((mesh.points() - origin) & up/mag(up)); f = amplitude*Foam::sin(2*mathematical::pi*xx/period) - zz; f0 = 0; diff --git a/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.C b/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.C index c31e2606b9bebd8411e5b12731e332873c1edcf3..062322da571169aff69591176e47f63b24c9a9d2 100644 --- a/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.C +++ b/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.C @@ -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. @@ -33,13 +33,25 @@ License namespace Foam { - -defineTypeNameAndDebug(badQualityToCell, 0); - -addToRunTimeSelectionTable(topoSetSource, badQualityToCell, word); - -addToRunTimeSelectionTable(topoSetSource, badQualityToCell, istream); - + defineTypeNameAndDebug(badQualityToCell, 0); + addToRunTimeSelectionTable(topoSetSource, badQualityToCell, word); + addToRunTimeSelectionTable(topoSetSource, badQualityToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + badQualityToCell, + word, + badQuality + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + badQualityToCell, + istream, + badQuality + ); } @@ -59,9 +71,8 @@ void Foam::badQualityToCell::combine(topoSet& set, const bool add) const motionSmoother::checkMesh(false, mesh_, dict_, faces); faces.sync(mesh_); - forAllConstIter(faceSet, faces, iter) + for (const label facei : faces) { - label facei = iter.key(); addOrDelete(set, mesh_.faceOwner()[facei], add); if (mesh_.isInternalFace(facei)) { @@ -73,36 +84,28 @@ void Foam::badQualityToCell::combine(topoSet& set, const bool add) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from dictionary Foam::badQualityToCell::badQualityToCell ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellSource(mesh), dict_(dict) {} -// Construct from Istream Foam::badQualityToCell::badQualityToCell ( const polyMesh& mesh, Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), dict_(is) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::badQualityToCell::~badQualityToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::badQualityToCell::applyToSet @@ -111,14 +114,22 @@ void Foam::badQualityToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding bad-quality cells" << endl; + if (verbose_) + { + Info<< " Adding bad-quality cells" << endl; + } + combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing bad-quality cells" << endl; + if (verbose_) + { + Info<< " Removing bad-quality cells" << endl; + } + combine(set, false); } } diff --git a/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.H b/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.H index 98f6be7a193585ab272e5b16fc8f5f34b4157605..942ace2c4a1bca5c28847dfb6ec73913dd7a81ea 100644 --- a/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.H +++ b/src/dynamicMesh/motionSmoother/badQualityToCell/badQualityToCell.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. @@ -35,7 +35,7 @@ SourceFiles #ifndef badQualityToCell_H #define badQualityToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "bitSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +49,7 @@ namespace Foam class badQualityToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -74,35 +74,22 @@ public: // Constructors //- Construct from dictionary - badQualityToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + badQualityToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - badQualityToCell - ( - const polyMesh& mesh, - Istream& - ); + badQualityToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~badQualityToCell(); + virtual ~badQualityToCell() = default; // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.C b/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.C index dd76d0b0c808d26b2f6ea16c909c6b7496bfa47c..c68d0b7351a060ddbae82d83a0847face00ff07d 100644 --- a/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.C +++ b/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.C @@ -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. @@ -33,13 +33,25 @@ License namespace Foam { - -defineTypeNameAndDebug(badQualityToFace, 0); - -addToRunTimeSelectionTable(topoSetSource, badQualityToFace, word); - -addToRunTimeSelectionTable(topoSetSource, badQualityToFace, istream); - + defineTypeNameAndDebug(badQualityToFace, 0); + addToRunTimeSelectionTable(topoSetSource, badQualityToFace, word); + addToRunTimeSelectionTable(topoSetSource, badQualityToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, badQualityToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, badQualityToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + badQualityToFace, + word, + badQuality + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + badQualityToFace, + istream, + badQuality + ); } @@ -59,9 +71,8 @@ void Foam::badQualityToFace::combine(topoSet& set, const bool add) const motionSmoother::checkMesh(false, mesh_, dict_, faces); faces.sync(mesh_); - forAllConstIter(faceSet, faces, iter) + for (const label facei : faces) { - label facei = iter.key(); addOrDelete(set, facei, add); } } @@ -69,36 +80,28 @@ void Foam::badQualityToFace::combine(topoSet& set, const bool add) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from dictionary Foam::badQualityToFace::badQualityToFace ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), dict_(dict) {} -// Construct from Istream Foam::badQualityToFace::badQualityToFace ( const polyMesh& mesh, Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), dict_(is) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::badQualityToFace::~badQualityToFace() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::badQualityToFace::applyToSet @@ -107,14 +110,22 @@ void Foam::badQualityToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding bad-quality faces" << endl; + if (verbose_) + { + Info<< " Adding bad-quality faces" << endl; + } + combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing bad-quality faces" << endl; + if (verbose_) + { + Info<< " Removing bad-quality faces" << endl; + } + combine(set, false); } } diff --git a/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.H b/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.H index e48fe2e030a586746bde2e3532c49da2d906d8e0..92ce3a058a80d3ad8b7c223950d821c76a3e9059 100644 --- a/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.H +++ b/src/dynamicMesh/motionSmoother/badQualityToFace/badQualityToFace.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. @@ -35,7 +35,7 @@ SourceFiles #ifndef badQualityToFace_H #define badQualityToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" #include "bitSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +49,7 @@ namespace Foam class badQualityToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -89,20 +89,15 @@ public: //- Destructor - virtual ~badQualityToFace(); + virtual ~badQualityToFace() = default; // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, - topoSet& + topoSet& set ) const; }; diff --git a/src/finiteVolume/Make/options b/src/finiteVolume/Make/options index 4ac4139c42af757a6d7bee668e4dee0bdb7f90a6..d4fc619be072d3e8df06e9af9e393082d811215f 100644 --- a/src/finiteVolume/Make/options +++ b/src/finiteVolume/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude diff --git a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C index 87e782dc4b83db850813d1cf0aecd69687116540..138d2d0af094e2a993444867371871209b2a8807 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C @@ -75,7 +75,7 @@ cylindricalInletVelocityFvPatchVectorField ) : fixedValueFvPatchField<vector>(p, iF, dict), - origin_(dict.lookupCompat("origin", {{"centre", 1712}})), + origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})), axis_(dict.lookup("axis")), axialVelocity_(Function1<scalar>::New("axialVelocity", dict)), radialVelocity_(Function1<scalar>::New("radialVelocity", dict)), diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H index e5831682df362d287137f2f88d9332605181bcee..8741de56d1b0f93406db036d1ccdb43f5fcf0069 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H @@ -84,13 +84,11 @@ SourceFiles #ifndef directionalPressureGradientExplicitSource_H #define directionalPressureGradientExplicitSource_H -#include "cellSetOption.H" #include "autoPtr.H" -#include "topoSetSource.H" -#include "cellSet.H" #include "fvMesh.H" #include "volFields.H" #include "fvOption.H" +#include "cellSetOption.H" #include "interpolationTable.H" diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H index fac0740aedb94d056b913fd7db58b0f059502140..051888aa9b922e9616ba89da9c613423b52b4110 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H @@ -51,8 +51,6 @@ SourceFiles #define meanVelocityForce_H #include "autoPtr.H" -#include "topoSetSource.H" -#include "cellSet.H" #include "fvMesh.H" #include "volFields.H" #include "cellSetOption.H" diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 58c3fa156f1b48f89a4d418e8815259784e1858d..d13a5f43e5e3b9a87264822610524ff7437b34b3 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -134,6 +134,7 @@ searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C topoSets = sets/topoSets +$(topoSets)/cellBitSet.C $(topoSets)/cellSet.C $(topoSets)/topoSet.C $(topoSets)/faceSet.C @@ -144,49 +145,56 @@ $(topoSets)/pointZoneSet.C sets/topoSetSource/topoSetSource.C -cellSources = sets/cellSources +cellSources = sets/cellSources +$(cellSources)/topoSetCellSource/topoSetCellSource.C +$(cellSources)/boxToCell/boxToCell.C +$(cellSources)/cellToCell/cellToCell.C +$(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C +$(cellSources)/cylinderToCell/cylinderToCell.C $(cellSources)/faceToCell/faceToCell.C +$(cellSources)/faceZoneToCell/faceZoneToCell.C $(cellSources)/fieldToCell/fieldToCell.C +$(cellSources)/labelToCell/labelToCell.C +$(cellSources)/nbrToCell/nbrToCell.C +$(cellSources)/nearestToCell/nearestToCell.C +$(cellSources)/noneToCell/noneToCell.C $(cellSources)/pointToCell/pointToCell.C -$(cellSources)/shapeToCell/shapeToCell.C -$(cellSources)/boxToCell/boxToCell.C $(cellSources)/regionToCell/regionToCell.C $(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C -$(cellSources)/labelToCell/labelToCell.C -$(cellSources)/surfaceToCell/surfaceToCell.C -$(cellSources)/cellToCell/cellToCell.C -$(cellSources)/nearestToCell/nearestToCell.C -$(cellSources)/nbrToCell/nbrToCell.C -$(cellSources)/zoneToCell/zoneToCell.C +$(cellSources)/shapeToCell/shapeToCell.C +$(cellSources)/searchableSurfaceToCell/searchableSurfaceToCell.C $(cellSources)/sphereToCell/sphereToCell.C -$(cellSources)/cylinderToCell/cylinderToCell.C -$(cellSources)/faceZoneToCell/faceZoneToCell.C -$(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C +$(cellSources)/surfaceToCell/surfaceToCell.C $(cellSources)/targetVolumeToCell/targetVolumeToCell.C +$(cellSources)/zoneToCell/zoneToCell.C faceSources = sets/faceSources +$(faceSources)/topoSetFaceSource/topoSetFaceSource.C +$(faceSources)/boundaryToFace/boundaryToFace.C +$(faceSources)/boxToFace/boxToFace.C +$(faceSources)/cellToFace/cellToFace.C +$(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C +$(faceSources)/cylinderToFace/cylinderToFace.C $(faceSources)/faceToFace/faceToFace.C $(faceSources)/labelToFace/labelToFace.C -$(faceSources)/cellToFace/cellToFace.C +$(faceSources)/noneToFace/noneToFace.C $(faceSources)/normalToFace/normalToFace.C -$(faceSources)/pointToFace/pointToFace.C $(faceSources)/patchToFace/patchToFace.C -$(faceSources)/boundaryToFace/boundaryToFace.C -$(faceSources)/zoneToFace/zoneToFace.C -$(faceSources)/boxToFace/boxToFace.C +$(faceSources)/pointToFace/pointToFace.C $(faceSources)/regionToFace/regionToFace.C -$(faceSources)/cylinderToFace/cylinderToFace.C -$(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C +$(faceSources)/zoneToFace/zoneToFace.C pointSources = sets/pointSources -$(pointSources)/labelToPoint/labelToPoint.C -$(pointSources)/pointToPoint/pointToPoint.C +$(pointSources)/topoSetPointSource/topoSetPointSource.C +$(pointSources)/boxToPoint/boxToPoint.C $(pointSources)/cellToPoint/cellToPoint.C $(pointSources)/faceToPoint/faceToPoint.C -$(pointSources)/boxToPoint/boxToPoint.C +$(pointSources)/labelToPoint/labelToPoint.C +$(pointSources)/nearestToPoint/nearestToPoint.C +$(pointSources)/noneToPoint/noneToPoint.C +$(pointSources)/pointToPoint/pointToPoint.C $(pointSources)/surfaceToPoint/surfaceToPoint.C $(pointSources)/zoneToPoint/zoneToPoint.C -$(pointSources)/nearestToPoint/nearestToPoint.C faceZoneSources = sets/faceZoneSources $(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C index 5691a89e31f75fa714003737e96798cdc88632ef..67509335f6073bc8a6ad399ac1cc5622467c9eab 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C @@ -57,18 +57,18 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest { pointIndexHit info(false, sample, -1); - const vector n(sample - centre_); + const vector n(sample - origin_); scalar magN = mag(n); if (nearestDistSqr >= sqr(magN - radius_)) { if (magN < ROOTVSMALL) { - info.rawPoint() = centre_ + vector(1,0,0)*radius_; + info.rawPoint() = origin_ + vector(1,0,0)*radius_; } else { - info.rawPoint() = centre_ + n/magN*radius_; + info.rawPoint() = origin_ + n/magN*radius_; } info.setHit(); info.setIndex(0); @@ -95,7 +95,7 @@ void Foam::searchableSphere::findLineAll if (magSqrDir > ROOTVSMALL) { - const vector toCentre(centre_-start); + const vector toCentre(origin_ - start); scalar magSqrToCentre = magSqr(toCentre); dir /= Foam::sqrt(magSqrDir); @@ -135,18 +135,18 @@ void Foam::searchableSphere::findLineAll Foam::searchableSphere::searchableSphere ( const IOobject& io, - const point& centre, + const point& origin, const scalar radius ) : searchableSurface(io), - centre_(centre), + origin_(origin), radius_(radius) { bounds() = boundBox ( - centre_ - radius_*vector::one, - centre_ + radius_*vector::one + origin_ - radius_*vector::one, + origin_ + radius_*vector::one ); } @@ -157,23 +157,20 @@ Foam::searchableSphere::searchableSphere const dictionary& dict ) : - searchableSurface(io), - centre_(dict.get<point>("centre")), - radius_(dict.get<scalar>("radius")) -{ - bounds() = boundBox + searchableSphere ( - centre_ - radius_*vector::one, - centre_ + radius_*vector::one - ); -} + io, + dict.getCompat<vector>("origin", {{"centre", -1806}}), + dict.get<scalar>("radius") + ) +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::searchableSphere::overlaps(const boundBox& bb) const { - return bb.overlaps(centre_, sqr(radius_)); + return bb.overlaps(origin_, sqr(radius_)); } @@ -181,8 +178,8 @@ const Foam::wordList& Foam::searchableSphere::regions() const { if (regions_.empty()) { - regions_.setSize(1); - regions_[0] = "region0"; + regions_.resize(1); + regions_.first() = "region0"; } return regions_; } @@ -195,10 +192,10 @@ void Foam::searchableSphere::boundingSpheres scalarField& radiusSqr ) const { - centres.setSize(1); - centres[0] = centre_; + centres.resize(1); + centres[0] = origin_; - radiusSqr.setSize(1); + radiusSqr.resize(1); radiusSqr[0] = Foam::sqr(radius_); // Add a bit to make sure all points are tested inside @@ -336,7 +333,7 @@ void Foam::searchableSphere::getNormal { if (info[i].hit()) { - normal[i] = normalised(info[i].hitPoint() - centre_); + normal[i] = normalised(info[i].hitPoint() - origin_); } else { @@ -362,7 +359,7 @@ void Foam::searchableSphere::getVolumeType volType[pointi] = ( - (magSqr(pt - centre_) <= rad2) + (magSqr(pt - origin_) <= rad2) ? volumeType::INSIDE : volumeType::OUTSIDE ); } diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H index 69ee3ce22a26b1d37f1a84dc01f509b4a9ce3126..6978a90c1c16bb4d2127b5cc4d8124a44fc248c1 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H @@ -29,10 +29,11 @@ Description \heading Dictionary parameters \table - Property | Description | Required | Default - type | sphere / searchableSphere | selector | - centre | The sphere centre | yes | - radius | The (outside) radius of sphere | yes | + Property | Description | Required | Default + type | sphere / searchableSphere | selector | + origin | The origin (centre) of the sphere | yes | + radius | The (outside) radius of sphere | yes | + centre | Alternative for 'origin' | no | \endtable SourceFiles @@ -64,7 +65,7 @@ private: // Private Member Data //- Centre point of the sphere - const point centre_; + const point origin_; //- The outer radius of the sphere const scalar radius_; @@ -151,7 +152,7 @@ public: // Usually the element centres (should be of length size()). virtual tmp<pointField> coordinates() const { - return tmp<pointField>::New(1, centre_); + return tmp<pointField>::New(1, origin_); } //- Get bounding spheres (centre and radius squared), one per element. diff --git a/src/meshTools/sets/cellSources/boxToCell/boxToCell.C b/src/meshTools/sets/cellSources/boxToCell/boxToCell.C index 7714d038daa27ec43bf7e98a4df7efe425da0a47..9cb921f3dd872630aa789b998e7b87ef5f43177a 100644 --- a/src/meshTools/sets/cellSources/boxToCell/boxToCell.C +++ b/src/meshTools/sets/cellSources/boxToCell/boxToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(boxToCell, 0); addToRunTimeSelectionTable(topoSetSource, boxToCell, word); addToRunTimeSelectionTable(topoSetSource, boxToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, boxToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, boxToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + boxToCell, + word, + box + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + boxToCell, + istream, + box + ); } @@ -73,29 +89,37 @@ Foam::boxToCell::boxToCell const treeBoundBoxList& bbs ) : - topoSetSource(mesh), + topoSetCellSource(mesh), bbs_(bbs) {} +Foam::boxToCell::boxToCell +( + const polyMesh& mesh, + treeBoundBoxList&& bbs +) +: + topoSetCellSource(mesh), + bbs_(std::move(bbs)) +{} + + Foam::boxToCell::boxToCell ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellSource(mesh), bbs_() { - if (dict.found("box")) + // Look for 'boxes' or 'box' + if (!dict.readIfPresent("boxes", bbs_)) { bbs_.resize(1); dict.readEntry("box", bbs_.first()); } - else - { - dict.readEntry("boxes", bbs_); - } } @@ -105,8 +129,8 @@ Foam::boxToCell::boxToCell Istream& is ) : - topoSetSource(mesh), - bbs_(1, treeBoundBox(checkIs(is))) + topoSetCellSource(mesh), + bbs_(one(), treeBoundBox(checkIs(is))) {} @@ -118,15 +142,23 @@ void Foam::boxToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with center within boxes " << bbs_ << endl; + if (verbose_) + { + Info<< " Adding cells with centre within boxes " + << bbs_ << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with center within boxes " << bbs_ << endl; + if (verbose_) + { + Info<< " Removing cells with centre within boxes " + << bbs_ << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H index 7360bd0e90a093fd81286819ec0e33d13b565721..09a7920f110394e376b5c89fad4c2875c7a5018e 100644 --- a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H +++ b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H @@ -25,17 +25,18 @@ Class Foam::boxToCell Description - A topoSetSource to select cells based on cell centres inside box(es). + A topoSetCellSource 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 | + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | \endtable Note - Must specify either "box" or "boxes" + Must specify either "box" or "boxes". + The selection of multiple boxes has precedence. SourceFiles boxToCell.C @@ -45,7 +46,7 @@ SourceFiles #ifndef boxToCell_H #define boxToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "treeBoundBoxList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,7 +60,7 @@ namespace Foam class boxToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -82,12 +83,11 @@ public: // Constructors - //- Construct from components - boxToCell - ( - const polyMesh& mesh, - const treeBoundBoxList& bbs - ); + //- Construct from components, copying bounding boxes + boxToCell(const polyMesh& mesh, const treeBoundBoxList& bbs); + + //- Construct from components, moving bounding boxes + boxToCell(const polyMesh& mesh, treeBoundBoxList&& bbs); //- Construct from dictionary boxToCell(const polyMesh& mesh, const dictionary& dict); @@ -102,11 +102,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C index 6761dab811bfcab957fd545fb60e7ab5ceee9c96..f061205c8a35a5954330c976f90433c2b5fd62d2 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(cellToCell, 0); addToRunTimeSelectionTable(topoSetSource, cellToCell, word); addToRunTimeSelectionTable(topoSetSource, cellToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, cellToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, cellToCell, istream); } @@ -54,7 +56,7 @@ Foam::cellToCell::cellToCell const word& setName ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(setName) {} @@ -65,8 +67,11 @@ Foam::cellToCell::cellToCell const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")) + cellToCell + ( + mesh, + dict.get<word>("set") + ) {} @@ -76,7 +81,7 @@ Foam::cellToCell::cellToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(checkIs(is)) {} @@ -89,25 +94,31 @@ void Foam::cellToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all elements of cellSet " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all elements of cellSet " << setName_ + << " ..." << endl; + } // Load the set cellSet loadedSet(mesh_, setName_); set.addSet(loadedSet); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all elements of cellSet " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all elements of cellSet " << setName_ + << " ..." << endl; + } // Load the set cellSet loadedSet(mesh_, setName_); - set.deleteSet(loadedSet); + set.subtractSet(loadedSet); } } diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H index 23fb8be3d83c68a6b0c8ccd964d378229b12dc4d..2b619f12f0d4fd2aaaca14249e9d09fc1bbd6a89 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H @@ -25,7 +25,7 @@ Class Foam::cellToCell Description - A topoSetSource to select the cells from another cellSet. + A topoSetCellSource to select the cells from another cellSet. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef cellToCell_H #define cellToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class cellToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -72,11 +72,7 @@ public: // Constructors //- Construct from components - cellToCell - ( - const polyMesh& mesh, - const word& setName - ); + cellToCell(const polyMesh& mesh, const word& setName); //- Construct from dictionary cellToCell(const polyMesh& mesh, const dictionary& dict); @@ -91,11 +87,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C index 6a88cfb80ea5f11e0292a726060d7ca7871bd899..6421182264f048fe57cf39ff7b8c1a872aa10726 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C @@ -34,6 +34,32 @@ namespace Foam defineTypeNameAndDebug(cylinderAnnulusToCell, 0); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, word); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, istream); + addToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderAnnulusToCell, + word + ); + addToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderAnnulusToCell, + istream + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderAnnulusToCell, + word, + cylinderAnnulus + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderAnnulusToCell, + istream, + cylinderAnnulus + ); } @@ -85,7 +111,7 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell const scalar innerRadius ) : - topoSetSource(mesh), + topoSetCellSource(mesh), point1_(point1), point2_(point2), outerRadius_(outerRadius), @@ -99,11 +125,14 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell const dictionary& dict ) : - topoSetSource(mesh), - point1_(dict.get<point>("p1")), - point2_(dict.get<point>("p2")), - outerRadius_(dict.get<scalar>("outerRadius")), - innerRadius_(dict.get<scalar>("innerRadius")) + cylinderAnnulusToCell + ( + mesh, + dict.get<point>("p1"), + dict.get<point>("p2"), + dict.get<scalar>("outerRadius"), + dict.get<scalar>("innerRadius") + ) {} @@ -113,7 +142,7 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), point1_(checkIs(is)), point2_(checkIs(is)), outerRadius_(readScalar(checkIs(is))), @@ -129,23 +158,29 @@ void Foam::cylinderAnnulusToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with centre within cylinder annulus," - << " with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ - << ", inner radius = " << innerRadius_ - << endl; + if (verbose_) + { + Info<< " Adding cells with centre within cylinder annulus," + << " with p1 = " << point1_ << ", p2 = " << point2_ + << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with centre within cylinder annulus," - << " with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ - << ", inner radius = " << innerRadius_ - << endl; + if (verbose_) + { + Info<< " Removing cells with centre within cylinder annulus," + << " with p1 = " << point1_ << ", p2 = " << point2_ + << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H index af8bd0bad239717cdbae0ea5f35d1d247bf56e07..9c02f64dfd615b9f25fe41be6000eaf8ebcd218d 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H @@ -25,7 +25,7 @@ Class Foam::cylinderAnnulusToCell Description - A topoSetSource to select cells based on cell centres inside a + A topoSetCellSource to select cells based on cell centres inside a cylinder annulus. \heading Dictionary parameters @@ -45,7 +45,7 @@ SourceFiles #ifndef cylinderAnnulusToCell_H #define cylinderAnnulusToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,7 +58,7 @@ namespace Foam class cylinderAnnulusToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -99,7 +99,7 @@ public: const point& point1, const point& point2, const scalar outerRadius, - const scalar innerRadius + const scalar innerRadius = 0 ); //- Construct from dictionary @@ -115,11 +115,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C index a8ceeb408b61c62ddc32e38b5024df3a197ebafe..9eda86e0f433fd26cc2f1bceb230808bae1214e2 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(cylinderToCell, 0); addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word); addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, cylinderToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, cylinderToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderToCell, + word, + cylinder + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + cylinderToCell, + istream, + cylinder + ); } @@ -82,7 +98,7 @@ Foam::cylinderToCell::cylinderToCell const scalar radius ) : - topoSetSource(mesh), + topoSetCellSource(mesh), point1_(point1), point2_(point2), radius_(radius) @@ -95,10 +111,13 @@ Foam::cylinderToCell::cylinderToCell const dictionary& dict ) : - topoSetSource(mesh), - point1_(dict.get<point>("p1")), - point2_(dict.get<point>("p2")), - radius_(dict.get<scalar>("radius")) + cylinderToCell + ( + mesh, + dict.get<point>("p1"), + dict.get<point>("p2"), + dict.get<scalar>("radius") + ) {} @@ -108,7 +127,7 @@ Foam::cylinderToCell::cylinderToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), point1_(checkIs(is)), point2_(checkIs(is)), radius_(readScalar(checkIs(is))) @@ -123,19 +142,25 @@ void Foam::cylinderToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with centre within cylinder, with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ - << endl; + if (verbose_) + { + Info<< " Adding cells with centre within cylinder, with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with centre within cylinder, with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ - << endl; + if (verbose_) + { + Info<< " Removing cells with centre within cylinder, with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H index 0d3db7640a66de5304693bfe69b3e731dee14375..f87bd7dbdce278932a71dee373055a1e21abf25b 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H @@ -25,7 +25,7 @@ Class Foam::cylinderToCell Description - A topoSetSource to select cells based on cell centres inside a cylinder. + A topoSetCellSource to select cells with their centres inside a cylinder. \heading Dictionary parameters \table @@ -43,7 +43,7 @@ SourceFiles #ifndef cylinderToCell_H #define cylinderToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class cylinderToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -109,11 +109,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C index 5499aaa9636a960773cd5d42373972e1cc130f9c..508b187dc8908b028e05764293d2d087639c7bca 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(faceToCell, 0); addToRunTimeSelectionTable(topoSetSource, faceToCell, word); addToRunTimeSelectionTable(topoSetSource, faceToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, faceToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, faceToCell, istream); } @@ -133,7 +135,7 @@ Foam::faceToCell::faceToCell const faceAction option ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(setName), option_(option) {} @@ -145,9 +147,12 @@ Foam::faceToCell::faceToCell const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(faceActionNames_.get("option", dict)) + faceToCell + ( + mesh, + dict.get<word>("set"), + faceActionNames_.get("option", dict) + ) {} @@ -157,7 +162,7 @@ Foam::faceToCell::faceToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(checkIs(is)), option_(faceActionNames_.read(checkIs(is))) {} @@ -171,17 +176,23 @@ void Foam::faceToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells according to faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding cells according to faceSet " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells according to faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing cells according to faceSet " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H index ced05a8f4ea52fde72e50eaab24db0c460830e21..64e85b381764113ba822ffc6523cb370c57202a3 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H @@ -25,7 +25,7 @@ Class Foam::faceToCell Description - A topoSetSource to select cells based on usage in a face set. + A topoSetCellSource to select cells based on usage in a face set. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef faceToCell_H #define faceToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class faceToCell : - public topoSetSource + public topoSetCellSource { public: //- Enumeration defining the valid options @@ -118,11 +118,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C index 8b10efb06a815e0d13a808d3ba637d2d058cbf86..c4d453e308d4a83c37ebb32858c61732b9d6a6ca 100644 --- a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C @@ -34,6 +34,8 @@ namespace Foam defineTypeNameAndDebug(faceZoneToCell, 0); addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word); addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, faceZoneToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, faceZoneToCell, istream); } @@ -65,7 +67,7 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const for (const faceZone& zone : mesh_.faceZones()) { - if (zoneName_.match(zone.name())) + if (selectedZones_.match(zone.name())) { hasMatched = true; @@ -76,9 +78,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const : zone.slaveCells() ); - Info<< " Found matching zone " << zone.name() - << " with " << cellLabels.size() << " cells on selected side." - << endl; + if (verbose_) + { + Info<< " Found matching zone " << zone.name() + << " with " << cellLabels.size() << " cells on " + << faceActionNames_[option_] << " side" << endl; + } for (const label celli : cellLabels) { @@ -94,7 +99,8 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any faceZone named " << zoneName_ << nl + << "Cannot find any faceZone matching " + << flatOutput(selectedZones_) << nl << "Valid names: " << flatOutput(mesh_.faceZones().names()) << endl; } @@ -106,12 +112,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const Foam::faceZoneToCell::faceZoneToCell ( const polyMesh& mesh, - const word& zoneName, + const wordRe& zoneName, const faceAction option ) : - topoSetSource(mesh), - zoneName_(zoneName), + topoSetCellSource(mesh), + selectedZones_(one(), zoneName), option_(option) {} @@ -122,10 +128,18 @@ Foam::faceZoneToCell::faceZoneToCell const dictionary& dict ) : - topoSetSource(mesh), - zoneName_(dict.get<wordRe>("name")), + topoSetCellSource(mesh), + selectedZones_(), option_(faceActionNames_.get("option", dict)) -{} +{ + // Look for 'zones' and 'zone', but accept 'name' as well + if (!dict.readIfPresent("zones", selectedZones_)) + { + selectedZones_.resize(1); + selectedZones_.first() = + dict.getCompat<wordRe>("zone", {{"name", 1806}}); + } +} Foam::faceZoneToCell::faceZoneToCell @@ -134,8 +148,8 @@ Foam::faceZoneToCell::faceZoneToCell Istream& is ) : - topoSetSource(mesh), - zoneName_(checkIs(is)), + topoSetCellSource(mesh), + selectedZones_(one(), wordRe(checkIs(is))), option_(faceActionNames_.read(checkIs(is))) {} @@ -148,17 +162,25 @@ void Foam::faceZoneToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all " << faceActionNames_[option_] - << " cells of faceZone " << zoneName_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all " << faceActionNames_[option_] + << " cells of face zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all " << faceActionNames_[option_] - << " cells of faceZone " << zoneName_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all " << faceActionNames_[option_] + << " cells of face zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H index 3096d7ddf75fc0f1c16e3761709465e1855d0848..e0821982718371e5d5f7c548b37dc47d0c8a5806 100644 --- a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H @@ -25,15 +25,20 @@ Class Foam::faceZoneToCell Description - A topoSetSource to select cells based on side of faceZone. + A topoSetCellSource 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 | + Property | Description | Required | Default + option | Selection type (master / slave) | yes | + zone | The face zone name or regex | possibly | + zones | The face zone names or regexs | possibly | + name | Older specification for 'zone' | no | \endtable +Note + Selection of multiple zones has precedence. + SourceFiles faceZoneToCell.C @@ -42,8 +47,8 @@ SourceFiles #ifndef faceZoneToCell_H #define faceZoneToCell_H -#include "topoSetSource.H" -#include "wordRe.H" +#include "topoSetCellSource.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +61,7 @@ namespace Foam class faceZoneToCell : - public topoSetSource + public topoSetCellSource { public: //- Enumeration defining the valid options @@ -75,8 +80,8 @@ private: //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of faceZone - wordRe zoneName_; + //- Matcher for face zones + wordRes selectedZones_; //- Option faceAction option_; @@ -98,7 +103,7 @@ public: faceZoneToCell ( const polyMesh& mesh, - const word& zoneName, + const wordRe& zoneName, const faceAction option ); @@ -115,11 +120,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C index 150eeb2ab978e5feb5bc29cfc38135fdec7fe589..2ec9e8045dc7e67b4e5d77ca7e1f487e83dfc87c 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C @@ -38,6 +38,22 @@ namespace Foam defineTypeNameAndDebug(fieldToCell, 0); addToRunTimeSelectionTable(topoSetSource, fieldToCell, word); addToRunTimeSelectionTable(topoSetSource, fieldToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, fieldToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, fieldToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + fieldToCell, + word, + field + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + fieldToCell, + istream, + field + ); } @@ -58,32 +74,40 @@ void Foam::fieldToCell::applyToSet topoSet& set ) const { - Info<< " Field min:" << min(field) - << " max:" << max(field) << endl; + if (verbose_) + { + Info << " Field min:" << min(field) << " max:" << max(field) << nl; + } - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells with value of field " << fieldName_ - << " within range " << min_ << ".." << max_ << endl; + if (verbose_) + { + Info<< " Adding all cells with value of field " << fieldName_ + << " within range " << min_ << ".." << max_ << endl; + } forAll(field, celli) { if (field[celli] >= min_ && field[celli] <= max_) { - set.insert(celli); + set.set(celli); } } } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells with value of field " << fieldName_ - << " within range " << min_ << ".." << max_ << endl; + if (verbose_) + { + Info<< " Removing all cells with value of field " << fieldName_ + << " within range " << min_ << ".." << max_ << endl; + } forAll(field, celli) { if (field[celli] >= min_ && field[celli] <= max_) { - set.erase(celli); + set.unset(celli); } } } @@ -100,7 +124,7 @@ Foam::fieldToCell::fieldToCell const scalar max ) : - topoSetSource(mesh), + topoSetCellSource(mesh), fieldName_(fieldName), min_(min), max_(max) @@ -113,10 +137,13 @@ Foam::fieldToCell::fieldToCell const dictionary& dict ) : - topoSetSource(mesh), - fieldName_(dict.get<word>("field")), - min_(dict.get<scalar>("min")), - max_(dict.get<scalar>("max")) + fieldToCell + ( + mesh, + dict.get<word>("field"), + dict.get<scalar>("min"), + dict.get<scalar>("max") + ) {} @@ -126,7 +153,7 @@ Foam::fieldToCell::fieldToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), fieldName_(checkIs(is)), min_(readScalar(checkIs(is))), max_(readScalar(checkIs(is))) diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H index c09e2773c815b5a7e02e7c85161c09e7dd8dfe58..6b596f166e3fbffeb6956db07418abdb0c1339f4 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldToCell.H @@ -25,7 +25,7 @@ Class Foam::fieldToCell Description - A topoSetSource to select cells based on field values. + A topoSetCellSource to select cells based on field values. \heading Dictionary parameters \table @@ -43,7 +43,7 @@ SourceFiles #ifndef fieldToCell_H #define fieldToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "scalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +57,7 @@ namespace Foam class fieldToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -115,11 +115,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/labelToCell/labelToCell.C b/src/meshTools/sets/cellSources/labelToCell/labelToCell.C index 13fda7b6d91ff993e137f4e1e787b943fd85e29c..43f2281067fc5959234b0a8db8df3c0e0b23fa44 100644 --- a/src/meshTools/sets/cellSources/labelToCell/labelToCell.C +++ b/src/meshTools/sets/cellSources/labelToCell/labelToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(labelToCell, 0); addToRunTimeSelectionTable(topoSetSource, labelToCell, word); addToRunTimeSelectionTable(topoSetSource, labelToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, labelToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, labelToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + labelToCell, + word, + label + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + labelToCell, + istream, + label + ); } @@ -53,19 +69,29 @@ Foam::labelToCell::labelToCell const labelList& labels ) : - topoSetSource(mesh), + topoSetCellSource(mesh), labels_(labels) {} +Foam::labelToCell::labelToCell +( + const polyMesh& mesh, + labelList&& labels +) +: + topoSetCellSource(mesh), + labels_(std::move(labels)) +{} + + Foam::labelToCell::labelToCell ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), - labels_(dict.get<labelList>("value")) + labelToCell(mesh, dict.get<labelList>("value")) {} @@ -75,7 +101,7 @@ Foam::labelToCell::labelToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), labels_(checkIs(is)) { check(labels_, mesh.nCells()); @@ -90,15 +116,23 @@ void Foam::labelToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells mentioned in dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Adding cells mentioned in dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells mentioned in dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Removing cells mentioned in dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, false); } diff --git a/src/meshTools/sets/cellSources/labelToCell/labelToCell.H b/src/meshTools/sets/cellSources/labelToCell/labelToCell.H index ca9c12e1ff37552c1bc48d7fe667add09a54e728..d9f1c06b3c390854289272f055398f9420a1d3e9 100644 --- a/src/meshTools/sets/cellSources/labelToCell/labelToCell.H +++ b/src/meshTools/sets/cellSources/labelToCell/labelToCell.H @@ -25,7 +25,7 @@ Class Foam::labelToCell Description - A topoSetSource to select cells based on explicitly given labels. + A topoSetCellSource to select cells based on explicitly given labels. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef labelToCell_H #define labelToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class labelToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -73,12 +73,11 @@ public: // Constructors - //- Construct from components - labelToCell - ( - const polyMesh& mesh, - const labelList& labels - ); + //- Construct from components, copying labels + labelToCell(const polyMesh& mesh, const labelList& labels); + + //- Construct from components, moving labels + labelToCell(const polyMesh& mesh, labelList&& labels); //- Construct from dictionary labelToCell(const polyMesh& mesh, const dictionary& dict); @@ -93,11 +92,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C index e4c55b966b785aa6dd84eb01f7d725daa2eda8ce..eee88d9a4f193e63710735a0391f5c049d2421de 100644 --- a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C +++ b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(nbrToCell, 0); addToRunTimeSelectionTable(topoSetSource, nbrToCell, word); addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, nbrToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, nbrToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + nbrToCell, + word, + nbr + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + nbrToCell, + istream, + nbr + ); } @@ -101,7 +117,7 @@ Foam::nbrToCell::nbrToCell const label minNbrs ) : - topoSetSource(mesh), + topoSetCellSource(mesh), minNbrs_(minNbrs) {} @@ -112,8 +128,7 @@ Foam::nbrToCell::nbrToCell const dictionary& dict ) : - topoSetSource(mesh), - minNbrs_(dict.get<label>("neighbours")) + nbrToCell(mesh, dict.get<label>("neighbours")) {} @@ -123,7 +138,7 @@ Foam::nbrToCell::nbrToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), minNbrs_(readLabel(checkIs(is))) {} @@ -136,17 +151,23 @@ void Foam::nbrToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with only " << minNbrs_ << " or less" - " neighbouring cells" << " ..." << endl; + if (verbose_) + { + Info<< " Adding cells with only " << minNbrs_ + << " or fewer neighbouring cells" << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with only " << minNbrs_ << " or less" - " neighbouring cells" << " ..." << endl; + if (verbose_) + { + Info<< " Removing cells with only " << minNbrs_ + << " or fewer neighbouring cells" << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H index 7bd4801bd0c5370d4f32da1ac86a5a0300cf3739..43f434cc8060b28c08750c8420d897c1a8193bc6 100644 --- a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H +++ b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.H @@ -25,7 +25,7 @@ Class Foam::nbrToCell Description - A topoSetSource to select cells based on number of neighbouring cells + A topoSetCellSource to select cells based on number of neighbouring cells (i.e. number of internal or coupled faces) \heading Dictionary parameters @@ -42,7 +42,7 @@ SourceFiles #ifndef nbrToCell_H #define nbrToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,7 +55,7 @@ namespace Foam class nbrToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -81,11 +81,7 @@ public: // Constructors //- Construct from components - nbrToCell - ( - const polyMesh& mesh, - const label minNbrs - ); + nbrToCell(const polyMesh& mesh, const label minNbrs); //- Construct from dictionary nbrToCell(const polyMesh& mesh, const dictionary& dict); @@ -100,11 +96,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C index 03779fd61d923d56b2e32fb7b08e102729cb877f..9f18e91cc4a87ce4d25b7404cb04c814ba1a9317 100644 --- a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C +++ b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.C @@ -35,6 +35,22 @@ namespace Foam defineTypeNameAndDebug(nearestToCell, 0); addToRunTimeSelectionTable(topoSetSource, nearestToCell, word); addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, nearestToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, nearestToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + nearestToCell, + word, + nearest + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + nearestToCell, + istream, + nearest + ); } @@ -87,19 +103,33 @@ Foam::nearestToCell::nearestToCell const pointField& points ) : - topoSetSource(mesh), + topoSetCellSource(mesh), points_(points) {} +Foam::nearestToCell::nearestToCell +( + const polyMesh& mesh, + pointField&& points +) +: + topoSetCellSource(mesh), + points_(std::move(points)) +{} + + Foam::nearestToCell::nearestToCell ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), - points_(dict.get<pointField>("points")) + nearestToCell + ( + mesh, + dict.get<pointField>("points") + ) {} @@ -109,7 +139,7 @@ Foam::nearestToCell::nearestToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), points_(checkIs(is)) {} @@ -122,15 +152,21 @@ void Foam::nearestToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells nearest to " << points_ << endl; + if (verbose_) + { + Info<< " Adding cells nearest to " << points_ << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells nearest to " << points_ << endl; + if (verbose_) + { + Info<< " Removing cells nearest to " << points_ << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H index e2b393f5e1ad80f3fd9726997fbaaf88917a69ed..f95f0118ed999d1288279b819e3e3774efb5efbc 100644 --- a/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H +++ b/src/meshTools/sets/cellSources/nearestToCell/nearestToCell.H @@ -25,7 +25,7 @@ Class Foam::nearestToCell Description - A topoSetSource to select cells nearest to points. + A topoSetCellSource to select cells nearest to points. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef nearestToCell_H #define nearestToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class nearestToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -78,12 +78,11 @@ public: // Constructors - //- Construct from components - nearestToCell - ( - const polyMesh& mesh, - const pointField& points - ); + //- Construct from components, copying points + nearestToCell(const polyMesh& mesh, const pointField& points); + + //- Construct from components, moving points + nearestToCell(const polyMesh& mesh, pointField&& points); //- Construct from dictionary nearestToCell(const polyMesh& mesh, const dictionary& dict); @@ -98,11 +97,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C index 90e99bc1120befcfa6dd41aba087c8cddaa38152..8aa5b11704cc3aac9a1624a2c046b8fb7b4f448c 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(pointToCell, 0); addToRunTimeSelectionTable(topoSetSource, pointToCell, word); addToRunTimeSelectionTable(topoSetSource, pointToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, pointToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, pointToCell, istream); } @@ -116,7 +118,7 @@ Foam::pointToCell::pointToCell const pointAction option ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(setName), option_(option) {} @@ -128,9 +130,12 @@ Foam::pointToCell::pointToCell const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(pointActionNames_.get("option", dict)) + pointToCell + ( + mesh, + dict.get<word>("set"), + pointActionNames_.get("option", dict) + ) {} @@ -140,7 +145,7 @@ Foam::pointToCell::pointToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(checkIs(is)), option_(pointActionNames_.read(checkIs(is))) {} @@ -154,17 +159,23 @@ void Foam::pointToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells according to pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding cells according to pointSet " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells according to pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing cells according to pointSet " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H index 2778f134cd1fefd28429cd4a13fd01275a2803d6..c61f8997af37655b1de6f70fc95feba0969cc2ca 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H @@ -25,7 +25,7 @@ Class Foam::pointToCell Description - A topoSetSource to select cells based on usage of points. + A topoSetCellSource to select cells based on usage of points. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef pointToCell_H #define pointToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class pointToCell : - public topoSetSource + public topoSetCellSource { public: //- Enumeration defining the valid options @@ -115,11 +115,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C index 8cbd157bf7db66adfdbdb99ac84f5cd69a4d03be..670dd99527ede81c726f48fdfc4a388b62d669fb 100644 --- a/src/meshTools/sets/cellSources/regionToCell/regionToCell.C +++ b/src/meshTools/sets/cellSources/regionToCell/regionToCell.C @@ -37,6 +37,8 @@ namespace Foam defineTypeNameAndDebug(regionToCell, 0); addToRunTimeSelectionTable(topoSetSource, regionToCell, word); addToRunTimeSelectionTable(topoSetSource, regionToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, regionToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, regionToCell, istream); } @@ -155,7 +157,7 @@ void Foam::regionToCell::unselectOutsideRegions regionSplit cellRegion(mesh_, blockedFace); // Determine regions containing insidePoints_ - boolList keepRegion(findRegions(true, cellRegion)); + boolList keepRegion(findRegions(verbose_, cellRegion)); // Go back to bool per cell forAll(cellRegion, celli) @@ -266,7 +268,7 @@ void Foam::regionToCell::erode regionSplit cellRegion(mesh_, blockedFace); // Determine regions containing insidePoints - boolList keepRegion(findRegions(true, cellRegion)); + boolList keepRegion(findRegions(verbose_, cellRegion)); // Extract cells in regions that are not to be kept. @@ -386,7 +388,7 @@ Foam::regionToCell::regionToCell const label nErode ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(setName), insidePoints_(insidePoints), nErode_(nErode) @@ -399,7 +401,7 @@ Foam::regionToCell::regionToCell const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(dict.lookupOrDefault<word>("set", "none")), insidePoints_ ( @@ -415,7 +417,7 @@ Foam::regionToCell::regionToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(checkIs(is)), insidePoints_(checkIs(is)), nErode_(readLabel(checkIs(is))) @@ -430,17 +432,25 @@ void Foam::regionToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells of connected region containing points " - << insidePoints_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all cells of connected region " + << "containing points " + << insidePoints_ << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells of connected region containing points " - << insidePoints_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all cells of connected region " + << "containing points " + << insidePoints_ << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/regionToCell/regionToCell.H b/src/meshTools/sets/cellSources/regionToCell/regionToCell.H index 7324aba1fac75112e281eea14db165a7978531d5..dd699df550ac1ef0c9aaa003bba45a181f495ef2 100644 --- a/src/meshTools/sets/cellSources/regionToCell/regionToCell.H +++ b/src/meshTools/sets/cellSources/regionToCell/regionToCell.H @@ -25,8 +25,8 @@ Class Foam::regionToCell Description - TopoSetSource. Select cells belonging to topological connected region - (that contains given points) + A topoSetCellSource to select cells belonging to a topological connected + region (that contains given points) In dictionary input: \verbatim @@ -43,10 +43,10 @@ Description \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 | '' + 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 @@ -57,7 +57,7 @@ SourceFiles #ifndef regionToCell_H #define regionToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -73,7 +73,7 @@ class regionSplit; class regionToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -146,11 +146,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C index 581214ba5489f8cb1873cb742d21a8aff93f0ddc..6bd0acdf3ffbbbf75417c4f1b0b1dcc22f3ef57a 100644 --- a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C +++ b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C @@ -35,6 +35,22 @@ namespace Foam defineTypeNameAndDebug(rotatedBoxToCell, 0); addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word); addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, rotatedBoxToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, rotatedBoxToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + rotatedBoxToCell, + word, + rotatedBox + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + rotatedBoxToCell, + istream, + rotatedBox + ); } @@ -117,7 +133,7 @@ Foam::rotatedBoxToCell::rotatedBoxToCell const vector& k ) : - topoSetSource(mesh), + topoSetCellSource(mesh), origin_(origin), i_(i), j_(j), @@ -131,17 +147,20 @@ Foam::rotatedBoxToCell::rotatedBoxToCell const dictionary& dict ) : - topoSetSource(mesh), - origin_(dict.get<point>("origin")), - i_(dict.get<vector>("i")), - j_(dict.get<vector>("j")), - k_(dict.get<vector>("k")) + rotatedBoxToCell + ( + mesh, + dict.get<point>("origin"), + dict.get<vector>("i"), + dict.get<vector>("j"), + dict.get<vector>("k") + ) {} Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is) : - topoSetSource(mesh), + topoSetCellSource(mesh), origin_(is), i_(is), j_(is), @@ -157,15 +176,23 @@ void Foam::rotatedBoxToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with center within rotated box " << endl; + if (verbose_) + { + Info<< " Adding cells with centre within rotated box" + << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with center within rotated box " << endl; + if (verbose_) + { + Info<< " Removing cells with centre within rotated box" + << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H index 204e2175de69300d5d02bf6882ac25599bfe2997..f13388afb21753e7ae00d2acd752043c8db65cc0 100644 --- a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H +++ b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.H @@ -25,7 +25,7 @@ Class Foam::rotatedBoxToCell Description - A topoSetSource to select cells based on cell centres inside + A topoSetCellSource to select cells based on cell centres inside rotated/skewed box (parallelopiped?). Box defined as origin and i,j,k vectors. @@ -55,7 +55,7 @@ SourceFiles #ifndef rotatedBoxToCell_H #define rotatedBoxToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "treeBoundBox.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,7 +69,7 @@ namespace Foam class rotatedBoxToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -120,11 +120,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.C b/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.C new file mode 100644 index 0000000000000000000000000000000000000000..5a5e529fdb6b81463e7e80768348337acc2607f4 --- /dev/null +++ b/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.C @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "searchableSurfaceToCell.H" +#include "polyMesh.H" +#include "Time.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(searchableSurfaceToCell, 0); + addToRunTimeSelectionTable + ( + topoSetSource, + searchableSurfaceToCell, + word + ); + addToRunTimeSelectionTable + ( + topoSetCellSource, + searchableSurfaceToCell, + word + ); + addNamedToRunTimeSelectionTable + ( + topoSetSource, + searchableSurfaceToCell, + word, + surface + ); +} + + +Foam::topoSetSource::addToUsageTable Foam::searchableSurfaceToCell::usage_ +( + searchableSurfaceToCell::typeName, + "\n Usage: searchableSurfaceToCell surface\n\n" + " Select cells with centre enclosed by the surface" + "\n" +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::searchableSurfaceToCell::combine(topoSet& set, const bool add) const +{ + if (!surf_) + { + return; + } + const searchableSurface& s = *surf_; + + // Add cells within the enclosing volumes + + const label len = mesh_.nCells(); + + List<volumeType> volTypes; + + s.getVolumeType(mesh_.cellCentres(), volTypes); + + for (label celli=0; celli < len; ++celli) + { + if (volTypes[celli] == volumeType::INSIDE) + { + addOrDelete(set, celli, add); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::searchableSurfaceToCell::searchableSurfaceToCell +( + const word& surfaceType, + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetCellSource(mesh), + surf_ + ( + searchableSurface::New + ( + surfaceType, + IOobject + ( + dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), + mesh.time().constant(), // Instance + "triSurface", // Local + mesh.time(), // Registry + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + dict + ) + ) +{ + // Check/warn for non-enclosed + if (surf_ && !surf_->hasVolumeType()) + { + WarningInFunction + << nl << "The surface '" << surf_->name() << "' of type '" + << surf_->type() << "' appears to be unclosed ... ignoring" + << nl << endl; + + surf_.clear(); + } +} + + +Foam::searchableSurfaceToCell::searchableSurfaceToCell +( + const polyMesh& mesh, + const dictionary& dict +) +: + searchableSurfaceToCell + ( + dict.get<word>("surface"), + mesh, + dict + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::searchableSurfaceToCell::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!surf_ || !surf_->hasVolumeType()) + { + return; + } + + if (action == topoSetSource::ADD || action == topoSetSource::NEW) + { + if (verbose_) + { + Info<< " Adding cells enclosed by searchableSurface" + << "..." << endl; + } + + combine(set, true); + } + else if (action == topoSetSource::SUBTRACT) + { + if (verbose_) + { + Info<< " Removing cells enclosed by searchableSurface" + << "..." << endl; + } + + combine(set, false); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.H b/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.H new file mode 100644 index 0000000000000000000000000000000000000000..bb436d54e5b8a609526a4bfd80e21133283468f7 --- /dev/null +++ b/src/meshTools/sets/cellSources/searchableSurfaceToCell/searchableSurfaceToCell.H @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::searchableSurfaceToCell + +Description + A topoSetSource to select cells based on cell centres within a + searchableSurface. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + surface | The searchable surface type | yes | + name | Name for the IOobject | no | mesh-name + \endtable + +SourceFiles + searchableSurfaceToCell.C + +\*---------------------------------------------------------------------------*/ + +#ifndef searchableSurfaceToCell_H +#define searchableSurfaceToCell_H + +#include "topoSetCellSource.H" +#include "searchableSurface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class searchableSurfaceToCell Declaration +\*---------------------------------------------------------------------------*/ + +class searchableSurfaceToCell +: + public topoSetCellSource +{ + // Private Data + + //- Add usage string + static addToUsageTable usage_; + + //- The searchableSurface + autoPtr<searchableSurface> surf_; + + + // Private Member Functions + + void combine(topoSet& set, const bool add) const; + + +public: + + //- Runtime type information + TypeName("searchableSurfaceToCell"); + + + // Constructors + + //- Construct surface-type from dictionary + searchableSurfaceToCell + ( + const word& surfaceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from dictionary + searchableSurfaceToCell + ( + const polyMesh& mesh, + const dictionary& dict + ); + + + //- Destructor + virtual ~searchableSurfaceToCell() = default; + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& set + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C index 387eb29f48cbc5c98bae47842d87e4c0ffadd8a3..352e884ee2e5a4f191f8eb83af9dc44705fefb82 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C @@ -37,6 +37,8 @@ namespace Foam defineTypeNameAndDebug(shapeToCell, 0); addToRunTimeSelectionTable(topoSetSource, shapeToCell, word); addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, shapeToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, shapeToCell, istream); } @@ -94,7 +96,7 @@ Foam::shapeToCell::shapeToCell const word& shapeName ) : - topoSetSource(mesh), + topoSetCellSource(mesh), type_(shapeName) { if (!cellModel::ptr(type_) && type_ != "splitHex") @@ -111,15 +113,8 @@ Foam::shapeToCell::shapeToCell const dictionary& dict ) : - topoSetSource(mesh), - type_(dict.get<word>("type")) -{ - if (!cellModel::ptr(type_) && type_ != "splitHex") - { - FatalErrorInFunction - << "Illegal cell type " << type_ << exit(FatalError); - } -} + shapeToCell(mesh, dict.get<word>("type")) +{} Foam::shapeToCell::shapeToCell @@ -128,7 +123,7 @@ Foam::shapeToCell::shapeToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), type_(checkIs(is)) { if (!cellModel::ptr(type_) && type_ != "splitHex") @@ -147,15 +142,23 @@ void Foam::shapeToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells of type " << type_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all cells of type " << type_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells of type " << type_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all cells of type " << type_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H index 8476e013abe021c62e6270e0ba6dcbe81b6d268c..cb53bee831b0afb31c7ee6363fd9325d12eeff39 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H @@ -25,7 +25,7 @@ Class Foam::shapeToCell Description - A topoSetSource to select cells based on cell shape. + A topoSetCellSource to select cells based on cell shape. Handles all known ones from static collection in cellModel and splitHex with 10 degrees feature angle. @@ -44,7 +44,7 @@ SourceFiles #ifndef shapeToCell_H #define shapeToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +57,7 @@ namespace Foam class shapeToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -90,11 +90,7 @@ public: // Constructors //- Construct from components - shapeToCell - ( - const polyMesh& mesh, - const word& shapeName - ); + shapeToCell(const polyMesh& mesh, const word& shapeName); //- Construct from dictionary shapeToCell(const polyMesh& mesh, const dictionary& dict); @@ -109,11 +105,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C index 3f640426e112ed080c680d458805fab3fcbd8155..072e084dbbf4d1c36c57f86c8e1fd6eae5e67902 100644 --- a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C +++ b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(sphereToCell, 0); addToRunTimeSelectionTable(topoSetSource, sphereToCell, word); addToRunTimeSelectionTable(topoSetSource, sphereToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, sphereToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, sphereToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + sphereToCell, + word, + sphere + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + sphereToCell, + istream, + sphere + ); } @@ -55,7 +71,7 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const forAll(ctrs, celli) { - if (magSqr(ctrs[celli] - centre_) <= rad2) + if (magSqr(ctrs[celli] - origin_) <= rad2) { addOrDelete(set, celli, add); } @@ -68,12 +84,12 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const Foam::sphereToCell::sphereToCell ( const polyMesh& mesh, - const point& centre, + const point& origin, const scalar radius ) : - topoSetSource(mesh), - centre_(centre), + topoSetCellSource(mesh), + origin_(origin), radius_(radius) {} @@ -84,9 +100,12 @@ Foam::sphereToCell::sphereToCell const dictionary& dict ) : - topoSetSource(mesh), - centre_(dict.get<point>("centre")), - radius_(dict.get<scalar>("radius")) + sphereToCell + ( + mesh, + dict.getCompat<vector>("origin", {{"centre", -1806}}), + dict.get<scalar>("radius") + ) {} @@ -96,8 +115,8 @@ Foam::sphereToCell::sphereToCell Istream& is ) : - topoSetSource(mesh), - centre_(checkIs(is)), + topoSetCellSource(mesh), + origin_(checkIs(is)), radius_(readScalar(checkIs(is))) {} @@ -110,17 +129,23 @@ void Foam::sphereToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells with centre within sphere, with centre = " - << centre_ << " and radius = " << radius_ << endl; + if (verbose_) + { + Info<< " Adding cells within a sphere with centre = " + << origin_ << " and radius = " << radius_ << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells with centre within sphere, with centre = " - << centre_ << " and radius = " << radius_ << endl; + if (verbose_) + { + Info<< " Removing cells within a sphere with centre = " + << origin_ << " and radius = " << radius_ << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H index 200b9f68b2ef14d056c4e1f0525af0b7fd2777b1..5ba3a2bd442fd52e60d45aea4f1329ee2d860980 100644 --- a/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H +++ b/src/meshTools/sets/cellSources/sphereToCell/sphereToCell.H @@ -25,13 +25,14 @@ Class Foam::sphereToCell Description - A topoSetSource to select cells based on cell centres inside sphere. + A topoSetCellSource 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 | + Property | Description | Required | Default + origin | The origin (centre) of the sphere | yes | + radius | The (outside) radius of sphere | yes | + centre | Alternative for 'origin' | no | \endtable SourceFiles @@ -42,7 +43,7 @@ SourceFiles #ifndef sphereToCell_H #define sphereToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,7 +56,7 @@ namespace Foam class sphereToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -64,7 +65,7 @@ class sphereToCell static addToUsageTable usage_; //- Centre point of the sphere - point centre_; + point origin_; //- The outer radius of the sphere scalar radius_; @@ -87,7 +88,7 @@ public: sphereToCell ( const polyMesh& mesh, - const point& centre, + const point& origin, const scalar radius ); @@ -104,11 +105,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C index a2a26564ff443c02121fd8fda0203550a3917fb5..39a31e2c468b4dd299d27e01ae8ce882c4c57ca3 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C @@ -40,6 +40,8 @@ namespace Foam defineTypeNameAndDebug(surfaceToCell, 0); addToRunTimeSelectionTable(topoSetSource, surfaceToCell, word); addToRunTimeSelectionTable(topoSetSource, surfaceToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, surfaceToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, surfaceToCell, istream); } @@ -72,25 +74,22 @@ Foam::label Foam::surfaceToCell::getNearest Map<label>& cache ) { - Map<label>::const_iterator iter = cache.find(pointi); + const auto iter = cache.cfind(pointi); - if (iter != cache.end()) + if (iter.found()) { - // Found cached answer - return iter(); + return *iter; // Return cached value } - else - { - pointIndexHit inter = querySurf.nearest(pt, span); - // Triangle label (can be -1) - label triI = inter.index(); + pointIndexHit inter = querySurf.nearest(pt, span); - // Store triangle on point - cache.insert(pointi, triI); + // Triangle label (can be -1) + const label trii = inter.index(); - return triI; - } + // Store triangle on point + cache.insert(pointi, trii); + + return trii; } @@ -148,7 +147,6 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const { cpuTime timer; - if (useSurfaceOrientation_ && (includeInside_ || includeOutside_)) { const meshSearch queryMesh(mesh_); @@ -156,8 +154,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const //- Calculate for each searchPoint inside/outside status. boolList isInside(querySurf().calcInside(mesh_.cellCentres())); - Info<< " Marked inside/outside using surface orientation in = " - << timer.cpuTimeIncrement() << " s" << endl << endl; + if (verbose_) + { + Info<< " Marked inside/outside using surface orientation in = " + << timer.cpuTimeIncrement() << " s" << nl << endl; + } forAll(isInside, celli) { @@ -208,8 +209,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const ); - Info<< " Marked inside/outside using surface intersection in = " - << timer.cpuTimeIncrement() << " s" << endl << endl; + if (verbose_) + { + Info<< " Marked inside/outside using surface intersection in = " + << timer.cpuTimeIncrement() << " s" << nl << endl; + } //- Add/remove cells using set forAll(cellType, celli) @@ -252,8 +256,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const if (curvature_ < -1) { - Info<< " Selecting cells with cellCentre closer than " - << nearDist_ << " to surface" << endl; + if (verbose_) + { + Info<< " Selecting cells with cellCentre closer than " + << nearDist_ << " to surface" << endl; + } // No need to test curvature. Insert near cells into set. @@ -269,17 +276,22 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const } } - Info<< " Determined nearest surface point in = " - << timer.cpuTimeIncrement() << " s" << endl << endl; - + if (verbose_) + { + Info<< " Determined nearest surface point in = " + << timer.cpuTimeIncrement() << " s" << nl << endl; + } } else { // Test near cells for curvature - Info<< " Selecting cells with cellCentre closer than " - << nearDist_ << " to surface and curvature factor" - << " less than " << curvature_ << endl; + if (verbose_) + { + Info<< " Selecting cells with cellCentre closer than " + << nearDist_ << " to surface and curvature factor" + << " less than " << curvature_ << endl; + } // Cache for nearest surface triangle for a point Map<label> pointToNearest(mesh_.nCells()/10); @@ -309,8 +321,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const } } - Info<< " Determined nearest surface point in = " - << timer.cpuTimeIncrement() << " s" << endl << endl; + if (verbose_) + { + Info<< " Determined nearest surface point in = " + << timer.cpuTimeIncrement() << " s" << nl << endl; + } } } } @@ -364,7 +379,7 @@ Foam::surfaceToCell::surfaceToCell const scalar curvature ) : - topoSetSource(mesh), + topoSetCellSource(mesh), surfName_(surfName), outsidePoints_(outsidePoints), includeCut_(includeCut), @@ -396,7 +411,7 @@ Foam::surfaceToCell::surfaceToCell const scalar curvature ) : - topoSetSource(mesh), + topoSetCellSource(mesh), surfName_(surfName), outsidePoints_(outsidePoints), includeCut_(includeCut), @@ -419,7 +434,7 @@ Foam::surfaceToCell::surfaceToCell const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellSource(mesh), surfName_(dict.get<fileName>("file").expand()), outsidePoints_(dict.get<pointField>("outsidePoints")), includeCut_(dict.get<bool>("includeCut")), @@ -452,7 +467,7 @@ Foam::surfaceToCell::surfaceToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), surfName_(checkIs(is)), outsidePoints_(checkIs(is)), includeCut_(readBool(checkIs(is))), @@ -489,17 +504,23 @@ void Foam::surfaceToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells in relation to surface " << surfName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding cells in relation to surface " << surfName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells in relation to surface " << surfName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing cells in relation to surface " << surfName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H index cf3fa9f2b8e2d2cc24cb1775d26db73dda56b1ee..7b2427a0472e007ae87cfb49f5f888a63f3a86a4 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H @@ -25,7 +25,7 @@ Class Foam::surfaceToCell Description - A topoSetSource to select cells based on relation to surface. + A topoSetCellSource to select cells based on relation to surface. Selects: - all cells inside/outside/cut by surface @@ -58,7 +58,7 @@ SourceFiles #ifndef surfaceToCell_H #define surfaceToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "Map.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -74,7 +74,7 @@ class triSurface; class surfaceToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -209,11 +209,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C index 1e1c3f6d0d747ee2f881a105ac76ab002c595eb1..51f15800d5d6e0316b687361a6b67ca114d5d728 100644 --- a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C @@ -38,6 +38,22 @@ namespace Foam defineTypeNameAndDebug(targetVolumeToCell, 0); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + targetVolumeToCell, + word, + targetVolume + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + targetVolumeToCell, + istream, + targetVolume + ); } @@ -103,14 +119,16 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const return; } - bitSet maskSet(mesh_.nCells(), true); label nTotCells = mesh_.globalData().nTotalCells(); if (maskSetName_.size()) { // Read cellSet - Info<< " Operating on subset defined by cellSet " << maskSetName_ - << endl; + if (verbose_) + { + Info<< " Operating on subset defined by cellSet " + << maskSetName_ << endl; + } maskSet = false; cellSet subset(mesh_, maskSetName_); @@ -138,7 +156,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const label maxPointi = -1; forAll(points, pointi) { - scalar c = (points[pointi] & normal_); + const scalar c = (points[pointi] & normal_); if (c > maxComp) { maxComp = c; @@ -247,9 +265,11 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const } - Info<< " Selected " << nSelected << " with actual volume " - << selectedVol << endl; - + if (verbose_) + { + Info<< " Selected " << nSelected << " with actual volume " + << selectedVol << endl; + } // Loop over selected cells only for (const label celli : selected) @@ -265,12 +285,14 @@ Foam::targetVolumeToCell::targetVolumeToCell ( const polyMesh& mesh, const scalar vol, - const vector& normal + const vector& normal, + const word& maskSetName ) : - topoSetSource(mesh), + topoSetCellSource(mesh), vol_(vol), - normal_(normal) + normal_(normal), + maskSetName_(maskSetName) {} @@ -280,10 +302,13 @@ Foam::targetVolumeToCell::targetVolumeToCell const dictionary& dict ) : - topoSetSource(mesh), - vol_(dict.get<scalar>("volume")), - normal_(dict.get<vector>("normal")), - maskSetName_(dict.lookupOrDefault<word>("set", "")) + targetVolumeToCell + ( + mesh, + dict.get<scalar>("volume"), + dict.get<vector>("normal"), + dict.lookupOrDefault<word>("set", "") + ) {} @@ -293,7 +318,7 @@ Foam::targetVolumeToCell::targetVolumeToCell Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), vol_(readScalar(checkIs(is))), normal_(checkIs(is)) {} @@ -307,17 +332,25 @@ void Foam::targetVolumeToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding cells up to target volume " << vol_ - << " out of total volume " << gSum(mesh_.cellVolumes()) << endl; + if (verbose_) + { + Info<< " Adding cells up to target volume " << vol_ + << " out of total volume " + << gSum(mesh_.cellVolumes()) << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing cells up to target volume " << vol_ - << " out of total volume " << gSum(mesh_.cellVolumes()) << endl; + if (verbose_) + { + Info<< " Removing cells up to target volume " << vol_ + << " out of total volume " + << gSum(mesh_.cellVolumes()) << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H index d2fc080970bd8e3ac04eaa345e904ed87a0a9633..63cc917f7f3433be2e8fad1978fde0d0dd90fe95 100644 --- a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H @@ -25,7 +25,7 @@ Class Foam::targetVolumeToCell Description - A topoSetSource to select cells based on the wanted volume of selected + A topoSetCellSource to select cells based on the wanted volume of selected cells. Adapts a plane until it has enough. \heading Dictionary parameters @@ -44,7 +44,7 @@ SourceFiles #ifndef targetVolumeToCell_H #define targetVolumeToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +60,7 @@ class bitSet; class targetVolumeToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -105,7 +105,8 @@ public: ( const polyMesh& mesh, const scalar vol, - const vector& normal + const vector& normal, + const word& maskSetName = "" ); //- Construct from dictionary @@ -121,11 +122,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C new file mode 100644 index 0000000000000000000000000000000000000000..ae579e4e4a5f505e217e7004c7296872a4b18cc9 --- /dev/null +++ b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "topoSetCellSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(topoSetCellSource, 0); + defineRunTimeSelectionTable(topoSetCellSource, word); + defineRunTimeSelectionTable(topoSetCellSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetCellSource::topoSetCellSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetCellSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetCellSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetCellSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << istreamConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetCellSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H new file mode 100644 index 0000000000000000000000000000000000000000..f506aaf0c802ec7c07ed0d4fbc8eed850c03fda6 --- /dev/null +++ b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::topoSetCellSource + +Description + Base class of a topoSet source for selecting cells. + +SourceFiles + topoSetCellSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetCellSource_H +#define topoSetCellSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class topoSetCellSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetCellSource +: + public topoSetSource +{ +public: + + //- Runtime type information + TypeName("topoSetCellSource"); + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetCellSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetCellSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetCellSource(const polyMesh& mesh); + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetCellSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetCellSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetCellSource() = default; + + + // Member Functions + + virtual topoSetSource::sourceType setType() const + { + return CELLSETSOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C index ee3e616b251b04e6bf2f19bb32c4cf2fb52d4ff5..558622336a515811bff1925781099c31090ac342 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(zoneToCell, 0); addToRunTimeSelectionTable(topoSetSource, zoneToCell, word); addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, zoneToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, zoneToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + zoneToCell, + word, + zone + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + zoneToCell, + istream, + zone + ); } @@ -54,14 +70,17 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const for (const cellZone& zone : mesh_.cellZones()) { - if (zoneName_.match(zone.name())) + if (selectedZones_.match(zone.name())) { hasMatched = true; const labelList& cellLabels = zone; - Info<< " Found matching zone " << zone.name() - << " with " << cellLabels.size() << " cells." << endl; + if (verbose_) + { + Info<< " Found matching zone " << zone.name() + << " with " << cellLabels.size() << " cells." << endl; + } for (const label celli : cellLabels) { @@ -77,7 +96,8 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any cellZone named " << zoneName_ << nl + << "Cannot find any cellZone matching " + << flatOutput(selectedZones_) << nl << "Valid names: " << flatOutput(mesh_.cellZones().names()) << endl; } @@ -89,11 +109,11 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const Foam::zoneToCell::zoneToCell ( const polyMesh& mesh, - const word& zoneName + const wordRe& zoneName ) : - topoSetSource(mesh), - zoneName_(zoneName) + topoSetCellSource(mesh), + selectedZones_(one(), zoneName) {} @@ -103,9 +123,17 @@ Foam::zoneToCell::zoneToCell const dictionary& dict ) : - topoSetSource(mesh), - zoneName_(dict.get<wordRe>("name")) -{} + topoSetCellSource(mesh), + selectedZones_() +{ + // Look for 'zones' and 'zone', but accept 'name' as well + if (!dict.readIfPresent("zones", selectedZones_)) + { + selectedZones_.resize(1); + selectedZones_.first() = + dict.getCompat<wordRe>("zone", {{"name", 1806}}); + } +} Foam::zoneToCell::zoneToCell @@ -114,8 +142,8 @@ Foam::zoneToCell::zoneToCell Istream& is ) : - topoSetSource(mesh), - zoneName_(checkIs(is)) + topoSetCellSource(mesh), + selectedZones_(one(), wordRe(checkIs(is))) {} @@ -127,17 +155,23 @@ void Foam::zoneToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells of cellZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all cells of cell zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells of cellZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all cells of cell zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H index d687226798024f8c4aae241497d35f94fecd34bc..15f107782df6ebf62226cbd9beb68589bd775621 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.H @@ -25,14 +25,19 @@ Class Foam::zoneToCell Description - A topoSetSource to select cells based on cellZone. + A topoSetCellSource to select cells based on one or more cellZones. \heading Dictionary parameters \table - Property | Description | Required | Default - name | The cell zone name or regex | yes | + Property | Description | Required | Default + zone | The cell zone name or regex | possibly | + zones | The cell zone names or regexs | possibly | + name | Older specification for 'zone' | no | \endtable +Note + Selection of multiple zones has precedence. + SourceFiles zoneToCell.C @@ -41,8 +46,8 @@ SourceFiles #ifndef zoneToCell_H #define zoneToCell_H -#include "topoSetSource.H" -#include "wordRe.H" +#include "topoSetCellSource.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,12 +55,12 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class zoneToCell Declaration + Class zoneToCell Declaration \*---------------------------------------------------------------------------*/ class zoneToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -63,8 +68,8 @@ class zoneToCell //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of cellZone - wordRe zoneName_; + //- Matcher for zones + wordRes selectedZones_; // Private Member Functions @@ -80,11 +85,7 @@ public: // Constructors //- Construct from components - zoneToCell - ( - const polyMesh& mesh, - const word& zoneName - ); + zoneToCell(const polyMesh& mesh, const wordRe& zoneName); //- Construct from dictionary zoneToCell(const polyMesh& mesh, const dictionary& dict); @@ -99,11 +100,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C index 9203ad8e394e35143176806697a69f4346872963..55eca622f0e575cbe141c739301a0de7d708edc5 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C @@ -96,52 +96,56 @@ void Foam::setToCellZone::applyToSet } else { - cellZoneSet& fzSet = refCast<cellZoneSet>(set); + cellZoneSet& zoneSet = refCast<cellZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells from cellSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding all cells from cellSet " << setName_ + << " ..." << endl; + } // Load the sets cellSet fSet(mesh_, setName_); // Start off from copy - DynamicList<label> newAddressing(fzSet.addressing()); + DynamicList<label> newAddressing(zoneSet.addressing()); - forAllConstIter(cellSet, fSet, iter) + for (const label celli : fSet) { - label celli = iter.key(); - - if (!fzSet.found(celli)) + if (!zoneSet.found(celli)) { newAddressing.append(celli); } } - fzSet.addressing().transfer(newAddressing); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells from cellSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing all cells from cellSet " << setName_ + << " ..." << endl; + } // Load the set cellSet loadedSet(mesh_, setName_); // Start off empty - DynamicList<label> newAddressing(fzSet.addressing().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); - forAll(fzSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fzSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fzSet.addressing()[i]); + newAddressing.append(zoneSet.addressing()[i]); } } - fzSet.addressing().transfer(newAddressing); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H index aadde9c799c7723df5357a8afbfc43cd1edadd06..30f50aaf3db4a81473607e12cbda7c697e18a35a 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H @@ -72,17 +72,13 @@ public: // Constructors //- Construct from components - setToCellZone - ( - const polyMesh& mesh, - const word& setName - ); + setToCellZone(const polyMesh& mesh, const word& setName); //- Construct from dictionary setToCellZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - setToCellZone(const polyMesh& mesh, Istream& is ); + setToCellZone(const polyMesh& mesh, Istream& is); //- Destructor diff --git a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C index 280850f1fbd7319ca56d007d38e1dc35de69da7f..1875b9c9c88c9b282d8ede59bb93b2015017ee4f 100644 --- a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C +++ b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(boundaryToFace, 0); addToRunTimeSelectionTable(topoSetSource, boundaryToFace, word); addToRunTimeSelectionTable(topoSetSource, boundaryToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, boundaryToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, boundaryToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + boundaryToFace, + word, + boundary + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + boundaryToFace, + istream, + boundary + ); } @@ -65,7 +81,7 @@ void Foam::boundaryToFace::combine(topoSet& set, const bool add) const Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh) : - topoSetSource(mesh) + topoSetFaceSource(mesh) {} @@ -75,7 +91,7 @@ Foam::boundaryToFace::boundaryToFace const dictionary& ) : - topoSetSource(mesh) + topoSetFaceSource(mesh) {} @@ -85,7 +101,7 @@ Foam::boundaryToFace::boundaryToFace Istream& ) : - topoSetSource(mesh) + topoSetFaceSource(mesh) {} @@ -97,15 +113,21 @@ void Foam::boundaryToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all boundary faces ..." << endl; + if (verbose_) + { + Info<< " Adding all boundary faces ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all boundary faces ..." << endl; + if (verbose_) + { + Info<< " Removing all boundary faces ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H index e654485fb6c5bda4ffaa04cb821e63384f983b8d..ae3e7f02155ec57909611a6877d56105f96de5b2 100644 --- a/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H +++ b/src/meshTools/sets/faceSources/boundaryToFace/boundaryToFace.H @@ -25,7 +25,7 @@ Class Foam::boundaryToFace Description - A topoSetSource to select all external (boundary) faces. + A topoSetFaceSource to select all external (boundary) faces. \heading Dictionary parameters None @@ -38,7 +38,7 @@ SourceFiles #ifndef boundaryToFace_H #define boundaryToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,7 +51,7 @@ namespace Foam class boundaryToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -87,11 +87,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/boxToFace/boxToFace.C b/src/meshTools/sets/faceSources/boxToFace/boxToFace.C index c589fcecb060d2043ba33fb9afd2e9fb352d519f..3eef661de9632b2d38dfc538f625655075f8d7f5 100644 --- a/src/meshTools/sets/faceSources/boxToFace/boxToFace.C +++ b/src/meshTools/sets/faceSources/boxToFace/boxToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(boxToFace, 0); addToRunTimeSelectionTable(topoSetSource, boxToFace, word); addToRunTimeSelectionTable(topoSetSource, boxToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, boxToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, boxToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + boxToFace, + word, + box + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + boxToFace, + istream, + box + ); } @@ -73,29 +89,37 @@ Foam::boxToFace::boxToFace const treeBoundBoxList& bbs ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), bbs_(bbs) {} +Foam::boxToFace::boxToFace +( + const polyMesh& mesh, + treeBoundBoxList&& bbs +) +: + topoSetFaceSource(mesh), + bbs_(std::move(bbs)) +{} + + Foam::boxToFace::boxToFace ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), bbs_() { - if (dict.found("box")) + // Look for 'boxes' or 'box' + if (!dict.readIfPresent("boxes", bbs_)) { bbs_.resize(1); dict.readEntry("box", bbs_.first()); } - else - { - dict.readEntry("boxes", bbs_); - } } @@ -105,8 +129,8 @@ Foam::boxToFace::boxToFace Istream& is ) : - topoSetSource(mesh), - bbs_(1, treeBoundBox(checkIs(is))) + topoSetFaceSource(mesh), + bbs_(one(), treeBoundBox(checkIs(is))) {} @@ -118,15 +142,23 @@ void Foam::boxToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces with centre within boxes " << bbs_ << endl; + if (verbose_) + { + Info<< " Adding faces with centre within boxes " + << bbs_ << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces with centre within boxes " << bbs_ << endl; + if (verbose_) + { + Info<< " Removing faces with centre within boxes " + << bbs_ << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/boxToFace/boxToFace.H b/src/meshTools/sets/faceSources/boxToFace/boxToFace.H index 6a9bc01cea769e7f330464dd7ac64d49900a4311..9de0f3ca635f435c3ffd9622721af7416e78ee69 100644 --- a/src/meshTools/sets/faceSources/boxToFace/boxToFace.H +++ b/src/meshTools/sets/faceSources/boxToFace/boxToFace.H @@ -25,17 +25,18 @@ Class Foam::boxToFace Description - A topoSetSource to select faces based on face centres inside box. + A topoSetFaceSource 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 | + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | \endtable Note - Must specify either "box" or "boxes" + Must specify either "box" or "boxes". + The selection of multiple boxes has precedence. SourceFiles boxToFace.C @@ -45,7 +46,7 @@ SourceFiles #ifndef boxToFace_H #define boxToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" #include "treeBoundBoxList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,7 +60,7 @@ namespace Foam class boxToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -82,12 +83,11 @@ public: // Constructors - //- Construct from components - boxToFace - ( - const polyMesh& mesh, - const treeBoundBoxList& bbs - ); + //- Construct from components, copying bounding boxes + boxToFace(const polyMesh& mesh, const treeBoundBoxList& bbs); + + //- Construct from components, moving bounding boxes + boxToFace(const polyMesh& mesh, treeBoundBoxList&& bbs); //- Construct from dictionary boxToFace(const polyMesh& mesh, const dictionary& dict); @@ -102,11 +102,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C index 5b271c8e0dab9a80597615e389a2da7df155d430..a5368ef03a81f4170b371657bdc7be531274220f 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C @@ -37,6 +37,8 @@ namespace Foam defineTypeNameAndDebug(cellToFace, 0); addToRunTimeSelectionTable(topoSetSource, cellToFace, word); addToRunTimeSelectionTable(topoSetSource, cellToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, cellToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, cellToFace, istream); } @@ -153,7 +155,7 @@ Foam::cellToFace::cellToFace const cellAction option ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(setName), option_(option) {} @@ -165,9 +167,12 @@ Foam::cellToFace::cellToFace const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(cellActionNames_.get("option", dict)) + cellToFace + ( + mesh, + dict.get<word>("set"), + cellActionNames_.get("option", dict) + ) {} @@ -177,7 +182,7 @@ Foam::cellToFace::cellToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(checkIs(is)), option_(cellActionNames_.read(checkIs(is))) {} @@ -191,17 +196,23 @@ void Foam::cellToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces according to cellSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding faces according to cellSet " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces according to cellSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing faces according to cellSet " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.H b/src/meshTools/sets/faceSources/cellToFace/cellToFace.H index 842203c6d127da8498494eeb3c348be6d4cc4ce6..b518d1ebe982f8c5b3fc90d21c439766007f8d4d 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.H +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.H @@ -25,7 +25,7 @@ Class Foam::cellToFace Description - A topoSetSource to select a faceSet from cells. + A topoSetFaceSource to select a faceSet from a cellSet. Either use 'all' cell faces, or only faces that have cells on 'both' sides. @@ -48,7 +48,7 @@ SourceFiles #ifndef cellToFace_H #define cellToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,7 +62,7 @@ namespace Foam class cellToFace : - public topoSetSource + public topoSetFaceSource { public: //- Enumeration defining the valid options @@ -121,11 +121,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C index 99ec5fc1a2bd495782dc1afe1ed61ce4d4b0648f..b3f7ea64de68aff012c958bb376a4a7fba581f3b 100644 --- a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C +++ b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.C @@ -34,6 +34,32 @@ namespace Foam defineTypeNameAndDebug(cylinderAnnulusToFace, 0); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, word); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, istream); + addToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderAnnulusToFace, + word + ); + addToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderAnnulusToFace, + istream + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderAnnulusToFace, + word, + cylinderAnnulus + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderAnnulusToFace, + istream, + cylinderAnnulus + ); } @@ -85,7 +111,7 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace const scalar innerRadius ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), point1_(point1), point2_(point2), outerRadius_(outerRadius), @@ -99,11 +125,14 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace const dictionary& dict ) : - topoSetSource(mesh), - point1_(dict.get<point>("p1")), - point2_(dict.get<point>("p2")), - outerRadius_(dict.get<scalar>("outerRadius")), - innerRadius_(dict.get<scalar>("innerRadius")) + cylinderAnnulusToFace + ( + mesh, + dict.get<point>("p1"), + dict.get<point>("p2"), + dict.get<scalar>("outerRadius"), + dict.get<scalar>("innerRadius") + ) {} @@ -113,7 +142,7 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), point1_(checkIs(is)), point2_(checkIs(is)), outerRadius_(readScalar(checkIs(is))), @@ -129,23 +158,31 @@ void Foam::cylinderAnnulusToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces with centre within cylinder annulus," - << " with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ - << ", inner radius = " << innerRadius_ - << endl; + if (verbose_) + { + Info<< " Adding faces with centre within cylinder annulus," + << " with p1 = " + << point1_ << ", p2 = " << point2_ + << ", radius = " << outerRadius_ + << ", inner radius = " << innerRadius_ + << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces with centre within cylinder annulus," - << " with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ - << ", inner radius = " << innerRadius_ - << endl; + if (verbose_) + { + 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 842ac28053e94e0044c6eef0a4b9286411fc54ca..15ec51732c1d7da238030ddfd4e874f5bbb33d4b 100644 --- a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H +++ b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H @@ -25,7 +25,7 @@ Class Foam::cylinderAnnulusToFace Description - A topoSetSource to select faces based on face centres inside a + A topoSetFaceSource to select faces based on face centres inside a cylinder annulus. \heading Dictionary parameters @@ -45,7 +45,7 @@ SourceFiles #ifndef cylinderAnnulusToFace_H #define cylinderAnnulusToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,7 +58,7 @@ namespace Foam class cylinderAnnulusToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -115,11 +115,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C index 0e82f1d94d6aabdaf3f18e9340d3c1f713a24fbf..a4806d99f701912d0eeaf931ac3a64f58420312b 100644 --- a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C +++ b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(cylinderToFace, 0); addToRunTimeSelectionTable(topoSetSource, cylinderToFace, word); addToRunTimeSelectionTable(topoSetSource, cylinderToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, cylinderToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, cylinderToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderToFace, + word, + cylinder + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + cylinderToFace, + istream, + cylinder + ); } @@ -82,7 +98,7 @@ Foam::cylinderToFace::cylinderToFace const scalar radius ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), point1_(point1), point2_(point2), radius_(radius) @@ -95,10 +111,13 @@ Foam::cylinderToFace::cylinderToFace const dictionary& dict ) : - topoSetSource(mesh), - point1_(dict.get<point>("p1")), - point2_(dict.get<point>("p2")), - radius_(dict.get<scalar>("radius")) + cylinderToFace + ( + mesh, + dict.get<point>("p1"), + dict.get<point>("p2"), + dict.get<scalar>("radius") + ) {} @@ -108,7 +127,7 @@ Foam::cylinderToFace::cylinderToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), point1_(checkIs(is)), point2_(checkIs(is)), radius_(readScalar(checkIs(is))) @@ -123,19 +142,25 @@ void Foam::cylinderToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces with centre within cylinder, with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ - << endl; + if (verbose_) + { + Info<< " Adding faces with centre within cylinder, with p1 = " + << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ + << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces with centre within cylinder, with p1 = " - << point1_ << ", p2 = " << point2_ << ", radius = " << radius_ - << endl; + if (verbose_) + { + Info<< " Removing faces with centre within cylinder, with p1 = " + << 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 6a2c4fe39e38171c006446efc54a05c01dc7b2b2..e159302afed2c2e1cb0905915de13b86378d2f7e 100644 --- a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H +++ b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H @@ -25,7 +25,7 @@ Class Foam::cylinderToFace Description - A topoSetSource to select faces based on face centres inside a cylinder. + A topoSetFaceSource to select faces based on face centres inside a cylinder. \heading Dictionary parameters \table @@ -43,7 +43,7 @@ SourceFiles #ifndef cylinderToFace_H #define cylinderToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class cylinderToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -109,11 +109,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/faceToFace/faceToFace.C b/src/meshTools/sets/faceSources/faceToFace/faceToFace.C index e3ee6f8d60ac1667ca41473f63dacbfb8d757ca2..c94a4be4da2efb30a51e94309a5eb985ec089507 100644 --- a/src/meshTools/sets/faceSources/faceToFace/faceToFace.C +++ b/src/meshTools/sets/faceSources/faceToFace/faceToFace.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(faceToFace, 0); addToRunTimeSelectionTable(topoSetSource, faceToFace, word); addToRunTimeSelectionTable(topoSetSource, faceToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, istream); } @@ -54,7 +56,7 @@ Foam::faceToFace::faceToFace const word& setName ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(setName) {} @@ -65,8 +67,11 @@ Foam::faceToFace::faceToFace const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")) + faceToFace + ( + mesh, + dict.get<word>("set") + ) {} @@ -76,7 +81,7 @@ Foam::faceToFace::faceToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(checkIs(is)) {} @@ -89,25 +94,31 @@ void Foam::faceToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from faceSet " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the set faceSet loadedSet(mesh_, setName_); set.addSet(loadedSet); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from faceSet " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the set faceSet loadedSet(mesh_, setName_); - set.deleteSet(loadedSet); + set.subtractSet(loadedSet); } } diff --git a/src/meshTools/sets/faceSources/faceToFace/faceToFace.H b/src/meshTools/sets/faceSources/faceToFace/faceToFace.H index 58ed57bedd34549cd499fa4fabe6b84629a8d4fa..452d21df0c34b5f53602b18b1d48723eed380e1a 100644 --- a/src/meshTools/sets/faceSources/faceToFace/faceToFace.H +++ b/src/meshTools/sets/faceSources/faceToFace/faceToFace.H @@ -25,7 +25,7 @@ Class Foam::faceToFace Description - A topoSetSource to select faces based on usage in another faceSet. + A topoSetFaceSource to select faces based on usage in another faceSet. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef faceToFace_H #define faceToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class faceToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -72,11 +72,7 @@ public: // Constructors //- Construct from components - faceToFace - ( - const polyMesh& mesh, - const word& setName - ); + faceToFace(const polyMesh& mesh, const word& setName); //- Construct from dictionary faceToFace(const polyMesh& mesh, const dictionary& dict); @@ -91,11 +87,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/labelToFace/labelToFace.C b/src/meshTools/sets/faceSources/labelToFace/labelToFace.C index 4ea83806cf57334c601906e329213af85ce2d14b..16899058b0943e3a655f85a6c1abe1b173723cb2 100644 --- a/src/meshTools/sets/faceSources/labelToFace/labelToFace.C +++ b/src/meshTools/sets/faceSources/labelToFace/labelToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(labelToFace, 0); addToRunTimeSelectionTable(topoSetSource, labelToFace, word); addToRunTimeSelectionTable(topoSetSource, labelToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, labelToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, labelToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + labelToFace, + word, + label + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + labelToFace, + istream, + label + ); } @@ -53,19 +69,33 @@ Foam::labelToFace::labelToFace const labelList& labels ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), labels_(labels) {} +Foam::labelToFace::labelToFace +( + const polyMesh& mesh, + labelList&& labels +) +: + topoSetFaceSource(mesh), + labels_(std::move(labels)) +{} + + Foam::labelToFace::labelToFace ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), - labels_(dict.get<labelList>("value")) + labelToFace + ( + mesh, + dict.get<labelList>("value") + ) {} @@ -75,7 +105,7 @@ Foam::labelToFace::labelToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), labels_(checkIs(is)) { check(labels_, mesh.nFaces()); @@ -90,15 +120,23 @@ void Foam::labelToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces mentioned in dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Adding faces mentioned in dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces mentioned dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Removing faces mentioned dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, false); } diff --git a/src/meshTools/sets/faceSources/labelToFace/labelToFace.H b/src/meshTools/sets/faceSources/labelToFace/labelToFace.H index 53bc405a78e005c0dc87ff3acf782447ba167292..96635f525c102e578fa4f871e33517856b942fdc 100644 --- a/src/meshTools/sets/faceSources/labelToFace/labelToFace.H +++ b/src/meshTools/sets/faceSources/labelToFace/labelToFace.H @@ -25,7 +25,7 @@ Class Foam::labelToFace Description - A topoSetSource to select faces given explicitly provided face labels. + A topoSetFaceSource to select faces given explicitly provided face labels. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef labelToFace_H #define labelToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,7 +55,7 @@ namespace Foam class labelToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -74,12 +74,11 @@ public: // Constructors - //- Construct from components - labelToFace - ( - const polyMesh& mesh, - const labelList& labels - ); + //- Construct from components, copying labels + labelToFace(const polyMesh& mesh, const labelList& labels); + + //- Construct from components, moving labels + labelToFace(const polyMesh& mesh, labelList&& labels); //- Construct from dictionary labelToFace(const polyMesh& mesh, const dictionary& dict); @@ -94,11 +93,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/normalToFace/normalToFace.C b/src/meshTools/sets/faceSources/normalToFace/normalToFace.C index d16998d626586f61e7d4f720d437844ebd31cf6d..162bdf15ecb82fd9bf48350e20664aa2b3353d60 100644 --- a/src/meshTools/sets/faceSources/normalToFace/normalToFace.C +++ b/src/meshTools/sets/faceSources/normalToFace/normalToFace.C @@ -35,6 +35,22 @@ namespace Foam defineTypeNameAndDebug(normalToFace, 0); addToRunTimeSelectionTable(topoSetSource, normalToFace, word); addToRunTimeSelectionTable(topoSetSource, normalToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, normalToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, normalToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + normalToFace, + word, + normal + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + normalToFace, + istream, + normal + ); } @@ -53,8 +69,6 @@ void Foam::normalToFace::setNormal() { normal_.normalise(); - Info<< " normalToFace : Normalized vector to " << normal_ << endl; - if (tol_ < -1 || tol_ > 1) { FatalErrorInFunction @@ -73,7 +87,7 @@ Foam::normalToFace::normalToFace const scalar tol ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), normal_(normal), tol_(tol) { @@ -83,9 +97,12 @@ Foam::normalToFace::normalToFace Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict) : - topoSetSource(mesh), - normal_(dict.get<vector>("normal")), - tol_(dict.get<scalar>("cos")) + normalToFace + ( + mesh, + dict.get<vector>("normal"), + dict.get<scalar>("cos") + ) { setNormal(); } @@ -93,7 +110,7 @@ Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict) Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is) : - topoSetSource(mesh), + topoSetFaceSource(mesh), normal_(checkIs(is)), tol_(readScalar(checkIs(is))) { @@ -109,10 +126,13 @@ void Foam::normalToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces according to normal being aligned with " - << normal_ << " (to within " << tol_ << ") ..." << endl; + if (verbose_) + { + Info<< " Adding faces according to normal being aligned with " + << normal_ << " (to within " << tol_ << ") ..." << endl; + } forAll(mesh_.faceAreas(), facei) { @@ -120,21 +140,22 @@ void Foam::normalToFace::applyToSet if (mag(1 - (n & normal_)) < tol_) { - set.insert(facei); + set.set(facei); } } } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces according to normal being aligned with " - << normal_ << " (to within " << tol_ << ") ..." << endl; + if (verbose_) + { + Info<< " Removing faces according to normal being aligned with " + << normal_ << " (to within " << tol_ << ") ..." << endl; + } DynamicList<label> toBeRemoved(set.size()/10); - forAllConstIter(topoSet, set, iter) + for (const label facei : static_cast<const labelHashSet&>(set)) { - const label facei = iter.key(); - const vector n = normalised(mesh_.faceAreas()[facei]); if (mag(1 - (n & normal_)) < tol_) @@ -143,7 +164,7 @@ void Foam::normalToFace::applyToSet } } - set.erase(toBeRemoved); + set.unset(toBeRemoved); } } diff --git a/src/meshTools/sets/faceSources/normalToFace/normalToFace.H b/src/meshTools/sets/faceSources/normalToFace/normalToFace.H index c27635615306d2455a4396776881aee36d07e642..09176ab29d986d047edd9349916d21102210fc28 100644 --- a/src/meshTools/sets/faceSources/normalToFace/normalToFace.H +++ b/src/meshTools/sets/faceSources/normalToFace/normalToFace.H @@ -25,7 +25,7 @@ Class Foam::normalToFace Description - A topoSetSource to select faces based on normal. + A topoSetFaceSource to select faces based on normal. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef normalToFace_H #define normalToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,7 +55,7 @@ namespace Foam class normalToFace : - public topoSetSource + public topoSetFaceSource { private: @@ -104,11 +104,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C index 9694a42fa4718d701df8f8b8cc3f495ac5312a1f..b2529bf378f82b85ad82c1c678514b103932652c 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(patchToFace, 0); addToRunTimeSelectionTable(topoSetSource, patchToFace, word); addToRunTimeSelectionTable(topoSetSource, patchToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, patchToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, patchToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + patchToFace, + word, + patch + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + patchToFace, + istream, + patch + ); } @@ -51,7 +67,7 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const { labelHashSet patchIDs = mesh_.boundaryMesh().patchSet ( - List<wordRe>(1, patchName_), + selectedPatches_, true, // warn if not found true // use patch groups if available ); @@ -60,8 +76,11 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const { const polyPatch& pp = mesh_.boundaryMesh()[patchi]; - Info<< " Found matching patch " << pp.name() - << " with " << pp.size() << " faces." << endl; + if (verbose_) + { + Info<< " Found matching patch " << pp.name() + << " with " << pp.size() << " faces." << endl; + } for ( @@ -77,8 +96,10 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const if (patchIDs.empty()) { WarningInFunction - << "Cannot find any patch named " << patchName_ << endl - << "Valid names are " << mesh_.boundaryMesh().names() << endl; + << "Cannot find any patches matching " + << flatOutput(selectedPatches_) << nl + << "Valid names are " << flatOutput(mesh_.boundaryMesh().names()) + << endl; } } @@ -88,11 +109,11 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const Foam::patchToFace::patchToFace ( const polyMesh& mesh, - const word& patchName + const wordRe& patchName ) : - topoSetSource(mesh), - patchName_(patchName) + topoSetFaceSource(mesh), + selectedPatches_(one(), patchName) {} @@ -102,9 +123,17 @@ Foam::patchToFace::patchToFace const dictionary& dict ) : - topoSetSource(mesh), - patchName_(dict.get<wordRe>("name")) -{} + topoSetFaceSource(mesh), + selectedPatches_() +{ + // Look for 'patches' and 'patch', but accept 'name' as well + if (!dict.readIfPresent("patches", selectedPatches_)) + { + selectedPatches_.resize(1); + selectedPatches_.first() = + dict.getCompat<wordRe>("patch", {{"name", 1806}}); + } +} Foam::patchToFace::patchToFace @@ -113,8 +142,8 @@ Foam::patchToFace::patchToFace Istream& is ) : - topoSetSource(mesh), - patchName_(checkIs(is)) + topoSetFaceSource(mesh), + selectedPatches_(one(), wordRe(checkIs(is))) {} @@ -126,16 +155,23 @@ void Foam::patchToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces of patch " << patchName_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces of patches " + << flatOutput(selectedPatches_) << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces of patch " << patchName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all faces of patches " + << flatOutput(selectedPatches_) << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.H b/src/meshTools/sets/faceSources/patchToFace/patchToFace.H index e956cc516cdedadd2f7e189e226f1a062ea0618b..f30657e494033d1ac73d24b5cc6012740dcd99f6 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.H +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.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,14 +25,19 @@ Class Foam::patchToFace Description - A topoSetSource to select faces based on usage in patches. + A topoSetFaceSource to select faces based on usage in patches. \heading Dictionary parameters \table - Property | Description | Required | Default - name | Patch name or regex to select | yes | + Property | Description | Required | Default + patch | The face zone name or regex | possibly | + patches | The face zone names or regexs | possibly | + name | Older specification for 'patch' | no | \endtable +Note + Selection of multiple patches has precedence. + SourceFiles patchToFace.C @@ -41,8 +46,8 @@ SourceFiles #ifndef patchToFace_H #define patchToFace_H -#include "topoSetSource.H" -#include "wordRe.H" +#include "topoSetFaceSource.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,7 +60,7 @@ namespace Foam class patchToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -63,8 +68,8 @@ class patchToFace //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of patch - wordRe patchName_; + //- Matcher for patches + wordRes selectedPatches_; // Private Member Functions @@ -80,11 +85,7 @@ public: // Constructors //- Construct from components - patchToFace - ( - const polyMesh& mesh, - const word& patchName - ); + patchToFace(const polyMesh& mesh, const wordRe& patchName); //- Construct from dictionary patchToFace(const polyMesh& mesh, const dictionary& dict); @@ -99,11 +100,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C index 21a1953cf8cfab776a094f4acc5a65424b9e6af3..ba32284bdec457854cb8e78c4362a98f4e552ae4 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C @@ -35,6 +35,22 @@ namespace Foam defineTypeNameAndDebug(pointToFace, 0); addToRunTimeSelectionTable(topoSetSource, pointToFace, word); addToRunTimeSelectionTable(topoSetSource, pointToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, pointToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, pointToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + pointToFace, + word, + point + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + pointToFace, + istream, + point + ); } @@ -147,7 +163,7 @@ Foam::pointToFace::pointToFace const pointAction option ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(setName), option_(option) {} @@ -159,9 +175,12 @@ Foam::pointToFace::pointToFace const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(pointActionNames_.get("option", dict)) + pointToFace + ( + mesh, + dict.get<word>("set"), + pointActionNames_.get("option", dict) + ) {} @@ -171,7 +190,7 @@ Foam::pointToFace::pointToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(checkIs(is)), option_(pointActionNames_.read(checkIs(is))) {} @@ -185,17 +204,23 @@ void Foam::pointToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding faces according to pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding faces according to pointSet " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing faces according to pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing faces according to pointSet " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H index 3e1ceb9f11162a735c7e3bef8ddbfec487914652..584e27bcb5d2f3163ab3044a21e86125e8ca6607 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H @@ -25,7 +25,7 @@ Class Foam::pointToFace Description - A topoSetSource to select faces based on use of points. + A topoSetFaceSource to select faces based on use of points. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef pointToFace_H #define pointToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class pointToFace : - public topoSetSource + public topoSetFaceSource { public: @@ -118,11 +118,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/regionToFace/regionToFace.C b/src/meshTools/sets/faceSources/regionToFace/regionToFace.C index 4825c804c60124788ce934ee1643d766dc9d0c5b..0bc632224002dff555066699f515bcb96db96684 100644 --- a/src/meshTools/sets/faceSources/regionToFace/regionToFace.C +++ b/src/meshTools/sets/faceSources/regionToFace/regionToFace.C @@ -40,6 +40,22 @@ namespace Foam defineTypeNameAndDebug(regionToFace, 0); addToRunTimeSelectionTable(topoSetSource, regionToFace, word); addToRunTimeSelectionTable(topoSetSource, regionToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, regionToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, regionToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + regionToFace, + word, + region + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + regionToFace, + istream, + region + ); } @@ -108,8 +124,11 @@ void Foam::regionToFace::markZone void Foam::regionToFace::combine(topoSet& set, const bool add) const { - Info<< " Loading subset " << setName_ - << " to delimit search region." << endl; + if (verbose_) + { + Info<< " Loading subset " << setName_ + << " to delimit search region." << endl; + } faceSet subSet(mesh_, setName_); @@ -146,10 +165,13 @@ void Foam::regionToFace::combine(topoSet& set, const bool add) const // Globally reduce combineReduce(ni, mappedPatchBase::nearestEqOp()); - Info<< " Found nearest face at " << ni.first().rawPoint() - << " on processor " << ni.second().second() - << " face " << ni.first().index() - << " distance " << Foam::sqrt(ni.second().first()) << endl; + if (verbose_) + { + Info<< " Found nearest face at " << ni.first().rawPoint() + << " on processor " << ni.second().second() + << " face " << ni.first().index() + << " distance " << Foam::sqrt(ni.second().first()) << endl; + } labelList faceRegion(patch.size(), -1); markZone @@ -180,7 +202,7 @@ Foam::regionToFace::regionToFace const point& nearPoint ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(setName), nearPoint_(nearPoint) {} @@ -192,7 +214,7 @@ Foam::regionToFace::regionToFace const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(dict.get<word>("set")), nearPoint_(dict.get<point>("nearPoint")) {} @@ -204,7 +226,7 @@ Foam::regionToFace::regionToFace Istream& is ) : - topoSetSource(mesh), + topoSetFaceSource(mesh), setName_(checkIs(is)), nearPoint_(checkIs(is)) {} @@ -218,21 +240,25 @@ void Foam::regionToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces of connected region of set " - << setName_ - << " starting from point " - << nearPoint_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces of connected region of set " + << setName_ << " starting from point " << nearPoint_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells of connected region of set " - << setName_ - << " starting from point " - << nearPoint_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all cells of connected region of set " + << setName_ << " starting from point " << nearPoint_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/regionToFace/regionToFace.H b/src/meshTools/sets/faceSources/regionToFace/regionToFace.H index fedd9d86d07ef6a3477f136b6f78de00c9673f7c..c3d79a55201f97229a8a5db7cd37d4e0fdfa1a55 100644 --- a/src/meshTools/sets/faceSources/regionToFace/regionToFace.H +++ b/src/meshTools/sets/faceSources/regionToFace/regionToFace.H @@ -25,8 +25,8 @@ Class Foam::regionToFace Description - A topoSetSource to select faces belonging to topological connected region - (that contains given point) + A topoSetFaceSource to select faces belonging to a topological connected + region (that contains given point) \heading Dictionary parameters \table @@ -43,7 +43,7 @@ SourceFiles #ifndef regionToFace_H #define regionToFace_H -#include "topoSetSource.H" +#include "topoSetFaceSource.H" #include "indirectPrimitivePatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +57,7 @@ namespace Foam class regionToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -113,11 +113,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C new file mode 100644 index 0000000000000000000000000000000000000000..bc3cc62c2516df84d574bb047fb18546e9e1f78f --- /dev/null +++ b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "topoSetFaceSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(topoSetFaceSource, 0); + defineRunTimeSelectionTable(topoSetFaceSource, word); + defineRunTimeSelectionTable(topoSetFaceSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetFaceSource::topoSetFaceSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetFaceSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetFaceSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetFaceSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << istreamConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetFaceSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H new file mode 100644 index 0000000000000000000000000000000000000000..018275ff59ca89b8ba8d37ad562237f8c5500abe --- /dev/null +++ b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::topoSetFaceSource + +Description + Base class of a topoSet source for selecting faces. + +SourceFiles + topoSetFaceSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetFaceSource_H +#define topoSetFaceSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class topoSetFaceSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetFaceSource +: + public topoSetSource +{ +public: + + //- Runtime type information + TypeName("topoSetFaceSource"); + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetFaceSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetFaceSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetFaceSource(const polyMesh& mesh); + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetFaceSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetFaceSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetFaceSource() = default; + + + // Member Functions + + virtual topoSetSource::sourceType setType() const + { + return FACESETSOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C index ea9090c0562e8c4d002d1885005f28872fa57e05..dc392765001e9f1e5d8fe5ac053e1eaa9f9e56c4 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(zoneToFace, 0); addToRunTimeSelectionTable(topoSetSource, zoneToFace, word); addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, word); + addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, istream); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + zoneToFace, + word, + zone + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceSource, + zoneToFace, + istream, + zone + ); } @@ -54,14 +70,17 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const for (const faceZone& zone : mesh_.faceZones()) { - if (zoneName_.match(zone.name())) + if (selectedZones_.match(zone.name())) { hasMatched = true; const labelList& faceLabels = zone; - Info<< " Found matching zone " << zone.name() - << " with " << faceLabels.size() << " faces." << endl; + if (verbose_) + { + Info<< " Found matching zone " << zone.name() + << " with " << faceLabels.size() << " faces." << endl; + } for (const label facei : faceLabels) { @@ -77,8 +96,10 @@ void Foam::zoneToFace::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 matching " + << flatOutput(selectedZones_) << nl + << "Valid names are " << flatOutput(mesh_.faceZones().names()) + << endl; } } @@ -88,11 +109,11 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const Foam::zoneToFace::zoneToFace ( const polyMesh& mesh, - const word& zoneName + const wordRe& zoneName ) : - topoSetSource(mesh), - zoneName_(zoneName) + topoSetFaceSource(mesh), + selectedZones_(one(), zoneName) {} @@ -102,9 +123,17 @@ Foam::zoneToFace::zoneToFace const dictionary& dict ) : - topoSetSource(mesh), - zoneName_(dict.get<wordRe>("name")) -{} + topoSetFaceSource(mesh), + selectedZones_() +{ + // Look for 'zones' and 'zone', but accept 'name' as well + if (!dict.readIfPresent("zones", selectedZones_)) + { + selectedZones_.resize(1); + selectedZones_.first() = + dict.getCompat<wordRe>("zone", {{"name", 1806}}); + } +} Foam::zoneToFace::zoneToFace @@ -113,8 +142,8 @@ Foam::zoneToFace::zoneToFace Istream& is ) : - topoSetSource(mesh), - zoneName_(checkIs(is)) + topoSetFaceSource(mesh), + selectedZones_(one(), wordRe(checkIs(is))) {} @@ -126,17 +155,23 @@ void Foam::zoneToFace::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces of faceZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all faces of face zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces of faceZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all faces of face zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H index 35d9c23ebe0edc40180bb893f6b23a66e95a043b..4c20ee4d96c077193771edf67cfecec18baf8d99 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.H @@ -25,14 +25,19 @@ Class Foam::zoneToFace Description - A topoSetSource to select faces based on faceZone. + A topoSetFaceSource to select faces based on one of more faceZones. \heading Dictionary parameters \table - Property | Description | Required | Default - name | The face zone name or regex | yes | + Property | Description | Required | Default + zone | The face zone name or regex | possibly | + zones | The face zone names or regexs | possibly | + name | Older specification for 'zone' | no | \endtable +Note + Selection of multiple zones has precedence. + SourceFiles zoneToFace.C @@ -41,8 +46,8 @@ SourceFiles #ifndef zoneToFace_H #define zoneToFace_H -#include "topoSetSource.H" -#include "wordRe.H" +#include "topoSetFaceSource.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,12 +55,12 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class zoneToFace Declaration + Class zoneToFace Declaration \*---------------------------------------------------------------------------*/ class zoneToFace : - public topoSetSource + public topoSetFaceSource { // Private data @@ -63,8 +68,8 @@ class zoneToFace //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of the faceZone - wordRe zoneName_; + //- Matcher for zones + wordRes selectedZones_; // Private Member Functions @@ -80,11 +85,7 @@ public: // Constructors //- Construct from components - zoneToFace - ( - const polyMesh& mesh, - const word& zoneName - ); + zoneToFace(const polyMesh& mesh, const wordRe& zoneName); //- Construct from dictionary zoneToFace(const polyMesh& mesh, const dictionary& dict); @@ -99,11 +100,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C index dfd056ae0ad2034622a9aae9d4d2fb8ebec2e251..d589d3d8c4606a2c85a869ca9b3f14372cab050b 100644 --- a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C @@ -96,53 +96,59 @@ void Foam::faceZoneToFaceZone::applyToSet } else { - faceZoneSet& fSet = refCast<faceZoneSet>(set); + faceZoneSet& zoneSet = refCast<faceZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from faceZone " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all faces from faceZone " << setName_ + << " ..." << endl; + } // Load the set faceZoneSet loadedSet(mesh_, setName_); - DynamicList<label> newAddressing(fSet.addressing()); - DynamicList<bool> newFlipMap(fSet.flipMap()); + DynamicList<label> newAddressing(zoneSet.addressing()); + DynamicList<bool> newFlipMap(zoneSet.flipMap()); forAll(loadedSet.addressing(), i) { - if (!fSet.found(loadedSet.addressing()[i])) + if (!zoneSet.found(loadedSet.addressing()[i])) { newAddressing.append(loadedSet.addressing()[i]); newFlipMap.append(loadedSet.flipMap()[i]); } } - fSet.addressing().transfer(newAddressing); - fSet.flipMap().transfer(newFlipMap); - fSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from faceZone " << setName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all faces from faceZone " << setName_ + << " ..." << endl; + } // Load the set faceZoneSet loadedSet(mesh_, setName_); - DynamicList<label> newAddressing(fSet.addressing().size()); - DynamicList<bool> newFlipMap(fSet.flipMap().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); + DynamicList<bool> newFlipMap(zoneSet.flipMap().size()); - forAll(fSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fSet.addressing()[i]); - newFlipMap.append(fSet.flipMap()[i]); + newAddressing.append(zoneSet.addressing()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } - fSet.addressing().transfer(newAddressing); - fSet.flipMap().transfer(newFlipMap); - fSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index 173c852cd691b8626b248536a89209be449ff3a6..71c983befe041c42edeafe30053c1743110b1526 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -58,6 +58,7 @@ Foam::topoSetSource::addToUsageTable Foam::searchableSurfaceToFaceZone::usage_ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone ( + const word& surfaceType, const polyMesh& mesh, const dictionary& dict ) @@ -67,7 +68,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone ( searchableSurface::New ( - dict.get<word>("surface"), + surfaceType, IOobject ( dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), @@ -83,6 +84,21 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone {} +Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + searchableSurfaceToFaceZone + ( + dict.get<word>("surface"), + mesh, + dict + ) +{} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::searchableSurfaceToFaceZone::~searchableSurfaceToFaceZone() @@ -162,10 +178,13 @@ void Foam::searchableSurfaceToFaceZone::applyToSet // Select intersected faces // ~~~~~~~~~~~~~~~~~~~~~~~~ - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from surface " - << surfacePtr_().name() << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces from surface " + << surfacePtr_().name() << " ..." << endl; + } DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<bool> newFlipMap(fzSet.flipMap()); @@ -184,10 +203,13 @@ void Foam::searchableSurfaceToFaceZone::applyToSet fzSet.flipMap().transfer(newFlipMap); fzSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from surface " - << surfacePtr_().name() << " ..." << endl; + if (verbose_) + { + Info<< " Removing all faces from surface " + << surfacePtr_().name() << " ..." << endl; + } // Start off empty DynamicList<label> newAddressing(fzSet.addressing().size()); diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H index a5507dd1faf36fe31069bb1fe34099c88656f029..100c481eef56cb1461a792d66e7685639bec0829 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H @@ -75,6 +75,15 @@ public: // Constructors + //- Construct surface-type from dictionary + searchableSurfaceToFaceZone + ( + const word& surfaceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from dictionary searchableSurfaceToFaceZone ( @@ -89,7 +98,7 @@ public: // Member Functions - virtual sourceType setType() const + virtual topoSetSource::sourceType setType() const { return FACEZONESOURCE; } diff --git a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C index 3b4e6ed5b7a7978beca40adcbbcf66936279b8b8..1470d91960c305a53f4e553398bcd885f964ec34 100644 --- a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C @@ -100,27 +100,30 @@ void Foam::setAndNormalToFaceZone::applyToSet } else { - faceZoneSet& fzSet = refCast<faceZoneSet>(set); + faceZoneSet& zoneSet = refCast<faceZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the sets faceSet loadedSet(mesh_, setName_); labelHashSet& faceIds = loadedSet; // Start off from copy - DynamicList<label> newAddressing(fzSet.addressing()); - DynamicList<bool> newFlipMap(fzSet.flipMap()); + DynamicList<label> newAddressing(zoneSet.addressing()); + DynamicList<bool> newFlipMap(zoneSet.flipMap()); const faceList& faces = mesh_.faces(); const pointField& points = mesh_.points(); for (const label facei : faceIds) { - if (!fzSet.found(facei)) + if (!zoneSet.found(facei)) { newAddressing.append(facei); @@ -136,33 +139,36 @@ void Foam::setAndNormalToFaceZone::applyToSet } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the set faceSet loadedSet(mesh_, setName_); // Start off empty - DynamicList<label> newAddressing(fzSet.addressing().size()); - DynamicList<bool> newFlipMap(fzSet.flipMap().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); + DynamicList<bool> newFlipMap(zoneSet.flipMap().size()); - forAll(fzSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fzSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fzSet.addressing()[i]); - newFlipMap.append(fzSet.flipMap()[i]); + newAddressing.append(zoneSet.addressing()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C index 3ed303102b5b2c44c094ca406cac2cea7b87bbde..04228b9f439849901240979f957e77d55b34330b 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C @@ -97,57 +97,63 @@ void Foam::setToFaceZone::applyToSet } else { - faceZoneSet& fzSet = refCast<faceZoneSet>(set); + faceZoneSet& zoneSet = refCast<faceZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the sets faceSet loadedSet(mesh_, setName_); const labelHashSet& faceLabels = loadedSet; // Start off from copy - DynamicList<label> newAddressing(fzSet.addressing()); - DynamicList<bool> newFlipMap(fzSet.flipMap()); + DynamicList<label> newAddressing(zoneSet.addressing()); + DynamicList<bool> newFlipMap(zoneSet.flipMap()); for (const label facei : faceLabels) { - if (!fzSet.found(facei)) + if (!zoneSet.found(facei)) { newAddressing.append(facei); newFlipMap.append(false); } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing all faces from faceSet " << setName_ + << " ..." << endl; + } // Load the set faceSet loadedSet(mesh_, setName_); // Start off empty - DynamicList<label> newAddressing(fzSet.addressing().size()); - DynamicList<bool> newFlipMap(fzSet.flipMap().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); + DynamicList<bool> newFlipMap(zoneSet.flipMap().size()); - forAll(fzSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fzSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fzSet.addressing()[i]); - newFlipMap.append(fzSet.flipMap()[i]); + newAddressing.append(zoneSet.addressing()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H index f82d796eeb0b5258c7ede09ea82b3e5099281c15..843c3fa66a74689080df96069062ab275ee0858b 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H @@ -30,8 +30,8 @@ Description \heading Dictionary parameters \table - Property | Description | Required | Default - faceSet | Name of input faceSet | yes | + Property | Description | Required | Default + faceSet | Name of input faceSet | yes | \endtable Note diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C index 8c016ea7f6cf998c601cf2d321d71f6f18187f2e..0942e4474bc1a454c4b999753c5063218579af52 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C @@ -106,26 +106,29 @@ void Foam::setsToFaceZone::applyToSet } else { - faceZoneSet& fzSet = refCast<faceZoneSet>(set); + faceZoneSet& zoneSet = refCast<faceZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all faces from faceSet " << faceSetName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding all faces from faceSet " << faceSetName_ + << " ..." << endl; + } // Load the sets faceSet fSet(mesh_, faceSetName_); cellSet cSet(mesh_, cellSetName_); // Start off from copy - DynamicList<label> newAddressing(fzSet.addressing()); - DynamicList<bool> newFlipMap(fzSet.flipMap()); + DynamicList<label> newAddressing(zoneSet.addressing()); + DynamicList<bool> newFlipMap(zoneSet.flipMap()); forAllConstIter(faceSet, fSet, iter) { label facei = iter.key(); - if (!fzSet.found(facei)) + if (!zoneSet.found(facei)) { bool flipFace = false; @@ -176,33 +179,36 @@ void Foam::setsToFaceZone::applyToSet } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all faces from faceSet " << faceSetName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing all faces from faceSet " << faceSetName_ + << " ..." << endl; + } // Load the set faceZoneSet loadedSet(mesh_, faceSetName_); // Start off empty - DynamicList<label> newAddressing(fzSet.addressing().size()); - DynamicList<bool> newFlipMap(fzSet.flipMap().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); + DynamicList<bool> newFlipMap(zoneSet.flipMap().size()); - forAll(fzSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fzSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fzSet.addressing()[i]); - newFlipMap.append(fzSet.flipMap()[i]); + newAddressing.append(zoneSet.addressing()[i]); + newFlipMap.append(zoneSet.flipMap()[i]); } } - fzSet.addressing().transfer(newAddressing); - fzSet.flipMap().transfer(newFlipMap); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.flipMap().transfer(newFlipMap); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H index 81bd21094065f29c67faafcd0c8adfa27f97374d..02d5d9048507635ff87c580551e956686b796ba0 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H @@ -29,10 +29,10 @@ Description \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 + 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 diff --git a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C index b907152dcc5735d1aad7ec98d62d5f2de85547a5..a76ea3aed61eaf993ba2c27957490e975210bf9d 100644 --- a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C +++ b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(boxToPoint, 0); addToRunTimeSelectionTable(topoSetSource, boxToPoint, word); addToRunTimeSelectionTable(topoSetSource, boxToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, boxToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, boxToPoint, istream); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + boxToPoint, + word, + box + ); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + boxToPoint, + istream, + box + ); } @@ -73,29 +89,37 @@ Foam::boxToPoint::boxToPoint const treeBoundBoxList& bbs ) : - topoSetSource(mesh), + topoSetPointSource(mesh), bbs_(bbs) {} +Foam::boxToPoint::boxToPoint +( + const polyMesh& mesh, + treeBoundBoxList&& bbs +) +: + topoSetPointSource(mesh), + bbs_(std::move(bbs)) +{} + + Foam::boxToPoint::boxToPoint ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetPointSource(mesh), bbs_() { - if (dict.found("box")) + // Look for 'boxes' or 'box' + if (!dict.readIfPresent("boxes", bbs_)) { bbs_.resize(1); dict.readEntry("box", bbs_.first()); } - else - { - dict.readEntry("boxes", bbs_); - } } @@ -105,8 +129,8 @@ Foam::boxToPoint::boxToPoint Istream& is ) : - topoSetSource(mesh), - bbs_(1, treeBoundBox(checkIs(is))) + topoSetPointSource(mesh), + bbs_(one(), treeBoundBox(checkIs(is))) {} @@ -118,17 +142,23 @@ void Foam::boxToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding points that are within boxes " << bbs_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding points that are within boxes " << bbs_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing points that are within boxes " << bbs_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing points that are within boxes " << bbs_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H index 474c1538ffc04ac9ff9138996a2c3bfe6bd80acb..36fe9544b9d299620f769115a76d878cea9f1066 100644 --- a/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H +++ b/src/meshTools/sets/pointSources/boxToPoint/boxToPoint.H @@ -25,17 +25,18 @@ Class Foam::boxToPoint Description - A topoSetSource to select points based on whether they are inside box. + A topoSetPointSource 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 | + Property | Description | Required | Default + box | A single bounding box | partly | + boxes | Multiple bounding boxes | partly | \endtable Note - Must specify either "box" or "boxes" + Must specify either "box" or "boxes". + The selection of multiple boxes has precedence. SourceFiles boxToPoint.C @@ -45,7 +46,7 @@ SourceFiles #ifndef boxToPoint_H #define boxToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" #include "treeBoundBoxList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,7 +60,7 @@ namespace Foam class boxToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -83,12 +84,11 @@ public: // Constructors - //- Construct from components - boxToPoint - ( - const polyMesh& mesh, - const treeBoundBoxList& bbs - ); + //- Construct from components, copying bounding boxes + boxToPoint(const polyMesh& mesh, const treeBoundBoxList& bbs); + + //- Construct from components, moving bounding boxes + boxToPoint(const polyMesh& mesh, treeBoundBoxList&& bbs); //- Construct from dictionary boxToPoint(const polyMesh& mesh, const dictionary& dict); @@ -103,11 +103,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C index 8ef233ec156e9971f7354cfc9576ebf179a1d932..3bc3ff3a719a7baa8fef586b60e86e5bd7ab88bc 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(cellToPoint, 0); addToRunTimeSelectionTable(topoSetSource, cellToPoint, word); addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, cellToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, cellToPoint, istream); } @@ -90,7 +92,7 @@ Foam::cellToPoint::cellToPoint const cellAction option ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(setName), option_(option) {} @@ -102,9 +104,12 @@ Foam::cellToPoint::cellToPoint const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(cellActionNames_.get("option", dict)) + cellToPoint + ( + mesh, + dict.get<word>("set"), + cellActionNames_.get("option", dict) + ) {} @@ -114,7 +119,7 @@ Foam::cellToPoint::cellToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(checkIs(is)), option_(cellActionNames_.read(checkIs(is))) {} @@ -128,15 +133,23 @@ void Foam::cellToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding from " << setName_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding from " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing from " << setName_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing from " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H index 7bf16ea8534b41b7ee11f9303306e298982fdb62..f00c71aa39eefba57ce0af0516b05aa28a5f8106 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.H @@ -25,7 +25,7 @@ Class Foam::cellToPoint Description - A topoSetSource to select points based on usage in cells. + A topoSetPointSource to select points based on usage in cells. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef cellToPoint_H #define cellToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class cellToPoint : - public topoSetSource + public topoSetPointSource { public: @@ -114,11 +114,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C index 9f6583eb16402cddc4d999cf597ed3419feda42e..3351a14ad6616401b6bb99a9597114513e596dcb 100644 --- a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C +++ b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(faceToPoint, 0); addToRunTimeSelectionTable(topoSetSource, faceToPoint, word); addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, faceToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, faceToPoint, istream); } Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_ @@ -84,7 +86,7 @@ Foam::faceToPoint::faceToPoint const faceAction option ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(setName), option_(option) {} @@ -96,9 +98,12 @@ Foam::faceToPoint::faceToPoint const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")), - option_(faceActionNames_.get("option", dict)) + faceToPoint + ( + mesh, + dict.get<word>("set"), + faceActionNames_.get("option", dict) + ) {} @@ -108,7 +113,7 @@ Foam::faceToPoint::faceToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(checkIs(is)), option_(faceActionNames_.read(checkIs(is))) {} @@ -122,17 +127,23 @@ void Foam::faceToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding points from face in faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding points from face in faceSet " << setName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing points from face in faceSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing points from face in faceSet " << setName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H index 7a2f3918d3dd6e809f40fb51e24ed5fda4bde734..375a08dd6fed682ebf600bb74a3127666026935f 100644 --- a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H +++ b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.H @@ -25,7 +25,7 @@ Class Foam::faceToPoint Description - A topoSetSource to select points based on usage in faces. + A topoSetPointSource to select points based on usage in faces. \heading Dictionary parameters \table @@ -42,7 +42,7 @@ SourceFiles #ifndef faceToPoint_H #define faceToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +56,7 @@ namespace Foam class faceToPoint : - public topoSetSource + public topoSetPointSource { public: @@ -114,11 +114,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C index 15e19a773b882f1bb1ffe46587f8ce8b1a2d547b..705c85c1fcfca6ac86188a07ea1e799b88f6499b 100644 --- a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C +++ b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(labelToPoint, 0); addToRunTimeSelectionTable(topoSetSource, labelToPoint, word); addToRunTimeSelectionTable(topoSetSource, labelToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, labelToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, labelToPoint, istream); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + labelToPoint, + word, + label + ); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + labelToPoint, + istream, + label + ); } @@ -53,19 +69,29 @@ Foam::labelToPoint::labelToPoint const labelList& labels ) : - topoSetSource(mesh), + topoSetPointSource(mesh), labels_(labels) {} +Foam::labelToPoint::labelToPoint +( + const polyMesh& mesh, + labelList&& labels +) +: + topoSetPointSource(mesh), + labels_(std::move(labels)) +{} + + Foam::labelToPoint::labelToPoint ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), - labels_(dict.get<labelList>("value")) + labelToPoint(mesh, dict.get<labelList>("value")) {} @@ -75,7 +101,7 @@ Foam::labelToPoint::labelToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), labels_(checkIs(is)) { check(labels_, mesh.nPoints()); @@ -90,15 +116,23 @@ void Foam::labelToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding points mentioned in dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Adding points mentioned in dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing points mentioned in dictionary" << " ..." << endl; + if (verbose_) + { + Info<< " Removing points mentioned in dictionary" + << " ..." << endl; + } addOrDelete(set, labels_, false); } diff --git a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H index 5670edcddf690f6fa1d04305029fdc5181833b13..c96f4b9d4ec2808b613e8b0eea92df93fe0de48c 100644 --- a/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H +++ b/src/meshTools/sets/pointSources/labelToPoint/labelToPoint.H @@ -25,7 +25,7 @@ Class Foam::labelToPoint Description - A topoSetSource to select points given explicitly provided labels. + A topoSetPointSource to select points given explicitly provided labels. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef labelToPoint_H #define labelToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class labelToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -73,12 +73,11 @@ public: // Constructors - //- Copy construct from components - labelToPoint - ( - const polyMesh& mesh, - const labelList& labels - ); + //- Construct from components, copying labels + labelToPoint(const polyMesh& mesh, const labelList& labels); + + //- Construct from components, moving labels + labelToPoint(const polyMesh& mesh, labelList&& labels); //- Construct from dictionary labelToPoint(const polyMesh& mesh, const dictionary& dict); @@ -93,11 +92,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C index 95fc156c0438e789212e56eb10086d2caa271d16..8b48b2e7c5e8cb7296e1d44a073e61d22e2d2f51 100644 --- a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C @@ -35,6 +35,22 @@ namespace Foam defineTypeNameAndDebug(nearestToPoint, 0); addToRunTimeSelectionTable(topoSetSource, nearestToPoint, word); addToRunTimeSelectionTable(topoSetSource, nearestToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, nearestToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, nearestToPoint, istream); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + nearestToPoint, + word, + nearest + ); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + nearestToPoint, + istream, + nearest + ); } @@ -106,19 +122,29 @@ Foam::nearestToPoint::nearestToPoint const pointField& points ) : - topoSetSource(mesh), + topoSetPointSource(mesh), points_(points) {} +Foam::nearestToPoint::nearestToPoint +( + const polyMesh& mesh, + pointField&& points +) +: + topoSetPointSource(mesh), + points_(std::move(points)) +{} + + Foam::nearestToPoint::nearestToPoint ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), - points_(dict.get<pointField>("points")) + nearestToPoint(mesh, dict.get<pointField>("points")) {} @@ -128,7 +154,7 @@ Foam::nearestToPoint::nearestToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), points_(checkIs(is)) {} @@ -141,15 +167,21 @@ void Foam::nearestToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding points nearest to " << points_ << endl; + if (verbose_) + { + Info<< " Adding points nearest to " << points_ << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing points nearest to " << points_ << endl; + if (verbose_) + { + Info<< " Removing points nearest to " << points_ << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H index ff224780ac4c7e4956bb403a3df9201018526b9c..0946c742f92f76876269905a80e3e63508ca8119 100644 --- a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H @@ -25,7 +25,7 @@ Class Foam::nearestToPoint Description - A topoSetSource to select points nearest to points. + A topoSetPointSource to select points nearest to points. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef nearestToPoint_H #define nearestToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class nearestToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -78,12 +78,11 @@ public: // Constructors - //- Construct from components - nearestToPoint - ( - const polyMesh& mesh, - const pointField& points - ); + //- Construct from components, copying points + nearestToPoint(const polyMesh& mesh, const pointField& points); + + //- Construct from components, moving points + nearestToPoint(const polyMesh& mesh, pointField&& points); //- Construct from dictionary nearestToPoint(const polyMesh& mesh, const dictionary& dict); @@ -98,11 +97,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C index 93a40e84e17446093de2f3bb181434a1d1e5b720..5ede16171a831044789b67b962823196f6ae0f97 100644 --- a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C +++ b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.C @@ -35,6 +35,8 @@ namespace Foam defineTypeNameAndDebug(pointToPoint, 0); addToRunTimeSelectionTable(topoSetSource, pointToPoint, word); addToRunTimeSelectionTable(topoSetSource, pointToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, pointToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, pointToPoint, istream); } @@ -54,7 +56,7 @@ Foam::pointToPoint::pointToPoint const word& setName ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(setName) {} @@ -65,8 +67,7 @@ Foam::pointToPoint::pointToPoint const dictionary& dict ) : - topoSetSource(mesh), - setName_(dict.get<word>("set")) + pointToPoint(mesh, dict.get<word>("set")) {} @@ -76,7 +77,7 @@ Foam::pointToPoint::pointToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), setName_(checkIs(is)) {} @@ -89,23 +90,31 @@ void Foam::pointToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all from pointSet " << setName_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all from pointSet " << setName_ + << " ..." << endl; + } // Load the set pointSet loadedSet(mesh_, setName_); set.addSet(loadedSet); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all from pointSet " << setName_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all from pointSet " << setName_ + << " ..." << endl; + } // Load the set pointSet loadedSet(mesh_, setName_); - set.deleteSet(loadedSet); + set.subtractSet(loadedSet); } } diff --git a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H index 9257d3bea9ec3337b9cb026564308dbdba0e0c0a..5f1286672e37e21e8ac90e7b300bc4d772e55191 100644 --- a/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H +++ b/src/meshTools/sets/pointSources/pointToPoint/pointToPoint.H @@ -25,7 +25,7 @@ Class Foam::pointToPoint Description - A topoSetSource to select the points from another pointSet. + A topoSetPointSource to select the points from another pointSet. \heading Dictionary parameters \table @@ -41,7 +41,7 @@ SourceFiles #ifndef pointToPoint_H #define pointToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ namespace Foam class pointToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -91,11 +91,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C index da51f7a9d95ec9bba87b85d652723fd51847e7d0..df45bddc992dbfff58f9cad40a20480540489e04 100644 --- a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C +++ b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.C @@ -37,6 +37,8 @@ namespace Foam defineTypeNameAndDebug(surfaceToPoint, 0); addToRunTimeSelectionTable(topoSetSource, surfaceToPoint, word); addToRunTimeSelectionTable(topoSetSource, surfaceToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, surfaceToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, surfaceToPoint, istream); } @@ -61,8 +63,11 @@ void Foam::surfaceToPoint::combine(topoSet& set, const bool add) const triSurface surf(surfName_, scale_); - Info<< " Read surface from " << surfName_ - << " in = "<< timer.cpuTimeIncrement() << " s" << endl << endl; + if (verbose_) + { + Info<< " Read surface from " << surfName_ + << " in = "<< timer.cpuTimeIncrement() << " s" << nl << endl; + } // Construct search engine on surface triSurfaceSearch querySurf(surf); @@ -133,7 +138,7 @@ Foam::surfaceToPoint::surfaceToPoint const bool includeOutside ) : - topoSetSource(mesh), + topoSetPointSource(mesh), surfName_(surfName), scale_(1.0), nearDist_(nearDist), @@ -150,7 +155,7 @@ Foam::surfaceToPoint::surfaceToPoint const dictionary& dict ) : - topoSetSource(mesh), + topoSetPointSource(mesh), surfName_(dict.get<fileName>("file").expand()), scale_(dict.lookupOrDefault<scalar>("scale", -1)), nearDist_(dict.get<scalar>("nearDistance")), @@ -167,7 +172,7 @@ Foam::surfaceToPoint::surfaceToPoint Istream& is ) : - topoSetSource(mesh), + topoSetPointSource(mesh), surfName_(checkIs(is)), scale_(1.0), nearDist_(readScalar(checkIs(is))), @@ -186,17 +191,23 @@ void Foam::surfaceToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding points in relation to surface " << surfName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding points in relation to surface " << surfName_ + << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing points in relation to surface " << surfName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing points in relation to surface " << surfName_ + << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H index 0f6ed0d4e5e9c7429a9e4887b978d5772cc90fe3..e9ae0d1cbd97d033b754e0be1d70c46d05875842 100644 --- a/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H +++ b/src/meshTools/sets/pointSources/surfaceToPoint/surfaceToPoint.H @@ -25,7 +25,7 @@ Class Foam::surfaceToPoint Description - A topoSetSource to selects points based on relation to surface. + A topoSetPointSource to select points based on relation to surface. Select based on: - distance to surface @@ -51,7 +51,7 @@ SourceFiles #ifndef surfaceToPoint_H #define surfaceToPoint_H -#include "topoSetSource.H" +#include "topoSetPointSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,7 +67,7 @@ class triSurfaceSearch; class surfaceToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -129,11 +129,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C new file mode 100644 index 0000000000000000000000000000000000000000..dd91b9c7a1589e51d60f9291e8fcf7c5c09f9238 --- /dev/null +++ b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "topoSetPointSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(topoSetPointSource, 0); + defineRunTimeSelectionTable(topoSetPointSource, word); + defineRunTimeSelectionTable(topoSetPointSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetPointSource::topoSetPointSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetPointSource> Foam::topoSetPointSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetPointSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetPointSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetPointSource> Foam::topoSetPointSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown topoSetPointSource type " + << sourceType << nl << nl + << "Valid types :" << endl + << istreamConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSetPointSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H new file mode 100644 index 0000000000000000000000000000000000000000..627b0621ed29fca4da82c5820db8eb6c4acec4bd --- /dev/null +++ b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::topoSetPointSource + +Description + Base class of a topoSet source for selecting points. + +SourceFiles + topoSetPointSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetPointSource_H +#define topoSetPointSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class topoSetPointSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetPointSource +: + public topoSetSource +{ +public: + + //- Runtime type information + TypeName("topoSetPointSource"); + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetPointSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetPointSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetPointSource(const polyMesh& mesh); + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetPointSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetPointSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetPointSource() = default; + + + // Member Functions + + virtual topoSetSource::sourceType setType() const + { + return POINTSETSOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C index 69d6ab31af340017e0abf1ed1aa07de44b5a112f..42ae6637948811180fcbd5cb2882ff4c886052ea 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C @@ -34,6 +34,22 @@ namespace Foam defineTypeNameAndDebug(zoneToPoint, 0); addToRunTimeSelectionTable(topoSetSource, zoneToPoint, word); addToRunTimeSelectionTable(topoSetSource, zoneToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, zoneToPoint, word); + addToRunTimeSelectionTable(topoSetPointSource, zoneToPoint, istream); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + zoneToPoint, + word, + zone + ); + addNamedToRunTimeSelectionTable + ( + topoSetPointSource, + zoneToPoint, + istream, + zone + ); } @@ -54,14 +70,17 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const for (const pointZone& zone : mesh_.pointZones()) { - if (zoneName_.match(zone.name())) + if (selectedZones_.match(zone.name())) { hasMatched = true; const labelList& pointLabels = zone; - Info<< " Found matching zone " << zone.name() - << " with " << pointLabels.size() << " points." << endl; + if (verbose_) + { + Info<< " Found matching zone " << zone.name() + << " with " << pointLabels.size() << " points." << endl; + } for (const label pointi : pointLabels) { @@ -77,7 +96,8 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const if (!hasMatched) { WarningInFunction - << "Cannot find any pointZone named " << zoneName_ << nl + << "Cannot find any pointZone matching " + << flatOutput(selectedZones_) << nl << "Valid names: " << flatOutput(mesh_.pointZones().names()) << endl; } @@ -89,11 +109,11 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const Foam::zoneToPoint::zoneToPoint ( const polyMesh& mesh, - const word& zoneName + const wordRe& zoneName ) : - topoSetSource(mesh), - zoneName_(zoneName) + topoSetPointSource(mesh), + selectedZones_(one(), zoneName) {} @@ -103,9 +123,17 @@ Foam::zoneToPoint::zoneToPoint const dictionary& dict ) : - topoSetSource(mesh), - zoneName_(dict.get<wordRe>("name")) -{} + topoSetPointSource(mesh), + selectedZones_() +{ + // Look for 'zones' and 'zone', but accept 'name' as well + if (!dict.readIfPresent("zones", selectedZones_)) + { + selectedZones_.resize(1); + selectedZones_.first() = + dict.getCompat<wordRe>("zone", {{"name", 1806}}); + } +} Foam::zoneToPoint::zoneToPoint @@ -114,8 +142,8 @@ Foam::zoneToPoint::zoneToPoint Istream& is ) : - topoSetSource(mesh), - zoneName_(checkIs(is)) + topoSetPointSource(mesh), + selectedZones_(one(), wordRe(checkIs(is))) {} @@ -127,17 +155,23 @@ void Foam::zoneToPoint::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all points of pointZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Adding all points of point zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all points of pointZone " << zoneName_ << " ..." - << endl; + if (verbose_) + { + Info<< " Removing all points of point zones " + << flatOutput(selectedZones_) << " ..." << endl; + } combine(set, false); } diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H index ea7c0eaee13711f0836b875f5854bdd590efc4e1..536a5797208e9ea36c643163ed4e23010667bfda 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.H @@ -25,14 +25,19 @@ Class Foam::zoneToPoint Description - A topoSetSource to select points based on pointZone. + A topoSetPointSource to select points based on one or more pointZones. \heading Dictionary parameters \table - Property | Description | Required | Default - name | The point zone name or regex | yes | + Property | Description | Required | Default + zone | The point zone name or regex | possibly | + zones | The point zone names or regexs | possibly | + name | Older specification for 'zone' | no | \endtable +Note + Selection of multiple zones has precedence. + SourceFiles zoneToPoint.C @@ -41,8 +46,8 @@ SourceFiles #ifndef zoneToPoint_H #define zoneToPoint_H -#include "topoSetSource.H" -#include "wordRe.H" +#include "topoSetPointSource.H" +#include "wordRes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,12 +55,12 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class zoneToPoint Declaration + Class zoneToPoint Declaration \*---------------------------------------------------------------------------*/ class zoneToPoint : - public topoSetSource + public topoSetPointSource { // Private data @@ -63,8 +68,8 @@ class zoneToPoint //- Add usage string static addToUsageTable usage_; - //- Name/regular expression of zone - wordRe zoneName_; + //- Matcher for zones + wordRes selectedZones_; // Private Member Functions @@ -80,11 +85,7 @@ public: // Constructors //- Construct from components - zoneToPoint - ( - const polyMesh& mesh, - const word& zoneName - ); + zoneToPoint(const polyMesh& mesh, const wordRe& zoneName); //- Construct from dictionary zoneToPoint(const polyMesh& mesh, const dictionary& dict); @@ -99,11 +100,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return POINTSETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C index fd714d51fa247fe61e1d5dd9d27d6c4b6f9d52d5..de2f8e58f2dbe0b2ea074e478344f086c80b82e0 100644 --- a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C @@ -96,51 +96,57 @@ void Foam::setToPointZone::applyToSet } else { - pointZoneSet& fzSet = refCast<pointZoneSet>(set); + pointZoneSet& zoneSet = refCast<pointZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all points from pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Adding all points from pointSet " << setName_ + << " ..." << endl; + } // Load the sets pointSet loadedSet(mesh_, setName_); const labelHashSet& pointLabels = loadedSet; // Start off from copy - DynamicList<label> newAddressing(fzSet.addressing()); + DynamicList<label> newAddressing(zoneSet.addressing()); for (const label pointi : pointLabels) { - if (!fzSet.found(pointi)) + if (!zoneSet.found(pointi)) { newAddressing.append(pointi); } } - fzSet.addressing().transfer(newAddressing); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.updateSet(); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all points from pointSet " << setName_ - << " ..." << endl; + if (verbose_) + { + Info<< " Removing all points from pointSet " << setName_ + << " ..." << endl; + } // Load the set pointSet loadedSet(mesh_, setName_); // Start off empty - DynamicList<label> newAddressing(fzSet.addressing().size()); + DynamicList<label> newAddressing(zoneSet.addressing().size()); - forAll(fzSet.addressing(), i) + forAll(zoneSet.addressing(), i) { - if (!loadedSet.found(fzSet.addressing()[i])) + if (!loadedSet.found(zoneSet.addressing()[i])) { - newAddressing.append(fzSet.addressing()[i]); + newAddressing.append(zoneSet.addressing()[i]); } } - fzSet.addressing().transfer(newAddressing); - fzSet.updateSet(); + zoneSet.addressing().transfer(newAddressing); + zoneSet.updateSet(); } } } diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.C b/src/meshTools/sets/topoSetSource/topoSetSource.C index 2bd6225e198ee7c1d39f120f669ebeaebdc50066..63370dd82a6723ac8c857f99b47fae4e1463e0ae 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.C +++ b/src/meshTools/sets/topoSetSource/topoSetSource.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,14 +46,15 @@ const Foam::Enum > Foam::topoSetSource::actionNames ({ - { setAction::CLEAR, "clear" }, - { setAction::NEW, "new" }, - { setAction::INVERT, "invert" }, { setAction::ADD, "add" }, - { setAction::DELETE, "delete" }, + { setAction::SUBTRACT, "subtract" }, { setAction::SUBSET, "subset" }, - { setAction::LIST, "list" }, + { setAction::INVERT, "invert" }, + { setAction::CLEAR, "clear" }, + { setAction::NEW, "new" }, { setAction::REMOVE, "remove" }, + { setAction::LIST, "list" }, + { setAction::SUBTRACT, "delete" }, // Compat (1806) }); @@ -148,11 +149,7 @@ Foam::autoPtr<Foam::topoSetSource> Foam::topoSetSource::New Foam::Istream& Foam::topoSetSource::checkIs(Istream& is) { - if (is.good() && !is.eof()) - { - return is; - } - else + if (!is.good() || is.eof()) { FatalErrorInFunction << exit(FatalError); @@ -173,11 +170,11 @@ void Foam::topoSetSource::addOrDelete { if (add) { - set.insert(id); + set.set(id); } else { - set.erase(id); + set.unset(id); } } @@ -191,11 +188,11 @@ void Foam::topoSetSource::addOrDelete { if (add) { - set.insert(labels); + set.set(labels); } else { - set.erase(labels); + set.unset(labels); } } @@ -204,7 +201,8 @@ void Foam::topoSetSource::addOrDelete Foam::topoSetSource::topoSetSource(const polyMesh& mesh) : - mesh_(mesh) + mesh_(mesh), + verbose_(true) {} diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.H b/src/meshTools/sets/topoSetSource/topoSetSource.H index 4dfacfe3c4f4f82e1187420983e61925b00d7250..aed7e6557a7859a2603735f0f3d9bc43bd98ab8e 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.H +++ b/src/meshTools/sets/topoSetSource/topoSetSource.H @@ -39,14 +39,13 @@ SourceFiles #define topoSetSource_H #include "pointField.H" -#include "word.H" #include "labelList.H" #include "faceList.H" #include "typeInfo.H" -#include "runTimeSelectionTables.H" #include "autoPtr.H" #include "Enum.H" #include "HashTable.H" +#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,26 +69,27 @@ public: //- Enumeration defining the types of sources enum sourceType { - CELLSETSOURCE, - FACESETSOURCE, - POINTSETSOURCE, + CELLSETSOURCE = 0x1, //!< Cells + FACESETSOURCE = 0x2, //!< Faces + POINTSETSOURCE = 0x4, //!< Points - CELLZONESOURCE, - FACEZONESOURCE, - POINTZONESOURCE + CELLZONESOURCE = 0x11, //!< Cells as zone + FACEZONESOURCE = 0x12, //!< Faces as zone + POINTZONESOURCE = 0x14, //!< Points as zone }; //- Enumeration defining the valid actions enum setAction { - CLEAR, - NEW, - INVERT, - ADD, - DELETE, - SUBSET, - LIST, - REMOVE + ADD, //!< Adds elements to the set + SUBTRACT, //!< Removes elements from the set + SUBSET, //!< Subset with elements in the set + INVERT, //!< Invert the elements in the set + CLEAR, //!< Clear the set, possibly creating it + NEW, //!< Create a new set and ADD elemets to it + REMOVE, //!< Remove the set (from the file system) + LIST, //!< Print contents of the set + DELETE = SUBTRACT, //!< \deprecated alias for SUBTRACT (OCT-2018) }; //- The setActions text representations @@ -126,11 +126,14 @@ protected: }; - // Protected data + // Protected Data //- Reference to the mesh const polyMesh& mesh_; + //- Verbosity (default: true) + bool verbose_; + // Protected Member Functions @@ -289,6 +292,18 @@ public: return mesh_; } + //- Return the current verbosity + bool verbose() const + { + return verbose_; + } + + //- Set the current verbosity + void verbose(bool on) + { + verbose_ = on; + } + // Member Functions @@ -296,7 +311,11 @@ public: virtual sourceType setType() const = 0; //- Apply specified action to the topoSet - virtual void applyToSet(const setAction action, topoSet& set) const = 0; + virtual void applyToSet + ( + const setAction action, + topoSet& set + ) const = 0; }; diff --git a/src/meshTools/sets/topoSets/cellBitSet.C b/src/meshTools/sets/topoSets/cellBitSet.C new file mode 100644 index 0000000000000000000000000000000000000000..4838b13a6096ce2150f7f175436dd509e9095a22 --- /dev/null +++ b/src/meshTools/sets/topoSets/cellBitSet.C @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cellBitSet.H" +#include "polyMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cellBitSet, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cellBitSet::cellBitSet(const polyMesh& mesh) +: + cellBitSet(mesh, false) +{} + + +Foam::cellBitSet::cellBitSet(const polyMesh& mesh, const bool val) +: + topoSet + ( + IOobject + ( + "cellBitSet", + mesh.time().constant(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + 0 // zero-sized (unallocated) labelHashSet + ), + selected_(mesh.nCells(), val) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::cellBitSet::found(const label id) const +{ + return selected_.test(id); +} + + +bool Foam::cellBitSet::set(const label id) +{ + return selected_.set(id); +} + + +bool Foam::cellBitSet::unset(const label id) +{ + return selected_.unset(id); +} + + +void Foam::cellBitSet::set(const labelUList& labels) +{ + selected_.set(labels); +} + + +void Foam::cellBitSet::unset(const labelUList& labels) +{ + selected_.unset(labels); +} + + +void Foam::cellBitSet::invert(const label maxLen) +{ + selected_.resize(maxLen); + selected_.flip(); +} + + +void Foam::cellBitSet::subset(const topoSet& set) +{ + // Only retain entries found in both sets + if (isA<cellBitSet>(set)) + { + selected_ &= refCast<const cellBitSet>(set).selected_; + } + else if (set.empty()) + { + selected_.reset(); + } + else + { + for (const label id : selected_) + { + if (!set.found(id)) + { + selected_.unset(id); + } + } + } +} + + +void Foam::cellBitSet::addSet(const topoSet& set) +{ + // Add entries to the set + if (isA<cellBitSet>(set)) + { + selected_ |= refCast<const cellBitSet>(set).selected_; + } + else + { + for (const label id : set) + { + selected_.set(id); + } + } +} + + +void Foam::cellBitSet::subtractSet(const topoSet& set) +{ + // Subtract entries from the set + if (isA<cellBitSet>(set)) + { + selected_ -= refCast<const cellBitSet>(set).selected_; + } + else + { + for (const label id : set) + { + selected_.unset(id); + } + } +} + + +Foam::label Foam::cellBitSet::maxSize(const polyMesh& mesh) const +{ + return mesh.nCells(); +} + + +void Foam::cellBitSet::writeDebug +( + Ostream& os, + const primitiveMesh& mesh, + const label maxLen +) const +{ + topoSet::writeDebug(os, mesh.cellCentres(), maxLen); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/cellBitSet.H b/src/meshTools/sets/topoSets/cellBitSet.H new file mode 100644 index 0000000000000000000000000000000000000000..ba64b40595dffa4bfd347fcdb563ad41bc4363bc --- /dev/null +++ b/src/meshTools/sets/topoSets/cellBitSet.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cellBitSet + +Description + A special purpose topoSet with the cell labels stored as a bitSet. + It does not correspond to a cellSet either (no associated IOobject). + +SourceFiles + cellBitSet.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cellBitSet_H +#define cellBitSet_H + +#include "topoSet.H" +#include "bitSet.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cellBitSet Declaration +\*---------------------------------------------------------------------------*/ + +class cellBitSet +: + public topoSet +{ + // Private data + + bitSet selected_; + +public: + + //- Runtime type information + TypeName("cellBitSet"); + + + // Constructors + + //- Construct with nCells elements, all elements unset + explicit cellBitSet(const polyMesh& mesh); + + //- Construct with nCells elements, using initial val + cellBitSet(const polyMesh& mesh, const bool val); + + + //- Destructor + virtual ~cellBitSet() = default; + + + // Member Functions + + //- Return the bitSet + const bitSet& addressing() const + { + return selected_; + } + + //- Access the bitSet + bitSet& addressing() + { + return selected_; + } + + //- Set values to false, leaving the size untouched + void reset() + { + selected_.reset(); + } + + //- Has the given index? + virtual bool found(const label id) const; + + //- Set an index + virtual bool set(const label id); + + //- Unset an index + virtual bool unset(const label id); + + //- Set multiple indices + virtual void set(const labelUList& labels); + + //- Unset multiple indices + virtual void unset(const labelUList& labels); + + //- 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. + virtual void subset(const topoSet& set); + + //- Add elements present in set. + virtual void addSet(const topoSet& set); + + //- Subtract elements present in set. + virtual void subtractSet(const topoSet& set); + + //- Sync cellBitSet across coupled patches. + virtual void sync(const polyMesh& mesh) + {} + + //- Return max index+1. + virtual label maxSize(const polyMesh& mesh) const; + + //- Update any stored data for new labels. + virtual void updateMesh(const mapPolyMesh& morphMap) + {} + + //- Update any stored data for mesh redistribution. + virtual void distribute(const mapDistributePolyMesh& map) + {} + + //- Write maxLen items with label and coordinates. + virtual void writeDebug + ( + Ostream& os, + const primitiveMesh& mesh, + const label maxLen + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/cellZoneSet.C b/src/meshTools/sets/topoSets/cellZoneSet.C index 4168af394a85392f475992183eb3458656b153cd..0ca2fdc96da9e7187c27682c1d944088efa645b7 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.C +++ b/src/meshTools/sets/topoSets/cellZoneSet.C @@ -49,7 +49,7 @@ void Foam::cellZoneSet::updateSet() cellSet::clearStorage(); cellSet::resize(2*addressing_.size()); - cellSet::insert(addressing_); + cellSet::set(addressing_); } @@ -189,7 +189,7 @@ void Foam::cellZoneSet::addSet(const topoSet& set) } -void Foam::cellZoneSet::deleteSet(const topoSet& set) +void Foam::cellZoneSet::subtractSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); diff --git a/src/meshTools/sets/topoSets/cellZoneSet.H b/src/meshTools/sets/topoSets/cellZoneSet.H index 8e21178a5e9cb1ba829c14d6f28b98f54f5da47f..c7e96c3058fb710b5e74dde45261ed04bab5ef94 100644 --- a/src/meshTools/sets/topoSets/cellZoneSet.H +++ b/src/meshTools/sets/topoSets/cellZoneSet.H @@ -122,8 +122,8 @@ public: //- Add elements present in set. virtual void addSet(const topoSet& set); - //- Delete elements present in set. - virtual void deleteSet(const topoSet& set); + //- Subtract elements present in set. + virtual void subtractSet(const topoSet& set); //- Sync cellSet across coupled patches; update cellZone from cellSet virtual void sync(const polyMesh& mesh); diff --git a/src/meshTools/sets/topoSets/faceSet.C b/src/meshTools/sets/topoSets/faceSet.C index 2de0053c38ebfae4447587d056747cf2b9d1a7ae..b4839065a8e9833a082f403f8fb06d9fac595918 100644 --- a/src/meshTools/sets/topoSets/faceSet.C +++ b/src/meshTools/sets/topoSets/faceSet.C @@ -143,7 +143,7 @@ void Foam::faceSet::sync(const polyMesh& mesh) { if (set[facei]) { - if (insert(facei)) + if (this->set(facei)) { ++nAdded; } @@ -207,7 +207,7 @@ void Foam::faceSet::distribute(const mapDistributePolyMesh& map) { if (inSet[facei]) { - insert(facei); + this->set(facei); } } } diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C index 674beddc35d5cccbb431615e06fcb3be1e2d8a3a..ff0431ac69f1848b78e965e54fb105fec8f96d78 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.C +++ b/src/meshTools/sets/topoSets/faceZoneSet.C @@ -54,7 +54,7 @@ void Foam::faceZoneSet::updateSet() faceSet::clearStorage(); faceSet::resize(2*addressing_.size()); - faceSet::insert(addressing_); + faceSet::set(addressing_); } @@ -260,7 +260,7 @@ void Foam::faceZoneSet::addSet(const topoSet& set) } -void Foam::faceZoneSet::deleteSet(const topoSet& set) +void Foam::faceZoneSet::subtractSet(const topoSet& set) { label nConflict = 0; @@ -301,7 +301,7 @@ void Foam::faceZoneSet::deleteSet(const topoSet& set) if (nConflict > 0) { WarningInFunction - << "deleteSet : there are " << nConflict + << "subtractSet : there are " << nConflict << " faces with different orientation in faceZonesSets " << name() << " and " << set.name() << endl; } diff --git a/src/meshTools/sets/topoSets/faceZoneSet.H b/src/meshTools/sets/topoSets/faceZoneSet.H index c8c0014906705df414fc326c3b377aadfa797ae8..09d60624626c7c34d55b8f8ecde5015dc0658831 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.H +++ b/src/meshTools/sets/topoSets/faceZoneSet.H @@ -137,8 +137,8 @@ public: //- Add elements present in set. virtual void addSet(const topoSet& set); - //- Delete elements present in set. - virtual void deleteSet(const topoSet& set); + //- Subtract elements present in set. + virtual void subtractSet(const topoSet& set); //- Sync faceZoneSet across coupled patches. virtual void sync(const polyMesh& mesh); diff --git a/src/meshTools/sets/topoSets/pointSet.C b/src/meshTools/sets/topoSets/pointSet.C index ed4347a59d845decc6d7ec780879d102bd0e37da..d0c9459420de81c8a1b43d518bf8b32b51508102 100644 --- a/src/meshTools/sets/topoSets/pointSet.C +++ b/src/meshTools/sets/topoSets/pointSet.C @@ -153,7 +153,7 @@ void Foam::pointSet::sync(const polyMesh& mesh) { if (contents[pointi]) { - newContents.insert(pointi); + newContents.set(pointi); } } @@ -202,7 +202,7 @@ void Foam::pointSet::distribute(const mapDistributePolyMesh& map) { if (inSet[pointi]) { - insert(pointi); + this->set(pointi); } } } diff --git a/src/meshTools/sets/topoSets/pointZoneSet.C b/src/meshTools/sets/topoSets/pointZoneSet.C index 06b8eba119f18f2a00a398c1568a56cd20fd7f7d..647adac1999070202ae9e081c96927187ff0a885 100644 --- a/src/meshTools/sets/topoSets/pointZoneSet.C +++ b/src/meshTools/sets/topoSets/pointZoneSet.C @@ -50,7 +50,7 @@ void Foam::pointZoneSet::updateSet() pointSet::clearStorage(); pointSet::resize(2*addressing_.size()); - pointSet::insert(addressing_); + pointSet::set(addressing_); } @@ -189,7 +189,7 @@ void Foam::pointZoneSet::addSet(const topoSet& set) } -void Foam::pointZoneSet::deleteSet(const topoSet& set) +void Foam::pointZoneSet::subtractSet(const topoSet& set) { DynamicList<label> newAddressing(addressing_.size()); diff --git a/src/meshTools/sets/topoSets/pointZoneSet.H b/src/meshTools/sets/topoSets/pointZoneSet.H index f32db072d9cff80930a8f6446e0e206ee110bcaa..a5668e2ed575b1805e82b030c496e881fc45f557 100644 --- a/src/meshTools/sets/topoSets/pointZoneSet.H +++ b/src/meshTools/sets/topoSets/pointZoneSet.H @@ -123,8 +123,8 @@ public: //- Add elements present in set. virtual void addSet(const topoSet& set); - //- Delete elements present in set. - virtual void deleteSet(const topoSet& set); + //- Subtract elements present in set. + virtual void subtractSet(const topoSet& set); //- Sync pointZoneSet across coupled patches. virtual void sync(const polyMesh& mesh); diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index c69ffa92ebba10322a1170f6339469e1cf3f7cc2..040eec3c0d771e7c9e7c35c9849a0e253172594a 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -174,7 +174,7 @@ void Foam::topoSet::updateLabels(const labelList& map) if (newId >= 0) { - newSet.insert(newId); + newSet.set(newId); } } @@ -491,6 +491,36 @@ Foam::topoSet::topoSet(const IOobject& io, labelHashSet&& labels) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +bool Foam::topoSet::found(const label id) const +{ + return static_cast<const labelHashSet&>(*this).found(id); +} + + +bool Foam::topoSet::set(const label id) +{ + return static_cast<labelHashSet&>(*this).set(id); +} + + +bool Foam::topoSet::unset(const label id) +{ + return static_cast<labelHashSet&>(*this).unset(id); +} + + +void Foam::topoSet::set(const labelUList& labels) +{ + static_cast<labelHashSet&>(*this).set(labels); +} + + +void Foam::topoSet::unset(const labelUList& labels) +{ + static_cast<labelHashSet&>(*this).unset(labels); +} + + void Foam::topoSet::invert(const label maxLen) { // Retain a copy of the original (current) set. @@ -506,7 +536,7 @@ void Foam::topoSet::invert(const label maxLen) { if (!original.found(id)) { - insert(id); + this->set(id); } } } @@ -514,25 +544,31 @@ void Foam::topoSet::invert(const label maxLen) void Foam::topoSet::subset(const topoSet& set) { - // Only retain entries found in both HashSets + // Only retain entries found in both sets static_cast<labelHashSet&>(*this) &= set; } void Foam::topoSet::addSet(const topoSet& set) { - // Add entries to the HashSet - static_cast<labelHashSet&>(*this) += set; + // Add entries to the set + static_cast<labelHashSet&>(*this) |= set; } -void Foam::topoSet::deleteSet(const topoSet& set) +void Foam::topoSet::subtractSet(const topoSet& set) { - // Remove entries from the HashSet + // Subtract entries from the set static_cast<labelHashSet&>(*this) -= set; } +void Foam::topoSet::deleteSet(const topoSet& set) +{ + this->subtractSet(set); +} + + void Foam::topoSet::sync(const polyMesh&) { NotImplemented; diff --git a/src/meshTools/sets/topoSets/topoSet.H b/src/meshTools/sets/topoSets/topoSet.H index 7255caecbba7fa81027586c74780b9c30c56944b..3fa955ab7b9c533a89f4e335f5e24dc18810a3a4 100644 --- a/src/meshTools/sets/topoSets/topoSet.H +++ b/src/meshTools/sets/topoSets/topoSet.H @@ -66,7 +66,6 @@ class topoSet public regIOobject, public labelHashSet { - protected: // Protected Member Functions @@ -312,7 +311,22 @@ public: virtual ~topoSet() = default; - // Member functions + // Member Functions + + //- Has the given index? + virtual bool found(const label id) const; + + //- Set an index + virtual bool set(const label id); + + //- Unset an index + virtual bool unset(const label id); + + //- Set multiple indices + virtual void set(const labelUList& labels); + + //- Unset multiple indices + virtual void unset(const labelUList& labels); //- Invert contents. // Insert all members [0,maxLen) which were not in set. @@ -324,7 +338,11 @@ public: //- Add elements present in set. virtual void addSet(const topoSet& set); - //- Delete elements present in set. + //- Subtract elements present in set. + virtual void subtractSet(const topoSet& set); + + //- Subtract elements present in set. + // \deprecated use subtractSet instead (OCT-2018) virtual void deleteSet(const topoSet& set); //- Sync set across coupled patches. diff --git a/src/meshTools/surfaceSets/surfaceSets.C b/src/meshTools/surfaceSets/surfaceSets.C index 9309e963ece4571111f2a31d714436a732383b52..6b639055917c53ba4d25af305d0873baf508afb4 100644 --- a/src/meshTools/surfaceSets/surfaceSets.C +++ b/src/meshTools/surfaceSets/surfaceSets.C @@ -496,7 +496,7 @@ Foam::labelHashSet Foam::surfaceSets::getHangingCells // // cellToCell deleteInsideSource(mesh, rawInside.name()); // -// deleteInsideSource.applyToSet(topoSetSource::DELETE, cutCells); +// deleteInsideSource.applyToSet(topoSetSource::SUBTRACT, cutCells); // Pout<< "Writing cut cells (" << cutCells.size() << ") to cellSet " // << cutCells.instance()/cutCells.local()/cutCells.name() // << endl << endl; @@ -544,8 +544,8 @@ Foam::labelHashSet Foam::surfaceSets::getHangingCells // cellSet inside(mesh, "inside", rawInside); // cellSet outside(mesh, "outside", rawOutside); // -// pToCell.applyToSet(topoSetSource::DELETE, inside); -// pToCell.applyToSet(topoSetSource::DELETE, outside); +// pToCell.applyToSet(topoSetSource::SUBTRACT, inside); +// pToCell.applyToSet(topoSetSource::SUBTRACT, outside); // // Pout<< nl // << "Removed " << rawInside.size() - inside.size() diff --git a/src/overset/regionsToCell/regionsToCell.C b/src/overset/regionsToCell/regionsToCell.C index 2cb3419a4f489523762fe7654ade57c7d7f5fcdb..24d29c5aebead5fbaaea35197e0595c82992ac36 100644 --- a/src/overset/regionsToCell/regionsToCell.C +++ b/src/overset/regionsToCell/regionsToCell.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,13 +34,25 @@ License namespace Foam { - -defineTypeNameAndDebug(regionsToCell, 0); - -addToRunTimeSelectionTable(topoSetSource, regionsToCell, word); - -addToRunTimeSelectionTable(topoSetSource, regionsToCell, istream); - + defineTypeNameAndDebug(regionsToCell, 0); + addToRunTimeSelectionTable(topoSetSource, regionsToCell, word); + addToRunTimeSelectionTable(topoSetSource, regionsToCell, istream); + addToRunTimeSelectionTable(topoSetCellSource, regionsToCell, word); + addToRunTimeSelectionTable(topoSetCellSource, regionsToCell, istream); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + regionsToCell, + word, + regions + ); + addNamedToRunTimeSelectionTable + ( + topoSetCellSource, + regionsToCell, + istream, + regions + ); } @@ -112,12 +124,10 @@ Foam::boolList Foam::regionsToCell::findRegions { boolList keepRegion(cellRegion.nRegions(), false); - forAll(insidePoints_, i) + for (const point& insidePt : insidePoints_) { // Find the region containing the insidePoint - const point& insidePt = insidePoints_[i]; - //label cellI = mesh_.findCell(insidePt); label cellI = -1; forAll(selectedCell, index) @@ -179,7 +189,7 @@ void Foam::regionsToCell::unselectOutsideRegions regionSplit cellRegion(mesh_, blockedFace); // Determine regions containing insidePoints_ - boolList keepRegion(findRegions(true, selectedCell, cellRegion)); + boolList keepRegion(findRegions(verbose_, selectedCell, cellRegion)); // Go back to bool per cell forAll(cellRegion, cellI) @@ -204,10 +214,8 @@ void Foam::regionsToCell::shrinkRegions const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); - forAll(pbm, patchI) + for (const polyPatch& pp : pbm) { - const polyPatch& pp = pbm[patchI]; - if (!pp.coupled() && !isA<emptyPolyPatch>(pp)) { forAll(pp, i) @@ -290,7 +298,7 @@ void Foam::regionsToCell::erode regionSplit cellRegion(mesh_, blockedFace); // Determine regions containing insidePoints - boolList keepRegion(findRegions(true, shrunkSelectedCell, cellRegion)); + boolList keepRegion(findRegions(verbose_, shrunkSelectedCell, cellRegion)); // Extract cells in regions that are not to be kept. @@ -374,9 +382,9 @@ void Foam::regionsToCell::combine(topoSet& set, const bool add) const cellSet subSet(mesh_, setName_); selectedCell = false; - forAllConstIter(cellSet, subSet, iter) + for (const label celli : static_cast<const labelHashSet&>(subSet)) { - selectedCell[iter.key()] = true; + selectedCell[celli] = true; } } @@ -401,7 +409,6 @@ void Foam::regionsToCell::combine(topoSet& set, const bool add) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::regionsToCell::regionsToCell ( const polyMesh& mesh, @@ -410,21 +417,20 @@ Foam::regionsToCell::regionsToCell const label nErode ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(setName), insidePoints_(insidePoints), nErode_(nErode) {} -// Construct from dictionary Foam::regionsToCell::regionsToCell ( const polyMesh& mesh, const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(dict.lookupOrDefault<word>("set", "none")), insidePoints_ ( @@ -432,30 +438,23 @@ Foam::regionsToCell::regionsToCell ? dict.lookup("insidePoints") : dict.lookup("insidePoint") ), - nErode_(dict.lookupOrDefault("nErode", 0)) + nErode_(dict.lookupOrDefault<label>("nErode", 0)) {} -// Construct from Istream Foam::regionsToCell::regionsToCell ( const polyMesh& mesh, Istream& is ) : - topoSetSource(mesh), + topoSetCellSource(mesh), setName_(checkIs(is)), insidePoints_(checkIs(is)), nErode_(readLabel(checkIs(is))) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::regionsToCell::~regionsToCell() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::regionsToCell::applyToSet @@ -464,17 +463,25 @@ void Foam::regionsToCell::applyToSet topoSet& set ) const { - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (action == topoSetSource::ADD || action == topoSetSource::NEW) { - Info<< " Adding all cells of connected region containing points " - << insidePoints_ << " ..." << endl; + if (verbose_) + { + Info<< " Adding all cells of connected region " + << "containing points " + << insidePoints_ << " ..." << endl; + } combine(set, true); } - else if (action == topoSetSource::DELETE) + else if (action == topoSetSource::SUBTRACT) { - Info<< " Removing all cells of connected region containing points " - << insidePoints_ << " ..." << endl; + if (verbose_) + { + Info<< " Removing all cells of connected region " + << "containing points " + << insidePoints_ << " ..." << endl; + } combine(set, false); } diff --git a/src/overset/regionsToCell/regionsToCell.H b/src/overset/regionsToCell/regionsToCell.H index 1f7c54457468a184749e46a83a10ddd5db8cdcf9..4f4aba80c38d8b40907e7737b43087f28aaf9777 100644 --- a/src/overset/regionsToCell/regionsToCell.H +++ b/src/overset/regionsToCell/regionsToCell.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,7 @@ SourceFiles #ifndef regionsToCell_H #define regionsToCell_H -#include "topoSetSource.H" +#include "topoSetCellSource.H" #include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,6 +57,7 @@ SourceFiles namespace Foam { +// Forward declarations class regionSplit; /*---------------------------------------------------------------------------*\ @@ -65,7 +66,7 @@ class regionSplit; class regionsToCell : - public topoSetSource + public topoSetCellSource { // Private data @@ -98,7 +99,7 @@ class regionsToCell ( const bool verbose, const boolList& selectedCell, - const regionSplit& + const regionSplit& cellRegion ) const; //- Unselect regions not containing a locationInMesh @@ -131,33 +132,23 @@ public: ); //- Construct from dictionary - regionsToCell - ( - const polyMesh& mesh, - const dictionary& dict - ); + regionsToCell(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - regionsToCell - ( - const polyMesh& mesh, - Istream& - ); + regionsToCell(const polyMesh& mesh, Istream& is); //- Destructor - virtual ~regionsToCell(); + virtual ~regionsToCell() = default; // Member Functions - virtual sourceType setType() const - { - return CELLSETSOURCE; - } - - virtual void applyToSet(const topoSetSource::setAction action, topoSet&) - const; + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& set + ) const; }; diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/system/topoSetDict b/tutorials/combustion/fireFoam/LES/compartmentFire/system/topoSetDict index e9154fd75f93342e96d965d88800f9d8ce072318..0f3ab08509c11bbcb0e56cd8b1037fbac090b916 100644 --- a/tutorials/combustion/fireFoam/LES/compartmentFire/system/topoSetDict +++ b/tutorials/combustion/fireFoam/LES/compartmentFire/system/topoSetDict @@ -67,7 +67,7 @@ actions source patchToFace; sourceInfo { - name inlet; + patch inlet; } } @@ -228,19 +228,13 @@ actions { name wallPanel; type faceZoneSet; - action delete; + action subtract; source setToFaceZone; sourceInfo { faceSet inletFace; } } - - - - - - ); // ************************************************************************* // diff --git a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/system/topoSetDict b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/system/topoSetDict index ad3c8e29850b3329c0dc223375b895dd4bc17e5a..492c5bd72f89daab1415f4be59b42ed850243e70 100644 --- a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/system/topoSetDict +++ b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/system/topoSetDict @@ -36,7 +36,7 @@ actions source patchToFace; sourceInfo { - name coupledWallTmp; + patch coupledWallTmp; } } diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/system/topoSetDict b/tutorials/combustion/fireFoam/LES/simplePMMApanel/system/topoSetDict index 2c47e07f5e709b45971e4c1540b98743dfebc15a..b1abf7f6bc0be00d2f38e087d96b8dcbee296f76 100644 --- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/system/topoSetDict +++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/system/topoSetDict @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name coupledPatch; + patch coupledPatch; } } diff --git a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/topoSetDict b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/topoSetDict index 1730a01d246c3b8e812f22c8f15cb2721b3b9f79..128937482119a50acb8fb0b74536974053ef829e 100644 --- a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/topoSetDict +++ b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/topoSetDict @@ -59,7 +59,7 @@ actions { name c1; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/system/topoSetDict b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/system/topoSetDict index 446ba1e24bd49b2bd079098703477380c850de64..1928aeb4f189fe07088fd0818c96e7e7eec0cda3 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/system/topoSetDict +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/system/topoSetDict @@ -63,7 +63,7 @@ actions { name solid; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { @@ -108,7 +108,7 @@ actions { name solid; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.1 b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.1 index 55431121f366c42d9872bb98040ea18a24506077..73cbe27a8dad59233f414c09444d4b940da69aa0 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.1 +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.1 @@ -25,7 +25,7 @@ actions source zoneToCell; sourceInfo { - name cylinder; + zone cylinder; } } { diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.2 b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.2 index c49ab1e2d8c5402f3bdf805a927a9026135ed2f5..2ab44cc7d5c89b904e5f505dc81a836d4951dbdc 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.2 +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/topoSetDict.2 @@ -25,17 +25,7 @@ actions source zoneToCell; sourceInfo { - name cylinder; - } - } - { - name rotorCells; - type cellSet; - action add; - source zoneToCell; - sourceInfo - { - name innerCylinder; + zones (cylinder innerCylinder); } } { diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict index 50c273074f068c522aa0adbfd227611ff8002c2f..14957ba5c2a12110b5da32322613e1d587794480 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict +++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict @@ -59,7 +59,7 @@ actions { name c1; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/system/topoSetDict b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/system/topoSetDict index 62cdff3e629ac966ba7e60cba5535d61f0c354ae..51c370663d5c5fd623adc1d6b7a3d0efb6d098d6 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/system/topoSetDict +++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/system/topoSetDict @@ -65,7 +65,7 @@ actions { name baffleFaceSet; type faceSet; - action delete; + action subtract; source boxToFace; sourceInfo { diff --git a/tutorials/incompressible/pimpleFoam/RAS/oscillatingInletACMI2D/system/topoSetDict b/tutorials/incompressible/pimpleFoam/RAS/oscillatingInletACMI2D/system/topoSetDict index 6fdbf3217356fd4b2122d82a6c9b7d1b4bee8bd1..efe8b3f4c65bb50e58d2b2b6cb9a4ca8fb25908f 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/oscillatingInletACMI2D/system/topoSetDict +++ b/tutorials/incompressible/pimpleFoam/RAS/oscillatingInletACMI2D/system/topoSetDict @@ -27,7 +27,7 @@ actions source patchToFace; sourceInfo { - name couple1; + patch couple1; } } { @@ -49,7 +49,7 @@ actions source patchToFace; sourceInfo { - name couple2; + patch couple2; } } { diff --git a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/createInletOutletSets.topoSetDict b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/createInletOutletSets.topoSetDict index 0149316d5245947f95b6cc779fe4cc91688fce90..a1aea929c533ae3a1d6f28970e05476c5119df10 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/createInletOutletSets.topoSetDict +++ b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/createInletOutletSets.topoSetDict @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name outerCylinder; + patch outerCylinder; } } diff --git a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/system/topoSetDict b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/system/topoSetDict index ec5a253e514427648f38e4fda5ff8fdbc540b82a..c89d90af46ec7d7c1ee7fd10bcf9a4eee1c95ed1 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/system/topoSetDict +++ b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/system/topoSetDict @@ -27,7 +27,7 @@ actions source patchToFace; sourceInfo { - name "AMI.*"; + patch "AMI.*"; } } ); diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/system/topoSetDict b/tutorials/incompressible/simpleFoam/pipeCyclic/system/topoSetDict index dbcaeb4865ff88d08482cbc3504fc87b028660de..ebf3952fe09a1ec9dea39470b75b706f53a1f037 100644 --- a/tutorials/incompressible/simpleFoam/pipeCyclic/system/topoSetDict +++ b/tutorials/incompressible/simpleFoam/pipeCyclic/system/topoSetDict @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name "side1"; + patch side1; } } { @@ -57,13 +57,13 @@ actions source patchToFace; sourceInfo { - name "walls"; + patch walls; } } { name c0; type cellSet; - action delete; + action subtract; source faceToCell; sourceInfo { diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/topoSetDict b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/topoSetDict index bcf459bfb8556409f6584c89be72564ce14b4809..58ff35ed4a26fdc4763b9c78e4d5bc2f4d6dea11 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/topoSetDict +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/topoSetDict @@ -25,8 +25,8 @@ actions source sphereToCell; sourceInfo { - centre (0.125 0.375 0.05); - radius 0.005; + origin (0.125 0.375 0.05); + radius 0.005; } } ); diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/system/topoSetDict b/tutorials/lagrangian/reactingParcelFoam/cylinder/system/topoSetDict index e0d4da9cfadddc653fe9f6589662ec93ee2f0d97..f237aab344b12e0bfbb50ed6ad0b8a2448950f95 100644 --- a/tutorials/lagrangian/reactingParcelFoam/cylinder/system/topoSetDict +++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/system/topoSetDict @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name filmWalls; + patch filmWalls; } } { diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/createObstacle.setSet b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/createObstacle.setSet index 59c9f9d9d6bbfbe6d82a764f21031d694a6f06a4..25de4d699aa616a9ba91e3c9618fc6d4ee2cf0f4 100644 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/createObstacle.setSet +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/createObstacle.setSet @@ -1,6 +1,6 @@ cellSet c0 new cellSet c0 invert -cellSet c0 delete boxToCell (0.4 0.1 0.1) (0.6 0.3 0.3) -cellSet c0 delete boxToCell (0.4 0.1 0.4) (0.6 0.3 0.6) -cellSet c0 delete boxToCell (0.4 0.4 0.1) (0.6 0.6 0.3) -cellSet c0 delete boxToCell (0.4 0.4 0.4) (0.6 0.6 0.6) +cellSet c0 subtract boxToCell (0.4 0.1 0.1) (0.6 0.3 0.3) +cellSet c0 subtract boxToCell (0.4 0.1 0.4) (0.6 0.3 0.6) +cellSet c0 subtract boxToCell (0.4 0.4 0.1) (0.6 0.6 0.3) +cellSet c0 subtract boxToCell (0.4 0.4 0.4) (0.6 0.6 0.6) diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/system/topoSetDict b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/system/topoSetDict index 24195e15d862621d52f1a0c2c16869ddf8de5d04..c60ef73a85c0c752d917b0b01b597f2ae3c6868c 100644 --- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/system/topoSetDict +++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/system/topoSetDict @@ -30,7 +30,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { @@ -40,7 +40,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { @@ -50,7 +50,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { @@ -60,7 +60,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/system/wallFilmRegion.topoSet b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/system/wallFilmRegion.topoSet index 03646e01398ef04889b98f6e7c218607ade8cd2c..8b7edbdfbfa71133f2a52b7b82ff38982d5fc3a4 100644 --- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/system/wallFilmRegion.topoSet +++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/system/wallFilmRegion.topoSet @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name filmWalls; + patch filmWalls; } } { diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/system/wallFilmRegion.topoSet b/tutorials/lagrangian/reactingParcelFoam/splashPanel/system/wallFilmRegion.topoSet index e0d4da9cfadddc653fe9f6589662ec93ee2f0d97..f237aab344b12e0bfbb50ed6ad0b8a2448950f95 100644 --- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/system/wallFilmRegion.topoSet +++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/system/wallFilmRegion.topoSet @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name filmWalls; + patch filmWalls; } } { diff --git a/tutorials/mesh/foamyHexMesh/blob/system/topoSetDict b/tutorials/mesh/foamyHexMesh/blob/system/topoSetDict index afa9c6971cdf2353977a571fec6e9dbd18f4823c..8d1ac69992b717df10071334907ba0e6d56c5366 100644 --- a/tutorials/mesh/foamyHexMesh/blob/system/topoSetDict +++ b/tutorials/mesh/foamyHexMesh/blob/system/topoSetDict @@ -110,7 +110,7 @@ actions source sphereToCell; sourceInfo { - centre (-0.3 -0.3 -0.3); + origin (-0.3 -0.3 -0.3); radius 0.4; } } diff --git a/tutorials/mesh/foamyHexMesh/flange/system/faceSetDict b/tutorials/mesh/foamyHexMesh/flange/system/faceSetDict index 107e7930e946f09a57f196e88327977eba08803d..4af8cfcb2bf2742dfea0615f28cfbfcf1a8a0001 100644 --- a/tutorials/mesh/foamyHexMesh/flange/system/faceSetDict +++ b/tutorials/mesh/foamyHexMesh/flange/system/faceSetDict @@ -18,8 +18,8 @@ FoamFile // Name of set to operate on name facesToBeRemoved; -// One of clear/new/invert/add/delete|subset/list -action new; +// One of (add | subtract | subset | clear | new | invert | list) +action new; // Actions to apply to pointSet. These are all the topoSetSource's ending // in ..ToFace (see the meshTools library). diff --git a/tutorials/mesh/foamyHexMesh/flange/system/topoSetDict-background b/tutorials/mesh/foamyHexMesh/flange/system/topoSetDict-background index 1ce14c127ced269625f069e0c7a609187396466c..7fb6380806c33d05c50e248ef3a4e2d3e737551c 100644 --- a/tutorials/mesh/foamyHexMesh/flange/system/topoSetDict-background +++ b/tutorials/mesh/foamyHexMesh/flange/system/topoSetDict-background @@ -23,7 +23,7 @@ FoamFile // // // action to perform on set. Two types: // // - require no source : clear/invert -// // - require source : new/add/delete/subset +// // - require source : add/subtract/subset/new // action new; // // The source entry varies according to the type of set: @@ -46,13 +46,15 @@ FoamFile // // Cells in cell zone // source zoneToCell; // { -// name ".*Zone"; // Name of cellZone, regular expressions allowed +// zones (".*Zone"); // Name of cellZones, regular expressions allowed +// zone ".*Zone"; // Name of cellZone, regular expressions allowed // } // // // Cells on master or slave side of faceZone // source faceZoneToCell; // { -// name ".*Zone"; // Name of faceZone, regular expressions allowed +// zones (".*Zone"); // Name of faceZones, regular expressions allowed +// zone ".*Zone"; // Name of faceZone, regular expressions allowed // option master; // master/slave // } // @@ -108,7 +110,7 @@ FoamFile // // Cells with centre within sphere // source sphereToCell; // { -// centre (0.2 0.2 -10); +// origin (0.2 0.2 -10); // radius 5.0; // } // @@ -184,13 +186,13 @@ FoamFile // // All faces of patch // source patchToFace; // { -// name ".*Wall"; // Name of patch, regular expressions allowed +// patch ".*Wall"; // Name of patch, regular expressions allowed // } // // // All faces of faceZone // source zoneToFace; // { -// name ".*Zone1"; // Name of faceZone, regular expressions allowed +// zone ".*Zone1"; // Name of faceZone, regular expressions allowed // } // // // Faces with face centre within box @@ -240,7 +242,7 @@ FoamFile // // All points in pointzone // source zoneToPoint; // { -// name ".*Zone"; // name of pointZone, regular expressions allowed +// zone ".*Zone"; // name of pointZone, regular expressions allowed // } // // // Points nearest to coordinates diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict index 3604118de25bbb0d285e006051190b46170970e3..754f878051b1ede3ef6bbc9f7e99e039cff29af3 100644 --- a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict @@ -56,7 +56,7 @@ actions { name inner; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { @@ -67,7 +67,7 @@ actions { name outer; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches index f4e1ce643035c6f64ce158524fcee27820fa2107..c5d0a898ebcc46fe34f613aef6bbb09a53e7c349 100644 --- a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches +++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches @@ -21,7 +21,7 @@ newFromPatch source patchToFace; sourceInfo { - name outer; + patch outer; } } diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/system/topoSetDict b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/system/topoSetDict index 562cea074648035b4657d8481b669d45266bc8fa..15b0923bb7ef588eef50f2cd7cddf477cabf3d02 100644 --- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/system/topoSetDict +++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/system/topoSetDict @@ -27,7 +27,7 @@ actions source zoneToCell; sourceInfo { - name topBlock; + zone topBlock; } } @@ -39,7 +39,7 @@ actions source zoneToCell; sourceInfo { - name centralBlock; + zone centralBlock; } } @@ -51,7 +51,7 @@ actions source zoneToCell; sourceInfo { - name bottomBlock; + zone bottomBlock; } } @@ -66,7 +66,7 @@ actions source patchToFace; sourceInfo { - name top; + patch top; } } @@ -192,7 +192,7 @@ actions source patchToFace; sourceInfo { - name bottom; + patch bottom; } } @@ -263,7 +263,7 @@ actions { name topBlockCells; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/system/setFieldsDict b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/system/setFieldsDict index 1743e4fe18c1f15e0ed2f26867e15b63cc266c8c..ee905dc545e50de0cc7c3f157f18adbf4484541d 100644 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/system/setFieldsDict +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/system/setFieldsDict @@ -27,8 +27,9 @@ regions ( sphereToCell { - centre (0.5 0.5 0); - radius 0.1; + centre (0.5 0.5 0); + radius 0.1; + fieldValues ( volScalarFieldValue alpha.water 0 diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/system/setFieldsDict b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/system/setFieldsDict index b9d9566b3e964848c8745b2334fe16b0ca7533b5..1ac3bd391bb9341ed6bb9f62810c1d01fcaf1ffd 100644 --- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/system/setFieldsDict +++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/system/setFieldsDict @@ -27,8 +27,9 @@ regions ( sphereToCell { - centre (0.5 0.5 0.5); - radius 0.1; + origin (0.5 0.5 0.5); + radius 0.1; + fieldValues ( volScalarFieldValue alpha.water 0 diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/createObstacle.setSet b/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/createObstacle.setSet index df2efd8a538290488e9924980130264d2ca930ec..6f646d44dc6a6105bfbe716e4d55159bdd4a74a9 100644 --- a/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/createObstacle.setSet +++ b/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/createObstacle.setSet @@ -1,3 +1,3 @@ cellSet c0 new cellSet c0 invert -cellSet c0 delete boxToCell (0.375 0.375 0) (0.625 0.625 0.25) +cellSet c0 subtract boxToCell (0.375 0.375 0) (0.625 0.625 0.25) diff --git a/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/system/topoSetDict b/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/system/topoSetDict index db9c6783c8d46f50e0b70c76bc6d4c3a6fb948bf..49101640d22dfdc86c8a5e0fd91dba07497d0759 100644 --- a/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/system/topoSetDict +++ b/tutorials/multiphase/interFoam/laminar/damBreakWithObstacle/system/topoSetDict @@ -30,7 +30,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { diff --git a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/system/topoSetDict.createCollector b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/system/topoSetDict.createCollector index da5d1cfd6c4bfef1ad068994341a9fefb76291d1..5d45a4ed6d6fcf227b087fa9d548ad6cf9c2c83b 100644 --- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/system/topoSetDict.createCollector +++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/system/topoSetDict.createCollector @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name sides; + patch sides; } } diff --git a/tutorials/multiphase/interIsoFoam/damBreakWithObstacle/system/topoSetDict b/tutorials/multiphase/interIsoFoam/damBreakWithObstacle/system/topoSetDict index db9c6783c8d46f50e0b70c76bc6d4c3a6fb948bf..49101640d22dfdc86c8a5e0fd91dba07497d0759 100644 --- a/tutorials/multiphase/interIsoFoam/damBreakWithObstacle/system/topoSetDict +++ b/tutorials/multiphase/interIsoFoam/damBreakWithObstacle/system/topoSetDict @@ -30,7 +30,7 @@ actions { name c0; type cellSet; - action delete; + action subtract; source boxToCell; sourceInfo { diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/system/createInletOutletSets.topoSetDict b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/system/createInletOutletSets.topoSetDict index 0149316d5245947f95b6cc779fe4cc91688fce90..a1aea929c533ae3a1d6f28970e05476c5119df10 100644 --- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/system/createInletOutletSets.topoSetDict +++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/system/createInletOutletSets.topoSetDict @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name outerCylinder; + patch outerCylinder; } } diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/system/topoSetDict b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/system/topoSetDict index ec5a253e514427648f38e4fda5ff8fdbc540b82a..c89d90af46ec7d7c1ee7fd10bcf9a4eee1c95ed1 100644 --- a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/system/topoSetDict +++ b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/system/topoSetDict @@ -27,7 +27,7 @@ actions source patchToFace; sourceInfo { - name "AMI.*"; + patch "AMI.*"; } } ); diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictHull b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictHull index 5533f402e59adf0e027d9e674aa421ddfc8df0ce..13a0176bd459c9ecf25e8e22bbee858023f12308 100644 --- a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictHull +++ b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictHull @@ -17,14 +17,14 @@ FoamFile actions ( { - name bgr0; // all around bgr - type cellSet; - action new; - source zoneToCell; - sourceInfo - { - name background; - } + name bgr0; // all around bgr + type cellSet; + action new; + source zoneToCell; + sourceInfo + { + zone background; + } } { name hullBox0; // all around bgr @@ -33,7 +33,7 @@ actions source zoneToCell; sourceInfo { - name hullBox; + zone hullBox; } } { @@ -43,7 +43,7 @@ actions source zoneToCell; sourceInfo { - name propeller; + zone propeller; } } { @@ -53,7 +53,7 @@ actions source zoneToCell; sourceInfo { - name rudder; + zone rudder; } } diff --git a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictPropeller b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictPropeller index f1dd3a613dc3c9dd05b5c11bcb7b5f6f34079c40..cd94103ab287e8437fc5c98ca39874efd25e2723 100644 --- a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictPropeller +++ b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictPropeller @@ -17,14 +17,14 @@ FoamFile actions ( { - name bgr0; // all around bgr - type cellSet; - action new; - source zoneToCell; - sourceInfo - { - name background; - } + name bgr0; // all around bgr + type cellSet; + action new; + source zoneToCell; + sourceInfo + { + zone background; + } } { name hullBox0; // all around hull @@ -33,7 +33,7 @@ actions source zoneToCell; sourceInfo { - name hullBox; + zone hullBox; } } { @@ -43,7 +43,7 @@ actions source zoneToCell; sourceInfo { - name propeller; + zone propeller; } } { @@ -53,7 +53,7 @@ actions source zoneToCell; sourceInfo { - name rudder; + zone rudder; } } diff --git a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictRudder b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictRudder index 4e79efeb1dc14f9f2b1990ba146813501141f312..b70cb4fee3b47778c2cfd44856a6ae926da7c4ad 100644 --- a/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictRudder +++ b/tutorials/multiphase/overInterDyMFoam/boatAndPropeller/system/topoSetDictRudder @@ -17,14 +17,14 @@ FoamFile actions ( { - name bgr0; // all around bgr - type cellSet; - action new; - source zoneToCell; - sourceInfo - { - name background; - } + name bgr0; // all around bgr + type cellSet; + action new; + source zoneToCell; + sourceInfo + { + zone background; + } } { name hullBox0; // all around hull @@ -33,7 +33,7 @@ actions source zoneToCell; sourceInfo { - name hullBox; + zone hullBox; } } { @@ -43,7 +43,7 @@ actions source zoneToCell; sourceInfo { - name propeller; + zone propeller; } } { @@ -53,7 +53,7 @@ actions source zoneToCell; sourceInfo { - name rudder; + zone rudder; } } diff --git a/tutorials/multiphase/overInterDyMFoam/twoSimpleRotors/system/topoSetDict b/tutorials/multiphase/overInterDyMFoam/twoSimpleRotors/system/topoSetDict index 6fb992b37a846e2dc759c741455bbc9acfdb3eaa..95d02e89a80433fc2b1444ebf3f4b697aa66261c 100644 --- a/tutorials/multiphase/overInterDyMFoam/twoSimpleRotors/system/topoSetDict +++ b/tutorials/multiphase/overInterDyMFoam/twoSimpleRotors/system/topoSetDict @@ -59,7 +59,7 @@ actions { name c1; type cellSet; - action delete; + action subtract; source cellToCell; sourceInfo { diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict index 6dfb30f4ecdb84aca1f4ec4ab9c4366adcc7dd99..8e258e26d372ef6428ea60a3954c7991ba057b7f 100644 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict @@ -41,7 +41,7 @@ actions source patchToFace; sourceInfo { - name freeSurface; + patch freeSurface; } } diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict-selectBottom b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict-selectBottom index ca30f92595b343196c4580a9968aff21b9a4cb2c..f1f9c238617c2ce2d26ca4ac522daa8aae0a1440 100644 --- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict-selectBottom +++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/system/topoSetDict-selectBottom @@ -24,7 +24,7 @@ actions source patchToFace; sourceInfo { - name floatingObject; + patch floatingObject; } } diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/topoSetDict b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/topoSetDict index 6dfb30f4ecdb84aca1f4ec4ab9c4366adcc7dd99..8e258e26d372ef6428ea60a3954c7991ba057b7f 100644 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/topoSetDict +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/system/topoSetDict @@ -41,7 +41,7 @@ actions source patchToFace; sourceInfo { - name freeSurface; + patch freeSurface; } } diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } ); diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict index 00bdad762d966774a2bafa9ec9dd67f25b25bb49..1aa54cc8196d783d62c0db6611d9c7932be3c15b 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict +++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/topoSetDict @@ -24,7 +24,7 @@ actions source zoneToCell; sourceInfo { - name rotor; + zone rotor; } } );