box.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-2026 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::box
26 
27 Description
28  A zoneGenerator which selects points, cells or faces with centres either
29  inside or outside a box or list of boxes.
30 
31  By default all the points, cells or faces of the mesh are tested for being
32  inside or outside the box or boxes but an optional single zone or list of
33  zones may be provided and those points, cells or faces are tested instead.
34  This provides an efficient method of hierarchical sub-division of space
35  where an initial selection of points cells or faces is refined by selecting
36  the sub-set inside or outside the given box or boxes rather than having to
37  generate another zone to intersect with.
38 
39 Usage
40  \table
41  Property | Description | Required | Default value
42  type | Type: box | 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  box | Min and max bounding points of the box | no |
48  boxes | List of bounding point pairs of the boxes | no |
49  min | Min bounding point of the box | no |
50  max | Max bounding point of the box | no |
51  zone | Optional zone to sub-set | no |
52  zones | Optional list of zones to sub-set | no |
53  \endtable
54 
55  A cellZone named \c box1 containing the cells with centres inside a
56  single box defined by its minimum and maximum bounding points is generated
57  by
58  \verbatim
59  box1
60  {
61  type box;
62  zoneType cell;
63 
64  min (-0.0075 0 -1);
65  max (-0.003 0.0025 1);
66  }
67  \endverbatim
68  or named \c box1 specifically if the zoneGenerator has to be named
69  differently:
70  \verbatim
71  <zoneGenerator name>
72  {
73  type box;
74  zoneType cell;
75  name box1;
76 
77  min (-0.0075 0 -1);
78  max (-0.003 0.0025 1);
79  }
80  \endverbatim
81  Alternatively the box can be specified using \c box entry followed by the
82  minimum and maximum bounding points:
83  \verbatim
84  box2
85  {
86  type box;
87  zoneType cell;
88 
89  box (-0.0075 0 -1) (-0.003 0.0025 1);
90  }
91  \endverbatim
92  or a list of boxes can be specified using the \c boxes entry followed by a
93  list of minimum and maximum bounding point pairs:
94  \verbatim
95  boxes
96  {
97  type box;
98  zoneType cell;
99 
100  boxes
101  (
102  (-0.0075 0 -1) (-0.003 0.0025 1)
103  (-0.005 0.001 -1) (-0.001 0.0025 1)
104  );
105  }
106  \endverbatim
107  To select all the cells outside a box set the optional \c select control
108  to \c outside:
109  \verbatim
110  box2
111  {
112  type box;
113  zoneType cell;
114  select outside;
115 
116  box (-0.0075 0 -1) (-0.003 0.0025 1);
117  }
118  \endverbatim
119 
120 See also
121  zoneGenerators::volume
122  boundBox
123 
124 SourceFiles
125  box.C
126 
127 \*---------------------------------------------------------------------------*/
128 
129 #ifndef box_zoneGenerator_H
130 #define box_zoneGenerator_H
131 
132 #include "volume.H"
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 namespace Foam
137 {
138 namespace zoneGenerators
139 {
140 
141 /*---------------------------------------------------------------------------*\
142  Class box Declaration
143 \*---------------------------------------------------------------------------*/
144 
145 class box
146 :
147  public volume
148 {
149  // Private Data
150 
151  //- Bounding boxes
152  List<boundBox> boxes_;
153 
154 
155  // Private Member Functions
156 
157  friend class volume;
158 
159  //- Return true if the boxes contain the given point
160  inline bool contains(const point& p) const;
161 
162 
163 public:
164 
165  //- Runtime type information
166  TypeName("box");
167 
168 
169  // Constructors
170 
171  //- Construct from dictionary
172  box
173  (
174  const word& name,
175  const polyMesh& mesh,
176  const dictionary& dict
177  );
178 
179 
180  //- Destructor
181  virtual ~box();
182 
183 
184  // Member Functions
185 
186  virtual zoneSet generate() const;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace zoneGenerators
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
Motion of the mesh specified as a list of pointMeshMovers.
const word & name() const
Return the zoneGenerator name.
const polyMesh & mesh() const
Return reference to the polyMesh.
virtual ~box()
Destructor.
Definition: box.C:80
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: box.C:86
friend class volume
Definition: box.H:216
TypeName("box")
Runtime type information.
box(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: box.C:60
const dimensionSet volume
Definition: annulus.H:177
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:41
dictionary dict
volScalarField & p