You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create iterators over single particle propreties and common groups of particle properties
auto positions = PositionIterator(cellstrucutre.local_particles());
for (std::vector3d& pos: positions) {
};
This can, to my understanding, be implemented by a boost transform iterator.
For combinations such as
PositionChargeIterator,
a design choice needs to be made:
Either one uses a boost zip iterator, then the individual properties (position, velocities) are numbered. (zip itertaor returns tuples)
Or we create proxy classes which forward the poiters and references as named members
Here's a sketch generated using ChatGTP. May or may not work, but looks OK
#include<boost/iterator/transform_iterator.hpp>classParticle {
public:const Vector3d& pos() const {
return position_;
}
private:
Vector3d position_;
};
// Define a function object to extract the pos() member from a Particle objectstructExtractPos {
const Vector3d& operator()(const Particle& particle) const {
return particle.pos();
}
};
intmain() {
std::vector<Particle> particles = /* ... */;
// Create a transform iterator that extracts the pos() member from each Particle objectauto pos_iterator = boost::make_transform_iterator(particles.begin(), ExtractPos{});
// Iterate over the pos() members of the particlesfor (auto pos : pos_iterator) {
// Do something with pos, which is a reference to a Vector3d object
}
return0;
}
Partial fix for #4721, closes#4696
Description of changes:
- Implements the `ParticlePropertyRange` struct containing static methods to transform a `ParticleRange` to a `boost::iterator_range` of properties of the particles, such as `ForceRange` or `ParticleRange`, which can then be used in range-based for-loops.
The refactoring of the P3M part is not finished yet, but I think this PR could also be extended to remove the ParticleRanges from the remaining Coulomb interactions.
Create iterators over single particle propreties and common groups of particle properties
This can, to my understanding, be implemented by a boost transform iterator.
For combinations such as
PositionChargeIterator,
a design choice needs to be made:
Either one uses a boost zip iterator, then the individual properties (position, velocities) are numbered. (zip itertaor returns tuples)
Or we create proxy classes which forward the poiters and references as named members
The text was updated successfully, but these errors were encountered: