multiWorldConnectionsObject.H
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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::multiWorldConnections
28
29Description
30 Centralized handling of multi-world MPI connections.
31
32Note
33 This class may move to static only or a singleton in the future.
34
35SourceFiles
36 multiWorldConnectionsObject.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef meshObjects_multiWorldConnections_H
41#define meshObjects_multiWorldConnections_H
42
43#include "MeshObject.H"
44#include "EdgeMap.H"
45#include "Time.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class multiWorldConnections Declaration
54\*---------------------------------------------------------------------------*/
57:
58 public MeshObject
59 <
60 Time,
61 TopologicalMeshObject,
62 multiWorldConnections
63 >
64{
65 // Private Typedefs
66
67 typedef MeshObject
68 <
69 Time,
73
74
75 // Private Data
76
77 //- Table of world/world connections to communicator label
78 EdgeMap<label> table_;
79
80
81 // Private Member Functions
82
83 //- Pairing from myWorld to other world by ID
84 // \return invalid on any error or if non-parallel
85 static edge worldPair(const label otherWorld);
86
87 //- Pairing from myWorld to other world by NAME.
88 // \return invalid on any error or if non-parallel
89 static edge worldPair(const word& otherWorld);
90
91 //- Allocate a communicator between myWorld and other world
92 static label createCommunicator(const edge& worlds);
93
94
95public:
96
97 //- Run-time type information
98 TypeName("multiWorld");
99
100
101 // Constructors
102
103 //- Construct
104 explicit multiWorldConnections(const Time& runTime);
105
106
107 // Selectors
108
109 //- Access mesh object
110 static const multiWorldConnections& New(const Time& runTime);
111
112
113 //- Destructor
115
116
117 // Member Functions
118
119 //- True if no world-to-world connections are defined
120 bool empty() const noexcept;
121
122 //- Number of world-to-world connections defined.
123 label size() const noexcept;
124
125 //- Create all communicators.
126 //- Low-level, not normally called directly
127 void createComms();
128
129 //- Define a connection from myWorld to other world by ID
130 bool addConnectionById(const label otherWorld);
131
132 //- Define a connection from myWorld to other world by NAME
133 bool addConnectionByName(const word& otherWorld);
134
135 //- Get communicator for myWorld to other world connection by ID.
136 // Uses cached value, or creates a new communicator
137 label getCommById(const label otherWorld) const;
138
139 //- Get communicator for myWorld to other world connection by NAME.
140 // Uses cached value, or creates a new communicator
141 label getCommByName(const word& otherWorld) const;
142
143 //- Get communicators used for myWorld to other worlds in sorted order.
144 // \return worldComm if no world-to-world communicators in use.
145 labelList comms() const;
146};
147
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151} // End namespace Foam
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155#endif
156
157// ************************************************************************* //
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:54
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Centralized handling of multi-world MPI connections.
label getCommByName(const word &otherWorld) const
Get communicator for myWorld to other world connection by NAME.
bool empty() const noexcept
True if no world-to-world connections are defined.
bool addConnectionByName(const word &otherWorld)
Define a connection from myWorld to other world by NAME.
label getCommById(const label otherWorld) const
Get communicator for myWorld to other world connection by ID.
TypeName("multiWorld")
Run-time type information.
label size() const noexcept
Number of world-to-world connections defined.
labelList comms() const
Get communicators used for myWorld to other worlds in sorted order.
bool addConnectionById(const label otherWorld)
Define a connection from myWorld to other world by ID.
static const multiWorldConnections & New(const Time &runTime)
Access mesh object.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73