Nektar++
InterfaceMapDG.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File InterfaceMapDG.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: MPI communication for interfaces, header file
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_INTERFACEMAPDG_H
36#define NEKTAR_INTERFACEMAPDG_H
37
40
42{
43
44/**
45 * Object for each interface present between two ranks, which are held in the
46 * InterfaceExchange object.
47 */
48
50{
51public:
52 /// Constructor
54 const ExpListSharedPtr &trace,
55 const SpatialDomains::InterfaceShPtr &interfaceShPtr);
56
57 /// Default destructor
59
60 inline void SetCheckLocal(bool flag)
61 {
62 m_checkLocal = flag;
63 }
64
65 /// Returns the missing coordinates vector
66 inline std::vector<Array<OneD, NekDouble>> GetMissingCoords()
67 {
68 return m_missingCoords;
69 }
70
71 /// Returns the interface object
73 {
74 return m_interface;
75 }
76
77 /// Calculates what coordinates on the interface are missing locally
79 /// Fills the Bwd trace by interpolating from the Fwd for local interfaces
82 /// Fills the Bwd trace from partitioned trace
85 /// Check whether the coordiniates in the original domain
88
89private:
90 /// Trace expansion list
92 /// Local interface object
94 /// Flag whether the opposite side of the interface is present locally
95 bool m_checkLocal = false;
96 /// Vector of coordinates on interface missing from the other side locally
97 std::vector<Array<OneD, NekDouble>> m_missingCoords;
98 /// Map of found coordinates present locally
99 std::map<int, std::pair<int, Array<OneD, NekDouble>>> m_foundLocalCoords;
100 /// Vector of indices corresponding to m_missingCoord locations in trace
101 std::vector<int> m_mapMissingCoordToTrace;
102};
103
104typedef std::shared_ptr<InterfaceTrace> InterfaceTraceSharedPtr;
105
106/**
107 * Object for one rank-to-rank communication for all interfaces shared
108 * between those ranks. e.g. if on rank 1 and there are interfaces shared with
109 * rank 2 and 3, there will be two InterfaceExchange objects in m_exchange in
110 * InterfaceMapDG. This holds the InterfaceTrace objects in m_interfaceTraces.
111 */
113{
114public:
115 /// Default destructor
117
118 /// Constructor
121 const ExpListSharedPtr &trace, const LibUtilities::CommSharedPtr &comm,
122 std::pair<int, std::vector<InterfaceTraceSharedPtr>> rankPair)
123 : m_movement(movement), m_zones(movement->GetZones()), m_trace(trace),
124 m_comm(comm), m_rank(rankPair.first),
125 m_interfaceTraces(rankPair.second)
126 {
127 }
128
129 /**
130 * Communicates with other ranks how many missing coordinates for each
131 * interface to expect
132 *
133 * @param requestSend List of send requests
134 * @param requestRecv List of receive requests
135 * @param requestNum Index of request in list to use
136 */
139 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum);
140
141 /**
142 * Sends/receives the missing coordinates to/from other ranks
143 *
144 * @param requestSend List of send requests
145 * @param requestRecv List of receive requests
146 * @param requestNum Index of request in list to use
147 */
150 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum);
151
152 /// Populates m_foundRankCoords using the FindDistance function
154
155 /**
156 * Calculates and sends the trace to other rank from the m_foundRankCoords
157 * structure using non-blocking pairwise communication i.e. Isend & Irecv
158 *
159 * @param requestSend List of send requests
160 * @param requestRecv List of receive requests
161 * @param requestNum Index of request in list to use
162 * @param Fwd The values to send across the interface
163 */
166 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum,
168
169 /**
170 * Loops over interfaces and partitions out the received trace from the
171 * other ranks for insertion into Bwd using FillRankBwdTrace
172 *
173 * @param Bwd The Bwd trace to be filled from across the interface
174 */
177
178private:
179 /// Movement object associated with the non-conformal interfaces
181 /// Map of zone IDs to zone bases
182 std::map<int, SpatialDomains::ZoneBaseShPtr> m_zones;
183 /// Trace expansion list
185 /// Communicator
187 /// Process rank
189 /// Vector of interface traces i.e. every interface side present on m_rank
190 const std::vector<InterfaceTraceSharedPtr> m_interfaceTraces;
191 /// Send buffer for coord exchange
193 /// Receive buffer for coord exchange
195 /// Receive buffer for trace exchange
197 /// Send buffer for trace exchange
199 /// Map of rank to total size of send buffer for all interfaces
200 std::map<int, int> m_totSendSize;
201 /// Map of rank to total size of receive buffer for all interfaces
202 std::map<int, int> m_totRecvSize;
203 /// Map of rank to array of size of send buffer for each interface
204 std::map<int, Array<OneD, int>> m_sendSize;
205 /// Map of rank to array of size of receive buffer for each interface
206 std::map<int, Array<OneD, int>> m_recvSize;
207
208 /**
209 * Caches the found coordinates to reuse when exchanging the trace in a
210 * map of integer rank to a map of integer missing coordinate location to a
211 * pair of local edge ID and found local coordinate
212 */
213 std::map<
214 int,
215 std::map<int, std::pair<std::pair<int, int>, Array<OneD, NekDouble>>>>
217};
218
219typedef std::shared_ptr<InterfaceExchange> InterfaceExchangeSharedPtr;
220
221/**
222 * Implements the communication patterns to allow for exchange of information
223 * across non-conformal interfaces and across different partitions. Holds all
224 * the InterfaceExchange objects in m_exchange.
225 */
227{
228public:
229 /// Default destructor
231
232 /**
233 * Sets up the InterfaceExchange objects stored in m_exchange, each object
234 * is rank -> rank and contains a vector of InterfaceTrace objects
235 * corresponding to shared interfaces between those ranks.
236 */
239 const ExpListSharedPtr &trace);
240
241 /**
242 * @brief Perform the trace exchange between processors, given the forwards
243 * and backwards spaces.
244 *
245 * @param Fwd Local forwards space of the trace (which will be sent)
246 * @param Bwd Local backwards space of the trace (which will receive
247 * contributions)
248 */
251 /**
252 * @brief Perform the coordinate exchange between processors. This is where
253 * the missing coordinates on the interface are found and sent to all other
254 * processors on the other side of that interface so the matching ranks can
255 * be found.
256 */
258
259private:
260 /// Mesh associated with this expansion list.
262 /// Movement object associated with the non-conformal interfaces
264 /// Interface sides present on current process
265 std::vector<InterfaceTraceSharedPtr> m_localInterfaces;
266 /// Trace expansion list
268 /// Vector of interface exchanges, i.e. every rank-to-rank comm needed
269 std::vector<InterfaceExchangeSharedPtr> m_exchange;
270};
271// class
272
273typedef std::shared_ptr<InterfaceMapDG> InterfaceMapDGSharedPtr;
274
275} // namespace Nektar::MultiRegions
276
277#endif // MULTIREGIONS_INTERFACE_MAP_DG_H
#define MULTI_REGIONS_EXPORT
std::map< int, Array< OneD, int > > m_sendSize
Map of rank to array of size of send buffer for each interface.
void RankFillSizes(LibUtilities::CommRequestSharedPtr &requestSend, LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum)
std::map< int, SpatialDomains::ZoneBaseShPtr > m_zones
Map of zone IDs to zone bases.
const ExpListSharedPtr m_trace
Trace expansion list.
void FillRankBwdTraceExchange(Array< OneD, NekDouble > &Bwd)
const std::vector< InterfaceTraceSharedPtr > m_interfaceTraces
Vector of interface traces i.e. every interface side present on m_rank.
const LibUtilities::CommSharedPtr m_comm
Communicator.
void SendFwdTrace(LibUtilities::CommRequestSharedPtr &requestSend, LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum, Array< OneD, NekDouble > &Fwd)
Array< OneD, NekDouble > m_send
Send buffer for coord exchange.
InterfaceExchange(SpatialDomains::MovementSharedPtr movement, const ExpListSharedPtr &trace, const LibUtilities::CommSharedPtr &comm, std::pair< int, std::vector< InterfaceTraceSharedPtr > > rankPair)
Constructor.
std::map< int, int > m_totSendSize
Map of rank to total size of send buffer for all interfaces.
void CalcRankDistances()
Populates m_foundRankCoords using the FindDistance function.
std::map< int, int > m_totRecvSize
Map of rank to total size of receive buffer for all interfaces.
virtual ~InterfaceExchange()=default
Default destructor.
SpatialDomains::MovementSharedPtr m_movement
Movement object associated with the non-conformal interfaces.
std::map< int, Array< OneD, int > > m_recvSize
Map of rank to array of size of receive buffer for each interface.
Array< OneD, NekDouble > m_recv
Receive buffer for coord exchange.
void SendMissing(LibUtilities::CommRequestSharedPtr &requestSend, LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum)
Array< OneD, NekDouble > m_recvTrace
Receive buffer for trace exchange.
std::map< int, std::map< int, std::pair< std::pair< int, int >, Array< OneD, NekDouble > > > > m_foundRankCoords
Array< OneD, NekDouble > m_sendTrace
Send buffer for trace exchange.
~InterfaceMapDG()=default
Default destructor.
SpatialDomains::MeshGraphSharedPtr m_graph
Mesh associated with this expansion list.
const ExpListSharedPtr m_trace
Trace expansion list.
void ExchangeTrace(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Perform the trace exchange between processors, given the forwards and backwards spaces.
std::vector< InterfaceExchangeSharedPtr > m_exchange
Vector of interface exchanges, i.e. every rank-to-rank comm needed.
void ExchangeCoords()
Perform the coordinate exchange between processors. This is where the missing coordinates on the inte...
SpatialDomains::MovementSharedPtr m_movement
Movement object associated with the non-conformal interfaces.
InterfaceMapDG(const SpatialDomains::MeshGraphSharedPtr &graph, const ExpListSharedPtr &trace)
std::vector< InterfaceTraceSharedPtr > m_localInterfaces
Interface sides present on current process.
ExpListSharedPtr m_trace
Trace expansion list.
void DomainCheck(Array< OneD, NekDouble > &gloCoord, SpatialDomains::MovementSharedPtr movement)
Check whether the coordiniates in the original domain.
std::vector< Array< OneD, NekDouble > > GetMissingCoords()
Returns the missing coordinates vector.
std::map< int, std::pair< int, Array< OneD, NekDouble > > > m_foundLocalCoords
Map of found coordinates present locally.
std::vector< int > m_mapMissingCoordToTrace
Vector of indices corresponding to m_missingCoord locations in trace.
SpatialDomains::InterfaceShPtr GetInterface()
Returns the interface object.
void CalcLocalMissing(SpatialDomains::MovementSharedPtr movement)
Calculates what coordinates on the interface are missing locally.
SpatialDomains::InterfaceShPtr m_interface
Local interface object.
std::vector< Array< OneD, NekDouble > > m_missingCoords
Vector of coordinates on interface missing from the other side locally.
virtual ~InterfaceTrace()=default
Default destructor.
InterfaceTrace(const ExpListSharedPtr &trace, const SpatialDomains::InterfaceShPtr &interfaceShPtr)
Constructor.
void FillRankBwdTrace(Array< OneD, NekDouble > &trace, Array< OneD, NekDouble > &Bwd)
Fills the Bwd trace from partitioned trace.
void FillLocalBwdTrace(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Fills the Bwd trace by interpolating from the Fwd for local interfaces.
bool m_checkLocal
Flag whether the opposite side of the interface is present locally.
std::shared_ptr< CommRequest > CommRequestSharedPtr
Definition: Comm.h:84
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::shared_ptr< InterfaceTrace > InterfaceTraceSharedPtr
std::shared_ptr< InterfaceMapDG > InterfaceMapDGSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< InterfaceExchange > InterfaceExchangeSharedPtr
std::shared_ptr< Interface > InterfaceShPtr
std::shared_ptr< Movement > MovementSharedPtr
Definition: MeshGraph.h:177
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174