cylinder.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::cylinder
26 
27 Description
28  A zoneGenerator which selects points, cells or faces with centres either
29  inside or outside a cylinder.
30 
31  By default all the points, cells or faces of the mesh are tested for being
32  inside or outside the cylinder 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 cylinder 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: cylinder | 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  point1 | First point on cylinder axis | yes |
48  point2 | Second point on cylinder axis | yes |
49  radius | Radius of the cylinder | yes |
50  zone | Optional zone to sub-set | no |
51  zones | Optional list of zones to sub-set | no |
52  \endtable
53 
54  A cellZone named \c cylinder1 containing the cells with centres inside
55  a cylinder is generated by
56  \verbatim
57  cylinder1
58  {
59  type cylinder;
60  zoneType cell;
61 
62  point1 (-0.0075 0 -1);
63  point2 (-0.003 0.0025 1);
64  radius 0.001;
65  }
66  \endverbatim
67 
68 See also
69  zoneGenerators::volume
70 
71 SourceFiles
72  cylinder.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef cylinder_zoneGenerator_H
77 #define cylinder_zoneGenerator_H
78 
79 #include "volume.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 namespace zoneGenerators
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class cylinder Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 class cylinder
93 :
94  public volume
95 {
96  // Private Data
97 
98  //- First point on cylinder axis
99  vector point1_;
100 
101  //- Second point on cylinder axis
102  vector point2_;
103 
104  //- Radius
105  scalar radius_;
106 
107  //- Axis vector calculated from point1_ and point2_
108  vector axis_;
109 
110  //- Radius squared calculated from radius_
111  scalar rad2_;
112 
113  //- Magnitude of the axis vector squared calculated from axis_
114  scalar magAxis2_;
115 
116 
117  // Private Member Functions
118 
119  friend class volume;
120 
121  //- Return true if the cylinderes contain the given point
122  inline bool contains(const point& p) const;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("cylinder");
129 
130 
131  // Constructors
132 
133  //- Construct from dictionary
134  cylinder
135  (
136  const word& name,
137  const polyMesh& mesh,
138  const dictionary& dict
139  );
140 
141 
142  //- Destructor
143  virtual ~cylinder();
144 
145 
146  // Member Functions
147 
148  virtual zoneSet generate() const;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace zoneGenerators
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
const word & name() const
virtual ~cylinder()
Destructor.
Definition: cylinder.C:83
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: cylinder.C:89
cylinder(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: cylinder.C:65
TypeName("cylinder")
Runtime type information.
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
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