diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index c383e52fdae69fe929079b01cdb265a8e67b85fe..8b95ab2952db68493e542fae02422ecbafb62a33 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -206,6 +206,7 @@ $(pointSources)/surfaceToPoint/surfaceToPoint.C $(pointSources)/zoneToPoint/zoneToPoint.C faceZoneSources = sets/faceZoneSources +$(faceZoneSources)/topoSetFaceZoneSource/topoSetFaceZoneSource.C $(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C $(faceZoneSources)/setsToFaceZone/setsToFaceZone.C $(faceZoneSources)/setToFaceZone/setToFaceZone.C @@ -214,9 +215,11 @@ $(faceZoneSources)/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C $(faceZoneSources)/planeToFaceZone/planeToFaceZone.C cellZoneSources = sets/cellZoneSources +$(cellZoneSources)/topoSetCellZoneSource/topoSetCellZoneSource.C $(cellZoneSources)/setToCellZone/setToCellZone.C pointZoneSources = sets/pointZoneSources +$(pointZoneSources)/topoSetPointZoneSource/topoSetPointZoneSource.C $(pointZoneSources)/setToPointZone/setToPointZone.C momentOfInertia/momentOfInertia.C diff --git a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C index c62f23f1a4ac87e012936df2b48ddab5f548567d..3ffdac89bb561955eb4a67bd8e7c4fc39c06f32c 100644 --- a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C +++ b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,6 @@ License namespace Foam { - defineTypeNameAndDebug(topoSetCellSource, 0); defineRunTimeSelectionTable(topoSetCellSource, word); defineRunTimeSelectionTable(topoSetCellSource, istream); } @@ -48,7 +47,8 @@ Foam::topoSetCellSource::topoSetCellSource(const polyMesh& mesh) // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // -Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New +Foam::autoPtr<Foam::topoSetCellSource> +Foam::topoSetCellSource::New ( const word& sourceType, const polyMesh& mesh, @@ -62,7 +62,7 @@ Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New FatalIOErrorInLookup ( dict, - "topoSetCellSource", + "cellSetSource", sourceType, *wordConstructorTablePtr_ ) << exit(FatalIOError); @@ -72,7 +72,8 @@ Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New } -Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New +Foam::autoPtr<Foam::topoSetCellSource> +Foam::topoSetCellSource::New ( const word& sourceType, const polyMesh& mesh, @@ -85,7 +86,7 @@ Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New { FatalErrorInLookup ( - "topoSetCellSource", + "cellSetSource", sourceType, *istreamConstructorTablePtr_ ) << exit(FatalError); diff --git a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H index ac658a10fc160596da86b55b93af311d8b577fc6..087b5a115b503b0d7ace4cbd7ef1af98031b022c 100644 --- a/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H +++ b/src/meshTools/sets/cellSources/topoSetCellSource/topoSetCellSource.H @@ -58,9 +58,6 @@ class topoSetCellSource { public: - //- Runtime type information - TypeName("topoSetCellSource"); - // Declare run-time constructor selection table // For the dictionary constructor diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C index ba425724d69ba466be43d7b4bebcaf3ab3a36c26..e269b316ef5d43d943ff72a6ba84fbf37bb79823 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,9 @@ namespace Foam defineTypeNameAndDebug(setToCellZone, 0); addToRunTimeSelectionTable(topoSetSource, setToCellZone, word); addToRunTimeSelectionTable(topoSetSource, setToCellZone, istream); + + addToRunTimeSelectionTable(topoSetCellZoneSource, setToCellZone, word); + addToRunTimeSelectionTable(topoSetCellZoneSource, setToCellZone, istream); } @@ -57,7 +60,7 @@ Foam::setToCellZone::setToCellZone const word& setName ) : - topoSetSource(mesh), + topoSetCellZoneSource(mesh), setName_(setName) {} @@ -68,7 +71,7 @@ Foam::setToCellZone::setToCellZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetCellZoneSource(mesh), setName_(dict.get<word>("set")) {} @@ -79,7 +82,7 @@ Foam::setToCellZone::setToCellZone Istream& is ) : - topoSetSource(mesh), + topoSetCellZoneSource(mesh), setName_(checkIs(is)) {} @@ -96,6 +99,7 @@ void Foam::setToCellZone::applyToSet { WarningInFunction << "Operation only allowed on a cellZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H index 8ae418164d90b4628ea4cebb7e630540dafdcd92..a5769511ccb2a157d1aae5c5e0bc0fd0bfd086f4 100644 --- a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H @@ -82,7 +82,7 @@ SourceFiles #ifndef setToCellZone_H #define setToCellZone_H -#include "topoSetSource.H" +#include "topoSetCellZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,7 +95,7 @@ namespace Foam class setToCellZone : - public topoSetSource + public topoSetCellZoneSource { // Private Data @@ -130,12 +130,6 @@ public: // Member Functions - //- The source category is a cellZone - virtual topoSetSource::sourceType setType() const - { - return CELLZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.C b/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.C new file mode 100644 index 0000000000000000000000000000000000000000..c4123bab6eeb4afe6e71112cc49960ac6eb6fc4f --- /dev/null +++ b/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "topoSetCellZoneSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineRunTimeSelectionTable(topoSetCellZoneSource, word); + defineRunTimeSelectionTable(topoSetCellZoneSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetCellZoneSource::topoSetCellZoneSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetCellZoneSource> +Foam::topoSetCellZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalIOErrorInLookup + ( + dict, + "cellZoneSource", + sourceType, + *wordConstructorTablePtr_ + ) << exit(FatalIOError); + } + + return autoPtr<topoSetCellZoneSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetCellZoneSource> +Foam::topoSetCellZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInLookup + ( + "cellZoneSource", + sourceType, + *istreamConstructorTablePtr_ + ) << exit(FatalError); + } + + return autoPtr<topoSetCellZoneSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.H b/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.H new file mode 100644 index 0000000000000000000000000000000000000000..73784f1a500d8eff9a7c62a23b8b44e953c37f48 --- /dev/null +++ b/src/meshTools/sets/cellZoneSources/topoSetCellZoneSource/topoSetCellZoneSource.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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::topoSetCellZoneSource + +Description + The \c topoSetCellZoneSource is a intermediate class + for handling \c topoSet sources for selecting cell zones. + + The class is not an executable \c topoSet itself, + yet a provider for common entries to its derived \c topoSet. + +SourceFiles + topoSetCellZoneSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetCellZoneSource_H +#define topoSetCellZoneSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class cellZoneSet; + +/*---------------------------------------------------------------------------*\ + Class topoSetCellZoneSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetCellZoneSource +: + public topoSetSource +{ +public: + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetCellZoneSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetCellZoneSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetCellZoneSource(const polyMesh& mesh); + + //- Clone (disallowed) + autoPtr<topoSetCellZoneSource> clone() const + { + NotImplemented; + return nullptr; + } + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetCellZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetCellZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetCellZoneSource() = default; + + + // Member Functions + + //- The source category is a cellZone + virtual topoSetSource::sourceType setType() const + { + return CELLZONE_SOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C index beb9a2f8b4a2fe8a0036c16df44cf3a4f8480206..f7c9cc191808b2bb196fbfb3c2158386fc18983b 100644 --- a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C +++ b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,6 @@ License namespace Foam { - defineTypeNameAndDebug(topoSetFaceSource, 0); defineRunTimeSelectionTable(topoSetFaceSource, word); defineRunTimeSelectionTable(topoSetFaceSource, istream); } @@ -48,7 +47,8 @@ Foam::topoSetFaceSource::topoSetFaceSource(const polyMesh& mesh) // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // -Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New +Foam::autoPtr<Foam::topoSetFaceSource> +Foam::topoSetFaceSource::New ( const word& sourceType, const polyMesh& mesh, @@ -62,7 +62,7 @@ Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New FatalIOErrorInLookup ( dict, - "topoSetFaceSource", + "faceSetSource", sourceType, *wordConstructorTablePtr_ ) << exit(FatalIOError); @@ -72,7 +72,8 @@ Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New } -Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New +Foam::autoPtr<Foam::topoSetFaceSource> +Foam::topoSetFaceSource::New ( const word& sourceType, const polyMesh& mesh, @@ -85,7 +86,7 @@ Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New { FatalErrorInLookup ( - "topoSetFaceSource", + "faceSetSource", sourceType, *istreamConstructorTablePtr_ ) << exit(FatalError); diff --git a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H index 10455d5032ad9144c842f1ad06935de50885efa9..aeed1ffb374fa1b83429c2f9af54f25ce1b1ed8a 100644 --- a/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H +++ b/src/meshTools/sets/faceSources/topoSetFaceSource/topoSetFaceSource.H @@ -58,9 +58,6 @@ class topoSetFaceSource { public: - //- Runtime type information - TypeName("topoSetFaceSource"); - // Declare run-time constructor selection table // For the dictionary constructor diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C index 3a73f2bd093606174dc4a3118ef0f871d6ccb51b..5475d90018a157b57ab32d69c35e3cb7a2473f86 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C @@ -37,6 +37,7 @@ namespace Foam defineTypeNameAndDebug(zoneToFace, 0); addToRunTimeSelectionTable(topoSetSource, zoneToFace, word); addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream); + addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, word); addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, istream); addNamedToRunTimeSelectionTable diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C index cc9623d464647ad2048eaa5bc80b97ea1043cf37..01017b20a90702bbf448de81c55e86b58c33ea7e 100644 --- a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,19 @@ namespace Foam defineTypeNameAndDebug(faceZoneToFaceZone, 0); addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, word); addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, istream); + + addToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + faceZoneToFaceZone, + word + ); + addToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + faceZoneToFaceZone, + istream + ); } @@ -57,7 +70,7 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone const word& setName ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(setName) {} @@ -68,7 +81,7 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(dict.get<word>("zone")) {} @@ -79,7 +92,7 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone Istream& is ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(checkIs(is)) {} @@ -96,6 +109,7 @@ void Foam::faceZoneToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H index afbcaf086ae6e3643a7368b613915c23fb7b3cb4..ad67b6440146d315a3f81ba44b3faae295df9ecf 100644 --- a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H @@ -81,7 +81,7 @@ SourceFiles #ifndef faceZoneToFaceZone_H #define faceZoneToFaceZone_H -#include "topoSetSource.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -94,7 +94,7 @@ namespace Foam class faceZoneToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { // Private Data @@ -114,11 +114,7 @@ public: // Constructors //- Construct from components - faceZoneToFaceZone - ( - const polyMesh& mesh, - const word& setName - ); + faceZoneToFaceZone(const polyMesh& mesh, const word& setName); //- Construct from dictionary faceZoneToFaceZone(const polyMesh& mesh, const dictionary& dict); @@ -133,12 +129,6 @@ public: // Member Functions - //- The source category is a faceZone - virtual topoSetSource::sourceType setType() const - { - return FACEZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.C b/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.C index 2fbd45576d0870f6231da892a7268c9d01ce02b6..e1b8a8727476646bef4f846d7a439969545cb3c7 100644 --- a/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.C @@ -41,6 +41,24 @@ namespace Foam defineTypeNameAndDebug(planeToFaceZone, 0); addToRunTimeSelectionTable(topoSetSource, planeToFaceZone, word); addToRunTimeSelectionTable(topoSetSource, planeToFaceZone, istream); + + addToRunTimeSelectionTable(topoSetFaceZoneSource, planeToFaceZone, word); + addToRunTimeSelectionTable(topoSetFaceZoneSource, planeToFaceZone, istream); + + addNamedToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + planeToFaceZone, + word, + plane + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + planeToFaceZone, + istream, + plane + ); } @@ -352,7 +370,7 @@ Foam::planeToFaceZone::planeToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), point_(dict.get<vector>("point")), normal_(dict.get<vector>("normal")), option_ @@ -368,7 +386,7 @@ Foam::planeToFaceZone::planeToFaceZone Istream& is ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), point_(checkIs(is)), normal_(checkIs(is)), option_(faceZoneActionNames_.read(checkIs(is))) @@ -387,25 +405,30 @@ void Foam::planeToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } - else - { - faceZoneSet& fzSet = refCast<faceZoneSet>(set); - if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) - { - Info<< " Adding faces which form a plane at " << point_ - << " with normal " << normal_ << endl; + faceZoneSet& zoneSet = refCast<faceZoneSet>(set); - combine(fzSet, true); - } - else if (action == topoSetSource::DELETE) + if (action == topoSetSource::NEW || action == topoSetSource::ADD) + { + if (verbose_) { - Info<< " Removing faces which form a plane at " << point_ - << " with normal " << normal_ << endl; + Info<< " Adding faces that form a plane at " + << point_ << " with normal " << normal_ << endl; + } - combine(fzSet, false); + combine(zoneSet, true); + } + else if (action == topoSetSource::SUBTRACT) + { + if (verbose_) + { + Info<< " Removing faces that form a plane at " + << point_ << " with normal " << normal_ << endl; } + + combine(zoneSet, false); } } diff --git a/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.H b/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.H index c63cc8199a81f51e3a5213628223d1f0e5a3985f..0a7548f8f3afd2c5ef6ceac4f0270d5f896ff9dd 100644 --- a/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.H @@ -101,23 +101,20 @@ SourceFiles #ifndef planeToFaceZone_H #define planeToFaceZone_H -#include "topoSetSource.H" -#include "Enum.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -class faceZoneSet; - /*---------------------------------------------------------------------------*\ Class planeToFaceZone Declaration \*---------------------------------------------------------------------------*/ class planeToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { public: @@ -166,18 +163,10 @@ public: planeToFaceZone() = delete; //- Construct from dictionary - planeToFaceZone - ( - const polyMesh& mesh, - const dictionary& dict - ); + planeToFaceZone(const polyMesh& mesh, const dictionary& dict); //- Construct from Istream - planeToFaceZone - ( - const polyMesh& mesh, - Istream& - ); + planeToFaceZone(const polyMesh& mesh, Istream& is); //- Destructor @@ -186,11 +175,6 @@ public: // Member Functions - virtual sourceType setType() const - { - return FACESETSOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index 854a6b655bc006ded0141fa37e4b776de24eac89..ab008e5d6c80cf0e3b130ccb031bd540052ac9eb 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -45,6 +45,20 @@ namespace Foam searchableSurfaceToFaceZone, word ); + addToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + searchableSurfaceToFaceZone, + word + ); + addNamedToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + searchableSurfaceToFaceZone, + word, + surface + ); + } @@ -92,7 +106,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), surfacePtr_ ( searchableSurface::New @@ -140,6 +154,7 @@ void Foam::searchableSurfaceToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H index 15bdae2d2126f08efe4bd25ca2ed0c09637eb591..de400b95684815b86d270033d15f8a5a7480bd18 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.H @@ -86,13 +86,14 @@ SourceFiles #ifndef searchableSurfaceToFaceZone_H #define searchableSurfaceToFaceZone_H -#include "topoSetSource.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward Declarations class searchableSurface; /*---------------------------------------------------------------------------*\ @@ -101,7 +102,7 @@ class searchableSurface; class searchableSurfaceToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { // Private Data @@ -155,12 +156,6 @@ public: // Member Functions - //- The source category is a faceZone - virtual topoSetSource::sourceType setType() const - { - return FACEZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C index da4b3aca219aa506e85127991797b2b19ca7613d..8110ea597b26ede22c15966b6a9cfb9b90a05591 100644 --- a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,19 @@ namespace Foam defineTypeNameAndDebug(setAndNormalToFaceZone, 0); addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, word); addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, istream); + + addToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + setAndNormalToFaceZone, + word + ); + addToRunTimeSelectionTable + ( + topoSetFaceZoneSource, + setAndNormalToFaceZone, + istream + ); } @@ -58,7 +71,7 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone const vector& normal ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(setName), normal_(normal) {} @@ -70,7 +83,7 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(dict.get<word>("faceSet")), normal_(dict.get<vector>("normal")) {} @@ -82,7 +95,7 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone Istream& is ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(checkIs(is)), normal_(checkIs(is)) {} @@ -100,6 +113,7 @@ void Foam::setAndNormalToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H index 784e00338b495bd6ec865e685d616d88b4ce2669..3eb5e9aceb463de146df54be155d2a1c623b482e 100644 --- a/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setAndNormalToFaceZone/setAndNormalToFaceZone.H @@ -80,7 +80,7 @@ SourceFiles #ifndef setAndNormalToFaceZone_H #define setAndNormalToFaceZone_H -#include "topoSetSource.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -93,7 +93,7 @@ namespace Foam class setAndNormalToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { // Private Data @@ -135,12 +135,6 @@ public: // Member Functions - //- The source category is a faceZone - virtual topoSetSource::sourceType setType() const - { - return FACEZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C index 5de2572750808f7ad3b38273c5534a376f409a57..8cd3d3646c9c187f62bfa780435c415cc032bfe3 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,9 @@ namespace Foam defineTypeNameAndDebug(setToFaceZone, 0); addToRunTimeSelectionTable(topoSetSource, setToFaceZone, word); addToRunTimeSelectionTable(topoSetSource, setToFaceZone, istream); + + addToRunTimeSelectionTable(topoSetFaceZoneSource, setToFaceZone, word); + addToRunTimeSelectionTable(topoSetFaceZoneSource, setToFaceZone, istream); } @@ -58,7 +61,7 @@ Foam::setToFaceZone::setToFaceZone const word& setName ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(setName) {} @@ -69,7 +72,7 @@ Foam::setToFaceZone::setToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(dict.get<word>("faceSet")) { if (dict.found("cellSet")) @@ -87,7 +90,7 @@ Foam::setToFaceZone::setToFaceZone Istream& is ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), setName_(checkIs(is)) {} @@ -104,6 +107,7 @@ void Foam::setToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H index bf072d4f0166fe512e957922b8aebceefd4fc22b..657458c56399c537bb88e5886d2aa93b3598d1b5 100644 --- a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H @@ -87,7 +87,7 @@ SourceFiles #ifndef setToFaceZone_H #define setToFaceZone_H -#include "topoSetSource.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -100,7 +100,7 @@ namespace Foam class setToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { // Private Data @@ -139,12 +139,6 @@ public: // Member Functions - //- The source category is a faceZone - virtual topoSetSource::sourceType setType() const - { - return FACEZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C index 451a8f61cae25381db37411ae94cbec44159a9d2..b630a7f151292ef68eda00f57b2b3fe21bd1a4d9 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C @@ -39,6 +39,9 @@ namespace Foam defineTypeNameAndDebug(setsToFaceZone, 0); addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, word); addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, istream); + + addToRunTimeSelectionTable(topoSetFaceZoneSource, setsToFaceZone, word); + addToRunTimeSelectionTable(topoSetFaceZoneSource, setsToFaceZone, istream); } @@ -61,7 +64,7 @@ Foam::setsToFaceZone::setsToFaceZone const bool flip ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), faceSetName_(faceSetName), cellSetName_(cellSetName), flip_(flip) @@ -74,7 +77,7 @@ Foam::setsToFaceZone::setsToFaceZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), faceSetName_(dict.get<word>("faceSet")), cellSetName_(dict.get<word>("cellSet")), flip_(dict.getOrDefault("flip", false)) @@ -87,7 +90,7 @@ Foam::setsToFaceZone::setsToFaceZone Istream& is ) : - topoSetSource(mesh), + topoSetFaceZoneSource(mesh), faceSetName_(checkIs(is)), cellSetName_(checkIs(is)), flip_(false) @@ -106,6 +109,7 @@ void Foam::setsToFaceZone::applyToSet { WarningInFunction << "Operation only allowed on a faceZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H index 6c4aec63a050ba2bdcd201da6813c89214c9030d..fc965df8a9e0fcb9e10e7476478374b90e22eb02 100644 --- a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H @@ -89,7 +89,7 @@ SourceFiles #ifndef setsToFaceZone_H #define setsToFaceZone_H -#include "topoSetSource.H" +#include "topoSetFaceZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -102,7 +102,7 @@ namespace Foam class setsToFaceZone : - public topoSetSource + public topoSetFaceZoneSource { // Private Data @@ -149,12 +149,6 @@ public: // Member Functions - //- The source category is a pointSet - virtual topoSetSource::sourceType setType() const - { - return FACEZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.C b/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.C new file mode 100644 index 0000000000000000000000000000000000000000..0ae4dc9befb1412723eb3c859cabdb1d84749b19 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "topoSetFaceZoneSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineRunTimeSelectionTable(topoSetFaceZoneSource, word); + defineRunTimeSelectionTable(topoSetFaceZoneSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetFaceZoneSource::topoSetFaceZoneSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetFaceZoneSource> +Foam::topoSetFaceZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalIOErrorInLookup + ( + dict, + "faceZoneSource", + sourceType, + *wordConstructorTablePtr_ + ) << exit(FatalIOError); + } + + return autoPtr<topoSetFaceZoneSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetFaceZoneSource> +Foam::topoSetFaceZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInLookup + ( + "faceZoneSource", + sourceType, + *istreamConstructorTablePtr_ + ) << exit(FatalError); + } + + return autoPtr<topoSetFaceZoneSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.H b/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.H new file mode 100644 index 0000000000000000000000000000000000000000..5d651eb281bc722b84eeaea884435b5fe9c34353 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/topoSetFaceZoneSource/topoSetFaceZoneSource.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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::topoSetFaceZoneSource + +Description + The \c topoSetFaceZoneSource is a intermediate class + for handling \c topoSet sources for selecting face zones. + + The class is not an executable \c topoSet itself, + yet a provider for common entries to its derived \c topoSet. + +SourceFiles + topoSetFaceZoneSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetFaceZoneSource_H +#define topoSetFaceZoneSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class faceZoneSet; + +/*---------------------------------------------------------------------------*\ + Class topoSetFaceZoneSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetFaceZoneSource +: + public topoSetSource +{ +public: + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetFaceZoneSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetFaceZoneSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetFaceZoneSource(const polyMesh& mesh); + + //- Clone (disallowed) + autoPtr<topoSetFaceZoneSource> clone() const + { + NotImplemented; + return nullptr; + } + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetFaceZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetFaceZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetFaceZoneSource() = default; + + + // Member Functions + + //- The source category is a faceZone + virtual topoSetSource::sourceType setType() const + { + return FACEZONE_SOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C index 67e828e373c6ccf2ace356e29340322fa4f7805c..b57fa617cfa29cc8693e12c093a938e1d57719d7 100644 --- a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C +++ b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,6 @@ License namespace Foam { - defineTypeNameAndDebug(topoSetPointSource, 0); defineRunTimeSelectionTable(topoSetPointSource, word); defineRunTimeSelectionTable(topoSetPointSource, istream); } @@ -48,7 +47,8 @@ Foam::topoSetPointSource::topoSetPointSource(const polyMesh& mesh) // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // -Foam::autoPtr<Foam::topoSetPointSource> Foam::topoSetPointSource::New +Foam::autoPtr<Foam::topoSetPointSource> +Foam::topoSetPointSource::New ( const word& sourceType, const polyMesh& mesh, @@ -62,7 +62,7 @@ Foam::autoPtr<Foam::topoSetPointSource> Foam::topoSetPointSource::New FatalIOErrorInLookup ( dict, - "topoSetPointSource", + "pointSetSource", sourceType, *wordConstructorTablePtr_ ) << exit(FatalIOError); @@ -85,7 +85,7 @@ Foam::autoPtr<Foam::topoSetPointSource> Foam::topoSetPointSource::New { FatalErrorInLookup ( - "topoSetPointSource", + "pointSetSource", sourceType, *istreamConstructorTablePtr_ ) << exit(FatalError); diff --git a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H index a0af5cd906b2159bccd651beea6b257d8dcc75d8..aac0aee5d9a1341d110076e8c19af403bf0480c4 100644 --- a/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H +++ b/src/meshTools/sets/pointSources/topoSetPointSource/topoSetPointSource.H @@ -58,9 +58,6 @@ class topoSetPointSource { public: - //- Runtime type information - TypeName("topoSetPointSource"); - // Declare run-time constructor selection table // For the dictionary constructor diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C index 56e891f6f2b2962081e7db8a571e2293cb37faed..8952f2baf9a1cd97ca3760e1dfe5f1e286253187 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C @@ -37,6 +37,7 @@ namespace Foam defineTypeNameAndDebug(zoneToPoint, 0); addToRunTimeSelectionTable(topoSetSource, zoneToPoint, word); addToRunTimeSelectionTable(topoSetSource, zoneToPoint, istream); + addToRunTimeSelectionTable(topoSetPointSource, zoneToPoint, word); addToRunTimeSelectionTable(topoSetPointSource, zoneToPoint, istream); addNamedToRunTimeSelectionTable diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C index 2fe5b7de3a38c5ee3a60b7a572be94834cb38811..d711a8e57541ade8b773ebbb60c137f83d03de04 100644 --- a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C @@ -38,6 +38,9 @@ namespace Foam defineTypeNameAndDebug(setToPointZone, 0); addToRunTimeSelectionTable(topoSetSource, setToPointZone, word); addToRunTimeSelectionTable(topoSetSource, setToPointZone, istream); + + addToRunTimeSelectionTable(topoSetPointZoneSource, setToPointZone, word); + addToRunTimeSelectionTable(topoSetPointZoneSource, setToPointZone, istream); } @@ -57,7 +60,7 @@ Foam::setToPointZone::setToPointZone const word& setName ) : - topoSetSource(mesh), + topoSetPointZoneSource(mesh), setName_(setName) {} @@ -68,7 +71,7 @@ Foam::setToPointZone::setToPointZone const dictionary& dict ) : - topoSetSource(mesh), + topoSetPointZoneSource(mesh), setName_(dict.get<word>("set")) {} @@ -79,7 +82,7 @@ Foam::setToPointZone::setToPointZone Istream& is ) : - topoSetSource(mesh), + topoSetPointZoneSource(mesh), setName_(checkIs(is)) {} @@ -96,6 +99,7 @@ void Foam::setToPointZone::applyToSet { WarningInFunction << "Operation only allowed on a pointZoneSet." << endl; + return; } else { diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H index 7110a417492d841ea4456d35772f8312a95e5c38..6c165b32983ef8549994fdd5974a314bce6e0894 100644 --- a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H @@ -83,7 +83,7 @@ SourceFiles #ifndef setToPointZone_H #define setToPointZone_H -#include "topoSetSource.H" +#include "topoSetPointZoneSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -96,7 +96,7 @@ namespace Foam class setToPointZone : - public topoSetSource + public topoSetPointZoneSource { // Private Data @@ -135,12 +135,6 @@ public: // Member Functions - //- The source category is a pointZone - virtual topoSetSource::sourceType setType() const - { - return POINTZONE_SOURCE; - } - virtual void applyToSet ( const topoSetSource::setAction action, diff --git a/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.C b/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.C new file mode 100644 index 0000000000000000000000000000000000000000..e1ded575c78dad12c41bd67253cf320b53d7d33c --- /dev/null +++ b/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "topoSetPointZoneSource.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineRunTimeSelectionTable(topoSetPointZoneSource, word); + defineRunTimeSelectionTable(topoSetPointZoneSource, istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::topoSetPointZoneSource::topoSetPointZoneSource(const polyMesh& mesh) +: + topoSetSource(mesh) +{} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::topoSetPointZoneSource> +Foam::topoSetPointZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict +) +{ + auto cstrIter = wordConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalIOErrorInLookup + ( + dict, + "pointZoneSource", + sourceType, + *wordConstructorTablePtr_ + ) << exit(FatalIOError); + } + + return autoPtr<topoSetPointZoneSource>(cstrIter()(mesh, dict)); +} + + +Foam::autoPtr<Foam::topoSetPointZoneSource> +Foam::topoSetPointZoneSource::New +( + const word& sourceType, + const polyMesh& mesh, + Istream& is +) +{ + auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType); + + if (!cstrIter.found()) + { + FatalErrorInLookup + ( + "pointZoneSource", + sourceType, + *istreamConstructorTablePtr_ + ) << exit(FatalError); + } + + return autoPtr<topoSetPointZoneSource>(cstrIter()(mesh, is)); +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.H b/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.H new file mode 100644 index 0000000000000000000000000000000000000000..ab0ea3d07225dd2eff645ca61f69dd98ab4e5dcf --- /dev/null +++ b/src/meshTools/sets/pointZoneSources/topoSetPointZoneSource/topoSetPointZoneSource.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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::topoSetPointZoneSource + +Description + The \c topoSetPointZoneSource is a intermediate class + for handling \c topoSet sources for selecting point zones. + + The class is not an executable \c topoSet itself, + yet a provider for common entries to its derived \c topoSet. + +SourceFiles + topoSetPointZoneSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef topoSetPointZoneSource_H +#define topoSetPointZoneSource_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class pointZoneSet; + +/*---------------------------------------------------------------------------*\ + Class topoSetPointZoneSource Declaration +\*---------------------------------------------------------------------------*/ + +class topoSetPointZoneSource +: + public topoSetSource +{ +public: + + // Declare run-time constructor selection table + + // For the dictionary constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetPointZoneSource, + word, + ( + const polyMesh& mesh, + const dictionary& dict + ), + (mesh, dict) + ); + + // For the Istream constructor + declareRunTimeSelectionTable + ( + autoPtr, + topoSetPointZoneSource, + istream, + ( + const polyMesh& mesh, + Istream& is + ), + (mesh, is) + ); + + + // Constructors + + //- Construct from components + explicit topoSetPointZoneSource(const polyMesh& mesh); + + //- Clone (disallowed) + autoPtr<topoSetPointZoneSource> clone() const + { + NotImplemented; + return nullptr; + } + + + // Selectors + + //- Return a reference to the selected source type + static autoPtr<topoSetPointZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + const dictionary& dict + ); + + //- Return a reference to the selected source type + static autoPtr<topoSetPointZoneSource> New + ( + const word& sourceType, + const polyMesh& mesh, + Istream& is + ); + + + //- Destructor + virtual ~topoSetPointZoneSource() = default; + + + // Member Functions + + //- The source category is a pointZone + virtual topoSetSource::sourceType setType() const + { + return POINTZONE_SOURCE; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index 9584631a239c8955e55712db2301d7ce34bfa9c4..80e6415f927b45c6f374e6175b02e7f9f08efb61 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,7 +50,8 @@ namespace Foam // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // -Foam::autoPtr<Foam::topoSet> Foam::topoSet::New +Foam::autoPtr<Foam::topoSet> +Foam::topoSet::New ( const word& setType, const polyMesh& mesh, @@ -75,7 +76,8 @@ Foam::autoPtr<Foam::topoSet> Foam::topoSet::New } -Foam::autoPtr<Foam::topoSet> Foam::topoSet::New +Foam::autoPtr<Foam::topoSet> +Foam::topoSet::New ( const word& setType, const polyMesh& mesh, @@ -100,7 +102,8 @@ Foam::autoPtr<Foam::topoSet> Foam::topoSet::New } -Foam::autoPtr<Foam::topoSet> Foam::topoSet::New +Foam::autoPtr<Foam::topoSet> +Foam::topoSet::New ( const word& setType, const polyMesh& mesh,