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

sendingReferralList.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) 2008-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 <molecule/sendingReferralList.H>
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 Foam::sendingReferralList::sendingReferralList()
00031 :
00032     labelList(),
00033     destinationProc_(-1)
00034 {}
00035 
00036 
00037 Foam::sendingReferralList::sendingReferralList
00038 (
00039     const label destinationProc,
00040     const labelList& cellsToSend
00041 )
00042 :
00043     labelList(cellsToSend),
00044     destinationProc_(destinationProc)
00045 {}
00046 
00047 
00048 Foam::sendingReferralList::sendingReferralList
00049 (
00050     const sendingReferralList& rL
00051 )
00052 :
00053     labelList(rL),
00054     destinationProc_(rL.destinationProc())
00055 {}
00056 
00057 
00058 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00059 
00060 Foam::sendingReferralList::~sendingReferralList()
00061 {}
00062 
00063 
00064 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00065 
00066 void Foam::sendingReferralList::operator=(const sendingReferralList& rhs)
00067 {
00068     // Check for assignment to self
00069     if (this == &rhs)
00070     {
00071         FatalErrorIn
00072         (
00073             "Foam::distribution::operator=(const Foam::distribution&)"
00074         )
00075             << "Attempted assignment to self"
00076             << abort(FatalError);
00077     }
00078 
00079     labelList::operator=(rhs);
00080 
00081     destinationProc_ = rhs.destinationProc();
00082 }
00083 
00084 
00085 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00086 
00087 bool operator==
00088 (
00089     const Foam::sendingReferralList& a,
00090     const Foam::sendingReferralList& b
00091 )
00092 {
00093     // Trivial reject: lists are different size
00094     if (a.size() != b.size())
00095     {
00096         return false;
00097     }
00098 
00099     // Or if source processors are not the same.
00100     if (a.destinationProc() != b.destinationProc())
00101     {
00102         return false;
00103     }
00104 
00105     Foam::List<bool> fnd(a.size(), false);
00106 
00107     forAll (b, bI)
00108     {
00109         Foam::label curLabel = b[bI];
00110 
00111         bool found = false;
00112 
00113         forAll (a, aI)
00114         {
00115             if (a[aI] == curLabel)
00116             {
00117                 found = true;
00118                 fnd[aI] = true;
00119                 break;
00120             }
00121         }
00122 
00123         if (!found)
00124         {
00125             return false;
00126         }
00127     }
00128 
00129     // check if all labels on a were marked
00130     bool result = true;
00131 
00132     forAll (fnd, aI)
00133     {
00134         result = (result && fnd[aI]);
00135     }
00136 
00137     return result;
00138 }
00139 
00140 
00141 Foam::Istream& Foam::operator>>
00142 (
00143     Istream& is,
00144     sendingReferralList& sRL
00145 )
00146 {
00147     is  >> sRL.destinationProc_ >> static_cast<labelList&>(sRL);
00148 
00149     is.check("Istream& operator<<(Istream& f, const sendingReferralList& sRL");
00150 
00151     return is;
00152 }
00153 
00154 
00155 Foam::Ostream& Foam::operator<<
00156 (
00157     Ostream& os,
00158     const sendingReferralList& rL
00159 )
00160 {
00161     os  << rL.destinationProc() << token::SPACE
00162         << static_cast< const labelList& >(rL);
00163 
00164     os.check("Ostream& operator<<(Ostream& f, const sendingReferralList& rL");
00165 
00166     return os;
00167 }
00168 
00169 
00170 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines