FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

PstreamCommsStruct.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "Pstream.H"
00027 #include <OpenFOAM/boolList.H>
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 Foam::Pstream::commsStruct::commsStruct()
00032 :
00033     above_(-1),
00034     below_(0),
00035     allBelow_(0),
00036     allNotBelow_(0)
00037 {}
00038 
00039 
00040 Foam::Pstream::commsStruct::commsStruct
00041 (
00042     const label above,
00043     const labelList& below,
00044     const labelList& allBelow,
00045     const labelList& allNotBelow
00046 )
00047 :
00048     above_(above),
00049     below_(below),
00050     allBelow_(allBelow),
00051     allNotBelow_(allNotBelow)
00052 {}
00053 
00054 
00055 Foam::Pstream::commsStruct::commsStruct
00056 (
00057     const label nProcs,
00058     const label myProcID,
00059     const label above,
00060     const labelList& below,
00061     const labelList& allBelow
00062 )
00063 :
00064     above_(above),
00065     below_(below),
00066     allBelow_(allBelow),
00067     allNotBelow_(nProcs - allBelow.size() - 1)
00068 {
00069     boolList inBelow(nProcs, false);
00070 
00071     forAll(allBelow, belowI)
00072     {
00073         inBelow[allBelow[belowI]] = true;
00074     }
00075 
00076     label notI = 0;
00077     forAll(inBelow, procI)
00078     {
00079         if ((procI != myProcID) && !inBelow[procI])
00080         {
00081             allNotBelow_[notI++] = procI;
00082         }
00083     }
00084     if (notI != allNotBelow_.size())
00085     {
00086         FatalErrorIn("commsStruct") << "problem!" << Foam::abort(FatalError);
00087     }
00088 }
00089 
00090 
00091 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00092 
00093 bool Foam::Pstream::commsStruct::operator==(const commsStruct& comm) const
00094 {
00095     return
00096     (
00097         (above_ == comm.above())
00098      && (below_ == comm.below())
00099      && (allBelow_ == allBelow())
00100      && (allNotBelow_ == allNotBelow())
00101     );
00102 }
00103 
00104 
00105 bool Foam::Pstream::commsStruct::operator!=(const commsStruct& comm) const
00106 {
00107     return !operator==(comm);
00108 }
00109 
00110 
00111 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
00112 
00113 Foam::Ostream& Foam::operator<<(Ostream& os, const Pstream::commsStruct& comm)
00114 {
00115     os  << comm.above_ << token::SPACE
00116         << comm.below_ << token::SPACE
00117         << comm.allBelow_ << token::SPACE
00118         << comm.allNotBelow_;
00119 
00120     os.check
00121     (
00122         "Ostream& operator<<(Ostream&, const commsStruct&)"
00123     );
00124 
00125     return os;
00126 }
00127 
00128 
00129 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines