BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / boundBox / boundBox.H
blobf531283c3c456607d30c0d323867ed01c970d595
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Class
25     Foam::boundBox
27 Description
28     A bounding box defined in terms of the points at its extremities.
30 \*---------------------------------------------------------------------------*/
32 #ifndef boundBox_H
33 #define boundBox_H
35 #include "pointField.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 namespace Foam
42 // Forward declaration of friend functions and operators
44 class boundBox;
45 template<class T> class tmp;
47 Istream& operator>>(Istream&, boundBox&);
48 Ostream& operator<<(Ostream&, const boundBox&);
51 /*---------------------------------------------------------------------------*\
52                           Class boundBox Declaration
53 \*---------------------------------------------------------------------------*/
55 class boundBox
57     // Private data
59         //- Minimum and maximum describing the bounding box
60         point min_, max_;
62     // Private Member Functions
64         //- Calculate the bounding box from the given points.
65         //  Does parallel communication (doReduce = true)
66         void calculate(const UList<point>&, const bool doReduce = true);
68 public:
70     // Static data members
72         //- The great value used for greatBox and invertedBox
73         static const scalar great;
75         //- A very large boundBox: min/max == -/+ VGREAT
76         static const boundBox greatBox;
78         //- A very large inverted boundBox: min/max == +/- VGREAT
79         static const boundBox invertedBox;
82     // Constructors
84         //- Construct null, setting points to zero
85         inline boundBox();
87         //- Construct from components
88         inline boundBox(const point& min, const point& max);
90         //- Construct as the bounding box of the given points
91         //  Does parallel communication (doReduce = true)
92         boundBox(const UList<point>&, const bool doReduce = true);
94         //- Construct as the bounding box of the given temporary pointField.
95         //  Does parallel communication (doReduce = true)
96         boundBox(const tmp<pointField>&, const bool doReduce = true);
98         //- Construct bounding box as subset of the pointField.
99         //  The indices could be from cell/face etc.
100         //  Does parallel communication (doReduce = true)
101         boundBox
102         (
103             const UList<point>&,
104             const labelUList& indices,
105             const bool doReduce = true
106         );
108         //- Construct bounding box as subset of the pointField.
109         //  The indices could be from edge/triFace etc.
110         //  Does parallel communication (doReduce = true)
111         template<unsigned Size>
112         boundBox
113         (
114             const UList<point>&,
115             const FixedList<label, Size>& indices,
116             const bool doReduce = true
117         );
119         //- Construct from Istream
120         inline boundBox(Istream&);
123     // Member functions
125         // Access
127             //- Minimum describing the bounding box
128             inline const point& min() const;
130             //- Maximum describing the bounding box
131             inline const point& max() const;
133             //- Minimum describing the bounding box, non-const access
134             inline point& min();
136             //- Maximum describing the bounding box, non-const access
137             inline point& max();
139             //- The midpoint of the bounding box
140             inline point midpoint() const;
142             //- The bounding box span (from minimum to maximum)
143             inline vector span() const;
145             //- The magnitude of the bounding box span
146             inline scalar mag() const;
148             //- The volume of the bound box
149             inline scalar volume() const;
151             //- Smallest length/height/width dimension
152             inline scalar minDim() const;
154             //- Largest length/height/width dimension
155             inline scalar maxDim() const;
157             //- Average length/height/width dimension
158             inline scalar avgDim() const;
160             //- Return corner points in an order corresponding to a 'hex' cell
161             tmp<pointField> points() const;
164         // Manipulate
166             //- Inflate box by factor*mag(span) in all dimensions
167             void inflate(const scalar s);
170         // Query
172             //- Overlaps/touches boundingBox?
173             inline bool overlaps(const boundBox&) const;
175             //- Contains point? (inside or on edge)
176             inline bool contains(const point&) const;
178             //- Fully contains other boundingBox?
179             inline bool contains(const boundBox&) const;
181             //- Contains point? (inside only)
182             inline bool containsInside(const point&) const;
184             //- Contains all of the points? (inside or on edge)
185             bool contains(const UList<point>&) const;
187             //- Contains all of the points? (inside or on edge)
188             bool contains
189             (
190                 const UList<point>&,
191                 const labelUList& indices
192             ) const;
194             //- Contains all of the points? (inside or on edge)
195             template<unsigned Size>
196             bool contains
197             (
198                 const UList<point>&,
199                 const FixedList<label, Size>& indices
200             ) const;
203             //- Contains any of the points? (inside or on edge)
204             bool containsAny(const UList<point>&) const;
206             //- Contains any of the points? (inside or on edge)
207             bool containsAny
208             (
209                 const UList<point>&,
210                 const labelUList& indices
211             ) const;
213             //- Contains any of the points? (inside or on edge)
214             template<unsigned Size>
215             bool containsAny
216             (
217                 const UList<point>&,
218                 const FixedList<label, Size>& indices
219             ) const;
222     // Friend Operators
224         inline friend bool operator==(const boundBox&, const boundBox&);
225         inline friend bool operator!=(const boundBox&, const boundBox&);
228     // IOstream operator
230         friend Istream& operator>>(Istream&, boundBox&);
231         friend Ostream& operator<<(Ostream&, const boundBox&);
235 //- Data associated with boundBox type are contiguous
236 template<>
237 inline bool contiguous<boundBox>() {return contiguous<point>();}
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 #include "boundBoxI.H"
246 #ifdef NoRepository
247 #   include "boundBoxTemplates.C"
248 #endif
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 #endif
254 // ************************************************************************* //