Ignore:
Timestamp:
10/06/22 12:50:04 (21 months ago)
Author:
jderouillat
Message:

Backport commits [1977, 2181, 2200-2202, 2250, 2252] related to UGRID in XIOS3 beta

Location:
XIOS3/branches/xios-3.0-beta/src/node
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/branches/xios-3.0-beta/src/node/file.cpp

    r2400 r2417  
    863863     std::vector<int> domainNvertices; 
    864864     std::vector<StdString> domainNames; 
     865     std::map<string, tuple<set<CDomain*>,set<CDomain*>,set<CDomain*>>> registeredDomains ; 
    865866 
    866867     for (int i = 0; i < size; ++i) 
     
    905906         domainNvertices.push_back(nvertex); 
    906907       } 
     908 
     909       if (nvertex==1)  std::get<0>(registeredDomains[domainName]).insert(domain[0]) ; 
     910       else if (nvertex==2) std::get<1>(registeredDomains[domainName]).insert(domain[0]) ; 
     911       else  std::get<2>(registeredDomains[domainName]).insert(domain[0]) ; 
     912     } 
     913 
     914     for(auto& it:registeredDomains) 
     915     { 
     916       list<CDomain*> domains ; 
     917       string domainName=it.first ; 
     918 
     919       for(auto& domain : std::get<0>(it.second) ) domains.push_back(domain) ; 
     920       for(auto& domain : std::get<1>(it.second) ) domains.push_back(domain) ; 
     921       for(auto& domain : std::get<2>(it.second) ) domains.push_back(domain) ; 
     922        
     923       // for each component of a given mesh (i.e. domains with same name but different number of vertices) 
     924       // associate the UGRID mesh in increasing order 
     925       for(auto& domain : domains ) 
     926       { 
     927         //domain-> computeWrittenIndex(); 
     928         //CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
     929         CArray<int, 1> indexToWrite = domain->getLocalView(CElementView::WORKFLOW)->getIndex(); 
     930         int nbWritten = indexToWrite.numElements(); 
     931 
     932         CArray<double,1> writtenLat, writtenLon; 
     933         CArray<double,2> writtenBndsLat, writtenBndsLon; 
     934 
     935         writtenLat.resize(nbWritten); 
     936         writtenLon.resize(nbWritten); 
     937         for (int idx = 0; idx < nbWritten; ++idx) 
     938         { 
     939           writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     940           writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     941         } 
     942     
     943         int nvertex = domain->nvertex, idx; 
     944        if (nvertex>1) 
     945         { 
     946           writtenBndsLat.resize(nvertex, nbWritten); 
     947           writtenBndsLon.resize(nvertex, nbWritten); 
     948           CArray<double,2>& boundslat = domain->bounds_latvalue; 
     949           CArray<double,2>& boundslon = domain->bounds_lonvalue; 
     950           for (idx = 0; idx < nbWritten; ++idx) 
     951             for (int nv = 0; nv < nvertex; ++nv) 
     952             { 
     953                writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
     954                writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
     955             } 
     956         } 
     957         domain->assignMesh(domainName, domain->nvertex); 
     958         //CContextServer* server=CContext::getCurrent()->server ; 
     959         //domain->mesh->createMeshEpsilon(server->intraComm, writtenLon, writtenLat, writtenBndsLon, writtenBndsLat); 
     960         MPI_Comm intraComm =CContext::getCurrent()->getIntraComm() ; 
     961         domain->mesh->createMeshEpsilon(intraComm, writtenLon, writtenLat, writtenBndsLon, writtenBndsLat); 
     962       } 
     963 
    907964     } 
    908965   } 
  • XIOS3/branches/xios-3.0-beta/src/node/mesh.cpp

    r2284 r2417  
    430430    if (nvertex == 1) 
    431431    { 
     432      if (nodesAreWritten) return ; 
     433 
    432434      nbNodes_ = lonvalue.numElements(); 
    433435      node_lon.resize(nbNodes_); 
     
    435437      node_lon = lonvalue; 
    436438      node_lat = latvalue; 
     439 
     440      unsigned long nodeCount = nbNodes_; 
     441      unsigned long nodeStart, nbNodes; 
     442      MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm); 
     443      int nNodes = nodeStart; 
     444      MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm); 
     445      nbNodesGlo = nNodes; 
     446 
     447      nodeStart -= nodeCount; 
     448      node_start = nodeStart; 
     449      node_count = nodeCount; 
    437450 
    438451      // Global node indexes 
     
    444457        for (size_t nh = 0; nh < 4; ++nh) 
    445458        { 
    446           nodeHash2IdxGlo[hashValues[nh]].push_back(mpiRank*nbNodes_ + nn); 
     459          nodeHash2IdxGlo[hashValues[nh]].push_back(nodeStart + nn); 
    447460        } 
    448461      } 
     
    453466    else if (nvertex == 2) 
    454467    { 
     468      if (edgesAreWritten) return ; 
     469 
    455470      nbEdges_ = bounds_lon.shape()[1]; 
    456471      edge_lon.resize(nbEdges_); 
     
    463478      unsigned long nbEdgesOnProc = nbEdges_; 
    464479      unsigned long nbEdgesAccum; 
     480      unsigned long nbEdgesGlo; 
    465481      MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm); 
     482      nbEdgesGlo = nbEdgesAccum ; 
     483      MPI_Bcast(&nbEdgesGlo, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm); 
    466484      nbEdgesAccum -= nbEdges_; 
     485      edge_start = nbEdgesAccum ; 
     486      edge_count = nbEdgesOnProc ; 
    467487 
    468488      CClientClientDHTSizet::Index2VectorInfoTypeMap edgeHash2IdxGlo; 
     
    674694    } //nvertex = 2 
    675695 
    676     else 
    677     { 
     696    else // nvertex > 2 
     697    { 
     698      if (facesAreWritten) return ; 
     699 
    678700      nbFaces_ = bounds_lon.shape()[1]; 
    679701      face_lon.resize(nbFaces_); 
Note: See TracChangeset for help on using the changeset viewer.