Commit 8969110f authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: distinguish between face zone topoSetSource (#1060)

- add intermediate class topoSetFaceZoneSource
  and corresponding New() factories
parent 54139592
......@@ -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
......
......@@ -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);
......
......@@ -58,9 +58,6 @@ class topoSetCellSource
{
public:
//- Runtime type information
TypeName("topoSetCellSource");
// Declare run-time constructor selection table
// For the dictionary constructor
......
......@@ -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
{
......
......@@ -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,
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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));
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
......@@ -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);
......
......@@ -58,9 +58,6 @@ class topoSetFaceSource
{
public:
//- Runtime type information
TypeName("topoSetFaceSource");
// Declare run-time constructor selection table
// For the dictionary constructor
......
......@@ -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
......
......@@ -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
{
......
......@@ -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,
......
......@@ -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,