source: XIOS/dev/dev_olga/src/filter/spatial_transform_filter.hpp @ 1654

Last change on this file since 1654 was 1653, checked in by oabramkina, 5 years ago

Developments for visualization of XIOS workflow.

Branch is spawned from trunk r1649.

Boost library is used for producing Graphviz DOT files. Current results: a DOT file representing a static workflow. For a complete proof of concept, DOT files for each timestamp should be generated. The necessary information has been collected by XIOS, it only requires rearranging the information for graphing (changes in classes CWorkflowGraph and CGraphviz).

File size: 6.0 KB
Line 
1#ifndef __XIOS_CSpatialTransformFilter__
2#define __XIOS_CSpatialTransformFilter__
3
4#include "filter.hpp"
5
6namespace xios
7{
8  class CGrid;
9  class CGridTransformation;
10  class CSpatialTransformFilterEngine;
11
12  /*!
13   * A generic filter with multiple input slots wrapping any type of spatial transformations.
14   */
15  class CSpatialTransformFilter : public CFilter
16  {
17    public:
18      /*!
19       * Constructs a filter wrapping the specified spatial transformation.
20       *
21       * \param gc the associated garbage collector
22       * \param engine the engine defining the spatial transformation
23       * \param outputValue default value of output pin
24       * \param [in] inputSlotsCount number of input, by default there is only one for field src
25       * \param buildWorkflowGraph indicates whether data will be visualized
26       */
27      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine,
28                              double outputValue, size_t inputSlotsCount = 1, bool buildWorkflowGraph = false);
29
30      inline StdString GetName(void) {return StdString("Spatial transform filter");};
31
32      /*!
33       * Builds the filter graph needed to transform the specified source grid into the specified destination grid.
34       *
35       * \param gc the associated garbage collector
36       * \param srcGrid the source grid
37       * \param destGrid the destination grid
38       * \param hasMissingValue whether field source has missing value
39       * \param defaultValue default value
40       * \param buildWorkflowGraph indicates whether data will be visualized
41       * \return the first and the last filters of the filter graph
42       */
43      static std::pair<std::shared_ptr<CSpatialTransformFilter>, std::shared_ptr<CSpatialTransformFilter> >
44      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue, bool buildWorkflowGraph = false);
45
46    protected:
47      /*!
48        Overriding this function to process transformations with auxillary inputs
49      */
50      void virtual onInputReady(std::vector<CDataPacketPtr> data);
51
52    protected:
53      //! Default value of output pin
54      double outputDefaultValue;
55  }; // class CSpatialTransformFilter
56
57
58 /*!
59   * A specific spatial filter for the temporal_splitting transformation scalar -> axis. An incoming flux will be stored in an aditional dimension given by the destination axis.
60   * At each flux received, the storing index (record) is increased. When it reach the size of the axis (nrecords) a new flux is generated and the record is reset to 0
61   */
62
63 class CSpatialTemporalFilter : public CSpatialTransformFilter
64  {
65    public:
66      /*!
67       * Constructs a filter wrapping the specified spatial transformation.
68       *
69       * \param gc the associated garbage collector
70       * \param engine the engine defining the spatial transformation
71       * \param [in] gridTransformation the associated transformations
72       * \param outputValue default value of output pin
73       * \param [in] inputSlotsCount number of input, by default there is only one for field src
74       * \param buildWorkflowGraph indicates whether data will be visualized
75       *
76       */
77      CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation,
78                            double outputValue, size_t inputSlotsCount = 1, bool buildWorkflowGraph = false);
79
80
81    protected:
82      /*!
83        Overriding this function to process transformations with auxillary inputs
84      */
85      void virtual onInputReady(std::vector<CDataPacketPtr> data);
86      //! Current record in the filter
87      int record ;
88      //! Maximum number of records
89      int nrecords;
90      //! Temporary storage for output flux
91      CArray<double, 1> tmpData; 
92
93
94  }; // class CSpatialTemporalFilter
95
96
97  /*!
98   * A generic filter engine wrapping a grid transformation.
99   */
100  class CSpatialTransformFilterEngine : public IFilterEngine
101  {
102    public:
103      /*!
104       * Returns the engine wrapping the specified grid transformation.
105       * If the engine already exists it is reused, otherwise it is created.
106       *
107       * \param gridTransformation the grid transformation the engine will use
108       * \return the engine wrapping the specified grid transformation
109       */
110      static CSpatialTransformFilterEngine* get(CGridTransformation* gridTransformation);
111
112      /*!
113       * Applies the grid transformation to the input data and returns the result.
114       *
115       * \param data a vector of packets corresponding to each slot (one in this case)
116       * \param [in] defaultValue default value of output data
117       * \return the result of the grid transformation
118       */
119      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0);
120
121       /*!
122       * Applies the grid transformation to the input data and returns the result.
123       *
124       * \param data a vector of packets corresponding to each slot (one in this case)
125       * \return the result of the grid transformation
126       */
127      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
128
129
130
131    protected:
132      /*!
133       * Constructs a filter engine wrapping the specified grid transformation.
134       *
135       * \param gridTransformation the grid transformation the engine will use
136       */
137      CSpatialTransformFilterEngine(CGridTransformation* gridTransformation);
138
139      /*!
140       * Applies the grid transformation to the input data and returns the result.
141       * This helper function handles all the communications.
142       *
143       * \param dataSrc the source data
144       * \param dataDest the resulting transformed data
145       */
146      void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest);
147
148      CGridTransformation* gridTransformation; //!< The grid transformation used by the engine
149
150      //! The allocated engines
151      static std::map<CGridTransformation*, std::shared_ptr<CSpatialTransformFilterEngine> > engines;
152  }; // class CSpatialTransformFilterEngine
153} // namespace xios
154
155#endif //__XIOS_CSpatialTransformFilter__
Note: See TracBrowser for help on using the repository browser.