View Issue Details

IDProjectCategoryView StatusLast Update
0003453OpenFOAMPatchpublic2020-02-16 11:31
Reporterhandrake0724 Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0003453: wrong setType value in cylinder and cylinderAnnulusToFace and addtional pointSource
DescriptionI found that cylinderToFace and cylinderAnnulusToFace was returning wrong type in setType() member function as follows:

virtual sourceType setType() const
{
    return CELLSETSOURCE;
}

this type should be FACESETSOURCE.
I noticed that faceSource and pointSource are lack of similar features available cellSource like sphereToCell, cylinderToCell, cylinderAnnulusToCell. so, I added additional classes sphereToFace, cylinderToPoint, cylinderAnnulusToPoint, sphereToPoint.
these classes may be useful working with topoSet, setSet utilities.

I have attached patch files for those things.
Please review it.
TagsNo tags attached.

Activities

handrake0724

2020-02-14 16:53

viewer  

patch.diff (34,094 bytes)   
diff --git a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H
index 7ca5cb49e..45518675b 100644
--- a/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H
+++ b/src/meshTools/sets/faceSources/cylinderAnnulusToFace/cylinderAnnulusToFace.H
@@ -115,7 +115,7 @@ public:
 
         virtual sourceType setType() const
         {
-            return CELLSETSOURCE;
+            return FACESETSOURCE;
         }
 
         virtual void applyToSet
diff --git a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H
index 03f735477..a3a320c04 100644
--- a/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H
+++ b/src/meshTools/sets/faceSources/cylinderToFace/cylinderToFace.H
@@ -111,7 +111,7 @@ public:
 
         virtual sourceType setType() const
         {
-            return CELLSETSOURCE;
+            return FACESETSOURCE;
         }
 
         virtual void applyToSet
