Changeset 2200


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
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r2181 r2200  
    556556      // The first domain for the same mesh that will be written is that with the highest value of nvertex. 
    557557      // Thus the entire mesh connectivity will be generated at once. 
     558 
    558559      if (isWrittenDomain(domid)) return ; 
    559560      else setWrittenDomain(domid); 
     
    570571      std::vector<StdString> dim0; 
    571572      StdString domainName = domain->name; 
    572       domain->assignMesh(domainName, domain->nvertex); 
    573       domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 
    574573 
    575574      StdString node_x = domainName + "_node_x"; 
     
    600599      SuperClassWriter::addAttribute("topology_dimension", 2, &domainName); 
    601600      SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); 
     601 
    602602 
    603603      try 
     
    810810                 startNodes[0] = domain->mesh->node_start; 
    811811                 countNodes[0] = domain->mesh->node_count; 
     812                 if (countNodes[0]==0) startNodes[0]=0 ; // for netcdf error 
    812813                 startEdgeNodes[0] = domain->ibegin; 
    813814                 startEdgeNodes[1] = 0; 
     
    846847                 startNodes[0] = domain->mesh->node_start; 
    847848                 countNodes[0] = domain->mesh->node_count; 
     849                 if (countNodes[0]==0) startNodes[0]=0; 
     850                  
    848851                 startEdges[0] = domain->mesh->edge_start; 
    849852                 countEdges[0] = domain->mesh->edge_count; 
     853                 if (countEdges[0]==0) startEdges[0]=0 ; // for netcdf error 
     854                  
    850855                 startEdgeNodes[0] = domain->mesh->edge_start; 
     856                 countEdgeNodes[0] = domain->mesh->edge_count; 
     857                 if (countEdgeNodes[0]==0) startEdgeNodes[0]=0; // for netcdf error 
    851858                 startEdgeNodes[1] = 0; 
    852                  countEdgeNodes[0] = domain->mesh->edge_count; 
    853859                 countEdgeNodes[1]= 2; 
     860 
    854861                 startEdgeFaces[0] = domain->mesh->edge_start; 
     862                 countEdgeFaces[0] = domain->mesh->edge_count; 
     863                 if (countEdgeFaces[0]==0) startEdgeFaces[0]=0 ; // for netcdf error 
    855864                 startEdgeFaces[1]= 0; 
    856                  countEdgeFaces[0] = domain->mesh->edge_count; 
    857865                 countEdgeFaces[1]= 2; 
     866                 
    858867                 startFaceConctv[0] = domain->ibegin; 
     868                 countFaceConctv[0] = domain->ni; 
    859869                 startFaceConctv[1] = 0; 
    860                  countFaceConctv[0] = domain->ni; 
    861870                 countFaceConctv[1] = domain->nvertex; 
    862871               } 
  • 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.