Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / db / IOstreams / Pstreams / PstreamCommsStruct.C
blob82acbfaf5ec006d6e629e9f49b145c095cd6d061
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "Pstream.H"
27 #include "boolList.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 Foam::Pstream::commsStruct::commsStruct()
33     above_(-1),
34     below_(0),
35     allBelow_(0),
36     allNotBelow_(0)
40 Foam::Pstream::commsStruct::commsStruct
42     const label above,
43     const labelList& below,
44     const labelList& allBelow,
45     const labelList& allNotBelow
48     above_(above),
49     below_(below),
50     allBelow_(allBelow),
51     allNotBelow_(allNotBelow)
55 Foam::Pstream::commsStruct::commsStruct
57     const label nProcs,
58     const label myProcID,
59     const label above,
60     const labelList& below,
61     const labelList& allBelow
64     above_(above),
65     below_(below),
66     allBelow_(allBelow),
67     allNotBelow_(nProcs - allBelow.size() - 1)
69     boolList inBelow(nProcs, false);
71     forAll(allBelow, belowI)
72     {
73         inBelow[allBelow[belowI]] = true;
74     }
76     label notI = 0;
77     forAll(inBelow, procI)
78     {
79         if ((procI != myProcID) && !inBelow[procI])
80         {
81             allNotBelow_[notI++] = procI;
82         }
83     }
84     if (notI != allNotBelow_.size())
85     {
86         FatalErrorIn("commsStruct") << "problem!" << Foam::abort(FatalError);
87     }
91 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
93 bool Foam::Pstream::commsStruct::operator==(const commsStruct& comm) const
95     return
96     (
97         (above_ == comm.above())
98      && (below_ == comm.below())
99      && (allBelow_ == allBelow())
100      && (allNotBelow_ == allNotBelow())
101     );
105 bool Foam::Pstream::commsStruct::operator!=(const commsStruct& comm) const
107     return !operator==(comm);
111 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
113 Foam::Ostream& Foam::operator<<(Ostream& os, const Pstream::commsStruct& comm)
115     os  << comm.above_ << token::SPACE
116         << comm.below_ << token::SPACE
117         << comm.allBelow_ << token::SPACE
118         << comm.allNotBelow_;
120     os.check
121     (
122         "Ostream& operator<<(Ostream&, const commsStruct&)"
123     );
125     return os;
129 // ************************************************************************* //