Changeset 2016 for XIOS


Ignore:
Timestamp:
01/17/21 22:43:51 (3 years ago)
Author:
ymipsl
Message:

Transformation : fix problem xhen chaining transformation that generate the element (for now only generate_rectilinear_domain)
YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r2011 r2016  
    17081708    if (CGrid::has(newId)) 
    17091709    { 
     1710      cout<<"Retrive existing grid : "<<newId<<endl ; 
    17101711      newGrid = CGrid::get(newId); 
    17111712      isNewGrid = false ; 
     
    17131714    else   
    17141715    { 
     1716      cout<<"Create new grid : "<<newId<<endl ; 
    17151717      newGrid = CGrid::create(newId) ; 
    17161718      isNewGrid = true ; 
     
    17671769        { 
    17681770          CDomain* dstDomain ; 
    1769           if (CDomain::has(dstElementId)) dstDomain = CDomain::get(dstElementId) ; 
    1770           else 
     1771          CDomain* lastDstDomain ; 
     1772          bool isGenerate=false ; 
     1773    
     1774          do  
    17711775          { 
    1772             dstDomain = CDomain::create() ; 
    1773             dstDomain->createAlias(dstElementId) ; 
    1774             if (srcElementId=="" && srcElement.type==TYPE_DOMAIN)  dstDomain->duplicateAttributes(srcElement.domain) ; // make a copy 
    1775             else dstDomain->duplicateAttributes(dstElement.domain) ; // make a copy 
    1776             CTransformation<CDomain>* transformation = CTransformation<CDomain>::createTransformation(transType,"") ; 
    1777             auto srcTransform = CTransformation<CDomain>::getTransformation(transType, transId) ; 
    1778             transformation->inheritFrom(srcTransform) ; 
    1779             tmpGridDst->addDomain(dstDomain->getId()) ; 
    1780  
    1781             algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
    1782                                                      posInGrid,posInGrid,posInGrid, 
    1783                                                      posInGrid,posInGrid,posInGrid ); 
    1784             //reuse existing algorithm interface for, now 
    1785          /*   algo = CGridTransformationFactory<CDomain>::createTransformation(transType, false, tmpGridDst, tmpGridSrc, 
    1786                                                                              transformation, 0,  
    1787                                                                              posInGrid,posInGrid,posInGrid, 
    1788                                                                              posInGrid,posInGrid,posInGrid ); 
    1789            */ 
    1790             dstDomain->setTransformationAlgorithm(algo) ; 
     1776 
     1777            if (CDomain::has(dstElementId))  
     1778            { 
     1779              dstDomain = CDomain::get(dstElementId) ; 
     1780              cout<<"Retrive existing domain : "<<dstElementId<<endl ; 
     1781            } 
     1782            else 
     1783            { 
     1784              dstDomain = CDomain::create() ; 
     1785              dstDomain->createAlias(dstElementId) ; 
     1786              cout<<"Create new domain : "<<dstDomain->getId()<<" with alias : "<<dstElementId<<endl ; 
     1787 
     1788              if (isGenerate) dstDomain->duplicateAttributes(lastDstDomain) ; 
     1789              else if (srcElementId=="" && srcElement.type==TYPE_DOMAIN)  dstDomain->duplicateAttributes(srcElement.domain) ; // make a copy 
     1790              else dstDomain->duplicateAttributes(dstElement.domain) ; // make a copy 
     1791              CTransformation<CDomain>* transformation = CTransformation<CDomain>::createTransformation(transType,"") ; 
     1792              auto srcTransform = CTransformation<CDomain>::getTransformation(transType, transId) ; 
     1793              transformation->inheritFrom(srcTransform) ; 
     1794              CGrid* tmpGridDst=CGrid::create(); // destination Grid 
     1795              tmpGridDst->addDomain(dstDomain->getId()) ; 
     1796 
     1797              algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
     1798                                                       posInGrid,posInGrid,posInGrid, 
     1799                                                       posInGrid,posInGrid,posInGrid ); 
     1800 
     1801 
     1802              dstDomain->setTransformationAlgorithm(algo) ; 
     1803              dstDomain->setTransformationPaths(transformationPath) ; 
     1804            } 
     1805            algo=dstDomain->getTransformationAlgorithm() ; 
     1806            isGenerate = algo->isGenerateTransformation() ; 
    17911807            transformationPath.removeNextTransform() ; 
     1808            dstElementId=transformationPath.getNextElementId() ; 
     1809            srcElementId=transformationPath.getNextElementSrcId() ; 
     1810            transType = transformationPath.getNextTransformationType() ; 
     1811            transId = transformationPath.getNextTransformationId() ; 
     1812            lastDstDomain=dstDomain ; 
    17921813            dstDomain->setTransformationPaths(transformationPath) ; 
    1793           } 
     1814          } while(transformationPath.hasTransform() && isGenerate) ; 
     1815 
    17941816          if (isNewGrid) newGrid->addDomain(dstDomain->getId()) ; 
    17951817          algo = dstDomain->getTransformationAlgorithm() ; 
     
    17981820        { 
    17991821          CAxis* dstAxis ; 
    1800           if (CAxis::has(dstElementId)) dstAxis = CAxis::get(dstElementId) ; 
    1801           else 
     1822          CAxis* lastDstAxis ; 
     1823          bool isGenerate=false ; 
     1824 
     1825          do  
    18021826          { 
    1803             dstAxis = CAxis::create() ; 
    1804             dstAxis->createAlias(dstElementId) ; 
    1805             if (srcElementId=="" && srcElement.type==TYPE_AXIS)  dstAxis->duplicateAttributes(srcElement.axis) ; // make a copy 
    1806             else dstAxis->duplicateAttributes(dstElement.axis) ; // make a copy 
    1807             CTransformation<CAxis>* transformation = CTransformation<CAxis>::createTransformation(transType,"") ; 
    1808             auto srcTransform = CTransformation<CAxis>::getTransformation(transType, transId) ; 
    1809             transformation->inheritFrom(srcTransform) ; 
    1810             tmpGridDst->addAxis(dstAxis->getId()) ; 
    1811  
    1812              algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
    1813                                                      posInGrid,posInGrid,posInGrid, 
    1814                                                      posInGrid,posInGrid,posInGrid ); 
    1815  
    1816             //reuse existing algorithm interface for, now 
    1817            /* algo = CGridTransformationFactory<CAxis>::createTransformation(transType, false, tmpGridDst, tmpGridSrc, 
    1818                                                                            transformation, 0,  
    1819                                                                            posInGrid,posInGrid,posInGrid, 
    1820                                                                            posInGrid,posInGrid,posInGrid );*/ 
    1821             dstAxis->setTransformationAlgorithm(algo) ; 
     1827            if (CAxis::has(dstElementId))  
     1828            { 
     1829              dstAxis = CAxis::get(dstElementId) ; 
     1830              cout<<"Retrive existing axis : "<<dstElementId<<endl ; 
     1831            } 
     1832            else 
     1833            { 
     1834              dstAxis = CAxis::create() ; 
     1835              dstAxis->createAlias(dstElementId) ; 
     1836              cout<<"Create new axis : "<<dstAxis->getId()<<" with alias : "<<dstElementId<<endl ; 
     1837               
     1838              if (isGenerate) dstAxis->duplicateAttributes(lastDstAxis) ; 
     1839              else if (srcElementId=="" && srcElement.type==TYPE_AXIS)  dstAxis->duplicateAttributes(srcElement.axis) ; // make a copy 
     1840              else dstAxis->duplicateAttributes(dstElement.axis) ; // make a copy 
     1841              CTransformation<CAxis>* transformation = CTransformation<CAxis>::createTransformation(transType,"") ; 
     1842              auto srcTransform = CTransformation<CAxis>::getTransformation(transType, transId) ; 
     1843              transformation->inheritFrom(srcTransform) ; 
     1844              tmpGridDst->addAxis(dstAxis->getId()) ; 
     1845 
     1846              algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
     1847                                                      posInGrid,posInGrid,posInGrid, 
     1848                                                      posInGrid,posInGrid,posInGrid ); 
     1849 
     1850              dstAxis->setTransformationAlgorithm(algo) ; 
     1851              dstAxis->setTransformationPaths(transformationPath) ; 
     1852            } 
     1853            
     1854            algo=dstAxis->getTransformationAlgorithm() ; 
     1855            isGenerate = algo->isGenerateTransformation() ; 
    18221856            transformationPath.removeNextTransform() ; 
     1857            dstElementId=transformationPath.getNextElementId() ; 
     1858            srcElementId=transformationPath.getNextElementSrcId() ; 
     1859            transType = transformationPath.getNextTransformationType() ; 
     1860            transId = transformationPath.getNextTransformationId() ; 
     1861            lastDstAxis=dstAxis ; 
    18231862            dstAxis->setTransformationPaths(transformationPath) ; 
    1824           } 
    1825            if (isNewGrid) newGrid->addAxis(dstAxis->getId()) ; 
     1863          } while(transformationPath.hasTransform() && isGenerate) ; 
     1864            
     1865          if (isNewGrid) newGrid->addAxis(dstAxis->getId()) ; 
    18261866          algo = dstAxis->getTransformationAlgorithm() ; 
    18271867        } 
     
    18291869        { 
    18301870          CScalar* dstScalar ; 
    1831           if (CScalar::has(dstElementId)) dstScalar = CScalar::get(dstElementId) ; 
    1832           else 
     1871          CScalar* lastDstScalar ; 
     1872          bool isGenerate=false ; 
     1873 
     1874          do  
    18331875          { 
    1834             dstScalar = CScalar::create() ; 
    1835             dstScalar->createAlias(dstElementId) ; 
    1836             if (srcElementId=="" && srcElement.type==TYPE_SCALAR)  dstScalar->duplicateAttributes(srcElement.scalar) ; // make a copy 
    1837             else dstScalar->duplicateAttributes(dstElement.scalar) ; // make a copy 
    1838             CTransformation<CScalar>* transformation = CTransformation<CScalar>::createTransformation(transType,"") ; 
    1839             auto srcTransform = CTransformation<CScalar>::getTransformation(transType, transId) ; 
    1840             transformation->inheritFrom(srcTransform) ; 
    1841             tmpGridDst->addScalar(dstScalar->getId()) ; 
    1842  
    1843             algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
    1844                                                      posInGrid,posInGrid,posInGrid, 
    1845                                                      posInGrid,posInGrid,posInGrid ); 
    1846             //reuse existing algorithm interface for, now 
    1847            /* algo = CGridTransformationFactory<CScalar>::createTransformation(transType, false, tmpGridDst, tmpGridSrc, 
    1848                                                                              transformation, 0,  
    1849                                                                              posInGrid,posInGrid,posInGrid, 
    1850                                                                              posInGrid,posInGrid,posInGrid );*/ 
    1851             dstScalar->setTransformationAlgorithm(algo) ; 
     1876            if (CScalar::has(dstElementId))  
     1877            { 
     1878              dstScalar = CScalar::get(dstElementId) ; 
     1879              cout<<"Retrive existing scalar : "<<dstElementId<<endl ; 
     1880            } 
     1881            else 
     1882            { 
     1883              dstScalar = CScalar::create() ; 
     1884              dstScalar->createAlias(dstElementId) ; 
     1885              cout<<"Create new scalar : "<<dstScalar->getId()<<" with alias : "<<dstElementId<<endl ; 
     1886               
     1887              if (isGenerate) dstScalar->duplicateAttributes(lastDstScalar) ; 
     1888              else if (srcElementId=="" && srcElement.type==TYPE_SCALAR)  dstScalar->duplicateAttributes(srcElement.scalar) ; // make a copy 
     1889              else dstScalar->duplicateAttributes(dstElement.scalar) ; // make a copy 
     1890              CTransformation<CScalar>* transformation = CTransformation<CScalar>::createTransformation(transType,"") ; 
     1891              auto srcTransform = CTransformation<CScalar>::getTransformation(transType, transId) ; 
     1892              transformation->inheritFrom(srcTransform) ; 
     1893              tmpGridDst->addScalar(dstScalar->getId()) ; 
     1894 
     1895              algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0,  
     1896                                                       posInGrid,posInGrid,posInGrid, 
     1897                                                       posInGrid,posInGrid,posInGrid ); 
     1898               
     1899              dstScalar->setTransformationAlgorithm(algo) ; 
     1900              dstScalar->setTransformationPaths(transformationPath) ; 
     1901            } 
     1902            algo=dstScalar->getTransformationAlgorithm() ; 
     1903            isGenerate = algo->isGenerateTransformation() ; 
    18521904            transformationPath.removeNextTransform() ; 
     1905            dstElementId=transformationPath.getNextElementId() ; 
     1906            srcElementId=transformationPath.getNextElementSrcId() ; 
     1907            transType = transformationPath.getNextTransformationType() ; 
     1908            transId = transformationPath.getNextTransformationId() ; 
     1909            lastDstScalar=dstScalar ; 
    18531910            dstScalar->setTransformationPaths(transformationPath) ; 
    1854           } 
    1855            if (isNewGrid) newGrid->addScalar(dstScalar->getId()) ; 
     1911          } while(transformationPath.hasTransform() && isGenerate) ; 
     1912 
     1913          if (isNewGrid) newGrid->addScalar(dstScalar->getId()) ; 
    18561914          algo = dstScalar->getTransformationAlgorithm() ;           
    18571915        } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_generate_rectilinear.cpp

    r1998 r2016  
    6464  } 
    6565  fillInAttributesDomainDestination(); 
     66  domainDestination->checkAttributes() ; 
    6667} 
    6768CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_generate_rectilinear.hpp

    r2011 r2016  
    3434  virtual ~CDomainAlgorithmGenerateRectilinear() {} 
    3535  static bool registerTrans(); 
     36  virtual bool isGenerateTransformation(void) { return true ;} 
    3637 
    3738protected: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.hpp

    r2011 r2016  
    4040    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) { abort() ;} //=0 
    4141    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, const vector<CArray<double,1>>& auxData, CArray<double,1>& dataOut) { abort() ;} //=0 
    42      
     42    virtual bool isGenerateTransformation(void) { return false ;} 
     43 
    4344    virtual vector<string> getAuxFieldId(void) ; 
    4445  protected : 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/grid_algorithm.cpp

    r2007 r2016  
    1010  } 
    1111 
    12  
     12  bool CGridAlgorithm::isGenerateTranformation(void) 
     13  {  
     14    return algorithm_->isGenerateTransformation() ; 
     15  }   
    1316} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/grid_algorithm.hpp

    r2011 r2016  
    2727    virtual void apply(const CArray<double,1>& dataIn, const vector<CArray<double,1>>& auxData, CArray<double,1>& dataOut) { abort(); } //=0 
    2828    virtual CTransformFilter* createTransformFilter(CGarbageCollector& gc, bool detectMissingValues, double defaultValue) ; 
     29    virtual bool isGenerateTranformation(void) ; 
    2930    
    3031    protected: 
Note: See TracChangeset for help on using the changeset viewer.