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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "UPstream.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  above_(-1),
36  below_(),
37  allBelow_(),
38  allNotBelow_()
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 // ************************************************************************* //
Foam::UPstream::commsStruct::commsStruct
commsStruct()
Default construct. Above == -1.
Definition: UPstreamCommsStruct.C:33
UPstream.H
Foam::UPstream::commsStruct::below
const labelList & below() const noexcept
Definition: UPstream.H:135
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::FatalError
error FatalError
os
OBJstream os(runTime.globalPath()/outputName)
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
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:453
Foam::List< label >
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::UPstream::commsStruct::above
label above() const noexcept
Definition: UPstream.H:130
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:445