diff --git a/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.C b/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.C
new file mode 100644
index 000000000..864078def
--- /dev/null
+++ b/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.C
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "sphereToFace.H"
+#include "polyMesh.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(sphereToFace, 0);
+    addToRunTimeSelectionTable(topoSetSource, sphereToFace, word);
+    addToRunTimeSelectionTable(topoSetSource, sphereToFace, istream);
+}
+
+
+Foam::topoSetSource::addToUsageTable Foam::sphereToFace::usage_
+(
+    sphereToFace::typeName,
+    "\n    Usage: sphereToFace (centreX centreY centreZ) radius\n\n"
+    "    Select all faces with face centre within bounding sphere\n\n"
+);
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::sphereToFace::combine(topoSet& set, const bool add) const
+{
+    const pointField& ctrs = mesh_.faceCentres();
+
+    const scalar radSquared = radius_*radius_;
+
+    forAll(ctrs, facei)
+    {
+        scalar offset = magSqr(centre_ - ctrs[facei]);
+        if (offset <= radSquared)
+        {
+            addOrDelete(set, facei, add);
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::sphereToFace::sphereToFace
+(
+    const polyMesh& mesh,
+    const vector& centre,
+    const scalar radius
+)
+:
+    topoSetSource(mesh),
+    centre_(centre),
+    radius_(radius)
+{}
+
+
+Foam::sphereToFace::sphereToFace
+(
+    const polyMesh& mesh,
+    const dictionary& dict
+)
+:
+    topoSetSource(mesh),
+    centre_(dict.lookup("centre")),
+    radius_(dict.lookup<scalar>("radius"))
+{}
+
+
+Foam::sphereToFace::sphereToFace
+(
+    const polyMesh& mesh,
+    Istream& is
+)
+:
+    topoSetSource(mesh),
+    centre_(checkIs(is)),
+    radius_(readScalar(checkIs(is)))
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::sphereToFace::~sphereToFace()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::sphereToFace::applyToSet
+(
+    const topoSetSource::setAction action,
+    topoSet& set
+) const
+{
+    if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
+    {
+        Info<< "    Adding faces with centre within sphere, with centre = "
+            << centre_ << " and radius = " << radius_ << endl;
+
+        combine(set, true);
+    }
+    else if (action == topoSetSource::DELETE)
+    {
+        Info<< "    Removing faces with centre within sphere, with centre = "
+            << centre_ << " and radius = " << radius_ << endl;
+
+        combine(set, false);
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.H b/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.H
new file mode 100644
index 000000000..a89ee0783
--- /dev/null
+++ b/src/meshTools/sets/faceSources/sphereToFace/sphereToFace.H
@@ -0,0 +1,130 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::sphereToFace
+
+Description
+    A topoSetSource to select cells based on cell centres inside sphere.
+
+SourceFiles
+    sphereToFace.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef sphereToFace_H
+#define sphereToFace_H
+
+#include "topoSetSource.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class sphereToFace Declaration
+\*---------------------------------------------------------------------------*/
+
+class sphereToFace
+:
+    public topoSetSource
+{
+
+    // Private Data
+
+        //- Add usage string
+        static addToUsageTable usage_;
+
+        //- Centre
+        vector centre_;
+
+        //- Radius
+        scalar radius_;
+
+
+    // Private Member Functions
+
+        void combine(topoSet& set, const bool add) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("sphereToFace");
+
+
+    // Constructors
+
+        //- Construct from components
+        sphereToFace
+        (
+            const polyMesh& mesh,
+            const vector& centre,
+            const scalar radius
+        );
+
+        //- Construct from dictionary
+        sphereToFace
+        (
+            const polyMesh& mesh,
+            const dictionary& dict
+        );
+
+        //- Construct from Istream
+        sphereToFace
+        (
+            const polyMesh& mesh,
+            Istream&
+        );
+
+
+    //- Destructor
+    virtual ~sphereToFace();
+
+
+    // Member Functions
+
+        virtual sourceType setType() const
+        {
+            return FACESETSOURCE;
+        }
+
+        virtual void applyToSet
+        (
+            const topoSetSource::setAction action,
+            topoSet&
+        ) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.C b/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.C
new file mode 100644
index 000000000..accdb2a58
--- /dev/null
+++ b/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.C
@@ -0,0 +1,160 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2017-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "cylinderAnnulusToPoint.H"
+#include "polyMesh.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(cylinderAnnulusToPoint, 0);
+    addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToPoint, word);
+    addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToPoint, istream);
+}
+
+
+Foam::topoSetSource::addToUsageTable Foam::cylinderAnnulusToPoint::usage_
+(
+    cylinderAnnulusToPoint::typeName,
+    "\n    Usage: cylinderAnnulusToPoint (p1X p1Y p1Z) (p2X p2Y p2Z)"
+    " outerRadius innerRadius\n\n"
+    "    Select all points within bounding cylinder annulus\n\n"
+);
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::cylinderAnnulusToPoint::combine(topoSet& set, const bool add) const
+{
+    const vector axis = p2_ - p1_;
+    const scalar orad2 = sqr(outerRadius_);
+    const scalar irad2 = sqr(innerRadius_);
+    const scalar magAxis2 = magSqr(axis);
+
+    const pointField& ctrs = mesh_.points();
+
+    forAll(ctrs, pointi)
+    {
+        vector d = ctrs[pointi] - p1_;
+        scalar magD = d & axis;
+
+        if ((magD > 0) && (magD < magAxis2))
+        {
+            scalar d2 = (d & d) - sqr(magD)/magAxis2;
+            if ((d2 < orad2) && (d2 > irad2))
+            {
+                addOrDelete(set, pointi, add);
+            }
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::cylinderAnnulusToPoint::cylinderAnnulusToPoint
+(
+    const polyMesh& mesh,
+    const vector& p1,
+    const vector& p2,
+    const scalar outerRadius,
+    const scalar innerRadius
+)
+:
+    topoSetSource(mesh),
+    p1_(p1),
+    p2_(p2),
+    outerRadius_(outerRadius),
+    innerRadius_(innerRadius)
+{}
+
+
+Foam::cylinderAnnulusToPoint::cylinderAnnulusToPoint
+(
+    const polyMesh& mesh,
+    const dictionary& dict
+)
+:
+    topoSetSource(mesh),
+    p1_(dict.lookup("p1")),
+    p2_(dict.lookup("p2")),
+    outerRadius_(dict.lookup<scalar>("outerRadius")),
+    innerRadius_(dict.lookup<scalar>("innerRadius"))
+{}
+
+
+Foam::cylinderAnnulusToPoint::cylinderAnnulusToPoint
+(
+    const polyMesh& mesh,
+    Istream& is
+)
+:
+    topoSetSource(mesh),
+    p1_(checkIs(is)),
+    p2_(checkIs(is)),
+    outerRadius_(readScalar(checkIs(is))),
+    innerRadius_(readScalar(checkIs(is)))
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::cylinderAnnulusToPoint::~cylinderAnnulusToPoint()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::cylinderAnnulusToPoint::applyToSet
+(
+    const topoSetSource::setAction action,
+    topoSet& set
+) const
+{
+    if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
+    {
+        Info<< "    Adding points within cylinder annulus,"
+            << " with p1 = "
+            << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
+        << " and inner radius = " << innerRadius_
+        << endl;
+
+        combine(set, true);
+    }
+    else if (action == topoSetSource::DELETE)
+    {
+        Info<< "    Removing points within cylinder, with p1 = "
+            << p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
+        << " and inner radius " << innerRadius_
+        << endl;
+
+        combine(set, false);
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.H b/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.H
new file mode 100644
index 000000000..233cb1b66
--- /dev/null
+++ b/src/meshTools/sets/pointSources/cylinderAnnulusToPoint/cylinderAnnulusToPoint.H
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2017-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::cylinderAnnulusToPoint
+
+Description
+    A topoSetSource to select faces based on face centres inside a
+    cylinder annulus.
+
+SourceFiles
+    cylinderAnnulusToPoint.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef cylinderAnnulusToPoint_H
+#define cylinderAnnulusToPoint_H
+
+#include "topoSetSource.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class cylinderAnnulusToPoint Declaration
+\*---------------------------------------------------------------------------*/
+
+class cylinderAnnulusToPoint
+:
+    public topoSetSource
+{
+
+    // Private Data
+
+        //- Add usage string
+        static addToUsageTable usage_;
+
+        //- First point on cylinder axis
+        vector p1_;
+
+        //- Second point on cylinder axis
+        vector p2_;
+
+        //- Outer Radius
+        scalar outerRadius_;
+
+        //- Inner Radius
+        scalar innerRadius_;
+
+
+    // Private Member Functions
+
+        void combine(topoSet& set, const bool add) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("cylinderAnnulusToPoint");
+
+
+    // Constructors
+
+        //- Construct from components
+        cylinderAnnulusToPoint
+        (
+            const polyMesh& mesh,
+            const vector& p1,
+            const vector& p2,
+            const scalar outerRadius,
+            const scalar innerRadius
+        );
+
+        //- Construct from dictionary
+        cylinderAnnulusToPoint
+        (
+            const polyMesh& mesh,
+            const dictionary& dict
+        );
+
+        //- Construct from Istream
+        cylinderAnnulusToPoint
+        (
+            const polyMesh& mesh,
+            Istream&
+        );
+
+
+    // Destructor
+    virtual ~cylinderAnnulusToPoint();
+
+    // Member Functions
+
+        virtual sourceType setType() const
+        {
+            return POINTSETSOURCE;
+        }
+
+        virtual void applyToSet
+        (
+            const topoSetSource::setAction action,
+            topoSet&
+        ) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.C b/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.C
new file mode 100644
index 000000000..c02258ee0
--- /dev/null
+++ b/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.C
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2017-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "cylinderToPoint.H"
+#include "polyMesh.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(cylinderToPoint, 0);
+    addToRunTimeSelectionTable(topoSetSource, cylinderToPoint, word);
+    addToRunTimeSelectionTable(topoSetSource, cylinderToPoint, istream);
+}
+
+
+Foam::topoSetSource::addToUsageTable Foam::cylinderToPoint::usage_
+(
+    cylinderToPoint::typeName,
+    "\n    Usage: cylinderToPoint (p1X p1Y p1Z) (p2X p2Y p2Z) radius\n\n"
+    "    Select all points within bounding cylinder\n\n"
+);
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::cylinderToPoint::combine(topoSet& set, const bool add) const
+{
+    const vector axis = p2_ - p1_;
+    const scalar rad2 = sqr(radius_);
+    const scalar magAxis2 = magSqr(axis);
+
+    const pointField& ctrs = mesh_.points();
+
+    forAll(ctrs, pointi)
+    {
+        vector d = ctrs[pointi] - p1_;
+        scalar magD = d & axis;
+
+        if ((magD > 0) && (magD < magAxis2))
+        {
+            scalar d2 = (d & d) - sqr(magD)/magAxis2;
+            if (d2 < rad2)
+            {
+                addOrDelete(set, pointi, add);
+            }
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::cylinderToPoint::cylinderToPoint
+(
+    const polyMesh& mesh,
+    const vector& p1,
+    const vector& p2,
+    const scalar radius
+)
+:
+    topoSetSource(mesh),
+    p1_(p1),
+    p2_(p2),
+    radius_(radius)
+{}
+
+
+Foam::cylinderToPoint::cylinderToPoint
+(
+    const polyMesh& mesh,
+    const dictionary& dict
+)
+:
+    topoSetSource(mesh),
+    p1_(dict.lookup("p1")),
+    p2_(dict.lookup("p2")),
+    radius_(dict.lookup<scalar>("radius"))
+{}
+
+
+Foam::cylinderToPoint::cylinderToPoint
+(
+    const polyMesh& mesh,
+    Istream& is
+)
+:
+    topoSetSource(mesh),
+    p1_(checkIs(is)),
+    p2_(checkIs(is)),
+    radius_(readScalar(checkIs(is)))
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::cylinderToPoint::~cylinderToPoint()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::cylinderToPoint::applyToSet
+(
+    const topoSetSource::setAction action,
+    topoSet& set
+) const
+{
+    if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
+    {
+        Info<< "    Adding points within cylinder, with p1 = "
+            << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
+
+        combine(set, true);
+    }
+    else if (action == topoSetSource::DELETE)
+    {
+        Info<< "    Removing points within cylinder, with p1 = "
+            << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
+
+        combine(set, false);
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.H b/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.H
new file mode 100644
index 000000000..9e171568b
--- /dev/null
+++ b/src/meshTools/sets/pointSources/cylinderToPoint/cylinderToPoint.H
@@ -0,0 +1,133 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2017-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::cylinderToPoint
+
+Description
+    A topoSetSource to select faces based on face centres inside a cylinder.
+
+SourceFiles
+    cylinderToPoint.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef cylinderToPoint_H
+#define cylinderToPoint_H
+
+#include "topoSetSource.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class cylinderToPoint Declaration
+\*---------------------------------------------------------------------------*/
+
+class cylinderToPoint
+:
+    public topoSetSource
+{
+
+    // Private Data
+
+        //- Add usage string
+        static addToUsageTable usage_;
+
+        //- First point on cylinder axis
+        vector p1_;
+
+        //- Second point on cylinder axis
+        vector p2_;
+
+        //- Radius
+        scalar radius_;
+
+
+    // Private Member Functions
+
+        void combine(topoSet& set, const bool add) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("cylinderToPoint");
+
+
+    // Constructors
+
+        //- Construct from components
+        cylinderToPoint
+        (
+            const polyMesh& mesh,
+            const vector& p1,
+            const vector& p2,
+            const scalar radius
+        );
+
+        //- Construct from dictionary
+        cylinderToPoint
+        (
+            const polyMesh& mesh,
+            const dictionary& dict
+        );
+
+        //- Construct from Istream
+        cylinderToPoint
+        (
+            const polyMesh& mesh,
+            Istream&
+        );
+
+
+    //- Destructor
+    virtual ~cylinderToPoint();
+
+
+    // Member Functions
+
+        virtual sourceType setType() const
+        {
+            return POINTSETSOURCE;
+        }
+
+        virtual void applyToSet
+        (
+            const topoSetSource::setAction action,
+            topoSet&
+        ) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.C b/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.C
new file mode 100644
index 000000000..2f465d5d4
--- /dev/null
+++ b/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.C
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "sphereToPoint.H"
+#include "polyMesh.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(sphereToPoint, 0);
+    addToRunTimeSelectionTable(topoSetSource, sphereToPoint, word);
+    addToRunTimeSelectionTable(topoSetSource, sphereToPoint, istream);
+}
+
+
+Foam::topoSetSource::addToUsageTable Foam::sphereToPoint::usage_
+(
+    sphereToPoint::typeName,
+    "\n    Usage: sphereToPoint (centreX centreY centreZ) radius\n\n"
+    "    Select all points within bounding sphere\n\n"
+);
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::sphereToPoint::combine(topoSet& set, const bool add) const
+{
+    const pointField& ctrs = mesh_.points();
+
+    const scalar radSquared = radius_*radius_;
+
+    forAll(ctrs, pointi)
+    {
+        scalar offset = magSqr(centre_ - ctrs[pointi]);
+        if (offset <= radSquared)
+        {
+            addOrDelete(set, pointi, add);
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::sphereToPoint::sphereToPoint
+(
+    const polyMesh& mesh,
+    const vector& centre,
+    const scalar radius
+)
+:
+    topoSetSource(mesh),
+    centre_(centre),
+    radius_(radius)
+{}
+
+
+Foam::sphereToPoint::sphereToPoint
+(
+    const polyMesh& mesh,
+    const dictionary& dict
+)
+:
+    topoSetSource(mesh),
+    centre_(dict.lookup("centre")),
+    radius_(dict.lookup<scalar>("radius"))
+{}
+
+
+Foam::sphereToPoint::sphereToPoint
+(
+    const polyMesh& mesh,
+    Istream& is
+)
+:
+    topoSetSource(mesh),
+    centre_(checkIs(is)),
+    radius_(readScalar(checkIs(is)))
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::sphereToPoint::~sphereToPoint()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::sphereToPoint::applyToSet
+(
+    const topoSetSource::setAction action,
+    topoSet& set
+) const
+{
+    if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
+    {
+        Info<< "    Adding points within sphere, with centre = "
+            << centre_ << " and radius = " << radius_ << endl;
+
+        combine(set, true);
+    }
+    else if (action == topoSetSource::DELETE)
+    {
+        Info<< "    Removing points within sphere, with centre = "
+            << centre_ << " and radius = " << radius_ << endl;
+
+        combine(set, false);
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.H b/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.H
new file mode 100644
index 000000000..4c9af7427
--- /dev/null
+++ b/src/meshTools/sets/pointSources/sphereToPoint/sphereToPoint.H
@@ -0,0 +1,130 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     | Website:  https://openfoam.org
+    \\  /    A nd           | Copyright (C) 2011-2019 OpenFOAM Foundation
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::sphereToPoint
+
+Description
+    A topoSetSource to select cells based on cell centres inside sphere.
+
+SourceFiles
+    sphereToPoint.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef sphereToPoint_H
+#define sphereToPoint_H
+
+#include "topoSetSource.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class sphereToPoint Declaration
+\*---------------------------------------------------------------------------*/
+
+class sphereToPoint
+:
+    public topoSetSource
+{
+
+    // Private Data
+
+        //- Add usage string
+        static addToUsageTable usage_;
+
+        //- Centre
+        vector centre_;
+
+        //- Radius
+        scalar radius_;
+
+
+    // Private Member Functions
+
+        void combine(topoSet& set, const bool add) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("sphereToPoint");
+
+
+    // Constructors
+
+        //- Construct from components
+        sphereToPoint
+        (
+            const polyMesh& mesh,
+            const vector& centre,
+            const scalar radius
+        );
+
+        //- Construct from dictionary
+        sphereToPoint
+        (
+            const polyMesh& mesh,
+            const dictionary& dict
+        );
+
+        //- Construct from Istream
+        sphereToPoint
+        (
+            const polyMesh& mesh,
+            Istream&
+        );
+
+
+    //- Destructor
+    virtual ~sphereToPoint();
+
+
+    // Member Functions
+
+        virtual sourceType setType() const
+        {
+            return POINTSETSOURCE;
+        }
+
+        virtual void applyToSet
+        (
+            const topoSetSource::setAction action,
+            topoSet&
+        ) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
patch.diff (34,094 bytes)   

henry

2020-02-14 17:10

manager   ~0011175

Thanks for the report, I have corrected cylinderAnnulusToFace, cylinderToFace.

> I added additional classes sphereToFace, cylinderToPoint, cylinderAnnulusToPoint, sphereToPoint. these classes may be useful working with topoSet, setSet utilities.

We don't have a use case for these and they have never been requested. Do you have cases that need them? We don't want to add lost of code to OpenFOAM which is not needed and never used as it increases the maintenance overhead and it is already difficult to secure funding for the current maintenance load.

handrake0724

2020-02-14 17:33

viewer   ~0011176

cellSource subclasses like boxToCell, etc. selects cells if cell center is within the specified region.
due to this behavior, sometimes the selected zone looks a little bit different than I expected.
while I was looking for a way, studied sets classes and reached the idea adding those classes.
Thus, with the same shape but different selection method, it would be handy to set refinement zone.

henry

2020-02-14 17:40

manager   ~0011177

Last edited: 2020-02-14 17:40

We don't have a use case for these and they have never been requested. Do you have cases that need them?
Can you supply a suitable test case which shows the need and advantage of them?

handrake0724

2020-02-14 18:24

viewer   ~0011178

the attached file is what I would like to make mesh with topoSet. this is a simple case but maybe my intention is to provide handy way to select cells with centers within region and also cells with intersecting region.
mesh.tar.gz (2,210 bytes)

henry

2020-02-14 18:35

manager   ~0011179

I have downloaded the case but it is not clear what topoSet is needed for, the sets are not used.

handrake0724

2020-02-15 16:55

viewer   ~0011181

Sorry, I noticed the case file was not enough and repacked.
FYI, the results from boxToCell and boxToPoint are attached which shows different behavior of selecting cells.
I am not sure about other's use case with sets library, I sometimes needed different selecting behavior like boxToPoint.
mesh.tar-2.gz (2,841 bytes)
withboxToCell.png (33,354 bytes)   
withboxToCell.png (33,354 bytes)   
withboxToPoint.png (34,970 bytes)   
withboxToPoint.png (34,970 bytes)   

henry

2020-02-15 17:10

manager   ~0011182

> I sometimes needed different selecting behavior like boxToPoint.

For what cases? Can you provide the case for which you added this functionality?

handrake0724

2020-02-15 17:49

viewer   ~0011183

in offshore field, coupling of potential and cfd solutions is a main topic for studying wave load for non linear wave. So EOM (Euler overlay method) which is a similar method to relaxation method implemented in waves2foam is likely to become a standard method in this field. In the eom method, synthesizing zones are set with sets library. At the time when I was not familiar with OpenFOAM, the zones were made with boxToCell but the selected cells were not satisfactory. Now I figured out it could be boxToPoint instead. I can not share the code though.
I think these classes find some guys usage. I noticed today openfoam-plus had them I am not sure since when.
You think it does not find any usage and is in user support then it is fine

henry

2020-02-15 18:06

manager   ~0011184

We have never needed them and they have never been requested and it is also not clear if you need them or if so for what; we don't have a case demonstrating this. I am happy to include and maintain them if they are needed but if they are not needed then it would be a maintenance overhead without funding. If you would like us to include and maintain code which only you need at the moment will you contribute to OpenFOAM maintenance? See

https://openfoam.org/news/funding-2020/
https://openfoam.org/maintenance/

handrake0724

2020-02-16 11:16

viewer   ~0011187

Unfortunately I don't have any fund to support you at the moment. I am fine with the bug fix and would like to close this issue.

henry

2020-02-16 11:31

manager   ~0011188

Resolved by commit 4deaba90f726697bdbb7be24ff900a67aaad2e59

Issue History

Date Modified Username Field Change
2020-02-14 16:53 handrake0724 New Issue
2020-02-14 16:53 handrake0724 File Added: patch.diff
2020-02-14 17:10 henry Note Added: 0011175
2020-02-14 17:33 handrake0724 Note Added: 0011176
2020-02-14 17:40 henry Note Added: 0011177
2020-02-14 17:40 henry Note Edited: 0011177
2020-02-14 18:24 handrake0724 File Added: mesh.tar.gz
2020-02-14 18:24 handrake0724 Note Added: 0011178
2020-02-14 18:35 henry Note Added: 0011179
2020-02-15 16:55 handrake0724 File Added: mesh.tar-2.gz
2020-02-15 16:55 handrake0724 File Added: withboxToCell.png
2020-02-15 16:55 handrake0724 File Added: withboxToPoint.png
2020-02-15 16:55 handrake0724 Note Added: 0011181
2020-02-15 17:10 henry Note Added: 0011182
2020-02-15 17:49 handrake0724 Note Added: 0011183
2020-02-15 18:06 henry Note Added: 0011184
2020-02-16 11:16 handrake0724 Note Added: 0011187
2020-02-16 11:31 henry Assigned To => henry
2020-02-16 11:31 henry Status new => closed
2020-02-16 11:31 henry Resolution open => fixed
2020-02-16 11:31 henry Fixed in Version => dev
2020-02-16 11:31 henry Note Added: 0011188