Changeset 687


Ignore:
Timestamp:
09/15/15 17:30:55 (9 years ago)
Author:
mhnguyen
Message:

Implementing auto-generate rectilinear domain

+) Add a new special transformation to generate (complete) rectilinear domain

Test
+) On Curie
+) test_new_feature passed

Location:
XIOS/trunk
Files:
8 added
22 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/Version2/iodef.xml

    r664 r687  
    2828     </file> 
    2929     <file id="output_Axis_transformed" name="output_Axis_transformed" type="one_file"> 
    30         <field field_ref="field_Axis_transformed" /> 
     30<!--        <field field_ref="field_Axis_transformed" />--> 
    3131     </file> 
    3232     <file id="output_Axis_transformed_interpolated" name="output_Axis_transformed_interpolated"> 
     
    3434     </file> 
    3535     <file id="output_Domain_transformed_interpolated" name="output_Domain_transformed_interpolated"> 
    36 <!--        <field field_ref="field_Domain_transformed_Interpolated" />--> 
     36        <field field_ref="field_Domain_transformed_Interpolated" /> 
    3737     </file> 
    3838     <file id="output_Scalar" name="output_Scalar" type="one_file"> 
     
    7070<!--       <zoom_domain zoom_ibegin="0" zoom_ni="2" zoom_jbegin="0" zoom_nj="2"/>--> 
    7171     </domain> 
    72      <domain id="domain_A_transformed" domain_ref="domain_A"> 
    73        <interpolate_from_file_domain file="" /> 
     72     <domain id="domain_A_transformed" domain_src="domain_A"> 
     73<!--       <interpolate_from_file_domain file="" />--> 
     74       <generate_rectilinear_domain /> 
    7475     </domain> 
    7576   </domain_definition> 
  • XIOS/trunk/src/config/domain_attribute.conf

    r666 r687  
    5656DECLARE_ENUM3(type,rectilinear,curvilinear,unstructured) 
    5757DECLARE_ATTRIBUTE(StdString, domain_ref) 
    58  
     58DECLARE_ATTRIBUTE(StdString, domain_src) 
  • XIOS/trunk/src/config/node_type.conf

    r657 r687  
    5151#endif //__XIOS_CInterpolateFromFileDomain__ 
    5252 
     53#ifdef __XIOS_CGenerateRectilinearDomain__ 
     54   DECLARE_NODE(GenerateRectilinearDomain, generate_rectilinear_domain) 
     55#endif //__XIOS_CGenerateRectilinearDomain__ 
     56 
     57 
    5358#ifdef __XIOS_CContext__ 
    5459   DECLARE_NODE_PAR(Context, context) 
  • XIOS/trunk/src/group_factory_decl.cpp

    r657 r687  
    3030  macro(CZoomDomainGroup) 
    3131  macro(CInterpolateFromFileDomainGroup) 
     32  macro(CGenerateRectilinearDomainGroup) 
    3233} 
  • XIOS/trunk/src/group_template_decl.cpp

    r657 r687  
    1919  macro(ZoomDomain) 
    2020  macro(InterpolateFromFileDomain) 
     21  macro(GenerateRectilinearDomain) 
    2122 
    2223} 
  • XIOS/trunk/src/node/domain.cpp

    r679 r687  
    2020#include "zoom_domain.hpp" 
    2121#include "interpolate_from_file_domain.hpp" 
     22#include "generate_rectilinear_domain.hpp" 
    2223 
    2324#include <algorithm> 
     
    3435      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    3536      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
     37      , srcObject_(0) 
    3638   { /* Ne rien faire de plus */ } 
    3739 
     
    4345      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    4446      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
     47      , srcObject_(0) 
    4548   { /* Ne rien faire de plus */ } 
    4649 
     
    158161 
    159162   //---------------------------------------------------------------- 
     163 
     164   /*! 
     165     Redistribute RECTILINEAR domain with a number of local domains. 
     166   All attributes ni,nj,ibegin,jbegin (if defined) will be rewritten 
     167   The optional attributes lonvalue, latvalue will be added. Because this function only serves (for now) 
     168   for interpolation from unstructured domain to rectilinear one, range of latvalue is 0-360 and lonvalue is -90 - +90 
     169    \param [in] nbLocalDomain number of local domain on the domain destination 
     170   */ 
     171   void CDomain::redistribute(int nbLocalDomain) 
     172   { 
     173     if (type_attr::rectilinear == type) 
     174     { 
     175        CContext* context = CContext::getCurrent(); 
     176        CContextClient* client = context->client; 
     177        int rankClient = client->clientRank; 
     178        int rankOnDomain = rankClient%nbLocalDomain; 
     179 
     180        if (ni_glo.isEmpty() || ni_glo <= 0 ) 
     181        { 
     182           ERROR("CDomain::redistribute(int nbLocalDomain)", 
     183              << "[ Id = " << this->getId() << " ] " 
     184              << "The global domain is badly defined," 
     185              << " check the \'ni_glo\'  value !") 
     186        } 
     187 
     188        if (nj_glo.isEmpty() || nj_glo <= 0 ) 
     189        { 
     190           ERROR("CDomain::redistribute(int nbLocalDomain)", 
     191              << "[ Id = " << this->getId() << " ] " 
     192              << "The global domain is badly defined," 
     193              << " check the \'nj_glo\'  value !") 
     194        } 
     195 
     196        int globalDomainSize = ni_glo * nj_glo; 
     197        if (globalDomainSize <= nbLocalDomain) 
     198        { 
     199          for (int idx = 0; idx < nbLocalDomain; ++idx) 
     200          { 
     201            if (rankOnDomain < globalDomainSize) 
     202            { 
     203              int iIdx = rankOnDomain % ni_glo; 
     204              int jIdx = rankOnDomain / ni_glo; 
     205              ibegin.setValue(iIdx); jbegin.setValue(jIdx); 
     206              ni.setValue(1); nj.setValue(1); 
     207            } 
     208            else 
     209            { 
     210              ibegin.setValue(0); jbegin.setValue(0); 
     211              ni.setValue(0); nj.setValue(0); 
     212            } 
     213          } 
     214        } 
     215        else 
     216        { 
     217          // Compute (approximately) number of segment on x and y axis 
     218          float yOverXRatio = (nj_glo.getValue())/(ni_glo.getValue()); 
     219          int nbProcOnX, nbProcOnY, range; 
     220          nbProcOnX = std::ceil(std::sqrt(nbLocalDomain/yOverXRatio)); 
     221          nbProcOnY = std::ceil(((float)nbLocalDomain)/nbProcOnX); 
     222 
     223          // Simple distribution: Sweep from top to bottom, left to right 
     224          // Calculate local begin on x 
     225          std::vector<int> ibeginVec(nbProcOnX,0), jbeginVec(nbProcOnY,0); 
     226          std::vector<int> niVec(nbProcOnX), njVec(nbProcOnY); 
     227          for (int i = 1; i < nbProcOnX; ++i) 
     228          { 
     229            range = ni_glo / nbProcOnX; 
     230            if (i < (ni_glo%nbProcOnX)) ++range; 
     231            niVec[i-1] = range; 
     232            ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; 
     233          } 
     234          niVec[nbProcOnX-1] = ni_glo - ibeginVec[nbProcOnX-1]; 
     235 
     236          // Calculate local begin on y 
     237          for (int j = 1; j < nbProcOnY; ++j) 
     238          { 
     239            range = nj_glo / nbProcOnY; 
     240            if (j < (nj_glo%nbProcOnY)) ++range; 
     241            njVec[j-1] = range; 
     242            jbeginVec[j] = jbeginVec[j-1] + njVec[j-1]; 
     243          } 
     244          njVec[nbProcOnY-1] = nj_glo - jbeginVec[nbProcOnY-1]; 
     245 
     246          // Now assign value to ni, ibegin, nj, jbegin 
     247          int iIdx = rankOnDomain % nbProcOnX; 
     248          int jIdx = rankOnDomain / nbProcOnX; 
     249 
     250          if (rankOnDomain != (nbLocalDomain-1)) 
     251          { 
     252            ibegin.setValue(ibeginVec[iIdx]); 
     253            jbegin.setValue(jbeginVec[jIdx]); 
     254            nj.setValue(njVec[jIdx]); 
     255            ni.setValue(niVec[iIdx]); 
     256          } 
     257          else // just merge all the remaining rectangle into the last one 
     258          { 
     259            ibegin.setValue(ibeginVec[iIdx]); 
     260            jbegin.setValue(jbeginVec[jIdx]); 
     261            nj.setValue(njVec[jIdx]); 
     262            ni.setValue(ni_glo - ibeginVec[iIdx]); 
     263          } 
     264        } 
     265 
     266        // Now fill other attributes 
     267        fillInRectilinearLonLat(); 
     268     } 
     269   } 
     270 
     271   /*! 
     272     Fill in the values for lonvalue_1d and latvalue_1d of rectilinear domain 
     273     Range of longitude value from 0 - 360 
     274     Range of latitude value from -90 - +90 
     275   */ 
     276   void CDomain::fillInRectilinearLonLat() 
     277   { 
     278     if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); 
     279     if (!latvalue_2d.isEmpty()) latvalue_1d.free(); 
     280     lonvalue_1d.resize(ni); 
     281     latvalue_1d.resize(nj); 
     282     double lonStep = double(360/ni_glo.getValue()); 
     283     double latStep = double(180/nj_glo.getValue()); 
     284 
     285     // Assign lon value 
     286     for (int i = 0; i < ni; ++i) 
     287     { 
     288       lonvalue_1d(i) = static_cast<double>(ibegin + i) * lonStep; 
     289     } 
     290 
     291     for (int j = 0; j < nj; ++j) 
     292     { 
     293       latvalue_1d(j) = static_cast<double>(jbegin + j) * latStep - 90; 
     294     } 
     295   } 
    160296 
    161297   void CDomain::checkDomain(void) 
     
    702838       if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 
    703839       { 
    704          if (lonvalue_1d.numElements() != i_index.numElements()) 
     840         if ((type_attr::rectilinear != type) && (lonvalue_1d.numElements() != i_index.numElements())) 
    705841           ERROR("CDomain::completeLonLatClient(void)", 
    706842                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     
    728864       if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) 
    729865       { 
    730          if (latvalue_1d.numElements() != i_index.numElements()) 
     866         if ((type_attr::rectilinear != type) && (latvalue_1d.numElements() != i_index.numElements())) 
    731867           ERROR("CDomain::completeLonLatClient(void)", 
    732868                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     
    15801716  } 
    15811717 
     1718  void CDomain::solveSrcInheritance() 
     1719  { 
     1720    if (!domain_src.isEmpty()) 
     1721    { 
     1722       if (!CDomain::has(this->domain_src.getValue()))                                   \ 
     1723          ERROR("CDomain::solveSrcInheritance()",                                \ 
     1724             << "[ src_name = " << this->domain_src.getValue() << "]"                 \ 
     1725             << " invalid domain name !"); 
     1726 
     1727       srcObject_ = CDomain::get(this->domain_src.getValue()); 
     1728    } 
     1729  } 
     1730 
     1731  CDomain* CDomain::getDomainSrc() 
     1732  { 
     1733    return srcObject_; 
     1734  } 
     1735 
    15821736  /*! 
    15831737    Parse children nodes of a domain in xml file. 
     
    15951749      StdString interpFromFileDomainDefRoot("interpolate_from_file_domain_definition"); 
    15961750      StdString interpFromFile("interpolate_from_file_domain"); 
     1751      StdString generateRectilinearDefRoot("generate_rectilinear_domain_definition"); 
     1752      StdString generateRectilinear("generate_rectilinear_domain"); 
    15971753      do 
    15981754      { 
     
    16081764          transformationMap_.push_back(std::make_pair(TRANS_INTERPOLATE_DOMAIN_FROM_FILE,tmp)); 
    16091765        } 
     1766        else if (node.getElementName() == generateRectilinear) 
     1767        { 
     1768          CGenerateRectilinearDomain* tmp = (CGenerateRectilinearDomainGroup::get(generateRectilinearDefRoot))->createChild(); 
     1769          tmp->parse(node); 
     1770          transformationMap_.push_back(std::make_pair(TRANS_GENERATE_RECTILINEAR_DOMAIN,tmp)); 
     1771        } 
    16101772      } while (node.goToNextElement()) ; 
    16111773      node.goToParentElement(); 
  • XIOS/trunk/src/node/domain.hpp

    r676 r687  
    7676         bool hasTransformation(); 
    7777         void solveInheritanceTransformation(); 
     78         void solveSrcInheritance(); 
     79         CDomain* getDomainSrc(); 
    7880         TransMapTypes getAllTransformations(); 
     81         void redistribute(int nbLocalDomain); 
    7982 
    8083      public: 
     
    164167         void setTransformations(const TransMapTypes&); 
    165168         void computeNGlobDomain(); 
     169         void fillInRectilinearLonLat(); 
    166170 
    167171         void sendIndex(); 
     
    187191         std::vector<int> nGlobDomain_; 
    188192         bool isUnstructed_; 
     193         CDomain* srcObject_; 
    189194 
    190195         DECLARE_REF_FUNC(Domain,domain) 
  • XIOS/trunk/src/node/field.cpp

    r676 r687  
    175175      client->sendEvent(event); 
    176176    } 
    177      
     177 
    178178    CTimer::get("XIOS Send Data").suspend(); 
    179179  } 
     
    498498        solveGridReference(); 
    499499     } 
     500     if (context->hasClient) 
     501     { 
     502       solveGenerateGrid(); 
     503     } 
     504 
    500505     solveGridDomainAxisRef(doSending2Sever); 
     506 
    501507     if (context->hasClient) 
    502508     { 
    503509       solveTransformedGrid(); 
    504510     } 
     511 
    505512     solveCheckMaskIndex(doSending2Sever); 
    506513   } 
     
    775782   } 
    776783 
     784   void CField::solveGenerateGrid() 
     785   { 
     786     if (!grid_ref.isEmpty() && hasDirectFieldReference() && !getDirectFieldReference()->grid_ref.isEmpty() 
     787         && grid_ref.getValue() != getDirectFieldReference()->grid_ref.getValue() && !grid->isTransformed()) 
     788       grid->completeGrid(getDirectFieldReference()->grid); 
     789   } 
     790 
    777791   ///------------------------------------------------------------------- 
    778792 
  • XIOS/trunk/src/node/field.hpp

    r676 r687  
    110110         void solveGridDomainAxisRef(bool checkAtt); 
    111111         void solveTransformedGrid(); 
     112         void solveGenerateGrid(); 
    112113 
    113114         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 
  • XIOS/trunk/src/node/grid.cpp

    r676 r687  
    1717#include "distribution_client.hpp" 
    1818#include "grid_transformation.hpp" 
     19#include "grid_generate.hpp" 
    1920 
    2021namespace xios { 
     
    11681169        pDom->solveRefInheritance(apply); 
    11691170        pDom->solveBaseReference(); 
     1171        pDom->solveSrcInheritance(); 
    11701172        pDom->solveInheritanceTransformation(); 
    11711173        if ((!pDom->domain_ref.isEmpty()) && (pDom->name.isEmpty())) 
     
    12031205  { 
    12041206    return transformations_; 
     1207  } 
     1208 
     1209  /*! 
     1210     Complete all the necessary (and lacking) attributes of a grid 
     1211     This function is similar to gridTransformation but works only (till now) on generate_rectilinear_domain transformation 
     1212  */ 
     1213  void CGrid::completeGrid(CGrid* transformGridSrc) 
     1214  { 
     1215    if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements()) 
     1216    { 
     1217      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)", 
     1218           << "Two grids have different dimension size" 
     1219           << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl 
     1220           << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements()); 
     1221    } 
     1222    else 
     1223    { 
     1224      int ssize = axis_domain_order.numElements(); 
     1225      for (int i = 0; i < ssize; ++i) 
     1226        if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i)) 
     1227          ERROR("CGrid::transformGrid(CGrid* transformGridSrc)", 
     1228                << "Grids " << this->getId() << " and " << transformGridSrc->getId() 
     1229                << " don't have elements in the same order"); 
     1230    } 
     1231 
     1232    CGridGenerate gridGenerate(this, transformGridSrc); 
     1233    gridGenerate.completeGrid(); 
    12051234  } 
    12061235 
  • XIOS/trunk/src/node/grid.hpp

    r680 r687  
    180180 
    181181         void transformGrid(CGrid* transformGridSrc); 
     182         void completeGrid(CGrid* transformGridSrc); 
     183         void doAutoDistribution(CGrid* transformGridSrc); 
    182184         bool isTransformed(); 
    183185         void setTransformed(); 
  • XIOS/trunk/src/node/node_enum.hpp

    r657 r687  
    2424         eInterpolateAxis, 
    2525         eZoomDomain, 
    26          eInterpolateFromFileDomain 
     26         eInterpolateFromFileDomain, 
     27         eGenerateRectilinearDomain 
    2728 
    2829      } ENodeType; 
  • XIOS/trunk/src/node/node_type.hpp

    r657 r687  
    1515#include "zoom_domain.hpp" 
    1616#include "interpolate_from_file_domain.hpp" 
     17#include "generate_rectilinear_domain.hpp" 
    1718 
    1819#endif // __XIOS_NODE_TYPE__ 
  • XIOS/trunk/src/node/transformation_enum.hpp

    r657 r687  
    1111        TRANS_INTERPOLATE_AXIS, 
    1212        TRANS_ZOOM_DOMAIN, 
    13         TRANS_INTERPOLATE_DOMAIN_FROM_FILE 
     13        TRANS_INTERPOLATE_DOMAIN_FROM_FILE, 
     14        TRANS_GENERATE_RECTILINEAR_DOMAIN 
    1415      } ETranformationType; 
    1516 
  • XIOS/trunk/src/object_factory_decl.cpp

    r657 r687  
    2929  macro(CZoomDomain) 
    3030  macro(CInterpolateFromFileDomain) 
     31  macro(CGenerateRectilinearDomain) 
    3132 
    3233  macro(CFieldGroup) 
     
    4243  macro(CZoomDomainGroup) 
    4344  macro(CInterpolateFromFileDomainGroup) 
     45  macro(CGenerateRectilinearDomainGroup) 
    4446} 
  • XIOS/trunk/src/object_template_decl.cpp

    r657 r687  
    1818  template class CObjectTemplate<CZoomDomain>; 
    1919  template class CObjectTemplate<CInterpolateFromFileDomain>; 
     20  template class CObjectTemplate<CGenerateRectilinearDomain>; 
    2021 
    2122  template class CObjectTemplate<CContextGroup>; 
     
    3132  template class CObjectTemplate<CZoomDomainGroup>; 
    3233  template class CObjectTemplate<CInterpolateFromFileDomainGroup>; 
     34  template class CObjectTemplate<CGenerateRectilinearDomainGroup>; 
    3335} 
  • XIOS/trunk/src/test/test_new_features.f90

    r666 r687  
    132132  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    133133  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
    134   CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat) 
     134  CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat, type='curvilinear') 
    135135 
    136136  CALL xios_set_domain_attr("domain_A_transformed", ni_glo=niDomGlo, nj_glo=njDomGlo, & 
    137                                                     ibegin=ibeginDomInterp, ni=niDomInterp, jbegin=jbeginDomInterp, nj=njDomInterp) 
    138   CALL xios_set_domain_attr("domain_A_transformed", lonvalue_2D=lontransformed, & 
    139                                                     latvalue_2D=lattransformed) 
     137                            type='rectilinear') 
     138!                                                    ibegin=ibeginDomInterp, ni=niDomInterp, jbegin=jbeginDomInterp, nj=njDomInterp) 
     139!  CALL xios_set_domain_attr("domain_A_transformed", lonvalue_2D=lontransformed, & 
     140!                                                    latvalue_2D=lattransformed) 
    140141 
    141142  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
     
    172173 
    173174  ni=0 ; lonvalue(:)=0 
    174   CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue_1D=lonvalue) 
     175!  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue_1D=lonvalue) 
    175176 
    176177!  print *,"ni",ni 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r671 r687  
    5858 
    5959  gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
    60   gridSourceDimensionSize_ = gridSource_->getGlobalDimension(); 
    61   gridDestinationDimensionSize_ = gridDestination_->getGlobalDimension(); 
    6260 
    6361  initializeMappingOfOriginalGridSource(); 
     
    7775 
    7876  CDistributionClient distribution(client->clientRank, originalGridSource_); 
    79   const std::vector<size_t>& globalIndexGridDestSendToServer = distribution.getGlobalDataIndexSendToServer(); 
    80  
    81   weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.size()); 
    82   globalIndexOfCurrentGridSource_  = globalIndexGridDestSendToServer; 
    83   globalIndexOfOriginalGridSource_ = globalIndexGridDestSendToServer; 
     77  const std::vector<size_t>& globalIndexGridSrcSendToServer = distribution.getGlobalDataIndexSendToServer(); 
     78 
     79  weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridSrcSendToServer.size()); 
     80  globalIndexOfCurrentGridSource_  = globalIndexGridSrcSendToServer; 
     81  globalIndexOfOriginalGridSource_ = globalIndexGridSrcSendToServer; 
    8482  weightOfGlobalIndexOfOriginalGridSource_ = 1.0; 
    8583} 
     
    346344                               ite = listAlgos_.end(), it; 
    347345  CGenericAlgorithmTransformation* algo = 0; 
    348  
     346  int nbAgloTransformation = 0; // Only count for executed transformation. Generate domain is a special one, not executed in the list 
    349347  for (it = itb; it != ite; ++it) 
    350348  { 
     
    358356    algo = algoTransformation_.back(); 
    359357 
    360     // Recalculate the distribution of grid destination 
    361     CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    362     const std::vector<size_t>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 
    363  
    364     // ComputeTransformation of global index of each element 
    365     std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); 
    366     std::vector<int> gridSrcDimensionSize = gridSource_->getGlobalDimension(); 
    367     int elementPosition = it->first; 
    368     algo->computeGlobalSourceIndex(elementPosition, 
    369                                    gridDestinationDimensionSize, 
    370                                    gridSrcDimensionSize, 
    371                                    globalIndexGridDestSendToServer, 
    372                                    globaIndexWeightFromDestToSource); 
    373  
    374     // Compute transformation of global indexes among grids 
    375     computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 
    376  
    377     // Now grid destination becomes grid source in a new transformation 
    378     setUpGrid(elementPositionInGrid, transType); 
    379   } 
    380  
    381   updateFinalGridDestination(); 
    382   computeFinalTransformationMapping(); 
     358    if (0 != algo) // Only registered transformation can be executed 
     359    { 
     360      // Recalculate the distribution of grid destination 
     361      CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
     362      const std::vector<size_t>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 
     363 
     364      // ComputeTransformation of global index of each element 
     365      std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); 
     366      std::vector<int> gridSrcDimensionSize = gridSource_->getGlobalDimension(); 
     367      int elementPosition = it->first; 
     368      algo->computeGlobalSourceIndex(elementPosition, 
     369                                     gridDestinationDimensionSize, 
     370                                     gridSrcDimensionSize, 
     371                                     globalIndexGridDestSendToServer, 
     372                                     globaIndexWeightFromDestToSource); 
     373 
     374      // Compute transformation of global indexes among grids 
     375      computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 
     376 
     377      // Now grid destination becomes grid source in a new transformation 
     378      setUpGrid(elementPositionInGrid, transType); 
     379      ++nbAgloTransformation; 
     380    } 
     381  } 
     382 
     383  if (0 != nbAgloTransformation) 
     384  { 
     385    updateFinalGridDestination(); 
     386    computeFinalTransformationMapping(); 
     387  } 
    383388} 
    384389 
  • XIOS/trunk/src/transformation/grid_transformation.hpp

    r668 r687  
    33   \author Ha NGUYEN 
    44   \since 14 May 2015 
    5    \date 18 June 2015 
     5   \date 26 Aug 2015 
    66 
    77   \brief Interface for all transformations. 
     
    3434{ 
    3535public: 
     36  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; 
     37 
     38public: 
    3639  /** Default constructor */ 
    3740  CGridTransformation(CGrid* destination, CGrid* source); 
     
    4447  CGrid* getGridSource() {return gridSource_; } 
    4548  CGrid* getGridDestination() { return gridDestination_; } 
     49  ListAlgoType getAlgoList() const {return listAlgos_; } 
    4650 
    47 private: 
     51protected: 
    4852  void computeTransformation(); 
    4953  void initializeAlgorithms(); 
     
    6064  void updateFinalGridDestination(); 
    6165 
    62 private: 
     66protected: 
    6367  //! Grid source on transformation 
    6468  CGrid* gridSource_; 
     
    7074  CGrid* originalGridSource_; 
    7175 
    72   //! Grid source dimension size 
    73   std::vector<int> gridSourceDimensionSize_; 
    74  
    75   //! Grid destination dimension size 
    76   std::vector<int> gridDestinationDimensionSize_; 
    77  
    78 private: 
    79   typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; 
     76protected: 
    8077  //! List of algorithm types and their order 
    8178  ListAlgoType listAlgos_; 
  • XIOS/trunk/src/type/type_util.hpp

    r658 r687  
    3030    class CInterpolateFromFileDomain; 
    3131    class CInterpolateFromFileDomainGroup; 
     32    class CGenerateRectilinearDomain; 
     33    class CGenerateRectilinearDomainGroup; 
    3234 
    3335  template <typename T> inline string getStrType(void); 
     
    7678  macro(CInterpolateFromFileDomain) 
    7779  macro(CInterpolateFromFileDomainGroup) 
     80  macro(CGenerateRectilinearDomain) 
     81  macro(CGenerateRectilinearDomainGroup) 
    7882#undef macro 
    7983} 
  • XIOS/trunk/src/utils.hpp

    r671 r687  
    171171      return hash; 
    172172    } 
     173 
     174    /*! 
     175      Adatped version of (stupid) boost hash (but working) 
     176    */ 
     177    static inline size_t boost_hash(const std::vector<T>& vec) 
     178    { 
     179      size_t hash = 0; 
     180      int sizeVec = vec.size(); 
     181      for(int i = 0; i < sizeVec; ++i) 
     182      { 
     183        hash ^= i + 0x9e3779b9 + (hash << 6) + (hash >> 2); 
     184      } 
     185      return hash; 
     186    } 
    173187  }; 
    174188 
     
    180194      Algo al; 
    181195      return hash_value(val, al); 
     196    } 
     197 
     198    std::size_t hashVec(const std::vector<T>& vec) 
     199    { 
     200      return HashAlgorithm<T>::boost_hash(vec); 
    182201    } 
    183202 
  • XIOS/trunk/src/xml_parser_decl.cpp

    r657 r687  
    2424    macro( ZoomDomain ) 
    2525    macro( InterpolateFromFileDomain ) 
     26    macro( GenerateRectilinearDomain ) 
    2627  } 
    2728} 
Note: See TracChangeset for help on using the changeset viewer.