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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
123 return os;
124}
125
126
127// ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Structure for communicating between processors.
Definition: UPstream.H:81
const labelList & allBelow() const noexcept
Definition: UPstream.H:141
commsStruct() noexcept
Default construct. Above == -1.
const labelList & below() const noexcept
The procIDs of all processors directly below.
Definition: UPstream.H:134
label above() const noexcept
The procID of the processor directly above.
Definition: UPstream.H:128
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Definition: UPstream.H:445
friend bool operator!=(const refineCell &rc1, const refineCell &rc2)
Definition: refineCell.H:106
friend bool operator==(const refineCell &rc1, const refineCell &rc2)
Definition: refineCell.H:97
@ SPACE
Space [isspace].
Definition: token.H:125
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333