Changeset 2690 for XIOS2/trunk/extern


Ignore:
Timestamp:
12/16/24 09:48:02 (7 weeks ago)
Author:
jderouillat
Message:

Added the sorting of the localTree to ensure the reproductibilty of second order interpolation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS2/trunk/extern/remap/src/parallel_tree.cpp

    r1639 r2690  
    261261} 
    262262 
     263struct compareElts 
     264{ 
     265  bool operator()(const std::tuple<double, double, double>& lhs, const std::tuple<double, double, double>& rhs) const 
     266  { 
     267    if (get<0>(lhs) < get<0>(rhs)) return true; 
     268    else if (get<0>(lhs) > get<0>(rhs)) return false; 
     269    else { 
     270      if (get<1>(lhs) < get<1>(rhs)) return true; 
     271      else if (get<1>(lhs) > get<1>(rhs)) return false; 
     272      else { 
     273        if (get<2>(lhs) < get<2>(rhs)) return true; 
     274        else if (get<2>(lhs) > get<2>(rhs)) return false; 
     275        else return true; 
     276      } 
     277    } 
     278  } 
     279}; 
    263280 
    264281void CParallelTree::buildLocalTree(const vector<Node>& node, const vector<int>& route) 
     
    282299                ptLocalElement[i] = &localElements[i]; 
    283300 
     301         
    284302        CTimer::get("buildLocalTree(transfer)").resume(); 
    285303        MPIRoute.transferToTarget(&ptElement[0], &ptLocalElement[0], packElement, unpackElement); 
     
    288306 
    289307        CTimer::get("buildLocalTree(local)").resume(); 
     308         
     309        // Force order access to localElements for reproductibilty using the map below 
     310        std::map<std::tuple<double, double, double>, int, compareElts> indexesFromCoords; 
     311        for (int i = 0; i < nbLocalElements; i++) 
     312        { 
     313            Elt& elt = localElements[i]; 
     314            indexesFromCoords[{elt.x.x,elt.x.y,elt.x.z}] = i; 
     315        } 
    290316 
    291317        int mpiRank; 
    292318        MPI_Comm_rank(communicator, &mpiRank); 
    293319        localTree.leafs.reserve(nbLocalElements); 
    294         for (int i = 0; i < nbLocalElements; i++) 
    295         { 
     320        for (const auto& itIndex : indexesFromCoords) 
     321        { 
     322                int i = itIndex.second;  
    296323                Elt& elt = localElements[i]; 
    297324                elt.id.ind = i; 
Note: See TracChangeset for help on using the changeset viewer.