From cee9d97918352be6e855dd6e0f78b74baed9a6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 7 Feb 2014 12:43:59 +0100 Subject: [PATCH 1/3] cleanup implementation of PositionFilter - add GetPositionFilter traid to get right filter 2D and 3D - fix dependencies --- .../particles/operations/CountParticles.hpp | 2 +- .../particleFilter/PositionFilter.hpp | 73 ++++++++++++------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/libPMacc/include/particles/operations/CountParticles.hpp b/src/libPMacc/include/particles/operations/CountParticles.hpp index ae8ef6084a..08e2110435 100644 --- a/src/libPMacc/include/particles/operations/CountParticles.hpp +++ b/src/libPMacc/include/particles/operations/CountParticles.hpp @@ -149,7 +149,7 @@ struct CountParticles template static uint64_cu countOnDevice(PBuffer& buffer, CellDesc cellDescription, const Space& origin, const Space& size) { - typedef bmpl::vector< PositionFilter3D<> > usedFilters; + typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; MyParticleFilter filter; filter.setStatus(true); /*activeate filter pipline*/ diff --git a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp index b5860aaac8..fa19842a32 100644 --- a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp @@ -1,5 +1,5 @@ /** - * Copyright 2013 Heiko Burau, Rene Widera + * Copyright 2013-2014 Heiko Burau, Rene Widera * * This file is part of libPMacc. * @@ -20,8 +20,7 @@ */ -#ifndef POSITIONFILTER_HPP -#define POSITIONFILTER_HPP +#pragma once #include "types.h" #include "particles/frame_types.hpp" @@ -35,13 +34,15 @@ namespace PMacc namespace privatePositionFilter { -template +template class PositionFilter : public Base { +public: + static const uint32_t dim = T_dim; protected: - DataSpace offset; - DataSpace max; - DataSpace superCellIdx; + DataSpace offset; + DataSpace max; + DataSpace superCellIdx; public: @@ -53,45 +54,67 @@ class PositionFilter : public Base { } - HDINLINE void setWindowPosition(DataSpace offset, DataSpace size) + HDINLINE void setWindowPosition(DataSpace offset, DataSpace size) { this->offset = offset; this->max = offset + size; } - HDINLINE void setSuperCellPosition(DataSpace superCellIdx) + HDINLINE void setSuperCellPosition(DataSpace superCellIdx) { this->superCellIdx = superCellIdx; } - HDINLINE DataSpace getOffset() + HDINLINE DataSpace getOffset() { return offset; } + template + HDINLINE bool operator()(FRAME & frame, lcellId_t id) + { + DataSpace localCellIdx = DataSpaceOperations::template map< + typename FRAME::SuperCellSize + > ((uint32_t) (frame[id][localCellIdx_])); + DataSpace pos = this->superCellIdx + localCellIdx; + bool result = false; + for (uint32_t d = 0; d < dim; ++d) + result&& = (this->offset[d] <= pos[d]) && (this->max[d] > pos[d]); + return Base::operator() (frame, id) && result; + } + }; } //namespace privatePositionFilter + +/** This wrapper class is needed because for filters we are only allowed to + * define one template parameter "base" (it is a constrain from FilterFactory) + */ template -class PositionFilter3D : public privatePositionFilter::PositionFilter +class PositionFilter3D : public privatePositionFilter::PositionFilter { -public: +}; - template - HDINLINE bool operator()(FRAME & frame, lcellId_t id) - { - DataSpace localCellIdx3D = DataSpaceOperations::template map< - typename FRAME::SuperCellSize - > ((uint32_t) (frame[id][localCellIdx_])); - DataSpace pos = this->superCellIdx + localCellIdx3D; - return (this->offset.x() <= pos.x() && this->offset.y() <= pos.y() && this->offset.z() <= pos.z() && - this->max.x() > pos.x() && this->max.y() > pos.y() && this->max.z() > pos.z()) && - Base::operator() (frame, id); - } +template +class PositionFilter2D : public privatePositionFilter::PositionFilter +{ }; -} //namespace Frame +template +struct GetPositionFilter; + +template<> +struct GetPositionFilter +{ + typedef PositionFilter3D<> type; +}; + +template<> +struct GetPositionFilter +{ + typedef PositionFilter2D<> type; +}; -#endif /* POSITIONFILTER_HPP */ +} //namespace PMacc From 5c45714cb2e8746476b8069f6ec2ee00061d340b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 7 Feb 2014 12:59:45 +0100 Subject: [PATCH 2/3] use new GetPositionFilter --- .../include/particles/particleFilter/PositionFilter.hpp | 7 +++---- src/picongpu/include/plugins/adios/ADIOSWriter.hpp | 2 +- src/picongpu/include/plugins/adios/WriteSpecies.hpp | 2 +- src/picongpu/include/plugins/hdf5/HDF5Writer.hpp | 2 +- src/picongpu/include/plugins/hdf5/WriteSpecies.hpp | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp index fa19842a32..990d68ac8a 100644 --- a/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp +++ b/src/libPMacc/include/particles/particleFilter/PositionFilter.hpp @@ -79,7 +79,7 @@ class PositionFilter : public Base DataSpace pos = this->superCellIdx + localCellIdx; bool result = false; for (uint32_t d = 0; d < dim; ++d) - result&& = (this->offset[d] <= pos[d]) && (this->max[d] > pos[d]); + result= result && (this->offset[d] <= pos[d]) && (pos[d]max[d]); return Base::operator() (frame, id) && result; } @@ -87,17 +87,16 @@ class PositionFilter : public Base } //namespace privatePositionFilter - /** This wrapper class is needed because for filters we are only allowed to * define one template parameter "base" (it is a constrain from FilterFactory) */ template -class PositionFilter3D : public privatePositionFilter::PositionFilter +class PositionFilter3D : public privatePositionFilter::PositionFilter { }; template -class PositionFilter2D : public privatePositionFilter::PositionFilter +class PositionFilter2D : public privatePositionFilter::PositionFilter { }; diff --git a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp index 6bda9077ec..86d86514cb 100644 --- a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp +++ b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp @@ -94,7 +94,7 @@ class ADIOSWriter : public ISimulationIO, public IPluginModule public: /* filter particles by global position*/ - typedef bmpl::vector< PositionFilter3D<> > usedFilters; + typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; private: diff --git a/src/picongpu/include/plugins/adios/WriteSpecies.hpp b/src/picongpu/include/plugins/adios/WriteSpecies.hpp index 28e571639f..b44a345251 100644 --- a/src/picongpu/include/plugins/adios/WriteSpecies.hpp +++ b/src/picongpu/include/plugins/adios/WriteSpecies.hpp @@ -118,7 +118,7 @@ struct WriteSpecies log ("ADIOS: ( end ) get mapped memory device pointer: %1%") % AdiosFrameType::getName(); log ("ADIOS: (begin) copy particle to host: %1%") % AdiosFrameType::getName(); - typedef bmpl::vector< PositionFilter3D<> > usedFilters; + typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; MyParticleFilter filter; /* activeate filter pipeline if moving window is activated */ diff --git a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp index f187c284d1..c59ee821fc 100644 --- a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp +++ b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp @@ -96,7 +96,7 @@ class HDF5Writer : public ISimulationIO, public IPluginModule public: /* filter particles by global position*/ - typedef bmpl::vector< PositionFilter3D<> > usedFilters; + typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; private: diff --git a/src/picongpu/include/plugins/hdf5/WriteSpecies.hpp b/src/picongpu/include/plugins/hdf5/WriteSpecies.hpp index 93b2e011c7..ddf1d00843 100644 --- a/src/picongpu/include/plugins/hdf5/WriteSpecies.hpp +++ b/src/picongpu/include/plugins/hdf5/WriteSpecies.hpp @@ -130,7 +130,7 @@ struct WriteSpecies log ("HDF5: ( end ) get mapped memory device pointer: %1%") % Hdf5FrameType::getName(); log ("HDF5: (begin) copy particle to host: %1%") % Hdf5FrameType::getName(); - typedef bmpl::vector< PositionFilter3D<> > usedFilters; + typedef bmpl::vector< typename GetPositionFilter::type > usedFilters; typedef typename FilterFactory::FilterType MyParticleFilter; MyParticleFilter filter; /* activate filter pipeline if moving window is activated */ From 93ee9467c00cd658e0086d6733ce0ae45688e6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 7 Feb 2014 13:06:33 +0100 Subject: [PATCH 3/3] fix typo in comments --- src/picongpu/include/plugins/adios/ADIOSWriter.hpp | 2 +- src/picongpu/include/plugins/hdf5/HDF5Writer.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp index 86d86514cb..355e2f8894 100644 --- a/src/picongpu/include/plugins/adios/ADIOSWriter.hpp +++ b/src/picongpu/include/plugins/adios/ADIOSWriter.hpp @@ -99,7 +99,7 @@ class ADIOSWriter : public ISimulationIO, public IPluginModule private: - /* fiter is a rule which describes which particles should be copyied to host*/ + /* filter is a rule which describes which particles should be copied to host*/ MyParticleFilter filter; template diff --git a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp index c59ee821fc..e33094c62e 100644 --- a/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp +++ b/src/picongpu/include/plugins/hdf5/HDF5Writer.hpp @@ -101,7 +101,7 @@ class HDF5Writer : public ISimulationIO, public IPluginModule private: - /* fiter is a rule which describe which particles shuld copy to host*/ + /* filter is a rule which describe which particles should copy to host*/ MyParticleFilter filter; template