Skip to content
Snippets Groups Projects
Commit c76866d5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Fix the debugging checks in the gravity calculation to use the maximal softening length as well.

parent 0a234e1b
Branches
Tags
1 merge request!884Support for multiple softening lengths in the gravity solver
...@@ -219,8 +219,14 @@ static INLINE void runner_dopair_grav_pp_full( ...@@ -219,8 +219,14 @@ static INLINE void runner_dopair_grav_pp_full(
const float r2 = dx * dx + dy * dy + dz * dz; const float r2 = dx * dx + dy * dy + dz * dz;
/* Pick the maximal softening length of i and j */
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (r2 == 0.f && h2_i == 0.) if (r2 == 0.f && h2 == 0.)
error("Interacting particles with 0 distance and 0 softening."); error("Interacting particles with 0 distance and 0 softening.");
/* Check that particles have been drifted to the current time */ /* Check that particles have been drifted to the current time */
...@@ -244,11 +250,6 @@ static INLINE void runner_dopair_grav_pp_full( ...@@ -244,11 +250,6 @@ static INLINE void runner_dopair_grav_pp_full(
error("Adding forces to an un-initialised gpart."); error("Adding forces to an un-initialised gpart.");
#endif #endif
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
/* Interact! */ /* Interact! */
float f_ij, pot_ij; float f_ij, pot_ij;
runner_iact_grav_pp_full(r2, h2, h_inv, h_inv_3, mass_j, &f_ij, &pot_ij); runner_iact_grav_pp_full(r2, h2, h_inv, h_inv_3, mass_j, &f_ij, &pot_ij);
...@@ -361,8 +362,14 @@ static INLINE void runner_dopair_grav_pp_truncated( ...@@ -361,8 +362,14 @@ static INLINE void runner_dopair_grav_pp_truncated(
const float r2 = dx * dx + dy * dy + dz * dz; const float r2 = dx * dx + dy * dy + dz * dz;
/* Pick the maximal softening length of i and j */
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (r2 == 0.f && h2_i == 0.) if (r2 == 0.f && h2 == 0.)
error("Interacting particles with 0 distance and 0 softening."); error("Interacting particles with 0 distance and 0 softening.");
/* Check that particles have been drifted to the current time */ /* Check that particles have been drifted to the current time */
...@@ -386,11 +393,6 @@ static INLINE void runner_dopair_grav_pp_truncated( ...@@ -386,11 +393,6 @@ static INLINE void runner_dopair_grav_pp_truncated(
error("Adding forces to an un-initialised gpart."); error("Adding forces to an un-initialised gpart.");
#endif #endif
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
/* Interact! */ /* Interact! */
float f_ij, pot_ij; float f_ij, pot_ij;
runner_iact_grav_pp_truncated(r2, h2, h_inv, h_inv_3, mass_j, r_s_inv, runner_iact_grav_pp_truncated(r2, h2, h_inv, h_inv_3, mass_j, r_s_inv,
...@@ -952,8 +954,14 @@ static INLINE void runner_doself_grav_pp_full( ...@@ -952,8 +954,14 @@ static INLINE void runner_doself_grav_pp_full(
const float dz = z_j - z_i; const float dz = z_j - z_i;
const float r2 = dx * dx + dy * dy + dz * dz; const float r2 = dx * dx + dy * dy + dz * dz;
/* Pick the maximal softening length of i and j */
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (r2 == 0.f && h2_i == 0.) if (r2 == 0.f && h2 == 0.)
error("Interacting particles with 0 distance and 0 softening."); error("Interacting particles with 0 distance and 0 softening.");
/* Check that particles have been drifted to the current time */ /* Check that particles have been drifted to the current time */
...@@ -976,11 +984,6 @@ static INLINE void runner_doself_grav_pp_full( ...@@ -976,11 +984,6 @@ static INLINE void runner_doself_grav_pp_full(
error("Adding forces to an un-initialised gpart."); error("Adding forces to an un-initialised gpart.");
#endif #endif
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
/* Interact! */ /* Interact! */
float f_ij, pot_ij; float f_ij, pot_ij;
runner_iact_grav_pp_full(r2, h2, h_inv, h_inv_3, mass_j, &f_ij, &pot_ij); runner_iact_grav_pp_full(r2, h2, h_inv, h_inv_3, mass_j, &f_ij, &pot_ij);
...@@ -1077,8 +1080,14 @@ static INLINE void runner_doself_grav_pp_truncated( ...@@ -1077,8 +1080,14 @@ static INLINE void runner_doself_grav_pp_truncated(
const float r2 = dx * dx + dy * dy + dz * dz; const float r2 = dx * dx + dy * dy + dz * dz;
/* Pick the maximal softening length of i and j */
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (r2 == 0.f && h2_i == 0.) if (r2 == 0.f && h2 == 0.)
error("Interacting particles with 0 distance and 0 softening."); error("Interacting particles with 0 distance and 0 softening.");
/* Check that particles have been drifted to the current time */ /* Check that particles have been drifted to the current time */
...@@ -1101,11 +1110,6 @@ static INLINE void runner_doself_grav_pp_truncated( ...@@ -1101,11 +1110,6 @@ static INLINE void runner_doself_grav_pp_truncated(
error("Adding forces to an un-initialised gpart."); error("Adding forces to an un-initialised gpart.");
#endif #endif
const float h = max(h_i, h_j);
const float h2 = h * h;
const float h_inv = 1.f / h;
const float h_inv_3 = h_inv * h_inv * h_inv;
/* Interact! */ /* Interact! */
float f_ij, pot_ij; float f_ij, pot_ij;
runner_iact_grav_pp_truncated(r2, h2, h_inv, h_inv_3, mass_j, r_s_inv, runner_iact_grav_pp_truncated(r2, h2, h_inv, h_inv_3, mass_j, r_s_inv,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment