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

Added a check to verify that a field tensor has been initialised before use.

parent fa6bd92d
...@@ -96,6 +96,9 @@ struct grav_tensor { ...@@ -96,6 +96,9 @@ struct grav_tensor {
/* Total number of gpart this field tensor interacted with */ /* Total number of gpart this field tensor interacted with */
long long num_interacted; long long num_interacted;
/* Last time this tensor was zeroed */
integertime_t ti_init;
#endif #endif
}; };
...@@ -232,9 +235,14 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) { ...@@ -232,9 +235,14 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) {
* *
* @param l The field tensor. * @param l The field tensor.
*/ */
INLINE static void gravity_field_tensors_init(struct grav_tensor *l) { INLINE static void gravity_field_tensors_init(struct grav_tensor *l,
integertime_t ti_current) {
bzero(l, sizeof(struct grav_tensor)); bzero(l, sizeof(struct grav_tensor));
#ifdef SWIFT_DEBUG_CHECKS
l->ti_init = ti_current;
#endif
} }
/** /**
...@@ -2185,7 +2193,7 @@ INLINE static void gravity_L2L(struct grav_tensor *la, ...@@ -2185,7 +2193,7 @@ INLINE static void gravity_L2L(struct grav_tensor *la,
const double pos_a[3], const double pos_b[3]) { const double pos_a[3], const double pos_b[3]) {
/* Initialise everything to zero */ /* Initialise everything to zero */
gravity_field_tensors_init(la); gravity_field_tensors_init(la, 0);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (lb->num_interacted == 0) error("Shifting tensors that did not interact"); if (lb->num_interacted == 0) error("Shifting tensors that did not interact");
......
...@@ -557,7 +557,7 @@ void runner_do_init_grav(struct runner *r, struct cell *c, int timer) { ...@@ -557,7 +557,7 @@ void runner_do_init_grav(struct runner *r, struct cell *c, int timer) {
cell_drift_multipole(c, e); cell_drift_multipole(c, e);
/* Reset the gravity acceleration tensors */ /* Reset the gravity acceleration tensors */
gravity_field_tensors_init(&c->multipole->pot); gravity_field_tensors_init(&c->multipole->pot, e->ti_current);
/* Recurse? */ /* Recurse? */
if (c->split) { if (c->split) {
......
...@@ -47,6 +47,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) { ...@@ -47,6 +47,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (c->ti_old_multipole != e->ti_current) error("c->multipole not drifted."); if (c->ti_old_multipole != e->ti_current) error("c->multipole not drifted.");
if (c->multipole->pot.ti_init != e->ti_current)
error("c->field tensor not initialised");
#endif #endif
if (c->split) { /* Node case */ if (c->split) { /* Node case */
...@@ -61,6 +63,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) { ...@@ -61,6 +63,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (cp->ti_old_multipole != e->ti_current) if (cp->ti_old_multipole != e->ti_current)
error("cp->multipole not drifted."); error("cp->multipole not drifted.");
if (cp->multipole->pot.ti_init != e->ti_current)
error("cp->field tensor not initialised");
#endif #endif
struct grav_tensor shifted_tensor; struct grav_tensor shifted_tensor;
...@@ -137,8 +141,8 @@ void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci, ...@@ -137,8 +141,8 @@ void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci,
if (multi_j->M_000 == 0.f) error("Multipole does not seem to have been set."); if (multi_j->M_000 == 0.f) error("Multipole does not seem to have been set.");
if (ci->ti_old_multipole != e->ti_current) if (ci->multipole->pot.ti_init != e->ti_current)
error("ci->multipole not drifted."); error("ci->grav tensor not initialised.");
#endif #endif
/* Do we need to drift the multipole ? */ /* Do we need to drift the multipole ? */
......
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