source: XIOS/dev/branch_openmp/src/filter/spatial_transform_filter.hpp @ 1331

Last change on this file since 1331 was 1331, checked in by yushan, 6 years ago

dev_omp

File size: 4.2 KB
Line 
1#ifndef __XIOS_CSpatialTransformFilter__
2#define __XIOS_CSpatialTransformFilter__
3
4#include "filter.hpp"
5namespace xios
6{
7  class CGrid;
8  class CGridTransformation;
9  class CSpatialTransformFilterEngine;
10
11  /*!
12   * A generic filter with multiple input slots wrapping any type of spatial transformations.
13   */
14  class CSpatialTransformFilter : public CFilter
15  {
16    public:
17      /*!
18       * Constructs a filter wrapping the specified spatial transformation.
19       *
20       * \param gc the associated garbage collector
21       * \param engine the engine defining the spatial transformation
22       * \param outputValue default value of output pin
23       * \param [in] inputSlotsCount number of input, by default there is only one for field src
24       */
25      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1);
26
27      /*!
28       * Builds the filter graph needed to transform the specified source grid into the specified destination grid.
29       *
30       * \param gc the associated garbage collector
31       * \param srcGrid the source grid
32       * \param destGrid the destination grid
33       * \param hasMissingValue whether field source has missing value
34       * \param defaultValue default value
35       * \return the first and the last filters of the filter graph
36       */
37      static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
38      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, bool hasMissingValue, double defaultValue);
39
40    protected:
41      /*!
42        Overriding this function to process transformations with auxillary inputs
43      */
44      void virtual onInputReady(std::vector<CDataPacketPtr> data);
45
46    protected:
47      //! Default value of output pin
48      double outputDefaultValue;
49  }; // class CSpatialTransformFilter
50
51  /*!
52   * A generic filter engine wrapping a grid transformation.
53   */
54  class CSpatialTransformFilterEngine : public IFilterEngine
55  {
56    public:
57      /*!
58       * Returns the engine wrapping the specified grid transformation.
59       * If the engine already exists it is reused, otherwise it is created.
60       *
61       * \param gridTransformation the grid transformation the engine will use
62       * \return the engine wrapping the specified grid transformation
63       */
64      static CSpatialTransformFilterEngine* get(CGridTransformation* gridTransformation);
65
66      /*!
67       * Applies the grid transformation to the input data and returns the result.
68       *
69       * \param data a vector of packets corresponding to each slot (one in this case)
70       * \param [in] defaultValue default value of output data
71       * \return the result of the grid transformation
72       */
73      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0);
74
75       /*!
76       * Applies the grid transformation to the input data and returns the result.
77       *
78       * \param data a vector of packets corresponding to each slot (one in this case)
79       * \return the result of the grid transformation
80       */
81      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
82
83
84
85    protected:
86      /*!
87       * Constructs a filter engine wrapping the specified grid transformation.
88       *
89       * \param gridTransformation the grid transformation the engine will use
90       */
91      CSpatialTransformFilterEngine(CGridTransformation* gridTransformation);
92
93      /*!
94       * Applies the grid transformation to the input data and returns the result.
95       * This helper function handles all the communications.
96       *
97       * \param dataSrc the source data
98       * \param dataDest the resulting transformed data
99       */
100      void apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest);
101
102      CGridTransformation* gridTransformation; //!< The grid transformation used by the engine
103
104      //! The allocated engines
105      //static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > engines;
106      static std::map<CGridTransformation*, boost::shared_ptr<CSpatialTransformFilterEngine> > *engines_ptr;
107      #pragma om threadprivate(engines_ptr)
108  }; // class CSpatialTransformFilterEngine
109} // namespace xios
110
111#endif //__XIOS_CSpatialTransformFilter__
Note: See TracBrowser for help on using the repository browser.