initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / molecularDynamics / molecule / interactionLists / referralLists / receivingReferralList.C
blob2f646fcba5f50ccc11ada22d43874e35f69674e4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM 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 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*----------------------------------------------------------------------------*/
27 #include "receivingReferralList.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::receivingReferralList::receivingReferralList()
34     labelListList(),
35     sourceProc_(-1)
39 Foam::receivingReferralList::receivingReferralList
41     const label sourceProc,
42     const labelListList& refCellsToSendTo
45     labelListList(refCellsToSendTo),
46     sourceProc_(sourceProc)
50 Foam::receivingReferralList::receivingReferralList
52     const receivingReferralList& rL
55     labelListList(rL),
56     sourceProc_(rL.sourceProc())
60 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
62 Foam::receivingReferralList::~receivingReferralList()
66 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
68 void Foam::receivingReferralList::operator=(const receivingReferralList& rhs)
70     // Check for assignment to self
71     if (this == &rhs)
72     {
73         FatalErrorIn
74         (
75             "Foam::receivingReferralList::operator="
76             "(const Foam::receivingReferralList&)"
77         )
78             << "Attempted assignment to self"
79             << abort(FatalError);
80     }
82     labelListList::operator=(rhs);
84     sourceProc_ = rhs.sourceProc();
88 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
90 bool operator==
92     const Foam::receivingReferralList& a,
93     const Foam::receivingReferralList& b
96     // Trivial reject: lists are different size
97     if (a.size() != b.size())
98     {
99         return false;
100     }
102     // Or if source processors are not the same.
103     if (a.sourceProc() != b.sourceProc())
104     {
105         return false;
106     }
108     Foam::List<bool> fnd(a.size(), false);
110     forAll (b, bI)
111     {
112         Foam::labelList curLList = b[bI];
114         bool found = false;
116         forAll (a, aI)
117         {
118             if (a[aI] == curLList)
119             {
120                 found = true;
121                 fnd[aI] = true;
122                 break;
123             }
124         }
126         if (!found)
127         {
128             return false;
129         }
130     }
132     // check if all LLists on a were marked
133     bool result = true;
135     forAll (fnd, aI)
136     {
137         result = (result && fnd[aI]);
138     }
140     return result;
144 Foam::Istream& Foam::operator>>(Istream& is, receivingReferralList& rRL)
146     is  >> rRL.sourceProc_ >> static_cast<labelListList&>(rRL);
148     is.check
149     (
150         "Istream& operator<<(Istream& f, const receivingReferralList& rRL"
151     );
153     return is;
157 Foam::Ostream& Foam::operator<<
159     Ostream& os,
160     const receivingReferralList& rRL
163     os  << rRL.sourceProc() << token::SPACE
164         << static_cast< const labelListList& >(rRL);
166     os.check
167     (
168         "Ostream& operator<<(Ostream& f, const receivingReferralList& rRL"
169     );
171     return os;
175 // ************************************************************************* //