OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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