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

Implementing the first prototype of filter

+) Create new class filter
+) Implement class for specific algorithm
+) Implement inversing algorithm

Test
+) On Curie
+) Grid with one axis: passed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field_impl.hpp

    r599 r619  
    2525    { 
    2626      const std::vector<CField*>& refField=getAllReference(); 
    27       std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(); 
    28  
    29       for (; it != end; it++) (*it)->setData(_data); 
    30       if (hasOutputFile || hasFieldOut) updateData(_data); 
     27      std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(), 
     28                                            itFilterSrc, iteFilterSrc; 
     29 
     30      for (; it != end; it++) 
     31      { 
     32        const std::vector<CField*>& fieldFilterSources = (*it)->getFilterSources(); 
     33        if (!fieldFilterSources.empty()) 
     34        { 
     35          itFilterSrc = fieldFilterSources.begin(); iteFilterSrc = fieldFilterSources.end(); 
     36          for (; itFilterSrc != iteFilterSrc; ++itFilterSrc) (*itFilterSrc)->updateDataWithoutOperation(_data); 
     37          (*it)->applyFilter(); 
     38          std::cout << "it data " << (*it)->data << std::endl; 
     39          std::cout << "it filtered data " << (*it)->filteredData << std::endl; 
     40          if ((*it)->hasOutputFile || (*it)->hasFieldOut) (*it)->updateFilteredData((*it)->filteredData); 
     41        } 
     42        else 
     43        { 
     44          (*it)->setData(_data); 
     45          if (hasOutputFile || hasFieldOut) updateData(_data); 
     46        } 
     47 
     48      } 
     49 
    3150    } 
    3251  } 
     
    5069  } 
    5170 
    52    template <int N> 
    53    bool CField::updateData(const CArray<double, N>& _data) 
     71   template<int N> 
     72   void CField::updateDataWithoutOperation(const CArray<double, N>& _data) 
     73   { 
     74     if (this->data.numElements() != this->grid->storeIndex_client.numElements()) 
     75     { 
     76        this->data.resize(this->grid->storeIndex_client.numElements()); 
     77        this->grid->inputField(_data, this->data); 
     78     } 
     79   } 
     80 
     81   template<int N> 
     82   bool CField::updateFilteredData(CArray<double, N>& filteredData) 
    5483   { 
    5584      CContext* context=CContext::getCurrent(); 
     
    7099      if (doOperation) 
    71100      { 
    72          if (this->data.numElements() != this->grid->storeIndex_client.numElements()) 
    73          { 
    74             this->data.resize(this->grid->storeIndex_client.numElements()); 
    75          } 
    76  
    77          CArray<double,1> input(data.numElements()); 
    78          this->grid->inputField(_data, input); 
    79          (*this->foperation)(input); 
     101         if (this->data.numElements() != filteredData.numElements()) 
     102         { 
     103            this->data.resize(filteredData.numElements()); 
     104         } 
     105 
     106         (*this->foperation)(filteredData); 
    80107 
    81108         *last_operation = currDate; 
     
    106133         } 
    107134 
    108          if (hasFieldOut) 
    109          { 
    110            fieldOut->setDataFromExpression(data); 
    111          } 
     135//         if (hasFieldOut) 
     136//         { 
     137//           fieldOut->setDataFromExpression(data); 
     138//         } 
    112139         return (true); 
    113140      } 
     
    116143   } 
    117144 
    118    bool CField::updateDataFromExpression(const CArray<double, 1>& _data) 
     145   template <int N> 
     146   bool CField::updateData(const CArray<double, N>& _data) 
    119147   { 
    120148      CContext* context=CContext::getCurrent(); 
     
    140168         } 
    141169 
    142         (*this->foperation)(_data); 
     170         CArray<double,1> input(data.numElements()); 
     171         this->grid->inputField(_data, input); 
     172         (*this->foperation)(input); 
    143173 
    144174         *last_operation = currDate; 
     
    179209   } 
    180210 
     211   bool CField::updateDataFromExpression(const CArray<double, 1>& _data) 
     212   { 
     213      CContext* context=CContext::getCurrent(); 
     214      const CDate & currDate = context->getCalendar()->getCurrentDate(); 
     215      const CDate opeDate      = *last_operation + freq_operation; 
     216      const CDate writeDate    = *last_Write     + freq_write; 
     217      bool doOperation, doWrite; 
     218 
     219 
     220      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
     221      info(50) << "Next operation "  << opeDate<<std::endl; 
     222 
     223      doOperation = (opeDate <= currDate); 
     224      if (isOnceOperation) 
     225        if (isFirstOperation) doOperation=true; 
     226        else doOperation=false; 
     227 
     228      if (doOperation) 
     229      { 
     230         if (this->data.numElements() != this->grid->storeIndex_client.numElements()) 
     231         { 
     232            this->data.resize(this->grid->storeIndex_client.numElements()); 
     233         } 
     234 
     235        (*this->foperation)(_data); 
     236 
     237         *last_operation = currDate; 
     238         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 
     239      } 
     240 
     241      doWrite = (writeDate < (currDate + freq_operation)); 
     242      if (isOnceOperation) 
     243      { 
     244        if(isFirstOperation) 
     245        { 
     246          doWrite=true; 
     247          isFirstOperation=false; 
     248        } 
     249        else doWrite=false; 
     250      } 
     251 
     252      if (doWrite) 
     253      { 
     254         this->foperation->final(); 
     255         *last_Write = writeDate; 
     256         if (hasOutputFile) 
     257         { 
     258           info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 
     259           CTimer::get("XIOS Send Data").resume(); 
     260           sendUpdateData(); 
     261           CTimer::get("XIOS Send Data").suspend(); 
     262         } 
     263 
     264         if (hasFieldOut) 
     265         { 
     266           fieldOut->setDataFromExpression(data); 
     267         } 
     268         return (true); 
     269      } 
     270 
     271      return (false); 
     272   } 
     273 
    181274  template <int N> 
    182275  void CField::getData(CArray<double, N>& _data) const 
Note: See TracChangeset for help on using the changeset viewer.