FreeFOAM The Cross-Platform CFD Toolkit
receivingReferralList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*----------------------------------------------------------------------------*/
25 
27 
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  labelListList(),
34  sourceProc_(-1)
35 {}
36 
37 
39 (
40  const label sourceProc,
41  const labelListList& refCellsToSendTo
42 )
43 :
44  labelListList(refCellsToSendTo),
45  sourceProc_(sourceProc)
46 {}
47 
48 
50 (
51  const receivingReferralList& rL
52 )
53 :
54  labelListList(rL),
55  sourceProc_(rL.sourceProc())
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
66 
68 {
69  // Check for assignment to self
70  if (this == &rhs)
71  {
73  (
74  "Foam::receivingReferralList::operator="
75  "(const Foam::receivingReferralList&)"
76  )
77  << "Attempted assignment to self"
78  << abort(FatalError);
79  }
80 
82 
83  sourceProc_ = rhs.sourceProc();
84 }
85 
86 
87 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
88 
89 bool operator==
90 (
93 )
94 {
95  // Trivial reject: lists are different size
96  if (a.size() != b.size())
97  {
98  return false;
99  }
100 
101  // Or if source processors are not the same.
102  if (a.sourceProc() != b.sourceProc())
103  {
104  return false;
105  }
106 
107  Foam::List<bool> fnd(a.size(), false);
108 
109  forAll (b, bI)
110  {
111  Foam::labelList curLList = b[bI];
112 
113  bool found = false;
114 
115  forAll (a, aI)
116  {
117  if (a[aI] == curLList)
118  {
119  found = true;
120  fnd[aI] = true;
121  break;
122  }
123  }
124 
125  if (!found)
126  {
127  return false;
128  }
129  }
130 
131  // check if all LLists on a were marked
132  bool result = true;
133 
134  forAll (fnd, aI)
135  {
136  result = (result && fnd[aI]);
137  }
138 
139  return result;
140 }
141 
142 
143 Foam::Istream& Foam::operator>>(Istream& is, receivingReferralList& rRL)
144 {
145  is >> rRL.sourceProc_ >> static_cast<labelListList&>(rRL);
146 
147  is.check
148  (
149  "Istream& operator<<(Istream& f, const receivingReferralList& rRL"
150  );
151 
152  return is;
153 }
154 
155 
156 Foam::Ostream& Foam::operator<<
157 (
158  Ostream& os,
159  const receivingReferralList& rRL
160 )
161 {
162  os << rRL.sourceProc() << token::SPACE
163  << static_cast< const labelListList& >(rRL);
164 
165  os.check
166  (
167  "Ostream& operator<<(Ostream& f, const receivingReferralList& rRL"
168  );
169 
170  return os;
171 }
172 
173 
174 // ************************ vim: set sw=4 sts=4 et: ************************ //