Skip to content

Commit 684c1aa

Browse files
authored
Merge pull request #120 from hannorein/interpolate_fix
Fixed array size (was too large) used in integrate_or_interpolate. ASSIST also now copies the particles initially, so that the radius, mass, hash, etc are maintained. Fixes #119
2 parents ed21941 + dcaf9f2 commit 684c1aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/assist.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,11 @@ void assist_integrate_or_interpolate(struct assist_extras* ax, double t){
482482
sim->exact_finish_time = 0;
483483

484484
if (ax->current_state==NULL){
485-
ax->current_state = malloc(sizeof(struct reb_particle)*6*sim->N);
486-
ax->last_state = malloc(sizeof(struct reb_particle)*6*sim->N);
485+
ax->current_state = malloc(sizeof(struct reb_particle)*sim->N);
486+
ax->last_state = malloc(sizeof(struct reb_particle)*sim->N);
487+
// Initialize new arrays with sim->particles (sets mass, radius, hash, if users use those)
488+
memcpy(ax->current_state, sim->particles, sizeof(struct reb_particle)*sim->N);
489+
memcpy(ax->last_state, sim->particles, sizeof(struct reb_particle)*sim->N);
487490
}else{
488491
assist_swap_particles(sim);
489492
}

0 commit comments

Comments
 (0)