Ignore:
Timestamp:
01/05/21 10:12:00 (3 years ago)
Author:
ymipsl
Message:

Some cleaning of old transformation dead code

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1999 r2002  
    394394  //---------------------------------------------------------------- 
    395395 
    396   /*! 
    397     Build up graph of grids which plays role of destination and source in grid transformation 
    398     This function should be called before \func solveGridReference() 
    399   */ 
    400   void CField::buildGridTransformationGraph() 
    401   TRY 
    402   { 
    403     CContext* context = CContext::getCurrent(); 
    404     if (context->getServiceType()==CServicesManager::CLIENT) 
    405     { 
    406       if (grid_ && !grid_->isTransformed() && hasDirectFieldReference() && grid_ != getDirectFieldReference()->grid_) 
    407       { 
    408         grid_->addTransGridSource(getDirectFieldReference()->grid_); 
    409       } 
    410     } 
    411   } 
    412   CATCH_DUMP_ATTR 
    413  
    414   /*! 
    415     Generate a new grid destination if there are more than one grid source pointing to a same grid destination 
    416   */ 
    417   void CField::generateNewTransformationGridDest() 
    418   TRY 
    419   { 
    420     CContext* context = CContext::getCurrent(); 
    421     if (context->getServiceType()==CServicesManager::CLIENT) 
    422     { 
    423       std::map<CGrid*,std::pair<bool,StdString> >& gridSrcMap = grid_->getTransGridSource(); 
    424       if (1 < gridSrcMap.size()) 
    425       { 
    426         // Search for grid source 
    427         CGrid* gridSrc = grid_; 
    428         CField* currField = this; 
    429         std::vector<CField*> hieraField; 
    430         while (currField->hasDirectFieldReference() && (gridSrc == grid_)) 
    431         { 
    432           hieraField.push_back(currField); 
    433           CField* tmp = currField->getDirectFieldReference(); 
    434           currField = tmp; 
    435           gridSrc = currField->grid_; 
    436         } 
    437  
    438         if (gridSrcMap.end() != gridSrcMap.find(gridSrc)) 
    439         { 
    440           CGrid* gridTmp; 
    441           std::pair<bool,StdString> newGridDest = gridSrcMap[gridSrc]; 
    442           if (newGridDest.first) 
    443           { 
    444             StdString newIdGridDest = newGridDest.second; 
    445             if (!CGrid::has(newIdGridDest)) 
    446             { 
    447               ERROR("CGrid* CGrid::generateNewTransformationGridDest()", 
    448                 << " Something wrong happened! Grid whose id " << newIdGridDest 
    449                 << "should exist "); 
    450             } 
    451             gridTmp = CGrid::get(newIdGridDest); 
    452           } 
    453           else 
    454           { 
    455             StdString newIdGridDest = CGrid::generateId(gridSrc, grid_); 
    456             gridTmp = CGrid::cloneGrid(newIdGridDest, grid_); 
    457  
    458             (gridSrcMap[gridSrc]).first = true; 
    459             (gridSrcMap[gridSrc]).second = newIdGridDest; 
    460           } 
    461  
    462           // Update all descendants 
    463           for (std::vector<CField*>::iterator it = hieraField.begin(); it != hieraField.end(); ++it) 
    464           { 
    465             (*it)->grid_ = gridTmp; 
    466             (*it)->updateRef((*it)->grid_); 
    467           } 
    468         } 
    469       } 
    470     } 
    471   } 
    472   CATCH_DUMP_ATTR 
    473  
    474396  void CField::updateRef(CGrid* grid) 
    475397  TRY 
     
    497419  CATCH_DUMP_ATTR 
    498420    
    499   /*! 
    500     Solve reference of all enabled fields even the source fields . 
    501     In this step, we do transformations. 
    502   */ 
    503   void CField::solveAllEnabledFieldsAndTransform() 
    504   TRY 
    505   { 
    506     CContext* context = CContext::getCurrent(); 
    507  
    508     if (!isReferenceSolvedAndTransformed) 
    509     { 
    510       isReferenceSolvedAndTransformed = true; 
    511  
    512       if (context->getServiceType()==CServicesManager::CLIENT) 
    513       { 
    514         solveRefInheritance(true); 
    515         if (hasDirectFieldReference()) getDirectFieldReference()->solveAllEnabledFieldsAndTransform(); 
    516       } 
    517  
    518       if (context->getServiceType()==CServicesManager::GATHERER || context->getServiceType()==CServicesManager::OUT_SERVER) 
    519         solveServerOperation(); 
    520  
    521       solveGridReference(); 
    522  
    523       if (context->getServiceType()==CServicesManager::CLIENT) 
    524       { 
    525         solveGenerateGrid(); 
    526         buildGridTransformationGraph(); 
    527       } 
    528  
    529       solveGridDomainAxisRef(false); 
    530  
    531       if (context->getServiceType()==CServicesManager::CLIENT) 
    532       { 
    533         solveTransformedGrid(); 
    534       } 
    535  
    536       solveGridDomainAxisRef(false); 
    537     } 
    538   } 
    539   CATCH_DUMP_ATTR 
    540421 
    541422  void CField::checkGridOfEnabledFields() 
     
    564445    solveCheckMaskIndex(true); 
    565446  }    
    566   CATCH_DUMP_ATTR 
    567  
    568   void CField::solveOnlyReferenceEnabledField(void) 
    569   TRY 
    570   { 
    571     CContext* context = CContext::getCurrent(); 
    572     if (!isReferenceSolved) 
    573     { 
    574       isReferenceSolved = true; 
    575  
    576       if (context->getServiceType()==CServicesManager::CLIENT) 
    577       { 
    578         solveRefInheritance(true); 
    579         if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(); 
    580       } 
    581  
    582       if (context->getServiceType()==CServicesManager::GATHERER || context->getServiceType()==CServicesManager::OUT_SERVER) 
    583         solveServerOperation(); 
    584  
    585       solveGridReference(); 
    586       grid_->solveElementsRefInheritance(true); // make it again to solve grid reading from file 
    587  
    588       if (context->getServiceType()==CServicesManager::CLIENT) 
    589       { 
    590         solveGenerateGrid(); 
    591         buildGridTransformationGraph(); 
    592       } 
    593     } 
    594   } 
    595   CATCH_DUMP_ATTR 
    596  
    597   void CField::solveAllReferenceEnabledField(bool doSending2Server) 
    598   TRY 
    599   { 
    600     CContext* context = CContext::getCurrent(); 
    601     solveOnlyReferenceEnabledField(); 
    602  
    603     if (!areAllReferenceSolved) 
    604     { 
    605       areAllReferenceSolved = true; 
    606        
    607       if (context->getServiceType()==CServicesManager::CLIENT) 
    608       { 
    609         solveRefInheritance(true); 
    610         if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false); 
    611       } 
    612       else if (context->getServiceType()==CServicesManager::GATHERER || context->getServiceType()==CServicesManager::OUT_SERVER) 
    613         solveServerOperation(); 
    614  
    615       solveGridReference(); 
    616     } 
    617  
    618     solveGridDomainAxisRef(doSending2Server); 
    619  
    620     if (context->getServiceType()==CServicesManager::CLIENT) 
    621     { 
    622       solveTransformedGrid(); 
    623     } 
    624  
    625   } 
    626447  CATCH_DUMP_ATTR 
    627448 
     
    1013834  } 
    1014835 
    1015   /*! 
    1016    * Constructs the graph filter for the field, enabling or not the data output. 
    1017    * This method should not be called more than once with enableOutput equal to true. 
    1018    * 
    1019    * \param gc the garbage collector to use when building the filter graph 
    1020    * \param enableOutput must be true when the field data is to be 
    1021    *                     read by the client or/and written to a file 
    1022    */ 
    1023    // ym obselete : to be removed later.... 
    1024   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 
    1025   TRY 
    1026   {      
    1027    //  ==> before removing, solving dependency in spatial_transform_filter.cpp about auxilairy field 
    1028 /* 
    1029     if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform(); 
    1030     if (!isGridChecked) checkGridOfEnabledFields(); 
    1031  
    1032     const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    1033     const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 
    1034  
    1035     CContext* context = CContext::getCurrent(); 
    1036     bool hasWriterServer = context->getServiceType()==CServicesManager::OUT_SERVER ; 
    1037     bool hasIntermediateServer = context->getServiceType()==CServicesManager::GATHERER ; 
    1038  
    1039     if (hasWriterServer) 
    1040     { 
    1041       if (!instantDataFilter) 
    1042         instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, true, false)); 
    1043  
    1044  
    1045       // If the field data is to be read by the client or/and written to a file 
    1046       if (enableOutput && !clientToModelStoreFilter_ && !fileWriterFilter) 
    1047       { 
    1048         if (getRelFile() && (getRelFile()->mode.isEmpty() || getRelFile()->mode == CFile::mode_attr::write)) 
    1049         { 
    1050           fileServerWriterFilter = std::shared_ptr<CFileServerWriterFilter>(new CFileServerWriterFilter(gc, this)); 
    1051           instantDataFilter->connectOutput(fileServerWriterFilter, 0); 
    1052         } 
    1053       } 
    1054     } 
    1055     else if (hasIntermediateServer) 
    1056     { 
    1057       if (!instantDataFilter) 
    1058         instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, false, false)); 
    1059  
    1060       // If the field data is to be read by the client or/and written to a file 
    1061       if (enableOutput && !clientToModelStoreFilter_ && !fileWriterFilter) 
    1062       { 
    1063         if (getRelFile() && (getRelFile()->mode.isEmpty() || getRelFile()->mode == CFile::mode_attr::write)) 
    1064         { 
    1065           fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this, getRelFile()->getContextClient())); 
    1066           instantDataFilter->connectOutput(fileWriterFilter, 0); 
    1067         } 
    1068       } 
    1069     } 
    1070     else 
    1071     { 
    1072       // Start by building a filter which can provide the field's instant data 
    1073       if (!instantDataFilter) 
    1074       { 
    1075         // Check if we have an expression to parse 
    1076         if (hasExpression()) 
    1077         { 
    1078           boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 
    1079           std::shared_ptr<COutputPin> filter = expr->reduce(gc, *this); 
    1080  
    1081           // Check if a spatial transformation is needed 
    1082           if (!field_ref.isEmpty()) 
    1083           { 
    1084             CGrid* gridRef = CField::get(field_ref)->grid_; 
    1085             if (grid_ && grid_ != gridRef && grid_->hasTransform()) 
    1086             { 
    1087                 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid_, detectMissingValues, defaultValue);  
    1088  
    1089               filter->connectOutput(filters.first, 0); 
    1090               filter = filters.second; 
    1091             } 
    1092           } 
    1093  
    1094           instantDataFilter = filter; 
    1095         } 
    1096         // Check if we have a reference on another field 
    1097         else if (!field_ref.isEmpty()) instantDataFilter = getFieldReference(gc); 
    1098         // Check if the data is to be read from a file 
    1099         else if (getRelFile() && !getRelFile()->mode.isEmpty() && getRelFile()->mode == CFile::mode_attr::read) 
    1100         { 
    1101           checkTimeAttributes(); 
    1102           instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, true, false, freq_offset, true, 
    1103                                                                                                        detectMissingValues, defaultValue)); 
    1104         } 
    1105         else // The data might be passed from the model 
    1106         { 
    1107           if (check_if_active.isEmpty()) check_if_active = false;  
    1108           instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, false, true, NoneDu, false, 
    1109                                                                                                       detectMissingValues, defaultValue)); 
    1110         } 
    1111       } 
    1112  
    1113       // If the field data is to be read by the client or/and written to a file 
    1114       if (enableOutput && !clientToModelStoreFilter_ && !fileWriterFilter) 
    1115       { 
    1116         if (!read_access.isEmpty() && read_access) 
    1117         { 
    1118           clientToModelStoreFilter_ = std::shared_ptr<CClientToModelStoreFilter>(new CClientToModelStoreFilter(gc, this)); 
    1119           instantDataFilter->connectOutput(clientToModelStoreFilter_, 0); 
    1120         } 
    1121  
    1122         if (getRelFile() && (getRelFile()->mode.isEmpty() || getRelFile()->mode == CFile::mode_attr::write)) 
    1123         { 
    1124           fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this, getRelFile()->getContextClient())); 
    1125           getTemporalDataFilter(gc, getRelFile()->output_freq)->connectOutput(fileWriterFilter, 0); 
    1126         } 
    1127       } 
    1128     } 
    1129 */   
    1130   } 
    1131   CATCH_DUMP_ATTR 
    1132  
    1133   /*! 
    1134    * Returns the filter needed to handle the field reference. 
    1135    * This method should only be called when building the filter graph corresponding to the field. 
    1136    * 
    1137    * \param gc the garbage collector to use 
    1138    * \return the output pin corresponding to the field reference 
    1139    */ 
    1140   std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc) 
    1141   TRY 
    1142   { 
    1143     if (instantDataFilter || field_ref.isEmpty()) 
    1144       ERROR("COutputPin* CField::getFieldReference(CGarbageCollector& gc)", 
    1145             "Impossible to get the field reference for a field which has already been parsed or which does not have a field_ref."); 
    1146  
    1147     CField* fieldRef = CField::get(field_ref); 
    1148     fieldRef->buildFilterGraph(gc, false); 
    1149  
    1150     std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters; 
    1151     // Check if a spatial transformation is needed 
    1152     if (grid_ && grid_ != fieldRef->grid_ && grid_->hasTransform()) 
    1153     {        
    1154       bool hasMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
    1155       double defaultValue  = hasMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0);                                 
    1156       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid_, grid_, hasMissingValue, defaultValue); 
    1157     } 
    1158     else 
    1159       filters.first = filters.second = std::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 
    1160  
    1161     fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 
    1162  
    1163     return filters.second; 
    1164   } 
    1165   CATCH_DUMP_ATTR 
    1166  
     836   
     837   
    1167838  /*! 
    1168839   * Returns the filter needed to handle a self reference in the field's expression. 
     
    14631134  CATCH_DUMP_ATTR 
    14641135 
    1465   void CField::solveTransformedGrid() 
    1466   TRY 
    1467   { 
    1468     if (grid_ && !grid_->isTransformed() && hasDirectFieldReference() && grid_ != getDirectFieldReference()->grid_) 
    1469     { 
    1470       std::vector<CGrid*> grids; 
    1471       // Source grid 
    1472       grids.push_back(getDirectFieldReference()->grid_); 
    1473       auto gridPath = getGridPath() ; 
    1474       grids.insert(grids.begin(), gridPath.begin(), gridPath.end()); 
    1475  
    1476       for (size_t i = 0, count = grids.size() - 1; i < count; ++i) 
    1477       { 
    1478         CGrid *gridSrc  = grids[i]; 
    1479         CGrid *gridDest = grids[i + 1]; 
    1480         if (!gridDest->isTransformed()) gridDest->transformGrid(gridSrc); 
    1481       } 
    1482     } 
    1483     else if (grid_ && grid_->hasTransform() && !grid_->isTransformed()) 
    1484     { 
    1485       // Temporarily deactivate the self-transformation of grid 
    1486       // grid_->transformGrid(grid_); 
    1487     } 
    1488   } 
    1489   CATCH_DUMP_ATTR 
    1490  
    1491   void CField::solveGenerateGrid() 
    1492   TRY 
    1493   { 
    1494     if (grid_ && !grid_->isTransformed() && hasDirectFieldReference() && grid_ != getDirectFieldReference()->grid_) 
    1495       grid_->completeGrid(getDirectFieldReference()->grid_); 
    1496     else grid_->completeGrid(); 
    1497   } 
    1498   CATCH_DUMP_ATTR 
    1499  
     1136   
    15001137  void CField::solveGridDomainAxisBaseRef() 
    15011138  TRY 
Note: See TracChangeset for help on using the changeset viewer.