44 : m_trace(trace), m_interface(interfaceShPtr)
56 : m_graph(meshGraph), m_movement(meshGraph->GetMovement()), m_trace(trace)
58 auto comm =
m_trace->GetComm()->GetSpaceComm();
59 auto interfaceCollection =
m_movement->GetInterfaces();
65 std::map<int, int> myIndxLRMap;
70 std::map<int, std::pair<InterfaceTraceSharedPtr, InterfaceTraceSharedPtr>>
80 for (
const auto &interface : interfaceCollection)
82 indxToInterfaceID[cnt] = interface.first.first;
83 myIndxLRMap[interface.first.first] = 0;
85 if (!interface.second->GetLeftInterface()->IsEmpty())
87 myIndxLRMap[interface.first.first] += 1;
89 localInterfaces[interface.first.first].first =
91 trace, interface.second->GetLeftInterface());
93 localInterfaces[interface.first.first].first);
96 if (!interface.second->GetRightInterface()->IsEmpty())
98 myIndxLRMap[interface.first.first] += 2;
100 localInterfaces[interface.first.first].second =
102 trace, interface.second->GetRightInterface());
104 localInterfaces[interface.first.first].second);
111 int nRanks = comm->GetSize();
116 for (
auto pres : myIndxLRMap)
118 interfaceEdges[cnt++] = pres.second;
121 comm->AllGather(interfaceEdges, rankLocalInterfaceIds);
124 std::map<int, std::vector<InterfaceTraceSharedPtr>> oppRankSharedInterface;
128 size_t myRank = comm->GetRank();
129 size_t numInterfaces = interfaceCollection.size();
130 for (
int i = 0; i < nRanks; ++i)
132 for (
size_t j = 0; j < numInterfaces; ++j)
134 int otherId = indxToInterfaceID[j];
138 int otherCode = rankLocalInterfaceIds[i * numInterfaces + j];
142 int myCode = myIndxLRMap[otherId];
150 localInterfaces[otherId].first->SetCheckLocal(
true);
151 localInterfaces[otherId].second->SetCheckLocal(
true);
158 if ((myCode == 1 && otherCode == 2) ||
159 (myCode == 1 && otherCode == 3) ||
160 (myCode == 3 && otherCode == 2))
162 oppRankSharedInterface[i].emplace_back(
163 localInterfaces[otherId].first);
166 else if ((myCode == 2 && otherCode == 1) ||
167 (myCode == 2 && otherCode == 3) ||
168 (myCode == 3 && otherCode == 1))
170 oppRankSharedInterface[i].emplace_back(
171 localInterfaces[otherId].second);
174 else if (myCode == 3 && otherCode == 3)
176 oppRankSharedInterface[i].emplace_back(
177 localInterfaces[otherId].first);
178 oppRankSharedInterface[i].emplace_back(
179 localInterfaces[otherId].second);
186 for (
auto &rank : oppRankSharedInterface)
202 auto comm =
m_trace->GetComm();
220 auto requestSend = comm->CreateRequest(
m_exchange.size());
221 auto requestRecv = comm->CreateRequest(
m_exchange.size());
225 m_exchange[i]->RankFillSizes(requestSend, requestRecv, i);
227 comm->WaitAll(requestSend);
228 comm->WaitAll(requestRecv);
232 m_exchange[i]->SendMissing(requestSend, requestRecv, i);
234 comm->WaitAll(requestSend);
235 comm->WaitAll(requestRecv);
239 i->CalcRankDistances();
278 for (
auto &childId : childEdge)
280 auto childElmt =
m_trace->GetExpFromGeomId(childId.first);
281 size_t nq = childElmt->GetTotPoints();
283 childElmt->GetCoords(xc, yc, zc);
287 for (
int i = 0; i < nq; ++i, ++cnt)
294 if (movement->GetMovedFlag() && movement->GetTranslateFlag())
316 for (
auto &childId : childEdge)
318 auto childElmt =
m_trace->GetExpFromGeomId(childId.first);
319 size_t nq = childElmt->GetTotPoints();
321 childElmt->GetCoords(xc, yc, zc);
325 for (
int i = 0; i < nq; ++i)
334 if (movement->GetMovedFlag() && movement->GetTranslateFlag())
340 if (foundLocalCoordsCopy.find(offset + i) !=
341 foundLocalCoordsCopy.end())
343 auto edge =
m_interface->GetOppInterface()->GetEdge(
344 foundLocalCoordsCopy[offset + i].first);
345 NekDouble dist = edge->FindDistance(xs, foundLocCoord);
350 std::make_pair(edge->GetGlobalID(), foundLocCoord);
357 auto parentEdge =
m_interface->GetOppInterface()->GetEdge();
358 for (
auto &edge : parentEdge)
361 if (!edge.second->MinMaxCheck(xs))
367 edge.second->FindDistance(xs, foundLocCoord);
372 edge.second->GetGlobalID(), foundLocCoord);
392 " coordinates on interface ID " +
394 " linked to interface ID " +
395 std::to_string(
m_interface->GetOppInterface()->GetId()) +
396 ". Check both sides of the interface line up.");
415 m_zones[localInterface->GetInterface()->GetId()]->GetMoved();
424 if (
m_zones[interface->GetInterface()->GetId()]->GetMoved())
430 interface->GetMissingCoords().size() * 3;
436 requestSend, requestNum);
438 requestRecv, requestNum);
458 if (
m_zones[interface->GetInterface()->GetId()]->GetMoved())
460 auto missing = interface->GetMissingCoords();
461 for (
auto coord : missing)
465 for (
int k = 0; k < 3; ++k, ++cnt)
494 auto comm =
m_trace->GetComm();
502 m_localInterface->FillLocalBwdTrace(Fwd, Bwd);
507 auto requestSend = comm->CreateRequest(
m_exchange.size());
508 auto requestRecv = comm->CreateRequest(
m_exchange.size());
511 m_exchange[i]->SendFwdTrace(requestSend, requestRecv, i, Fwd);
517 m_localInterface->FillLocalBwdTrace(Fwd, Bwd);
520 comm->WaitAll(requestSend);
521 comm->WaitAll(requestRecv);
526 i->FillRankBwdTraceExchange(Bwd);
539 int traceId =
m_trace->GetElmtToExpId(foundLocCoord.second.first);
543 Fwd +
m_trace->GetPhys_Offset(traceId);
545 Bwd[foundLocCoord.first] =
546 m_trace->GetExp(traceId)->StdPhysEvaluate(locCoord, edgePhys);
571 if (!std::isnan(trace[i]))
590 int traceId =
m_trace->GetElmtToExpId(i.second.first.second);
594 Fwd +
m_trace->GetPhys_Offset(traceId);
597 m_trace->GetExp(traceId)->StdPhysEvaluate(locCoord, edgePhys);
643 for (
int j = disp[i]; j < disp[i + 1]; j += 3)
652 if ((foundRankCoordsCopy.find(j / 3) !=
653 foundRankCoordsCopy.end()) &&
654 (foundRankCoordsCopy[j / 3].first.first == i))
657 foundRankCoordsCopy[j / 3].first.second);
658 NekDouble dist = edge->FindDistance(xs, foundLocCoord);
663 std::make_pair(i, edge->GetGlobalID()), foundLocCoord);
668 for (
auto &edge : localEdge)
671 if (!edge.second->MinMaxCheck(xs))
676 NekDouble dist = edge.second->FindDistance(xs, foundLocCoord);
681 std::make_pair(i, edge.second->GetGlobalID()),
695 int oppid =
m_interface->GetOppInterface()->GetId();
698 auto zones = movement->GetZones();
699 auto disp = zones[id]->v_GetDisp();
700 auto oppdisp = zones[oppid]->v_GetDisp();
703 auto box = movement->GetDomainBox();
704 auto length = movement->GetDomainLength();
711 for (
int i = 0; i < disp.size(); ++i)
714 ExactMove = std::fmod(disp[i], length[i]);
715 ExactOppMove = std::fmod(oppdisp[i], length[i]);
716 tmp = oppdisp[i] / length[i];
717 gloCoord[i] = gloCoord[i] - disp[i] + ExactMove;
720 if (oppdisp[i] - disp[i] < 0)
722 if (gloCoord[i] > box[i + 3] + ExactOppMove)
724 gloCoord[i] = gloCoord[i] - length[i] + tmp * length[i];
728 gloCoord[i] = gloCoord[i] + tmp * length[i];
733 if (gloCoord[i] < box[i] + ExactOppMove)
735 gloCoord[i] = gloCoord[i] + length[i] + tmp * length[i];
739 gloCoord[i] = gloCoord[i] + tmp * length[i];
#define ASSERTL0(condition, msg)
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
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, 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.
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.
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::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.
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.
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
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kFindDistanceMin
std::shared_ptr< Interface > InterfaceShPtr
std::shared_ptr< Movement > MovementSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr