1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "PstreamReduceOps.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 const Foam::scalar Foam::boundBox::great(VGREAT);
35 const Foam::boundBox Foam::boundBox::greatBox
37 point(-VGREAT, -VGREAT, -VGREAT),
38 point(VGREAT, VGREAT, VGREAT)
42 const Foam::boundBox Foam::boundBox::invertedBox
44 point(VGREAT, VGREAT, VGREAT),
45 point(-VGREAT, -VGREAT, -VGREAT)
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
58 if (doReduce && Pstream::parRun())
60 // Use values that get overwritten by reduce minOp, maxOp below
61 min_ = point(VGREAT, VGREAT, VGREAT);
62 max_ = point(-VGREAT, -VGREAT, -VGREAT);
70 for (label i = 1; i < points.size(); i++)
72 min_ = ::Foam::min(min_, points[i]);
73 max_ = ::Foam::max(max_, points[i]);
77 // Reduce parallel information
80 reduce(min_, minOp<point>());
81 reduce(max_, maxOp<point>());
86 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
93 calculate(points, doReduce);
97 Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
102 calculate(points(), doReduce);
107 Foam::boundBox::boundBox(Istream& is)
109 operator>>(is, *this);
113 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
115 Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
117 if (os.format() == IOstream::ASCII)
119 os << bb.min_ << token::SPACE << bb.max_;
125 reinterpret_cast<const char*>(&bb.min_),
130 // Check state of Ostream
131 os.check("Ostream& operator<<(Ostream&, const boundBox&)");
136 Foam::Istream& Foam::operator>>(Istream& is, boundBox& bb)
138 if (is.format() == IOstream::ASCII)
140 return is >> bb.min_ >> bb.max_;
146 reinterpret_cast<char*>(&bb.min_),
151 // Check state of Istream
152 is.check("Istream& operator>>(Istream&, boundBox&)");
156 // ************************************************************************* //