Changeset 621 for XIOS/trunk/src/node


Ignore:
Timestamp:
06/22/15 13:36:21 (9 years ago)
Author:
mhnguyen
Message:

Implementing generic transformation algorithm (local commit)

+) Change a little bit to make sure everything work in order

Test
+) test_new_features passe with inverse

Location:
XIOS/trunk/src/node
Files:
4 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r620 r621  
    1818      , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 
    1919      , isDistributed_(false) 
    20    { /* Ne rien faire de plus */ } 
     20      , transformationMap_() 
     21   { 
     22   } 
    2123 
    2224   CAxis::CAxis(const StdString & id) 
     
    2426      , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 
    2527      , isDistributed_(false) 
    26    { /* Ne rien faire de plus */ } 
     28      , transformationMap_() 
     29   { 
     30   } 
    2731 
    2832   CAxis::~CAxis(void) 
     
    308312  bool CAxis::hasTransformation() 
    309313  { 
    310     return (!transformations_.empty()); 
    311   } 
    312  
    313   void CAxis::setTransformations(const std::vector<CTransformation*>& transformations) 
    314   { 
    315     transformations_ = transformations; 
    316   } 
    317  
    318   std::vector<CTransformation*> CAxis::getAllTransformations(void) 
    319   { 
    320     if (!hasTransformation()) 
    321       setTransformations(this->getVirtualTransformationGroup()->getAllChildren()); 
    322  
    323     return transformations_; 
     314    return (!transformationMap_.empty()); 
     315  } 
     316 
     317  void CAxis::setTransformations(const TransMapTypes& axisTrans) 
     318  { 
     319    transformationMap_ = axisTrans; 
     320  } 
     321 
     322  CAxis::TransMapTypes CAxis::getAllTransformations(void) 
     323  { 
     324    return transformationMap_; 
     325  } 
     326 
     327  /*! 
     328    Check the validity of all transformations applied on axis 
     329  This functions is called AFTER all inherited attributes are solved 
     330  */ 
     331  void CAxis::checkTransformations() 
     332  { 
     333    TransMapTypes::const_iterator itb = transformationMap_.begin(), it, 
     334                                  ite = transformationMap_.end(); 
     335    for (it = itb; it != ite; ++it) 
     336    { 
     337      (it->second)->checkValid(this); 
     338    } 
    324339  } 
    325340 
     
    350365    if (node.goToChildElement()) 
    351366    { 
    352       StdString tranformation("transformation"); 
     367      StdString inverseAxisDefRoot("inverse_axis_definition"); 
     368      StdString inverse("inverse_axis"); 
     369      StdString zoomAxisDefRoot("zoom_axis_definition"); 
     370      StdString zoom("zoom_axis"); 
    353371      do 
    354372      { 
    355         if (node.getElementName() == tranformation) { 
    356            this->getVirtualTransformationGroup()->parseChild(node); 
     373        if (node.getElementName() == inverse) { 
     374          CInverseAxis* tmp = (CInverseAxisGroup::get(inverseAxisDefRoot))->createChild(); 
     375          tmp->parse(node); 
     376          transformationMap_[TRANS_INVERSE_AXIS] = tmp; 
     377        } else if (node.getElementName() == zoom) { 
     378          CZoomAxis* tmp = (CZoomAxisGroup::get(zoomAxisDefRoot))->createChild(); 
     379          tmp->parse(node); 
     380          transformationMap_[TRANS_ZOOM_AXIS] = tmp; 
    357381        } 
    358382      } while (node.goToNextElement()) ; 
    359383      node.goToParentElement(); 
    360384    } 
    361     setTransformations(this->getVirtualTransformationGroup()->getAllChildren()); 
    362385  } 
    363386 
  • XIOS/trunk/src/node/axis.hpp

    r620 r621  
    1616#include "transformation.hpp" 
    1717#include "transformation_enum.hpp" 
     18#include "inverse_axis.hpp" 
     19#include "zoom_axis.hpp" 
    1820 
    1921namespace xios { 
     
    2325   class CAxisAttributes; 
    2426   class CAxis; 
    25    class CTransformationGroup; 
    26    class CVirtualTransformationGroup; 
    2727 
    28    DECLARE_VIRTUAL_NODE(TransformationGroup); 
    2928   ///-------------------------------------------------------------- 
    3029 
     
    3938      : public CObjectTemplate<CAxis> 
    4039      , public CAxisAttributes 
    41       , public CVirtualTransformationGroup 
    4240   { 
    4341         enum EEventId 
     
    5452         typedef CAxisAttributes RelAttributes; 
    5553         typedef CAxisGroup      RelGroup; 
     54         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; 
    5655 
     56      public: 
    5757         /// Constructeurs /// 
    5858         CAxis(void); 
     
    9696         bool hasTransformation(); 
    9797         void solveInheritanceTransformation(); 
    98          std::vector<CTransformation*> getAllTransformations(); 
     98         TransMapTypes getAllTransformations(); 
    9999 
    100100      public: 
     
    106106         void checkMask(); 
    107107         void checkZoom(); 
     108         void checkTransformations(); 
     109         void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 
     110                                 CServerDistributionDescription::ServerDistributionType disType); 
    108111 
    109112 
    110  
    111          void setTransformations(const std::vector<CTransformation*>&); 
     113         void setTransformations(const TransMapTypes&); 
    112114      private: 
    113115         bool isChecked; 
    114116         bool areClientAttributesChecked_; 
    115117         std::set<StdString> relFiles; 
    116          std::vector<CTransformation*> transformations_; 
     118         TransMapTypes transformationMap_; 
    117119         bool isDistributed_; 
    118120 
  • XIOS/trunk/src/node/field.cpp

    r620 r621  
    3131      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false), filter(0) 
    3232      , isReadDataRequestPending(false) 
     33      , filterSources_(), algorithms_() 
    3334      { setVirtualVariableGroup(); } 
    3435 
     
    4445      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false), filter(0) 
    4546      , isReadDataRequestPending(false) 
     47      , filterSources_(), algorithms_() 
    4648   { setVirtualVariableGroup(); } 
    4749 
     
    804806         gridRefOfFieldRef->transformGrid(relGridRef); 
    805807         filterSources_.push_back(fieldRef); 
    806 //         transformations_ = relGridRef->getTransformations(); 
    807 //         switch (gridRefOfFieldRef->getGridElementType()) { 
    808 //         case CGrid::GRID_ONLY_AXIS: 
    809 ////           filter = new CAxisFilter(gridRefOfFieldRef, relGridRef); 
    810 ////           break; 
    811 //         default: 
    812 //           filter = new CAxisFilter(gridRefOfFieldRef, relGridRef); 
    813 //           break; 
    814 //         } 
    815 //         setAlgorithms(); 
    816808       } 
    817809     } 
    818810   } 
    819  
    820  
    821 //  void CField::setAlgorithms() 
    822 //  { 
    823 //    std::vector<ETransformationType>::iterator itTrans  = transformations_.begin(), 
    824 //                                               iteTrans = transformations_.end(); 
    825 //    std::set<ETransformationType> tmp; 
    826 //    for (; itTrans != iteTrans; ++itTrans) 
    827 //    { 
    828 //      if (tmp.end() == tmp.find(*itTrans)) 
    829 //      { 
    830 //        switch (*itTrans) { 
    831 //        case eInverse: 
    832 //          algorithms_.push_back(new CInvertAlgorithm()); 
    833 //          break; 
    834 //        default: 
    835 //          break; 
    836 //        } 
    837 //      } 
    838 //      tmp.insert(*itTrans); 
    839 //    } 
    840 //  } 
    841811 
    842812   const std::vector<CField*>& CField::getFilterSources() 
     
    857827             const std::map<int, CArray<int,1>* >& localIndexToSend = (*itFilterSrc)->grid->getTransformations()->getLocalIndexToSendFromGridSource(); 
    858828             const std::map<int, std::vector<CArray<int,1>* > > localIndexToReceive = (*itFilterSrc)->grid->getTransformations()->getLocalIndexToReceiveOnGridDest(); 
     829 
    859830             sendAndReceiveTransformedData(localIndexToSend, dataToSend, 
    860831                                           localIndexToReceive, dataToReceive); 
     
    862833 
    863834        } 
    864  
    865 //        std::cout << "it data " << (*it)->data << std::endl; 
    866 //        std::cout << "it filtered data " << (*it)->filteredData << std::endl; 
    867835     } 
    868836   } 
  • XIOS/trunk/src/node/field.hpp

    r620 r621  
    232232         std::vector<CField*> filterSources_; 
    233233         std::vector<CGenericAlgorithm*> algorithms_; 
    234          std::vector<ETransformationType> transformations_; 
    235234         DECLARE_REF_FUNC(Field,field) 
    236235 
  • XIOS/trunk/src/node/field_impl.hpp

    r620 r621  
    3838          { 
    3939            (*itFilterSrc)->updateDataWithoutOperation(_data, (*itFilterSrc)->data); 
    40             (*it)->updateDataWithoutOperation(_data, (*it)->filteredData); 
     40            if ((*it)->filteredData.numElements() != (*it)->grid->storeIndex_client.numElements()) 
     41            { 
     42               (*it)->filteredData.resize((*it)->grid->storeIndex_client.numElements()); 
     43            } 
    4144            (*it)->applyFilter((*itFilterSrc)->data, (*it)->filteredData); 
    4245          } 
    4346          if ((*it)->hasOutputFile || (*it)->hasFieldOut) (*it)->updateFilteredData((*it)->filteredData); 
    44 //          itFilterSrc = fieldFilterSources.begin(); iteFilterSrc = fieldFilterSources.end(); 
    45 //          for (; itFilterSrc != iteFilterSrc; ++itFilterSrc) (*itFilterSrc)->updateDataWithoutOperation(_data); 
    46 //          (*it)->applyFilter(); 
    47 //          std::cout << "it data " << (*it)->data << std::endl; 
    48 //          std::cout << "it filtered data " << (*it)->filteredData << std::endl; 
    49 //          if ((*it)->hasOutputFile || (*it)->hasFieldOut) (*it)->updateFilteredData((*it)->filteredData); 
    5047        } 
    5148        else 
     
    5451          if (hasOutputFile || hasFieldOut) updateData(_data); 
    5552        } 
    56  
    5753      } 
    5854 
  • XIOS/trunk/src/node/grid.cpp

    r620 r621  
    11521152    transformations_ = new CGridTransformation(transformedGrid, this); 
    11531153    transformations_->computeTransformationMapping(); 
    1154     std::cout << "send index " << *(transformations_->getLocalIndexToSendFromGridSource()[0]) << std::endl; 
    1155     std::cout << "receive index " << *(transformations_->getLocalIndexToReceiveOnGridDest()[0][0]) << std::endl; 
    11561154  } 
    11571155 
  • XIOS/trunk/src/node/node_enum.hpp

    r619 r621  
    1919         eContext,gContext, 
    2020         eCalendarWrapper, 
    21          eTransformation 
    22  
     21         eTransformation, 
     22         eInverseAxis, 
     23         eZoomAxis 
    2324//#include "node_type.conf" 
    2425 
  • XIOS/trunk/src/node/node_type.hpp

    r619 r621  
    1010#include "context.hpp" 
    1111#include "transformation.hpp" 
     12#include "inverse_axis.hpp" 
     13#include "zoom_axis.hpp" 
    1214 
    1315#endif // __XIOS_NODE_TYPE__ 
  • XIOS/trunk/src/node/transformation.hpp

    r619 r621  
    22#define __XMLIO_CTransformation__ 
    33 
    4 /// xios headers /// 
    54#include "xmlioserver_spl.hpp" 
    6 #include "attribute_enum.hpp" 
    7 #include "attribute_enum_impl.hpp" 
    8 #include "attribute_array.hpp" 
    9 #include "declare_attribute.hpp" 
    10 #include "object_template.hpp" 
    11 #include "group_factory.hpp" 
    12 #include "declare_group.hpp" 
     5#include "transformation_enum.hpp" 
    136 
    147namespace xios { 
    15  
    16   /// ////////////////////// Déclarations ////////////////////// /// 
    17   class CTransformationGroup; 
    18   class CTransformationAttributes; 
    19   class CTransformation; 
    20   ///-------------------------------------------------------------- 
    21  
    22   // Declare/Define CFileAttribute 
    23   BEGIN_DECLARE_ATTRIBUTE_MAP(CTransformation) 
    24 #include "transformation_attribute.conf" 
    25   END_DECLARE_ATTRIBUTE_MAP(CTransformation) 
    268 
    279  ///-------------------------------------------------------------- 
    2810  /*! 
    2911    \class CTransformation 
    30     This class describes transformation in xml file. 
     12    This class describes inverse_axis in xml file. 
    3113  */ 
     14  template<typename T> 
    3215  class CTransformation 
    33     : public CObjectTemplate<CTransformation> 
    34     , public CTransformationAttributes 
    3516  { 
    36     public : 
    37       enum TransformationId 
    38       { 
    39         TRANS_ID_ZOOM, TRANS_ID_INVERSE 
    40       }; 
    41       typedef CObjectTemplate<CTransformation> SuperClass; 
    42       typedef CTransformationAttributes SuperClassAttribute; 
     17  public: 
     18    typedef typename boost::unordered_map<ETranformationType, CTransformation<T>*, boost::hash<int> > TransformationMapTypes; 
     19    typedef TransformationMapTypes TransMapTypes; 
    4320 
    4421    public : 
    4522      /// Constructeurs /// 
    46       CTransformation(void); 
    47       explicit CTransformation(const StdString& id); 
     23      CTransformation(void) {} 
     24      virtual void checkValid(T* dest) = 0; 
    4825 
    4926      /// Destructeur /// 
    50       virtual ~CTransformation(void); 
    51  
    52       /// Accesseurs statiques /// 
    53       static StdString GetName(void); 
    54       static StdString GetDefName(void); 
    55       static ENodeType GetType(void); 
    56     private: 
    57       static std::vector<StdString> TransformationTypes; 
    58       static std::vector<TransformationId> TransformationTypeIds; 
    59  
    60     public : 
    61       void checkAttributes(); 
    62  
    63     private: 
    64       void checkAttributesType(TransformationId& transType); 
    65       void checkAttributesZoomType(); 
    66       void checkAttributesInverseType(); 
    67  
    68     private: 
     27      virtual ~CTransformation(void) {} 
    6928  }; // class CTransformation 
    7029 
    71   DECLARE_GROUP(CTransformation); 
    7230} // namespace xios 
    7331 
  • XIOS/trunk/src/node/transformation_enum.hpp

    r619 r621  
    88{ 
    99      /// ////////////////////// Définitions ////////////////////// /// 
    10       typedef enum transformationType 
     10      typedef enum transformation_type 
    1111      { 
    12          UnknownTransformation = 0, 
    13          eInverse, 
    14          eZoom 
    15  
    16 //#include "node_type.conf" 
    17  
    18       } ETransformationType; 
     12        TRANS_ZOOM_AXIS, 
     13        TRANS_INVERSE_AXIS 
     14      } ETranformationType; 
    1915 
    2016} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.