Changeset 1460 for XIOS/dev/branch_openmp/src/filter
- Timestamp:
- 03/22/18 10:43:20 (6 years ago)
- Location:
- XIOS/dev/branch_openmp/src/filter
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/filter/file_writer_filter.cpp
r1328 r1460 37 37 } 38 38 39 bool CFileWriterFilter::mustAutoTrigger() const 40 { 41 return true; 42 } 43 39 44 bool CFileWriterFilter::isDataExpected(const CDate& date) const 40 45 { -
XIOS/dev/branch_openmp/src/filter/file_writer_filter.hpp
r1119 r1460 24 24 25 25 /*! 26 * Tests if the filter must auto-trigger. 27 * 28 * \return true if the filter must auto-trigger 29 */ 30 bool virtual mustAutoTrigger() const; 31 32 /*! 26 33 * Tests whether data is expected for the specified date. 27 34 * -
XIOS/dev/branch_openmp/src/filter/filter.cpp
r1119 r1460 41 41 } 42 42 43 bool CFilter::mustAutoTrigger() const 44 { 45 return COutputPin::mustAutoTrigger(); 46 } 47 43 48 bool CFilter::isDataExpected(const CDate& date) const 44 49 { -
XIOS/dev/branch_openmp/src/filter/filter.hpp
r1119 r1460 49 49 50 50 /*! 51 * Tests if the filter must auto-trigger. 52 * 53 * \return true if the filter must auto-trigger 54 */ 55 bool virtual mustAutoTrigger() const; 56 57 /*! 51 58 * Tests whether data is expected for the specified date. 52 59 * -
XIOS/dev/branch_openmp/src/filter/input_pin.hpp
r1119 r1460 60 60 61 61 /*! 62 * Tests if the pin must auto-trigger. 63 * 64 * \return true if the pin must auto-trigger 65 */ 66 bool virtual mustAutoTrigger() const = 0; 67 68 /*! 62 69 * Tests whether data is expected for the specified date. 63 70 * -
XIOS/dev/branch_openmp/src/filter/output_pin.cpp
r1119 r1460 66 66 } 67 67 68 bool COutputPin::mustAutoTrigger() const 69 { 70 std::vector<std::pair<boost::shared_ptr<CInputPin>, size_t> >::const_iterator it, itEnd; 71 for (it = outputs.begin(), itEnd = outputs.end(); it != itEnd; ++it) 72 { 73 if (it->first->mustAutoTrigger()) 74 return true; 75 } 76 77 return false; 78 } 79 68 80 void COutputPin::setOutputTriggers() 69 81 { -
XIOS/dev/branch_openmp/src/filter/output_pin.hpp
r1119 r1460 44 44 */ 45 45 bool virtual canBeTriggered() const; 46 47 /*! 48 * Tests if the pin must auto-trigger. 49 * 50 * \return true if the pin must auto-trigger 51 */ 52 bool virtual mustAutoTrigger() const; 46 53 47 54 /*! -
XIOS/dev/branch_openmp/src/filter/source_filter.cpp
r1328 r1460 7 7 namespace xios 8 8 { 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, 9 CSourceFilter::CSourceFilter(CGarbageCollector& gc, CGrid* grid, bool compression, 10 10 const CDuration offset /*= NoneDu*/, bool manualTrigger /*= false*/, 11 11 bool hasMissingValue /*= false*/, … … 13 13 : COutputPin(gc, manualTrigger) 14 14 , grid(grid) 15 , compression(compression) 15 16 , offset(offset) 16 17 , hasMissingValue(hasMissingValue), defaultValue(defaultValue) … … 31 32 packet->status = CDataPacket::NO_ERROR; 32 33 33 packet->data.resize(grid->storeIndex_client.numElements()); 34 grid->inputField(data, packet->data); 34 packet->data.resize(grid->storeIndex_client.numElements()); 35 36 if (compression) 37 { 38 packet->data = defaultValue; 39 grid->uncompressField(data, packet->data); 40 } 41 else 42 grid->inputField(data, packet->data); 35 43 44 45 46 // if (compression) grid->inputField(data, packet->data) ; 47 // else 48 // { 49 // // just make a flat copy 50 // CArray<double, N> data_tmp(data.copy()) ; // supress const attribute 51 // CArray<double,1> dataTmp2(data_tmp.dataFirst(),shape(data.numElements()),neverDeleteData) ; 52 // packet->data = dataTmp2 ; 53 // } 36 54 // Convert missing values to NaN 37 55 if (hasMissingValue) … … 65 83 packet->timestamp = date; 66 84 packet->status = CDataPacket::NO_ERROR; 67 68 // if (data.size() != grid->storeIndex_toSrv.size()) 85 69 86 if (data.size() != grid->storeIndex_fromSrv.size()) 70 87 ERROR("CSourceFilter::streamDataFromServer(CDate date, const std::map<int, CArray<double, 1> >& data)", … … 75 92 std::map<int, CArray<double, 1> >::const_iterator it, itEnd = data.end(); 76 93 for (it = data.begin(); it != itEnd; it++) 77 { 78 // CArray<int,1>& index = grid->storeIndex_toSrv[it->first]; 94 { 79 95 CArray<int,1>& index = grid->storeIndex_fromSrv[it->first]; 80 96 for (int n = 0; n < index.numElements(); n++) -
XIOS/dev/branch_openmp/src/filter/source_filter.hpp
r1205 r1460 27 27 */ 28 28 CSourceFilter(CGarbageCollector& gc, CGrid* grid, 29 bool compression=true, 29 30 const CDuration offset = NoneDu, bool manualTrigger = false, 30 31 bool hasMissingValue = false, … … 64 65 const bool hasMissingValue; 65 66 const double defaultValue; 67 const bool compression ; //!< indicate if the data need to be compressed : on client size : true, on server side : false 66 68 }; // class CSourceFilter 67 69 } // namespace xios -
XIOS/dev/branch_openmp/src/filter/spatial_transform_filter.cpp
r1328 r1460 4 4 #include "context.hpp" 5 5 #include "context_client.hpp" 6 #include "timer.hpp" 6 7 using namespace ep_lib; 7 8 … … 29 30 size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 30 31 double defaultValue = (hasMissingValue) ? std::numeric_limits<double>::quiet_NaN() : 0.0; 31 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 32 32 33 34 const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 35 CGridTransformationSelector::ListAlgoType::const_iterator it ; 36 37 bool isSpatialTemporal=false ; 38 for (it=algoList.begin();it!=algoList.end();++it) if (it->second.first == TRANS_TEMPORAL_SPLITTING) isSpatialTemporal=true ; 39 40 boost::shared_ptr<CSpatialTransformFilter> filter ; 41 if( isSpatialTemporal) filter = boost::shared_ptr<CSpatialTransformFilter>(new CSpatialTemporalFilter(gc, engine, gridTransformation, defaultValue, inputCount)); 42 else filter = boost::shared_ptr<CSpatialTransformFilter>(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 43 44 33 45 if (!lastFilter) 34 46 lastFilter = filter; … … 58 70 onOutputReady(outputPacket); 59 71 } 72 73 74 75 76 77 CSpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount) 78 : CSpatialTransformFilter(gc, engine, outputValue, inputSlotsCount), record(0) 79 { 80 const CGridTransformationSelector::ListAlgoType& algoList = gridTransformation->getAlgoList() ; 81 CGridTransformationSelector::ListAlgoType::const_iterator it ; 82 83 int pos ; 84 for (it=algoList.begin();it!=algoList.end();++it) 85 if (it->second.first == TRANS_TEMPORAL_SPLITTING) 86 { 87 pos=it->first ; 88 if (pos < algoList.size()-1) 89 ERROR("SpatialTemporalFilter::CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount))", 90 "temporal splitting operation must be the last of whole transformation on same grid") ; 91 } 92 93 CGrid* grid=gridTransformation->getGridDestination() ; 94 95 CAxis* axis = grid->getAxis(gridTransformation->getElementPositionInGridDst2AxisPosition().find(pos)->second) ; 96 97 nrecords = axis->index.numElements() ; 98 } 99 100 101 void CSpatialTemporalFilter::onInputReady(std::vector<CDataPacketPtr> data) 102 { 103 CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 104 CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 105 106 if (outputPacket) 107 { 108 size_t nelements=outputPacket->data.numElements() ; 109 if (!tmpData.numElements()) 110 { 111 tmpData.resize(nelements); 112 tmpData=outputDefaultValue ; 113 } 114 115 nelements/=nrecords ; 116 size_t offset=nelements*record ; 117 for(size_t i=0;i<nelements;++i) tmpData(i+offset) = outputPacket->data(i) ; 118 119 record ++ ; 120 if (record==nrecords) 121 { 122 record=0 ; 123 CDataPacketPtr packet = CDataPacketPtr(new CDataPacket); 124 packet->date = data[0]->date; 125 packet->timestamp = data[0]->timestamp; 126 packet->status = data[0]->status; 127 packet->data.resize(tmpData.numElements()); 128 packet->data = tmpData; 129 onOutputReady(packet); 130 tmpData.resize(0) ; 131 } 132 } 133 } 134 60 135 61 136 CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation) … … 122 197 void CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest) 123 198 { 199 CTimer::get("CSpatialTransformFilterEngine::apply").resume(); 200 124 201 CContextClient* client = CContext::getCurrent()->client; 125 202 … … 235 312 236 313 dataDest = dataCurrentDest; 314 315 CTimer::get("CSpatialTransformFilterEngine::apply").suspend() ; 237 316 } 238 317 } // namespace xios -
XIOS/dev/branch_openmp/src/filter/spatial_transform_filter.hpp
r1334 r1460 3 3 4 4 #include "filter.hpp" 5 5 6 namespace xios 6 7 { … … 48 49 double outputDefaultValue; 49 50 }; // class CSpatialTransformFilter 51 52 53 /*! 54 * 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. 55 * 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 56 */ 57 58 class CSpatialTemporalFilter : public CSpatialTransformFilter 59 { 60 public: 61 /*! 62 * Constructs a filter wrapping the specified spatial transformation. 63 * 64 * \param gc the associated garbage collector 65 * \param engine the engine defining the spatial transformation 66 * \param [in] gridTransformation the associated transformations 67 * \param outputValue default value of output pin 68 * \param [in] inputSlotsCount number of input, by default there is only one for field src 69 */ 70 CSpatialTemporalFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, CGridTransformation* gridTransformation, double outputValue, size_t inputSlotsCount = 1); 71 72 73 protected: 74 /*! 75 Overriding this function to process transformations with auxillary inputs 76 */ 77 void virtual onInputReady(std::vector<CDataPacketPtr> data); 78 //! Current record in the filter 79 int record ; 80 //! Maximum number of records 81 int nrecords; 82 //! Temporary storage for output flux 83 CArray<double, 1> tmpData; 84 85 86 }; // class CSpatialTemporalFilter 87 50 88 51 89 /*! -
XIOS/dev/branch_openmp/src/filter/store_filter.cpp
r1328 r1460 111 111 } 112 112 113 bool CStoreFilter::mustAutoTrigger() const 114 { 115 return false; 116 } 117 113 118 bool CStoreFilter::isDataExpected(const CDate& date) const 114 119 { -
XIOS/dev/branch_openmp/src/filter/store_filter.hpp
r1205 r1460 53 53 54 54 /*! 55 * Tests if the filter must auto-trigger. 56 * 57 * \return true if the filter must auto-trigger 58 */ 59 bool virtual mustAutoTrigger() const; 60 61 /*! 55 62 * Tests whether data is expected for the specified date. 56 63 * -
XIOS/dev/branch_openmp/src/filter/temporal_filter.cpp
r1328 r1460 5 5 namespace xios 6 6 { 7 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue,CArray<double, 1>& tmpData);7 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, CArray<double, 1>& tmpData); 8 8 9 9 CTemporalFilter::CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 10 10 const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 11 bool ignoreMissingValue /*= false*/ , double missingValue /*= 0.0*/)11 bool ignoreMissingValue /*= false*/) 12 12 : CFilter(gc, 1, this) 13 , functor(createFunctor(opId, ignoreMissingValue, missingValue,tmpData))13 , functor(createFunctor(opId, ignoreMissingValue, tmpData)) 14 14 , isOnceOperation(functor->timeType() == func::CFunctor::once) 15 15 , isInstantOperation(functor->timeType() == func::CFunctor::instant) … … 17 17 , samplingOffset(samplingOffset) 18 18 , opFreq(opFreq) 19 , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 20 , nextOperationDate(initDate + this->samplingOffset + opFreq) 19 , offsetMonth({0, this->samplingOffset.month, 0, 0, 0, 0, 0}) 20 , offsetAllButMonth({this->samplingOffset.year, 0 , this->samplingOffset.day, 21 this->samplingOffset.hour, this->samplingOffset.minute, 22 this->samplingOffset.second, this->samplingOffset.timestep}) 23 , initDate(initDate) 24 , nextSamplingDate(initDate + (this->samplingOffset + initDate.getRelCalendar().getTimeStep())) 25 , nbOperationDates(1) 26 // , nextOperationDate(initDate + opFreq + this->samplingOffset) 21 27 , isFirstOperation(true) 22 28 { … … 35 41 { 36 42 usePacket = (data[0]->date >= nextSamplingDate); 37 outputResult = (data[0]->date + samplingFreq > nextOperationDate); 43 // outputResult = (data[0]->date + samplingFreq > nextOperationDate); 44 outputResult = (data[0]->date > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 38 45 copyLess = (isInstantOperation && usePacket && outputResult); 39 46 } … … 54 61 if (outputResult) 55 62 { 63 nbOperationDates ++; 56 64 if (!copyLess) 57 65 { … … 69 77 70 78 isFirstOperation = false; 71 nextOperationDate = nextOperationDate + samplingFreq + opFreq - samplingFreq;79 // nextOperationDate = initDate + samplingFreq + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth; 72 80 } 73 81 } … … 76 84 } 77 85 86 bool CTemporalFilter::mustAutoTrigger() const 87 { 88 return true; 89 } 90 78 91 bool CTemporalFilter::isDataExpected(const CDate& date) const 79 92 { 80 return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 93 // return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 94 return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date > initDate + nbOperationDates*opFreq - samplingFreq + offsetMonth + offsetAllButMonth); 81 95 } 82 96 83 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue,CArray<double, 1>& tmpData)97 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, CArray<double, 1>& tmpData) 84 98 { 85 99 func::CFunctor* functor = NULL; 86 100 87 double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue;101 double defaultValue = std::numeric_limits<double>::quiet_NaN(); 88 102 89 103 #define DECLARE_FUNCTOR(MType, mtype) \ -
XIOS/dev/branch_openmp/src/filter/temporal_filter.hpp
r1205 r1460 26 26 * \param ignoreMissingValue true if and only if the missing value must be ignored 27 27 when doing the operation 28 * \param missingValue the missing value29 28 */ 30 29 CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 31 30 const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 32 bool ignoreMissingValue = false , double missingValue = 0.0);31 bool ignoreMissingValue = false); 33 32 34 33 /*! … … 39 38 */ 40 39 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 40 41 /*! 42 * Tests if the filter must auto-trigger. 43 * 44 * \return true if the filter must auto-trigger 45 */ 46 bool virtual mustAutoTrigger() const; 41 47 42 48 /*! … … 56 62 const CDuration samplingOffset; //!< The sampling offset, i.e. the offset after which the input data will be used 57 63 const CDuration opFreq; //!< The operation frequency, i.e. the frequency at which the output data will be computed 64 const CDuration offsetMonth; //!< The month duration of samplingOffset 65 CDuration offsetAllButMonth; //!< All but the month duration of samplingOffset 66 const CDate initDate; 58 67 CDate nextSamplingDate; //!< The date of the next sampling 59 CDate nextOperationDate; //!< The date of the next operation 68 int nbOperationDates; //!< The number of times an operation is performed 69 // CDate nextOperationDate; //!< The date of the next operation 60 70 bool isFirstOperation; //!< True before the first operation was been computed 61 71 }; // class CTemporalFilter
Note: See TracChangeset
for help on using the changeset viewer.