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

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