UPstreamCommsStruct.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) 2011-2015 OpenFOAM Foundation
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 
26 #include "UPstream.H"
27 #include "boolList.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  above_(-1),
34  below_(0),
35  allBelow_(0),
36  allNotBelow_(0)
37 {}
38 
39 
41 (
42  const label above,
43  const labelList& below,
44  const labelList& allBelow,
45  const labelList& allNotBelow
46 )
47 :
48  above_(above),
49  below_(below),
50  allBelow_(allBelow),
51  allNotBelow_(allNotBelow)
52 {}
53 
54 
56 (
57  const label nProcs,
58  const label myProcID,
59  const label above,
60  const labelList& below,
61  const labelList& allBelow
62 )
63 :
64  above_(above),
65  below_(below),
66  allBelow_(allBelow),
67  allNotBelow_(nProcs - allBelow.size() - 1)
68 {
69  boolList inBelow(nProcs, false);
70 
71  forAll(allBelow, belowI)
72  {
73  inBelow[allBelow[belowI]] = true;
74  }
75 
76  label notI = 0;
77  forAll(inBelow, procI)
78  {
79  if ((procI != myProcID) && !inBelow[procI])
80  {
81  allNotBelow_[notI++] = procI;
82  }
83  }
84  if (notI != allNotBelow_.size())
85  {
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
92 
94 {
95  return
96  (
97  (above_ == comm.above())
98  && (below_ == comm.below())
99  && (allBelow_ == allBelow())
100  && (allNotBelow_ == allNotBelow())
101  );
102 }
103 
104 
106 {
107  return !operator==(comm);
108 }
109 
110 
111 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
112 
114 {
115  os << comm.above_ << token::SPACE
116  << comm.below_ << token::SPACE
117  << comm.allBelow_ << token::SPACE
118  << comm.allNotBelow_;
119 
120  os.check
121  (
122  "Ostream& operator<<(Ostream&, const commsStruct&)"
123  );
124 
125  return os;
126 }
127 
128 
129 // ************************************************************************* //
boolList.H
Foam::UPstream::commsStruct::commsStruct
commsStruct()
Construct null.
Definition: UPstreamCommsStruct.C:31
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
UPstream.H
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:387
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::UPstream::commsStruct::above_
label above_
procID of above processor
Definition: UPstream.H:81
Foam::UPstream::commsStruct::operator==
bool operator==(const commsStruct &) const
Definition: UPstreamCommsStruct.C:93
Foam::UPstream::commsStruct::below_
labelList below_
procIDs of processors directly below me
Definition: UPstream.H:84
Foam::UPstream::commsStruct::allBelow_
labelList allBelow_
procIDs of all processors below (so not just directly below)
Definition: UPstream.H:87
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::UPstream::commsStruct::allNotBelow_
labelList allNotBelow_
procIDs of all processors not below. (inverse set of
Definition: UPstream.H:91
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::UPstream::commsStruct::above
label above() const
Definition: UPstream.H:125
Foam::UPstream::commsStruct
Structure for communicating between processors.
Definition: UPstream.H:76
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::UPstream::commsStruct::operator!=
bool operator!=(const commsStruct &) const
Definition: UPstreamCommsStruct.C:105
Foam::UPstream::commsStruct::below
const labelList & below() const
Definition: UPstream.H:130
Foam::token::SPACE
@ SPACE
Definition: token.H:95