diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index bc800b920a..fa48186c90 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 - sets to set to the source set" << nl + << " new - use all elements from the source set" << nl << " add - adds all elements from the source set" << nl - << " delete - deletes ,," << nl + << " subtract - subtract the source set elements" << nl << " subset - 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 f08ea75169..a9cd056c58 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 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("source")); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 66302acdfa..cc78c31090 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 37bc94df27..44001f4dd8 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("centre")); + const vector origin(dict.getCompat("origin", {{"centre", 1806}})); const word fieldName(dict.get("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("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("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 c31e2606b9..062322da57 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 98f6be7a19..942ace2c4a 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 dd76d0b0c8..c68d0b7351 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 e48fe2e030..92ce3a058a 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 4ac4139c42..d4fc619be0 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 87e782dc4b..138d2d0af0 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(p, iF, dict), - origin_(dict.lookupCompat("origin", {{"centre", 1712}})), + origin_(dict.getCompat("origin", {{"centre", 1712}})), axis_(dict.lookup("axis")), axialVelocity_(Function1::New("axialVelocity", dict)), radialVelocity_(Function1::New("radialVelocity", dict)), diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.H index e5831682df..8741de56d1 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 fac0740aed..051888aa9b 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 58c3fa156f..d13a5f43e5 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)/faceToCell/faceToCell.C -$(cellSources)/fieldToCell/fieldToCell.C -$(cellSources)/pointToCell/pointToCell.C -$(cellSources)/shapeToCell/shapeToCell.C +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)/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 5691a89e31..67509335f6 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("centre")), - radius_(dict.get("radius")) -{ - bounds() = boundBox + searchableSphere ( - centre_ - radius_*vector::one, - centre_ + radius_*vector::one - ); -} + io, + dict.getCompat("origin", {{"centre", -1806}}), + dict.get("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 69ee3ce22a..6978a90c1c 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 coordinates() const { - return tmp::New(1, centre_); + return tmp::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 7714d038da..9cb921f3dd 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 7360bd0e90..09a7920f11 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 6761dab811..f061205c8a 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("set")) + cellToCell + ( + mesh, + dict.get("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 23fb8be3d8..2b619f12f0 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 6a88cfb80e..6421182264 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("p1")), - point2_(dict.get("p2")), - outerRadius_(dict.get("outerRadius")), - innerRadius_(dict.get("innerRadius")) + cylinderAnnulusToCell + ( + mesh, + dict.get("p1"), + dict.get("p2"), + dict.get("outerRadius"), + dict.get("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 af8bd0bad2..9c02f64dfd 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 a8ceeb408b..9eda86e0f4 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("p1")), - point2_(dict.get("p2")), - radius_(dict.get("radius")) + cylinderToCell + ( + mesh, + dict.get("p1"), + dict.get("p2"), + dict.get("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 0d3db7640a..f87bd7dbdc 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 5499aaa963..508b187dc8 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("set")), - option_(faceActionNames_.get("option", dict)) + faceToCell + ( + mesh, + dict.get("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 ced05a8f4e..64e85b3817 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 8b10efb06a..c4d453e308 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("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("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 3096d7ddf7..e082198271 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 150eeb2ab9..2ec9e8045d 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 ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + if (verbose_) { - Info<< " Adding all cells with value of field " << fieldName_ - << " within range " << min_ << ".." << max_ << endl; + Info << " Field min:" << min(field) << " max:" << max(field) << nl; + } + + if (action == topoSetSource::ADD || action == topoSetSource::NEW) + { + 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("field")), - min_(dict.get("min")), - max_(dict.get("max")) + fieldToCell + ( + mesh, + dict.get("field"), + dict.get("min"), + dict.get("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 c09e2773c8..6b596f166e 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 13fda7b6d9..43f2281067 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("value")) + labelToCell(mesh, dict.get("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 ca9c12e1ff..d9f1c06b3c 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 e4c55b966b..eee88d9a4f 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