processorTopology.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2022-2023 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 Class
28  Foam::processorTopology
29 
30 Description
31  Determines/represents processor-processor connection.
32  After instantiation contains the processor-processor connection table
33  (globally synchronized on all processors).
34 
35 Note
36  A processorTopology is usually generated by using the \c New
37  factory method, which has been wrapped into a separate header to
38  minimize dependencies.
39 
40 Warning
41  Does not currently correctly support multiple processor
42  patches connecting two processors.
43 
44 SourceFiles
45  processorTopologyNew.H
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef Foam_processorTopology_H
50 #define Foam_processorTopology_H
51 
52 #include "labelList.H"
53 #include "lduSchedule.H"
54 #include "Map.H"
55 #include "UPstream.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class processorTopology Declaration
64 \*---------------------------------------------------------------------------*/
65 
67 {
68  // Private Data
69 
70  //- Map from neighbour proc to patch index
71  //- (processor-local information!)
72  Map<label> procPatchMap_;
73 
74  //- The neighbour processor connections (ascending order) associated
75  //- with the local rank.
76  // Possibly demand-driven data.
77  mutable labelList procNeighbours_;
78 
79  //- The complete processor to processor connection adjacency table.
80  //- Globally synchronized information.
81  // Likely demand-driven data.
82  mutable labelListList procAdjacencyTable_;
83 
84  //- Order in which the patches should be initialised/evaluated
85  //- corresponding to the schedule
86  lduSchedule patchSchedule_;
87 
88  //- The communicator used during creation of the topology
89  label comm_;
90 
91 
92  // Private Methods Functions
93 
94  // Could expose as public...
95  // //- Map of neighbour processor to \em local boundary patch index.
96  // const Map<label>& procPatchMap() const noexcept
97  // {
98  // return procPatchMap_;
99  // }
100 
101 public:
102 
103  // Generated Methods
104 
105  //- Copy construct
106  processorTopology(const processorTopology&) = default;
107 
108  //- Move construct
110 
111  //- Copy assignment
112  processorTopology& operator=(const processorTopology&) = default;
113 
114  //- Move assignment
116 
117 
118  // Constructors
119 
120  //- Default construct (empty)
122 
123 
124  // Static Functions
125 
126  //- Factory method to create topology, schedule and proc/patch maps.
127  // Scans the list of patches for processor connections corresponding
128  // to the ProcPatch type.
129  template<class ProcPatch, class PatchListType>
130  static processorTopology New
131  (
132  const PatchListType& patches,
133  const label comm
134  );
135 
136 
137  // Member Functions
138 
139  //- The communicator used during creation of the topology
140  label comm() const noexcept { return comm_; }
141 
142  //- The neighbour processor connections (ascending order) associated
143  //- with the \em local rank.
144  const labelList& procNeighbours() const;
145 
146  //- The complete processor to processor connection adjacency table.
147  //- Globally synchronized information.
148  // Likely demand-driven data.
149  const labelListList& procAdjacency() const;
150 
151  //- Which \em local boundary is attached to specified neighbour
152  //- processor.
153  // \return -1 if not currently connected to specified processor.
154  label procPatchLookup(const label proci) const
155  {
156  return procPatchMap_.lookup(proci, -1);
157  }
158 
159  //- Order in which the patches should be initialised/evaluated
160  //- corresponding to the schedule
161  const lduSchedule& patchSchedule() const noexcept
162  {
163  return patchSchedule_;
164  }
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
processorTopology & operator=(const processorTopology &)=default
Copy assignment.
processorTopology()
Default construct (empty)
const lduSchedule & patchSchedule() const noexcept
Order in which the patches should be initialised/evaluated corresponding to the schedule.
label procPatchLookup(const label proci) const
Which local boundary is attached to specified neighbour processor.
const labelListList & procAdjacency() const
The complete processor to processor connection adjacency table. Globally synchronized information...
const direction noexcept
Definition: Scalar.H:258
label comm() const noexcept
The communicator used during creation of the topology.
Determines/represents processor-processor connection. After instantiation contains the processor-proc...
static processorTopology New(const PatchListType &patches, const label comm)
Factory method to create topology, schedule and proc/patch maps.
const labelList & procNeighbours() const
The neighbour processor connections (ascending order) associated with the local rank.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
Definition: HashTableI.H:222
const polyBoundaryMesh & patches
Namespace for OpenFOAM.