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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "UPstream.H"
29 #include "boolList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  above_(-1),
36  below_(0),
37  allBelow_(0),
38  allNotBelow_(0)
39 {}
40 
41 
43 (
44  const label above,
45  const labelList& below,
46  const labelList& allBelow,
47  const labelList& allNotBelow
48 )
49 :
50  above_(above),
51  below_(below),
52  allBelow_(allBelow),
53  allNotBelow_(allNotBelow)
54 {}
55 
56 
58 (
59  const label nProcs,
60  const label myProcID,
61  const label above,
62  const labelList& below,
63  const labelList& allBelow
64 )
65 :
66  above_(above),
67  below_(below),
68  allBelow_(allBelow),
69  allNotBelow_(nProcs - allBelow.size() - 1)
70 {
71  boolList inBelow(nProcs, false);
72 
73  forAll(allBelow, belowI)
74  {
75  inBelow[allBelow[belowI]] = true;
76  }
77 
78  label notI = 0;
79  forAll(inBelow, proci)
80  {
81  if ((proci != myProcID) && !inBelow[proci])
82  {
83  allNotBelow_[notI++] = proci;
84  }
85  }
86  if (notI != allNotBelow_.size())
87  {
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
94 
96 {
97  return
98  (
99  (above_ == comm.above())
100  && (below_ == comm.below())
101  && (allBelow_ == allBelow())
102  && (allNotBelow_ == allNotBelow())
103  );
104 }
105 
106 
108 {
109  return !operator==(comm);
110 }
111 
112 
113 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
114 
116 {
117  os << comm.above_ << token::SPACE
118  << comm.below_ << token::SPACE
119  << comm.allBelow_ << token::SPACE
120  << comm.allNotBelow_;
121 
122  os.check(FUNCTION_NAME);
123  return os;
124 }
125 
126 
127 // ************************************************************************* //
boolList.H
Foam::UPstream::commsStruct::commsStruct
commsStruct()
Construct null.
Definition: UPstreamCommsStruct.C:33
UPstream.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::UPstream::commsStruct::operator==
bool operator==(const commsStruct &) const
Definition: UPstreamCommsStruct.C:95
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::UPstream::commsStruct::above
label above() const
Definition: UPstream.H:132
Foam::UPstream::commsStruct
Structure for communicating between processors.
Definition: UPstream.H:83
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::List< label >
Foam::token::SPACE
Space [isspace].
Definition: token.H:117
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:270
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::UPstream::commsStruct::operator!=
bool operator!=(const commsStruct &) const
Definition: UPstreamCommsStruct.C:107
Foam::UPstream::nProcs
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Definition: UPstream.H:446
Foam::UPstream::commsStruct::below
const labelList & below() const
Definition: UPstream.H:137