Nektar++
Loading...
Searching...
No Matches
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,
57
58 /// Default destructor
60
61 inline void SetCheckLocal(bool flag)
62 {
63 m_checkLocal = flag;
64 }
65
66 /// Returns the missing coordinates vector
67 inline std::vector<Array<OneD, NekDouble>> GetMissingCoords()
68 {
69 return m_missingCoords;
70 }
71
72 MULTI_REGIONS_EXPORT std::map<int, std::pair<int, Array<OneD, NekDouble>>>
74 {
75 return m_foundLocalCoords;
76 }
77
78 MULTI_REGIONS_EXPORT std::map<int, std::pair<int, NekDouble>> GetRotAngle()
79 {
80 return m_phyRotAngle;
81 }
82
83 /// Returns the interface object
88
89 /// Calculates what coordinates on the interface are missing locally
90 void CalcLocalMissing();
91 /// Fills the Bwd trace by interpolating from the Fwd for local interfaces
94 /// Rotates the interface velocity for sector rotation
96 const int &dim);
97 /// Rotates the interface derivative velocity for sector rotation
99 const int &dim);
100 /// Rotate the 3D vector field in Bwd around the axis 'dir' by 'angle'.
101 void DeriveRotate(TensorOfArray3D<NekDouble> &Bwd, const int dir,
102 const NekDouble angle);
103 /// Fills the Bwd trace from partitioned trace
106 /// Update the coordiniates after movement
107 void DomainCheck(Array<OneD, NekDouble> &gloCoord, NekDouble &angle);
108
109private:
110 /// Trace expansion list
112 /// Local interface object
114 /// Movement object associated with the non-conformal interfaces
116 /// Flag whether the opposite side of the interface is present locally
117 bool m_checkLocal = false;
118 /// Vector of coordinates on interface missing from the other side locally
119 std::vector<Array<OneD, NekDouble>> m_missingCoords;
120 /// Map of found coordinates present locally
121 std::map<int, std::pair<int, Array<OneD, NekDouble>>> m_foundLocalCoords;
122 /// Map of phy rotate angle for sector rotate interfaces
123 std::map<int, std::pair<int, NekDouble>> m_phyRotAngle;
124 /// Vector of indices corresponding to m_missingCoord locations in trace
125 std::vector<int> m_mapMissingCoordToTrace;
126};
127
128typedef std::shared_ptr<InterfaceTrace> InterfaceTraceSharedPtr;
129
130/**
131 * Object for one rank-to-rank communication for all interfaces shared
132 * between those ranks. e.g. if on rank 1 and there are interfaces shared with
133 * rank 2 and 3, there will be two InterfaceExchange objects in m_exchange in
134 * InterfaceMapDG. This holds the InterfaceTrace objects in m_interfaceTraces.
135 */
137{
138public:
139 /// Default destructor
141
142 /// Constructor
145 const ExpListSharedPtr &trace, const LibUtilities::CommSharedPtr &comm,
146 std::pair<int, std::vector<InterfaceTraceSharedPtr>> rankPair)
147 : m_movement(movement), m_zones(movement->GetZones()), m_trace(trace),
148 m_comm(comm), m_rank(rankPair.first),
149 m_interfaceTraces(rankPair.second)
150 {
151 }
152
153 /**
154 * Communicates with other ranks how many missing coordinates for each
155 * interface to expect
156 *
157 * @param requestSend List of send requests
158 * @param requestRecv List of receive requests
159 * @param requestNum Index of request in list to use
160 */
163 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum);
164
165 /**
166 * Sends/receives the missing coordinates to/from other ranks
167 *
168 * @param requestSend List of send requests
169 * @param requestRecv List of receive requests
170 * @param requestNum Index of request in list to use
171 */
174 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum);
175
176 /// Populates m_foundRankCoords using the FindDistance function
178
179 /**
180 * Calculates and sends the trace to other rank from the m_foundRankCoords
181 * structure using non-blocking pairwise communication i.e. Isend & Irecv
182 *
183 * @param requestSend List of send requests
184 * @param requestRecv List of receive requests
185 * @param requestNum Index of request in list to use
186 * @param Fwd The values to send across the interface
187 */
190 LibUtilities::CommRequestSharedPtr &requestRecv, int requestNum,
192
193 /**
194 * Loops over interfaces and partitions out the received trace from the
195 * other ranks for insertion into Bwd using FillRankBwdTrace
196 *
197 * @param Bwd The Bwd trace to be filled from across the interface
198 */
201
202private:
203 /// Movement object associated with the non-conformal interfaces
205 /// Map of zone IDs to zone bases
206 std::map<int, SpatialDomains::ZoneBaseShPtr> m_zones;
207 /// Trace expansion list
209 /// Communicator
211 /// Process rank
213 /// Vector of interface traces i.e. every interface side present on m_rank
214 const std::vector<InterfaceTraceSharedPtr> m_interfaceTraces;
215 /// Send buffer for coord exchange
217 /// Receive buffer for coord exchange
219 /// Receive buffer for trace exchange
221 /// Send buffer for trace exchange
223 /// Map of rank to total size of send buffer for all interfaces
224 std::map<int, int> m_totSendSize;
225 /// Map of rank to total size of receive buffer for all interfaces
226 std::map<int, int> m_totRecvSize;
227 /// Map of rank to array of size of send buffer for each interface
228 std::map<int, Array<OneD, int>> m_sendSize;
229 /// Map of rank to array of size of receive buffer for each interface
230 std::map<int, Array<OneD, int>> m_recvSize;
231
232 /**
233 * Caches the found coordinates to reuse when exchanging the trace in a
234 * map of integer rank to a map of integer missing coordinate location to a
235 * pair of local edge ID and found local coordinate
236 */
237 std::map<
238 int,
239 std::map<int, std::pair<std::pair<int, int>, Array<OneD, NekDouble>>>>
241};
242
243typedef std::shared_ptr<InterfaceExchange> InterfaceExchangeSharedPtr;
244
245/**
246 * Implements the communication patterns to allow for exchange of information
247 * across non-conformal interfaces and across different partitions. Holds all
248 * the InterfaceExchange objects in m_exchange.
249 */
251{
252public:
253 /// Default destructor
255
256 /**
257 * Sets up the InterfaceExchange objects stored in m_exchange, each object
258 * is rank -> rank and contains a vector of InterfaceTrace objects
259 * corresponding to shared interfaces between those ranks.
260 */
263 const ExpListSharedPtr &trace);
264
265 /**
266 * @brief Perform the trace exchange between processors, given the forwards
267 * and backwards spaces.
268 *
269 * @param Fwd Local forwards space of the trace (which will be sent)
270 * @param Bwd Local backwards space of the trace (which will receive
271 * contributions)
272 */
275 /**
276 * @brief Perform the coordinate exchange between processors. This is where
277 * the missing coordinates on the interface are found and sent to all other
278 * processors on the other side of that interface so the matching ranks can
279 * be found.
280 */
282
283 /// Returns the interface object
284 MULTI_REGIONS_EXPORT std::vector<InterfaceTraceSharedPtr> GetLocalInterface()
285 {
286 return m_localInterfaces;
287 }
288
289private:
290 /// Mesh associated with this expansion list.
292 /// Movement object associated with the non-conformal interfaces
294 /// Interface sides present on current process
295 std::vector<InterfaceTraceSharedPtr> m_localInterfaces;
296 /// Trace expansion list
298 /// Vector of interface exchanges, i.e. every rank-to-rank comm needed
299 std::vector<InterfaceExchangeSharedPtr> m_exchange;
300};
301// class
302
303typedef std::shared_ptr<InterfaceMapDG> InterfaceMapDGSharedPtr;
304
305} // namespace Nektar::MultiRegions
306
307#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.
std::vector< InterfaceTraceSharedPtr > m_localInterfaces
Interface sides present on current process.
std::vector< InterfaceTraceSharedPtr > GetLocalInterface()
Returns the interface object.
ExpListSharedPtr m_trace
Trace expansion list.
void RotLocalBwdTrace(Array< OneD, Array< OneD, NekDouble > > &Bwd, const int &dim)
Rotates the interface velocity for sector rotation.
std::vector< Array< OneD, NekDouble > > GetMissingCoords()
Returns the missing coordinates vector.
std::map< int, std::pair< int, Array< OneD, NekDouble > > > GetLocalCoords()
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.
SpatialDomains::InterfaceShPtr m_interface
Local interface object.
std::map< int, std::pair< int, NekDouble > > GetRotAngle()
std::vector< Array< OneD, NekDouble > > m_missingCoords
Vector of coordinates on interface missing from the other side locally.
virtual ~InterfaceTrace()=default
Default destructor.
void DomainCheck(Array< OneD, NekDouble > &gloCoord, NekDouble &angle)
Update the coordiniates after movement.
void FillRankBwdTrace(Array< OneD, NekDouble > &trace, Array< OneD, NekDouble > &Bwd)
Fills the Bwd trace from partitioned trace.
void CalcLocalMissing()
Calculates what coordinates on the interface are missing locally.
void RotLocalBwdDeriveTrace(TensorOfArray3D< NekDouble > &Bwd, const int &dim)
Rotates the interface derivative velocity for sector rotation.
SpatialDomains::MovementSharedPtr m_movement
Movement object associated with the non-conformal interfaces.
std::map< int, std::pair< int, NekDouble > > m_phyRotAngle
Map of phy rotate angle for sector rotate interfaces.
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.
void DeriveRotate(TensorOfArray3D< NekDouble > &Bwd, const int dir, const NekDouble angle)
Rotate the 3D vector field in Bwd around the axis 'dir' by 'angle'.
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:220
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:217