18#include "ParticleIterator.h"
30#include "utils/mardyn_assert.h"
31#include "ParticleIterator.h"
36 RegionParticleIterator (Type t, CellContainer_T_ptr cells_arg,
const CellIndex_T offset_arg,
const CellIndex_T stride_arg,
const int startCellIndex_arg,
const int regionDimensions_arg[3],
const int globalDimensions_arg[3],
const double startRegion_arg[3],
const double endRegion_arg[3]);
39 void operator++()
override;
42 CellIndex_T getGlobalCellIndex();
43 void next_non_empty_cell()
override;
48 CellIndex_T _localCellIndex;
49 CellIndex_T _regionDimensions[3];
50 CellIndex_T _globalDimensions[3];
52 double _startRegion[3];
56inline RegionParticleIterator :: RegionParticleIterator () :
ParticleIterator(), _localCellIndex(0) {
59inline RegionParticleIterator :: RegionParticleIterator (Type t, CellContainer_T_ptr cells_arg,
const CellIndex_T offset_arg,
const CellIndex_T stride_arg,
const int startCellIndex_arg,
const int regionDimensions_arg[3],
const int globalDimensions_arg[3],
const double startRegion_arg[3],
const double endRegion_arg[3]) :
60 ParticleIterator(t, cells_arg, offset_arg, stride_arg, false), _localCellIndex (offset_arg) {
62#ifdef ENABLE_REDUCED_MEMORY_MODE
63 _cell_index = offset_arg;
66 for (
int d = 0; d < 3; d++) {
67 _regionDimensions[d] = regionDimensions_arg[d];
68 _globalDimensions[d] = globalDimensions_arg[d];
69 _startRegion[d] = startRegion_arg[d];
70 _endRegion[d] = endRegion_arg[d];
73 _baseZ = startCellIndex_arg / (_globalDimensions[0] * _globalDimensions[1]);
74 _baseY = (startCellIndex_arg % (_globalDimensions[0] * _globalDimensions[1])) / _globalDimensions[0];
75 _baseX = (startCellIndex_arg % (_globalDimensions[0] * _globalDimensions[1])) % _globalDimensions[0];
77 _cell_index = getGlobalCellIndex();
78 updateCellIteratorCell();
80 mardyn_assert(_cells !=
nullptr);
82 const CellContainer_T& cells = *_cells;
83 const CellIndex_T numCellsInRegion = _regionDimensions[2] * _regionDimensions[1] * _regionDimensions[0];
86 if (_localCellIndex < numCellsInRegion) {
94 if (cells[_cell_index].isNotEmpty() and (this->
operator*()).inBox(_startRegion, _endRegion)) {
107 mardyn_assert(_stride == other._stride);
108 _cells = other._cells;
109 _cell_index = other._cell_index;
110 _cell_iterator = other._cell_iterator;
111 _baseX = other._baseX;
112 _baseY = other._baseY;
113 _baseZ = other._baseZ;
114 _localCellIndex = other._localCellIndex;
115 for(
int d = 0; d < 3; d++){
116 _regionDimensions[d] = other._regionDimensions[d];
117 _globalDimensions[d] = other._globalDimensions[d];
118 _startRegion[d] = other._startRegion[d];
119 _endRegion[d] = other._endRegion[d];
124inline void RegionParticleIterator :: operator ++() {
126 ParticleIterator :: operator++();
127 }
while (isValid() and !(this->
operator*()).inBox(_startRegion, _endRegion));
130inline void RegionParticleIterator :: next_non_empty_cell() {
132 mardyn_assert(_cells !=
nullptr);
134 const CellContainer_T& cells = *_cells;
135 const CellIndex_T numCellsInRegion = _regionDimensions[2] * _regionDimensions[1] * _regionDimensions[0];
138 for (_localCellIndex += _stride; _localCellIndex < numCellsInRegion; _localCellIndex += _stride) {
142 if (c.
isNotEmpty() and (_type == ALL_CELLS or not c.isHaloCell())) {
143 _cell_index = getGlobalCellIndex();
144 updateCellIteratorCell();
150inline ParticleIterator::CellIndex_T RegionParticleIterator :: getGlobalCellIndex() {
151 CellIndex_T dz = _localCellIndex / (_regionDimensions[0] * _regionDimensions[1]);
152 CellIndex_T dy = (_localCellIndex % (_regionDimensions[0] * _regionDimensions[1])) / _regionDimensions[0];
153 CellIndex_T dx = (_localCellIndex % (_regionDimensions[0] * _regionDimensions[1])) % _regionDimensions[0];
154 return (_baseX + dx) + (_baseY + dy) * _globalDimensions[0] + (_baseZ + dz) * _globalDimensions[0] * _globalDimensions[1];
ParticleCellBase defines the interface for cells used by the LinkedCells data structure to store mole...
Definition: ParticleCellBase.h:23
bool isNotEmpty() const
Check if current cell contains molecules.
Definition: ParticleCellBase.h:44
Definition: ParticleIterator.h:50
Definition: RegionParticleIterator.h:33