sphere.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::zoneGenerators::sphere
26 
27 Description
28  A zoneGenerator which selects points, cells or faces with centres either
29  inside or outside a sphere.
30 
31  By default all the points, cells or faces of the mesh are tested for being
32  inside or outside the sphere but an optional single zone or list of zones
33  may be provided and those points, cells or faces are tested instead. This
34  provides an efficient method of hierarchical sub-division of space where an
35  initial selection of points cells or faces is refined by selecting the
36  sub-set inside or outside the given sphere rather than having to generate
37  another zone to intersect with.
38 
39 Usage
40  \table
41  Property | Description | Required | Default value
42  type | Type: sphere | yes |
43  name | Name of the zone | no | zoneGenerator name
44  zoneType | Type of zone | yes |
45  select | Select either the inside or outside | no | inside
46  moveUpdate | Switch to update after mesh motion | no | false
47  centre | Centre of the sphere | yes |
48  radius | Radius of the sphere | yes |
49  zone | Optional zone to sub-set | no |
50  zones | Optional list of zones to sub-set | no |
51  \endtable
52 
53  A cellZone named \c sphere1 containing the cells with centres inside
54  a cylinder can be generated by
55  \verbatim
56  sphere1
57  {
58  type sphere;
59  zoneType cell;
60 
61  centre (-0.003 0.0025 0);
62  radius 0.001;
63  }
64  \endverbatim
65 
66 See also
67  zoneGenerators::volume
68 
69 SourceFiles
70  sphere.C
71 
72 \*---------------------------------------------------------------------------*/
73 
74 #ifndef sphere_zoneGenerator_H
75 #define sphere_zoneGenerator_H
76 
77 #include "volume.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 namespace zoneGenerators
84 {
85 
86 /*---------------------------------------------------------------------------*\
87  Class sphere Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 class sphere
91 :
92  public volume
93 {
94  // Private Data
95 
96  //- Centre
97  vector centre_;
98 
99  //- Radius
100  scalar radius_;
101 
102  //- Radius squared
103  scalar radiusSqr_;
104 
105 
106  // Private Member Functions
107 
108  friend class volume;
109 
110  //- Return true if the spherees contain the given point
111  inline bool contains(const point& p) const;
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("sphere");
118 
119 
120  // Constructors
121 
122  //- Construct from dictionary
123  sphere
124  (
125  const word& name,
126  const polyMesh& mesh,
127  const dictionary& dict
128  );
129 
130 
131  //- Destructor
132  virtual ~sphere();
133 
134 
135  // Member Functions
136 
137  virtual zoneSet generate() const;
138 };
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace zoneGenerators
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
const word & name() const
virtual ~sphere()
Destructor.
Definition: sphere.C:67
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: sphere.C:73
TypeName("sphere")
Runtime type information.
sphere(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sphere.C:52
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:41
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dictionary dict
volScalarField & p