45 : m_trace(trace), m_interface(interfaceShPtr)
57 : m_graph(meshGraph), m_movement(meshGraph->GetMovement()), m_trace(trace)
59 auto comm =
m_trace->GetComm()->GetSpaceComm();
60 auto interfaceCollection =
m_movement->GetInterfaces();
66 std::map<int, int> myIndxLRMap;
71 std::map<int, std::pair<InterfaceTraceSharedPtr, InterfaceTraceSharedPtr>>
81 for (
const auto &interface : interfaceCollection)
83 indxToInterfaceID[cnt] = interface.first.first;
84 myIndxLRMap[interface.first.first] = 0;
86 if (!interface.second->GetLeftInterface()->IsEmpty())
88 myIndxLRMap[interface.first.first] += 1;
90 localInterfaces[interface.first.first].first =
92 trace, interface.second->GetLeftInterface());
94 localInterfaces[interface.first.first].first);
97 if (!interface.second->GetRightInterface()->IsEmpty())
99 myIndxLRMap[interface.first.first] += 2;
101 localInterfaces[interface.first.first].second =
103 trace, interface.second->GetRightInterface());
105 localInterfaces[interface.first.first].second);
112 int nRanks = comm->GetSize();
117 for (
auto pres : myIndxLRMap)
119 interfaceEdges[cnt++] = pres.second;
122 comm->AllGather(interfaceEdges, rankLocalInterfaceIds);
125 std::map<int, std::vector<InterfaceTraceSharedPtr>> oppRankSharedInterface;
129 size_t myRank = comm->GetRank();
130 size_t numInterfaces = interfaceCollection.size();
131 for (
int i = 0; i < nRanks; ++i)
133 for (
size_t j = 0; j < numInterfaces; ++j)
135 int otherId = indxToInterfaceID[j];
139 int otherCode = rankLocalInterfaceIds[i * numInterfaces + j];
143 int myCode = myIndxLRMap[otherId];
151 localInterfaces[otherId].first->SetCheckLocal(
true);
152 localInterfaces[otherId].second->SetCheckLocal(
true);
159 if ((myCode == 1 && otherCode == 2) ||
160 (myCode == 1 && otherCode == 3) ||
161 (myCode == 3 && otherCode == 2))
163 oppRankSharedInterface[i].emplace_back(
164 localInterfaces[otherId].first);
167 else if ((myCode == 2 && otherCode == 1) ||
168 (myCode == 2 && otherCode == 3) ||
169 (myCode == 3 && otherCode == 1))
171 oppRankSharedInterface[i].emplace_back(
172 localInterfaces[otherId].second);
175 else if (myCode == 3 && otherCode == 3)
177 oppRankSharedInterface[i].emplace_back(
178 localInterfaces[otherId].first);
179 oppRankSharedInterface[i].emplace_back(
180 localInterfaces[otherId].second);
187 for (
auto &rank : oppRankSharedInterface)
200 auto comm =
m_trace->GetComm()->GetSpaceComm();
205 interfaceTrace->CalcLocalMissing();
211 auto requestSend = comm->CreateRequest(
m_exchange.size());
212 auto requestRecv = comm->CreateRequest(
m_exchange.size());
216 m_exchange[i]->RankFillSizes(requestSend, requestRecv, i);
218 comm->WaitAll(requestSend);
219 comm->WaitAll(requestRecv);
223 m_exchange[i]->SendMissing(requestSend, requestRecv, i);
225 comm->WaitAll(requestSend);
226 comm->WaitAll(requestRecv);
230 i->CalcRankDistances();
252 for (
auto &childId : childEdge)
254 auto childElmt =
m_trace->GetExpFromGeomId(childId.first);
255 size_t nq = childElmt->GetTotPoints();
257 childElmt->GetCoords(xc, yc, zc);
261 for (
int i = 0; i < nq; ++i, ++cnt)
285 for (
auto &childId : childEdge)
287 auto childElmt =
m_trace->GetExpFromGeomId(childId.first);
288 size_t nq = childElmt->GetTotPoints();
290 childElmt->GetCoords(xc, yc, zc);
294 for (
int i = 0; i < nq; ++i)
303 auto parentEdge =
m_interface->GetOppInterface()->GetEdge();
304 for (
auto &edge : parentEdge)
307 if (!edge.second->MinMaxCheck(xs))
313 edge.second->FindDistance(xs, foundLocCoord);
318 edge.second->GetGlobalID(), foundLocCoord);
333 if (
m_trace->GetComm()->IsSerial())
337 " coordinates on interface ID " +
339 " linked to interface ID " +
340 std::to_string(
m_interface->GetOppInterface()->GetId()) +
341 ". Check both sides of the interface line up.");
360 m_zones[localInterface->GetInterface()->GetId()]->GetMoved();
369 if (
m_zones[interface->GetInterface()->GetId()]->GetMoved())
375 interface->GetMissingCoords().size() * 3;
381 requestSend, requestNum);
383 requestRecv, requestNum);
403 if (
m_zones[interface->GetInterface()->GetId()]->GetMoved())
405 auto missing = interface->GetMissingCoords();
406 for (
auto coord : missing)
410 for (
int k = 0; k < 3; ++k, ++cnt)
435 auto comm =
m_trace->GetComm()->GetSpaceComm();
443 m_localInterface->FillLocalBwdTrace(Fwd, Bwd);
448 auto requestSend = comm->CreateRequest(
m_exchange.size());
449 auto requestRecv = comm->CreateRequest(
m_exchange.size());
452 m_exchange[i]->SendFwdTrace(requestSend, requestRecv, i, Fwd);
458 m_localInterface->FillLocalBwdTrace(Fwd, Bwd);
461 comm->WaitAll(requestSend);
462 comm->WaitAll(requestRecv);
467 i->FillRankBwdTraceExchange(Bwd);
480 int traceId =
m_trace->GetElmtToExpId(foundLocCoord.second.first);
484 Fwd +
m_trace->GetPhys_Offset(traceId);
486 Bwd[foundLocCoord.first] =
487 m_trace->GetExp(traceId)->StdPhysEvaluate(locCoord, edgePhys);
512 if (!std::isnan(trace[i]))
531 int traceId =
m_trace->GetElmtToExpId(i.second.first);
535 Fwd +
m_trace->GetPhys_Offset(traceId);
538 m_trace->GetExp(traceId)->StdPhysEvaluate(locCoord, edgePhys);
572 for (
int j = disp[i]; j < disp[i + 1]; j += 3)
580 for (
auto &edge : localEdge)
583 if (!edge.second->MinMaxCheck(xs))
588 NekDouble dist = edge.second->FindDistance(xs, foundLocCoord);
593 edge.second->GetGlobalID(), foundLocCoord);
#define ASSERTL0(condition, msg)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
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.
std::map< int, std::map< int, std::pair< int, Array< OneD, NekDouble > > > > m_foundRankCoords
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.
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.
Array< OneD, NekDouble > m_sendTrace
Send buffer for trace exchange.
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.
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 m_interface
Local interface object.
std::vector< Array< OneD, NekDouble > > m_missingCoords
Vector of coordinates on interface missing from the other side locally.
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 CalcLocalMissing()
Calculates what coordinates on the interface are missing locally.
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
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kFindDistanceMin
std::shared_ptr< Interface > InterfaceShPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.