Ignore:
Timestamp:
04/25/18 17:30:25 (6 years ago)
Author:
oabramkina
Message:

Bigfix for UGRID: fields describing the same mesh (= fields defined on domains with the same name) are sorted in the decreasing order of nvertex. The first, and the only, domain to be written is that with the highest value of nvertex. The entire mesh connectivity will be generated according to this domain.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp

    r1486 r1494  
    549549        data_out->writeFile(CFile::get(this)); 
    550550 
     551        if (!useCFConvention) sortEnabledFieldsForUgrid(); 
     552 
    551553        // Do not recreate the file structure if opening an existing file 
    552554        if (!data_out->IsInAppendMode()) 
     
    809811   } 
    810812 
     813   /*! 
     814   \brief Sorting domains with the same name (= describing the same mesh) in the decreasing order of nvertex for UGRID files. 
     815   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. 
     816   */ 
     817   void CFile::sortEnabledFieldsForUgrid() 
     818   { 
     819     int size = this->enabledFields.size(); 
     820     std::vector<int> domainNvertices; 
     821     std::vector<StdString> domainNames; 
     822 
     823     for (int i = 0; i < size; ++i) 
     824     { 
     825       std::vector<CDomain*> domain = this->enabledFields[i]->getRelGrid()->getDomains(); 
     826       if (domain.size() != 1) 
     827       { 
     828         ERROR("void CFile::sortEnabledFieldsForUgrid()", 
     829               "A domain, and only one, should be defined for grid "<< this->enabledFields[i]->getRelGrid()->getId() << "."); 
     830       } 
     831       StdString domainName = domain[0]->getDomainOutputName(); 
     832       int nvertex; 
     833       if (domain[0]->nvertex.isEmpty()) 
     834       { 
     835         ERROR("void CFile::sortEnabledFieldsForUgrid()", 
     836               "Attributes nvertex must be defined for domain "<< domain[0]->getDomainOutputName() << "."); 
     837       } 
     838       else 
     839         nvertex = domain[0]->nvertex; 
     840 
     841       for (int j = 0; j < i; ++j) 
     842       { 
     843         if (domainName == domainNames[j] && nvertex > domainNvertices[j]) 
     844         { 
     845           CField* tmpSwap = this->enabledFields[j]; 
     846           this->enabledFields[j] = this->enabledFields[i]; 
     847           this->enabledFields[i] = tmpSwap; 
     848           domainNames.push_back(domainNames[j]); 
     849           domainNames[j] = domainName; 
     850           domainNvertices.push_back(domainNvertices[j]); 
     851           domainNvertices[j] = nvertex; 
     852         } 
     853         else 
     854         { 
     855           domainNames.push_back(domainName); 
     856           domainNvertices.push_back(nvertex); 
     857         } 
     858       } 
     859       if (i==0) 
     860       { 
     861         domainNames.push_back(domainName); 
     862         domainNvertices.push_back(nvertex); 
     863       } 
     864     } 
     865   } 
     866 
    811867   void CFile::sendGridOfEnabledFields() 
    812868   {  
Note: See TracChangeset for help on using the changeset viewer.