Ignore:
Timestamp:
02/11/15 16:23:02 (9 years ago)
Author:
mhnguyen
Message:

Redesigning grid structure

+) Add an intermediate class to calculate distribution on client and servers
+) Change all index of attributes to zero (0), instead of one(1)

Test
+) On Curie
+) Test new features passes but some data are still shifted

File:
1 edited

Legend:

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

    r540 r551  
    5757      StdSize size = this->size.getValue(); 
    5858 
     59      if (!this->ibegin.isEmpty()) 
     60      { 
     61        StdSize ibegin = this->ibegin.getValue(); 
     62        if ((ibegin < 0) || (ibegin > size-1)) 
     63          ERROR("CAxis::checkAttributes(void)",<< "Attribut <ibegin> of the axis must be non-negative and smaller than size-1") ; 
     64      } 
     65      else this->ibegin.setValue(0); 
     66 
     67      if (!this->ni.isEmpty()) 
     68      { 
     69        StdSize ni = this->ni.getValue(); 
     70        if ((ni < 0) || (ni > size)) 
     71          ERROR("CAxis::checkAttributes(void)",<< "Attribut <ni> of the axis must be non-negative and smaller than size") ; 
     72      } 
     73      else this->ni.setValue(size); 
     74 
    5975      StdSize zoom_begin,zoom_end, zoom_size ; 
    6076 
    61       zoom_begin = (this->zoom_begin.isEmpty()) ?  1 : this->zoom_begin.getValue() ; 
    62       zoom_end = (this->zoom_end.isEmpty()) ?  size : this->zoom_end.getValue() ; 
     77//      zoom_begin = (this->zoom_begin.isEmpty()) ?  1 : this->zoom_begin.getValue() ; 
     78//      zoom_end = (this->zoom_end.isEmpty()) ?  size : this->zoom_end.getValue() ; 
     79//      zoom_size = (this->zoom_size.isEmpty()) ?  size : this->zoom_size.getValue() ; 
     80 
     81      // Maybe index begins at 0 (zero) 
     82      zoom_begin = (this->zoom_begin.isEmpty()) ?  0 : this->zoom_begin.getValue() ; 
     83      zoom_end = (this->zoom_end.isEmpty()) ?  size-1 : this->zoom_end.getValue() ; 
    6384      zoom_size = (this->zoom_size.isEmpty()) ?  size : this->zoom_size.getValue() ; 
    6485 
     
    6687      if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 
    6788      if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 
     89// 
     90//      if ( (zoom_begin < 1) || (zoom_begin > size) || (zoom_end<1) || (zoom_end>size) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
     91//        ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 
    6892 
    69       if ( (zoom_begin < 1) || (zoom_begin > size) || (zoom_end<1) || (zoom_end>size) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
     93      if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<1) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
    7094        ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 
     95 
    7196      this->zoom_begin.setValue(zoom_begin) ; 
    7297      this->zoom_end.setValue(zoom_end) ; 
     
    78103               << "The array \'value\' has a different size that the one defined by the \'size\' attribut") 
    79104 
     105      this->checkData(); 
     106      this->checkMask(); 
    80107      this->isChecked = true; 
     108   } 
     109 
     110   void CAxis::checkData() 
     111   { 
     112      if (data_begin.isEmpty()) data_begin.setValue(0); 
     113      if (!data_n.isEmpty() && data_n.getValue() <= 0) 
     114      { 
     115        ERROR("CAxis::checkData(void)", 
     116              << "Data dimension is negative (data_n).") ; 
     117      } 
     118      else if (data_n.isEmpty()) 
     119        data_n.setValue(zoom_size.getValue()); 
     120 
     121      if (data_index.isEmpty()) 
     122      { 
     123        int dn = data_n.getValue(); 
     124        data_index.resize(dn); 
     125        for (int i = 0; i < dn; ++i) data_index(i) = (i+1); 
     126      } 
     127   } 
     128 
     129   void CAxis::checkMask() 
     130   { 
     131      int begin_mask = 0, 
     132          end_mask = ni.getValue()-1; 
     133 
     134      if (!zoom_begin.isEmpty()) 
     135      { 
     136         int zoom_end = zoom_begin.getValue() + zoom_size.getValue() - 1; 
     137 
     138         begin_mask = std::max(ibegin.getValue(), zoom_begin.getValue()); 
     139         end_mask   = std::min(ibegin.getValue() + ni.getValue()-1, zoom_end); 
     140 
     141         begin_mask -= ibegin.getValue(); 
     142         end_mask   -= ibegin.getValue(); 
     143      } 
     144 
     145 
     146      if (!mask.isEmpty()) 
     147      { 
     148         if (mask.extent(0) != ni) 
     149            ERROR("CAxis::checkMask(void)", 
     150                  <<"the mask has not the same size than the local axis"<<endl 
     151                  <<"Local size is "<<ni<<"x"<<endl 
     152                  <<"Mask size is "<<mask.extent(0)<<"x"); 
     153         for (int i = 0; i < ni; ++i) 
     154         { 
     155           if (i < begin_mask && i > end_mask)  mask(i) = false; 
     156         } 
     157      } 
     158      else // (!mask.hasValue()) 
     159      { // Si aucun masque n'est défini, 
     160        // on en crée un nouveau qui valide l'intégralité du domaine. 
     161         mask.resize(ni) ; 
     162         for (int i = 0; i < ni.getValue(); ++i) 
     163         { 
     164               if (i >= begin_mask && i <= end_mask) 
     165                 mask(i) = true; 
     166               else  mask(i) = false; 
     167         } 
     168      } 
    81169   } 
    82170 
Note: See TracChangeset for help on using the changeset viewer.