Ignore:
Timestamp:
09/11/19 10:22:09 (5 years ago)
Author:
yushan
Message:

Introducing the new graph functionality. Attribute build_workflow_graph=.TRUE. is used in the field definition section in the xml file to enable the workflow graph of the field and other fields referecing to it. A more detailed document will be available soon on the graph fuctionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r1645 r1704  
    44#include "context_client.hpp" 
    55#include "timer.hpp" 
     6#include "workflow_graph.hpp" 
     7#include "file.hpp" 
    68 
    79namespace xios 
     
    6466  { 
    6567    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
    66     CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     68    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue, this->tag, this->start_graph, this->end_graph, this->field); 
    6769    if (outputPacket) 
    6870      onOutputReady(outputPacket); 
     
    9698  { 
    9799    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
    98     CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     100    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue, this->tag, this->start_graph, this->end_graph, this->field); 
    99101 
    100102    if (outputPacket) 
     
    121123        packet->data.resize(tmpData.numElements()); 
    122124        packet->data = tmpData; 
     125        packet->field = this->field; 
    123126        onOutputReady(packet); 
    124127        tmpData.resize(0) ; 
     
    159162  } 
    160163 
    161   CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue) 
    162   { 
     164  bool CSpatialTransformFilterEngine::buildGraph(std::vector<CDataPacketPtr> data, int tag, Time start_graph, Time end_graph, CField *field) 
     165  { 
     166    bool building_graph = tag ? data[0]->timestamp >= start_graph && data[0]->timestamp <= end_graph : false; 
     167    if(building_graph) 
     168    { 
     169      this->filterID = InvalidableObject::filterIdGenerator++; 
     170      int edgeID = InvalidableObject::edgeIdGenerator++;     
     171 
     172      CWorkflowGraph::allocNodeEdge(); 
     173 
     174      CWorkflowGraph::addNode(this->filterID, "Spatial Transform Filter", 4, 1, 1, data[0]); 
     175      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; 
     176      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = field->record4graphXiosAttributes(); 
     177      if(field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +field->file->record4graphXiosAttributes(); 
     178 
     179 
     180      if(CWorkflowGraph::build_begin) 
     181      { 
     182        CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); 
     183 
     184        (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0; 
     185      } 
     186      else CWorkflowGraph::build_begin = true; 
     187    } 
     188 
     189    return building_graph; 
     190  } 
     191 
     192  CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue, int tag, Time start_graph, Time end_graph, CField *field) 
     193  { 
     194     
     195    bool BG = buildGraph(data, tag, start_graph, end_graph, field); 
     196 
    163197    CDataPacketPtr packet(new CDataPacket); 
    164198    packet->date = data[0]->date; 
     
    177211      if (0 != packet->data.numElements()) 
    178212        (packet->data)(0) = defaultValue; 
    179       apply(data[0]->data, packet->data); 
    180     } 
     213      if(BG) apply(data[0]->data, packet->data, this->filterID); 
     214      else apply(data[0]->data, packet->data); 
     215    } 
     216 
     217    if(BG) packet->src_filterID=this->filterID; 
     218    if(BG) packet->distance=data[0]->distance+1; 
     219    packet->field = field; 
    181220 
    182221    return packet; 
    183222  } 
    184223 
    185   void CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest) 
     224  void CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest, int filterID) 
    186225  { 
    187226    CTimer::get("CSpatialTransformFilterEngine::apply").resume();  
     
    296335        const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second; 
    297336        int srcRank = itRecv->first; 
     337 
     338        if(filterID >=0) // building_graph 
     339        { 
     340           (*CWorkflowGraph::mapFilters_ptr_with_info)[filterID].filter_name = (*itAlgo)->getName(); 
     341        }  
    298342        if (srcRank != rank) 
    299343        { 
Note: See TracChangeset for help on using the changeset viewer.