Changeset 2200 for XIOS/trunk/src/node


Ignore:
Timestamp:
08/19/21 13:28:53 (3 years ago)
Author:
ymipsl
Message:

Bugs fix for UGRID convention output

  • global indexation was not taking into account
  • coherence problem in connectivity for node, edge and face mesh
  • add UGRID testcase based on sphere cube

YM

Location:
XIOS/trunk/src/node
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/file.cpp

    r1639 r2200  
    867867   \brief Sorting domains with the same name (= describing the same mesh) in the decreasing order of nvertex for UGRID files. 
    868868   This insures that the domain with the highest nvertex is written first and thus all known mesh connectivity is generated at once by this domain. 
     869   Secondly, we associate the UGRID mesh to the domain in incresing order, i.e. nvertex=1 first, nvertex=2 and then nvertex>2. 
     870   In this case the connectivity of each component of the mesh (node, edge and face) are fully coherent. 
    869871   */ 
    870872   void CFile::sortEnabledFieldsForUgrid() 
     
    874876     std::vector<int> domainNvertices; 
    875877     std::vector<StdString> domainNames; 
     878     std::map<string, tuple<CDomain*,CDomain*,CDomain*>> registeredDomains ; 
    876879 
    877880     for (int i = 0; i < size; ++i) 
     
    916919         domainNvertices.push_back(nvertex); 
    917920       } 
     921 
     922       if (nvertex==1)  std::get<0>(registeredDomains[domainName])=domain[0] ; 
     923       else if (nvertex==2) std::get<1>(registeredDomains[domainName])=domain[0] ; 
     924       else  std::get<2>(registeredDomains[domainName])=domain[0] ; 
     925     } 
     926 
     927     for(auto& it:registeredDomains) 
     928     { 
     929       list<CDomain*> domains ; 
     930       string domainName=it.first ; 
     931 
     932       if (std::get<0>(it.second)!=nullptr) domains.push_back(std::get<0>(it.second)) ; 
     933       if (std::get<1>(it.second)!=nullptr) domains.push_back(std::get<1>(it.second)) ;  
     934       if (std::get<2>(it.second)!=nullptr) domains.push_back(std::get<2>(it.second)) ;  
     935        
     936       // for each component of a given mesh (i.e. domains with same name but different number of vertices) 
     937       // associate the UGRID mesh in increasing order 
     938       for(auto& domain : domains ) 
     939       { 
     940         domain-> computeWrittenIndex(); 
     941         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
     942         int nbWritten = indexToWrite.numElements(); 
     943         CArray<double,1> writtenLat, writtenLon; 
     944         CArray<double,2> writtenBndsLat, writtenBndsLon; 
     945 
     946         writtenLat.resize(nbWritten); 
     947         writtenLon.resize(nbWritten); 
     948         for (int idx = 0; idx < nbWritten; ++idx) 
     949         { 
     950           writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
     951           writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
     952         } 
     953     
     954         int nvertex = domain->nvertex, idx; 
     955        if (nvertex>1) 
     956         { 
     957           writtenBndsLat.resize(nvertex, nbWritten); 
     958           writtenBndsLon.resize(nvertex, nbWritten); 
     959           CArray<double,2>& boundslat = domain->bounds_latvalue; 
     960           CArray<double,2>& boundslon = domain->bounds_lonvalue; 
     961           for (idx = 0; idx < nbWritten; ++idx) 
     962             for (int nv = 0; nv < nvertex; ++nv) 
     963             { 
     964                writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
     965                writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
     966             } 
     967         } 
     968         domain->assignMesh(domainName, domain->nvertex); 
     969         CContextServer* server=CContext::getCurrent()->server ; 
     970         domain->mesh->createMeshEpsilon(server->intraComm, writtenLon, writtenLat, writtenBndsLon, writtenBndsLat); 
     971       } 
     972 
    918973     } 
    919974   } 
  • XIOS/trunk/src/node/mesh.cpp

    r1639 r2200  
    433433      node_lat = latvalue; 
    434434 
     435      unsigned long nodeCount = nbNodes_; 
     436      unsigned long nodeStart, nbNodes; 
     437      MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm); 
     438      int nNodes = nodeStart; 
     439      MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm); 
     440      nbNodesGlo = nNodes; 
     441 
     442      nodeStart -= nodeCount; 
     443      node_start = nodeStart; 
     444      node_count = nodeCount; 
     445 
    435446      // Global node indexes 
    436447      vector<size_t> hashValues(4); 
     
    441452        for (size_t nh = 0; nh < 4; ++nh) 
    442453        { 
    443           nodeHash2IdxGlo[hashValues[nh]].push_back(mpiRank*nbNodes_ + nn); 
     454          nodeHash2IdxGlo[hashValues[nh]].push_back(nodeStart + nn);  
    444455        } 
    445456      } 
    446457      pNodeGlobalIndex = new CClientClientDHTSizet (nodeHash2IdxGlo, comm); 
     458 
    447459      nodesAreWritten = true; 
    448460    } 
     
    460472      unsigned long nbEdgesOnProc = nbEdges_; 
    461473      unsigned long nbEdgesAccum; 
     474      unsigned long nbEdgesGlo; 
    462475      MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm); 
     476      nbEdgesGlo = nbEdgesAccum ; 
     477      MPI_Bcast(&nbEdgesGlo, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm); 
    463478      nbEdgesAccum -= nbEdges_; 
     479      edge_start = nbEdgesAccum ; 
     480      edge_count = nbEdgesOnProc ; 
    464481 
    465482      CClientClientDHTSizet::Index2VectorInfoTypeMap edgeHash2IdxGlo; 
     
    670687    } //nvertex = 2 
    671688 
    672     else 
     689    else // nvertex > 2 
    673690    { 
    674691      nbFaces_ = bounds_lon.shape()[1]; 
     
    16011618  } // createMeshEpsilon 
    16021619 
     1620 
    16031621  ///---------------------------------------------------------------- 
    16041622  /*! 
Note: See TracChangeset for help on using the changeset viewer.