Skip to content
Snippets Groups Projects
Commit 200c35cc authored by Josh Borrow's avatar Josh Borrow
Browse files

Added debugging checks for negative values

parent 7021a704
No related branches found
No related tags found
1 merge request!540Add Pressure-Energy (P-U) SPH
...@@ -63,10 +63,12 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( ...@@ -63,10 +63,12 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
/* Compute density of pi. */ /* Compute density of pi. */
const float hi_inv = 1.f / hi; const float hi_inv = 1.f / hi;
const float ui = r * hi_inv; const float ui = r * hi_inv;
kernel_deval(ui, &wi, &wi_dx); kernel_deval(ui, &wi, &wi_dx);
pi->rho += mj * wi; pi->rho += mj * wi;
pi->density.rho_dh -= mj * (hydro_dimension * wi + ui * wi_dx); pi->density.rho_dh -= mj * (hydro_dimension * wi + ui * wi_dx);
pi->pressure_bar += mj * wi * pj->u; pi->pressure_bar += mj * wi * pj->u;
pi->density.pressure_bar_dh -= pi->density.pressure_bar_dh -=
mj * pj->u * (hydro_dimension * wi + ui * wi_dx); mj * pj->u * (hydro_dimension * wi + ui * wi_dx);
...@@ -113,6 +115,26 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( ...@@ -113,6 +115,26 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
pj->density.rot_v[0] += facj * curlvr[0]; pj->density.rot_v[0] += facj * curlvr[0];
pj->density.rot_v[1] += facj * curlvr[1]; pj->density.rot_v[1] += facj * curlvr[1];
pj->density.rot_v[2] += facj * curlvr[2]; pj->density.rot_v[2] += facj * curlvr[2];
#ifdef SWIFT_DEBUG_CHECKS
if (pi->u < -FLT_MIN)
error("Particle %lld has negative u=%.3e\n", pi->id, pi->u);
if (pj->u < -FLT_MIN)
error("Particle %lld has negative u=%.3e\n", pj->id, pj->u);
if (pi->pressure_bar < -FLT_MIN)
error("Particle %lld has negative P_bar=%.3e\n", pi->id, pi->pressure_bar);
if (pi->rho < -FLT_MIN)
error("Particle %lld has negative rho=%.3e\n", pi->id, pi->rho);
if (mj < -FLT_MIN)
error("Particle %lld has negative m=%.3e\n", pj->id, mj);
if (wi < -FLT_MIN)
error("Particle %lld has negative rho=%.3e\n", pi->id, wi);
#endif
} }
/** /**
...@@ -146,7 +168,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( ...@@ -146,7 +168,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
pi->rho += mj * wi; pi->rho += mj * wi;
pi->density.rho_dh -= mj * (hydro_dimension * wi + ui * wi_dx); pi->density.rho_dh -= mj * (hydro_dimension * wi + ui * wi_dx);
pi->pressure_bar += mj * wi * pj->u; pi->pressure_bar += mj * wi * pj->u;
pi->density.pressure_bar_dh -= pi->density.pressure_bar_dh -=
mj * pj->u * (hydro_dimension * wi + ui * wi_dx); mj * pj->u * (hydro_dimension * wi + ui * wi_dx);
pi->density.wcount += wi; pi->density.wcount += wi;
...@@ -171,6 +195,23 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( ...@@ -171,6 +195,23 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
pi->density.rot_v[0] += faci * curlvr[0]; pi->density.rot_v[0] += faci * curlvr[0];
pi->density.rot_v[1] += faci * curlvr[1]; pi->density.rot_v[1] += faci * curlvr[1];
pi->density.rot_v[2] += faci * curlvr[2]; pi->density.rot_v[2] += faci * curlvr[2];
#ifdef SWIFT_DEBUG_CHECKS
if (pi->u < -FLT_MIN)
error("Particle %lld has negative u=%.3e\n", pi->id, pi->u);
if (pi->pressure_bar < -FLT_MIN)
error("Particle %lld has negative P_bar=%.3e\n", pi->id, pi->pressure_bar);
if (pi->rho < -FLT_MIN)
error("Particle %lld has negative rho=%.3e\n", pi->id, pi->rho);
if (mj < -FLT_MIN)
error("Particle %lld has negative m=%.3e\n", pj->id, mj);
if (wi < -FLT_MIN)
error("Particle %lld has negative rho=%.3e\n", pi->id, wi);
#endif
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment