Commit 23859640 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also update the basic and potential gravity schemes to work with the new updated gravity code

parent ea54b741
......@@ -192,6 +192,18 @@ __attribute__((always_inline)) INLINE static void gravity_end_force(
struct gpart* gp, float const_G, const float potential_normalisation,
const int periodic) {
/* Record the norm of the acceleration for the adaptive opening criteria.
* Will always be an (active) timestep behind. */
gp->old_a_grav_norm = gp->a_grav[0] * gp->a_grav[0] +
gp->a_grav[1] * gp->a_grav[1] +
gp->a_grav[2] * gp->a_grav[2];
gp->old_a_grav_norm = sqrtf(gp->old_a_grav_norm);
#ifdef SWIFT_DEBUG_CHECKS
if (gp->old_a_grav_norm == 0.f) error("Old acceleration is 0!");
#endif
/* Let's get physical... */
gp->a_grav[0] *= const_G;
gp->a_grav[1] *= const_G;
......@@ -254,6 +266,7 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
struct gpart* gp, const struct gravity_props* grav_props) {
gp->time_bin = 0;
gp->old_a_grav_norm = 0.f;
gravity_init_gpart(gp);
}
......
......@@ -42,6 +42,9 @@ struct gpart {
/*! Particle mass. */
float mass;
/*! Norm of the acceleration at the previous step. */
float old_a_grav_norm;
/*! Particle FoF properties (group ID, group size, ...) */
struct fof_gpart_data fof_data;
......
......@@ -176,6 +176,18 @@ __attribute__((always_inline)) INLINE static void gravity_end_force(
/* Apply the periodic correction to the peculiar potential */
if (periodic) gp->potential += potential_normalisation;
/* Record the norm of the acceleration for the adaptive opening criteria.
* Will always be an (active) timestep behind. */
gp->old_a_grav_norm = gp->a_grav[0] * gp->a_grav[0] +
gp->a_grav[1] * gp->a_grav[1] +
gp->a_grav[2] * gp->a_grav[2];
gp->old_a_grav_norm = sqrtf(gp->old_a_grav_norm);
#ifdef SWIFT_DEBUG_CHECKS
if (gp->old_a_grav_norm == 0.f) error("Old acceleration is 0!");
#endif
/* Let's get physical... */
gp->a_grav[0] *= const_G;
gp->a_grav[1] *= const_G;
......@@ -236,6 +248,7 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
struct gpart* gp, const struct gravity_props* grav_props) {
gp->time_bin = 0;
gp->old_a_grav_norm = 0.f;
gravity_init_gpart(gp);
}
......
......@@ -39,11 +39,14 @@ struct gpart {
/*! Particle acceleration. */
float a_grav[3];
/*! Gravitational potential */
float potential;
/*! Particle mass. */
float mass;
/*! Gravitational potential */
float potential;
/*! Norm of the acceleration at the previous step. */
float old_a_grav_norm;
/*! Particle FoF properties (group ID, group size, ...) */
struct fof_gpart_data fof_data;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment