Ignore:
Timestamp:
06/22/15 13:36:12 (7 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.cpp

    r603 r619  
    1313#include "context_server.hpp" 
    1414#include <set> 
     15#include "axis_filter.hpp" 
     16#include "invert_algorithm.hpp" 
    1517 
    1618namespace xios{ 
     
    2729      , foperation(), hasInstantData(false), hasExpression(false) 
    2830      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    29       , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     31      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false), filter(0) 
    3032      , isReadDataRequestPending(false) 
    3133      { setVirtualVariableGroup(); } 
     
    4042      , foperation(), hasInstantData(false), hasExpression(false) 
    4143      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    42       , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     44      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false), filter(0) 
    4345      , isReadDataRequestPending(false) 
    4446   { setVirtualVariableGroup(); } 
     
    5153      if (hasExpression) delete expression; 
    5254      if (slotUpdateDate != NULL) delete slotUpdateDate; 
     55      if (0 != filter) delete filter; 
    5356 
    5457   } 
     
    172175            int rank=(*it).first ; 
    173176            CArray<int,1>& index = *(it->second) ; 
     177                       std::cout << "rank " << index << std::endl; 
     178                       std::cout << "data " << data << std::endl; 
    174179            CArray<double,1> data_tmp(index.numElements()) ; 
    175180            for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
     
    527532      return(this->last_operation); 
    528533   } 
    529  
    530    //---------------------------------------------------------------- 
    531  
    532 //   void CField::processEnabledField(void) 
    533 //   { 
    534 //      if (!processed) 
    535 //      { 
    536 //        processed = true; 
    537 //        solveRefInheritance(true); 
    538 //        solveBaseReference(); 
    539 //        solveOperation(); 
    540 //        solveGridReference(); 
    541 // 
    542 //        if (hasDirectFieldReference()) baseRefObject->processEnabledField(); 
    543 //        buildExpression(); 
    544 //        active = true; 
    545 //      } 
    546 //    } 
    547534 
    548535   void CField::solveAllReferenceEnabledField(bool doSending2Sever) 
     
    562549     } 
    563550     solveGridDomainAxisRef(doSending2Sever); 
     551     if (context->hasClient) 
     552     { 
     553       solveTransformedGrid(); 
     554     } 
    564555     solveCheckMaskIndex(doSending2Sever); 
    565556   } 
     
    576567     { 
    577568       areAllExpressionBuilt = true; 
    578 //       solveCheckMaskIndex(true); 
    579 //       solveCheckMaskIndex(); 
    580        if (hasDirectFieldReference()) baseRefObject->buildAllExpressionEnabledField(); 
     569       if (hasDirectFieldReference() && (grid_ref.isEmpty())) baseRefObject->buildAllExpressionEnabledField(); 
    581570       buildExpression(); 
    582571       active = true; 
     
    770759   } 
    771760 
     761   CGrid* CField::getGridRefOfBaseReference() 
     762   { 
     763     solveRefInheritance(true); 
     764     solveBaseReference(); 
     765     baseRefObject->solveGridReference(); 
     766 
     767     return baseRefObject->grid; 
     768   } 
     769 
     770   void CField::solveTransformedGrid() 
     771   { 
     772     if (!grid_ref.isEmpty() && (!field_ref.isEmpty())) 
     773     { 
     774       CField* fieldRef  = this; 
     775       CGrid* gridRefOfFieldRef = 0; 
     776       while (fieldRef->hasDirectFieldReference()) 
     777       { 
     778         if ((!(fieldRef->grid_ref.isEmpty())) && 
     779             (fieldRef->grid_ref.getValue() != grid_ref.getValue())) 
     780         { 
     781           gridRefOfFieldRef = fieldRef->getGridRefOfBaseReference(); 
     782           fieldRef->addReference(this); 
     783           fieldRef->solveGridDomainAxisRef(false); 
     784           fieldRef->solveCheckMaskIndex(false); 
     785           break; 
     786         } 
     787         CField* tmp = fieldRef->getDirectFieldReference(); 
     788         fieldRef = tmp; 
     789       } 
     790 
     791       if ((0 == gridRefOfFieldRef) && 
     792           (!(fieldRef->grid_ref.isEmpty())) && 
     793           (fieldRef->grid_ref.getValue() != grid_ref.getValue())) 
     794       { 
     795         gridRefOfFieldRef = fieldRef->getGridRefOfBaseReference(); 
     796         fieldRef->addReference(this); 
     797         fieldRef->solveGridDomainAxisRef(false); 
     798         fieldRef->solveCheckMaskIndex(false); 
     799       } 
     800 
     801       CGrid* relGridRef = CGrid::get(grid_ref.getValue()); 
     802       if ((0 != gridRefOfFieldRef) && (relGridRef != gridRefOfFieldRef) && (!(relGridRef->isTransformed()))) 
     803       { 
     804         gridRefOfFieldRef->transformGrid(relGridRef); 
     805         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           break; 
     813         } 
     814         setAlgorithms(); 
     815       } 
     816     } 
     817   } 
     818 
     819 
     820  void CField::setAlgorithms() 
     821  { 
     822    std::vector<ETransformationType>::iterator itTrans  = transformations_.begin(), 
     823                                               iteTrans = transformations_.end(); 
     824    std::set<ETransformationType> tmp; 
     825    for (; itTrans != iteTrans; ++itTrans) 
     826    { 
     827      if (tmp.end() == tmp.find(*itTrans)) 
     828      { 
     829        switch (*itTrans) { 
     830        case eInverse: 
     831          algorithms_.push_back(new CInvertAlgorithm()); 
     832          break; 
     833        default: 
     834          break; 
     835        } 
     836      } 
     837      tmp.insert(*itTrans); 
     838    } 
     839  } 
     840 
     841   const std::vector<CField*>& CField::getFilterSources() 
     842   { 
     843     return filterSources_; 
     844   } 
     845 
     846   void CField::applyFilter() 
     847   { 
     848     filter->setInputs(filterSources_); 
     849     filter->setOutput(this); 
     850     filter->apply(algorithms_); 
     851 
     852   } 
     853 
    772854   ///------------------------------------------------------------------- 
    773855 
Note: See TracChangeset for help on using the changeset viewer.