Ignore:
Timestamp:
08/19/21 13:28:53 (5 months 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

File:
1 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   } 
Note: See TracChangeset for help on using the changeset viewer.