diff --git a/src/drift.h b/src/drift.h index e994e4fde7339d6eedbe376ccc136152564106ae..7af873a542587f8ebb0313f6abff0597851c7188 100644 --- a/src/drift.h +++ b/src/drift.h @@ -151,9 +151,9 @@ __attribute__((always_inline)) INLINE static void drift_part( /* Predict velocities (for gravity terms) */ if (p->gpart != NULL) { - p->v[0] += (p->gpart->a_grav[0] + p->gpart->a_grav_mesh[0]) * dt_kick_grav; - p->v[1] += (p->gpart->a_grav[1] + p->gpart->a_grav_mesh[1]) * dt_kick_grav; - p->v[2] += (p->gpart->a_grav[2] + p->gpart->a_grav_mesh[2]) * dt_kick_grav; + p->v[0] += xp->a_grav[0] * dt_kick_grav; + p->v[1] += xp->a_grav[1] * dt_kick_grav; + p->v[2] += xp->a_grav[2] * dt_kick_grav; } /* Predict the values of the extra fields */ diff --git a/src/hydro/AnarchyPU/hydro_part.h b/src/hydro/AnarchyPU/hydro_part.h index d55307bf9f73761c6e54eea096d6efbcd4fd4d56..185416f317e2a46b3f800ffbc121430652d7f930 100644 --- a/src/hydro/AnarchyPU/hydro_part.h +++ b/src/hydro/AnarchyPU/hydro_part.h @@ -55,6 +55,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index bb614c897588a7f7ae4a00041d070c3a0c2460f1..fc34fa80260ced93741f50449c776fb3a482ccb2 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -54,6 +54,9 @@ struct xpart { /* Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /* Entropy at the last full step. */ float entropy_full; diff --git a/src/hydro/Gizmo/hydro_part.h b/src/hydro/Gizmo/hydro_part.h index 3244aa1b6cc288a613db1df4a0176939b5c51dc8..17b0179916db7a65dcbba7800723fab1d049fd7d 100644 --- a/src/hydro/Gizmo/hydro_part.h +++ b/src/hydro/Gizmo/hydro_part.h @@ -39,6 +39,9 @@ struct xpart { /* Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /* Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; diff --git a/src/hydro/Minimal/hydro_part.h b/src/hydro/Minimal/hydro_part.h index 6db84cdc0179b42d154fd96e498823f6e3f41fac..94aaf51282b129ee6f3a29d4dca6a4e6983b397a 100644 --- a/src/hydro/Minimal/hydro_part.h +++ b/src/hydro/Minimal/hydro_part.h @@ -58,6 +58,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/Phantom/hydro_part.h b/src/hydro/Phantom/hydro_part.h index 170c0d9e434f65e5baaf68c31ccc16797de2f40f..73a9c4bde74c10604bbdc9664c9ff391461dd4d3 100644 --- a/src/hydro/Phantom/hydro_part.h +++ b/src/hydro/Phantom/hydro_part.h @@ -56,6 +56,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/Planetary/hydro_part.h b/src/hydro/Planetary/hydro_part.h index bcd905acc4a60b1d7f05bd6860b1597dc9c17df7..40d2f778356bdc296e344b9821f44ada213ce229 100644 --- a/src/hydro/Planetary/hydro_part.h +++ b/src/hydro/Planetary/hydro_part.h @@ -61,6 +61,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/PressureEnergy/hydro_part.h b/src/hydro/PressureEnergy/hydro_part.h index 66b44d56c8818969ca10c199fe0f26bf73a38b70..8be543aadc8ad494bec4e7f1127e865f6f9f9d41 100644 --- a/src/hydro/PressureEnergy/hydro_part.h +++ b/src/hydro/PressureEnergy/hydro_part.h @@ -58,6 +58,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h index 30db47c9d2e94046c312f31a096033bee1c6a667..605bdfb8fb36932842256f54b754feca08f018a2 100644 --- a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h +++ b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h @@ -58,6 +58,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/PressureEntropy/hydro_part.h b/src/hydro/PressureEntropy/hydro_part.h index 9a03c8862a491165376d16a03fe27429572ec9ab..3177475b1c71c69026707052273841288679b98a 100644 --- a/src/hydro/PressureEntropy/hydro_part.h +++ b/src/hydro/PressureEntropy/hydro_part.h @@ -50,6 +50,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Entropy at the last full step. */ float entropy_full; diff --git a/src/hydro/SPHENIX/hydro_part.h b/src/hydro/SPHENIX/hydro_part.h index 4a3c2877909bcbf5a11769e6f6d30ce71a1d4010..f13e29c0e3e4f89ea6bd09e594b7e6dcfb4bfafd 100644 --- a/src/hydro/SPHENIX/hydro_part.h +++ b/src/hydro/SPHENIX/hydro_part.h @@ -53,6 +53,9 @@ struct xpart { /*! Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /*! Internal energy at the last full step. */ float u_full; diff --git a/src/hydro/Shadowswift/hydro_part.h b/src/hydro/Shadowswift/hydro_part.h index bc374e5500c23fc3e9c6210adb1079f6c55accde..2ed26b8568dce0aa6b43f8bdeced26d6e2caf3ba 100644 --- a/src/hydro/Shadowswift/hydro_part.h +++ b/src/hydro/Shadowswift/hydro_part.h @@ -41,6 +41,9 @@ struct xpart { /* Velocity at the last full step. */ float v_full[3]; + /*! Gravitational acceleration at the end of the last step */ + float a_grav[3]; + /* Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; diff --git a/src/runner_time_integration.c b/src/runner_time_integration.c index b7b014b731e5ffae0458607560756e6ce80b5e89..bfb2611e5f4c2f9545465aca23792dbd839954e4 100644 --- a/src/runner_time_integration.c +++ b/src/runner_time_integration.c @@ -177,6 +177,14 @@ void runner_do_kick1(struct runner *r, struct cell *c, const int timer) { kick_part(p, xp, dt_kick_hydro, dt_kick_grav, dt_kick_mesh_grav, dt_kick_therm, dt_kick_corr, cosmo, hydro_props, entropy_floor, ti_begin, ti_end, ti_begin_mesh, ti_end_mesh); + + /* Update the accelerations to be used in the drift for hydro */ + if (p->gpart != NULL) { + + xp->a_grav[0] = p->gpart->a_grav[0] + p->gpart->a_grav_mesh[0]; + xp->a_grav[1] = p->gpart->a_grav[1] + p->gpart->a_grav_mesh[1]; + xp->a_grav[2] = p->gpart->a_grav[2] + p->gpart->a_grav_mesh[2]; + } } }