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 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  treeBoundBoxList
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 #include "treeBoundBoxList.H"
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 namespace Foam
138 {
139 namespace zoneGenerators
140 {
141 
142 /*---------------------------------------------------------------------------*\
143  Class box Declaration
144 \*---------------------------------------------------------------------------*/
145 
146 class box
147 :
148  public volume
149 {
150  // Private Data
151 
152  //- Bounding boxes
153  treeBoundBoxList boxes_;
154 
155 
156  // Private Member Functions
157 
158  friend class volume;
159 
160  //- Return true if the boxes contain the given point
161  inline bool contains(const point& p) const;
162 
163 
164 public:
165 
166  //- Runtime type information
167  TypeName("box");
168 
169 
170  // Constructors
171 
172  //- Construct from dictionary
173  box
174  (
175  const word& name,
176  const polyMesh& mesh,
177  const dictionary& dict
178  );
179 
180 
181  //- Destructor
182  virtual ~box();
183 
184 
185  // Member Functions
186 
187  virtual zoneSet generate() const;
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace zoneGenerators
194 } // End namespace Foam
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
const word & name() const
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:217
TypeName("box")
Runtime type information.
box(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: box.C:60
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
List< treeBoundBox > treeBoundBoxList
List of bounding boxes.
dictionary dict
volScalarField & p