-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declarative style for particle update comm #2407
Conversation
Codecov Report
@@ Coverage Diff @@
## python #2407 +/- ##
=======================================
- Coverage 72% 72% -1%
=======================================
Files 485 484 -1
Lines 29926 29509 -417
=======================================
- Hits 21682 21295 -387
+ Misses 8244 8214 -30
Continue to review full report at Codecov.
|
@KaiSzuttor the AMD issue is unrelated. |
AMD fixed in #2412. |
Looks good. A few doc comments would be helpful, though. diff --git a/src/core/particle_data.cpp b/src/core/particle_data.cpp
+template <typename S, S Particle::*s, typename T, T S::*m>
+struct UpdateParticle {
+ int id;
+ T value;
+
+ void operator()(Particle &p) const { (p.*s).*m = value; }
+
+ template <class Archive> void serialize(Archive &ar, long int) {
+ ar &id;
+ ar &value;
+ }
+};
+
+template <typename T, T ParticleProperties::*m>
+using UpdateProperty = UpdateParticle<ParticleProperties, &Particle::p, T, m>;
+template <typename T, T ParticlePosition ::*m>
+using UpdatePosition = UpdateParticle<ParticlePosition, &Particle::r, T, m>;
+template <typename T, T ParticleMomentum ::*m>
+using UpdateMomentum = UpdateParticle<ParticleMomentum, &Particle::m, T, m>;
+template <typename T, T ParticleForce ::*m>
+using UpdateForce = UpdateParticle<ParticleForce, &Particle::f, T, m>; Please insert some docs, also with regards to the template params +template <typename S, S Particle::*s, typename T, T S::*m> struct message_type; Please also insert some comments here about how the message type distinciotn works. +
+template <typename S, S Particle::*s, typename T, T S::*m>
+using message_type_t = typename message_type<S, s, T, m>::type;
+
+struct UpdateParticleVisitor : public boost::static_visitor<void> {
+ template <typename Message> void operator()(const Message &msg) const {
+ assert(local_particles[msg.id]);
+ msg(*local_particles[msg.id]);
+ }
+}; Please mention here via what mechanism the actual update gets called since not all readers of this might be familiar with the pattern. |
collision detection seems to have issues |
Yeah, I called the master instead of the local interface... |
please merge the current python branch |
@KaiSzuttor I removed the unused return values and cleaned up a bit. |
and reduce duplication.