From 8dbefb16bca67ba83b8923c3eebba11ac5ac39a1 Mon Sep 17 00:00:00 2001 From: Bert Vandenbroucke <bert.vandenbroucke@gmail.com> Date: Fri, 6 Jul 2018 19:48:37 +0100 Subject: [PATCH] Fixed bug in test27cells when running shadowfax hydro. Tried to fix 1D shadowswift, no success yet. --- src/hydro/Shadowswift/hydro.h | 5 +++-- src/hydro_properties.c | 1 + tests/test27cells.c | 14 +++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hydro/Shadowswift/hydro.h b/src/hydro/Shadowswift/hydro.h index 70eb5d3230..aa8477ad3d 100644 --- a/src/hydro/Shadowswift/hydro.h +++ b/src/hydro/Shadowswift/hydro.h @@ -182,12 +182,13 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( if (hnew < p->h) { /* Iteration succesful: we accept, but manually set h to a smaller value for the next time step */ - p->density.wcount = 1.0f; + const float hinvdim = pow_dimension(1.0f / p->h); + p->density.wcount = hinvdim; p->h = 1.1f * hnew; } else { /* Iteration not succesful: we force h to become 1.1*hnew */ p->density.wcount = 0.0f; - p->density.wcount_dh = 1.0f / (1.1f * hnew - p->h); + p->density.wcount_dh = p->h / (1.1f * hnew - p->h); return; } volume = p->cell.volume; diff --git a/src/hydro_properties.c b/src/hydro_properties.c index c5448f7735..5540d8c33c 100644 --- a/src/hydro_properties.c +++ b/src/hydro_properties.c @@ -72,6 +72,7 @@ void hydro_props_init(struct hydro_props *p, /* change the meaning of target_neighbours and delta_neighbours */ p->target_neighbours = 1.0f; p->delta_neighbours = 0.0f; + p->eta_neighbours = 1.0f; #endif /* Maximal smoothing length */ diff --git a/tests/test27cells.c b/tests/test27cells.c index ada1b782cf..f62c169486 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -217,8 +217,20 @@ void clean_up(struct cell *ci) { * @brief Initializes all particles field to be ready for a density calculation */ void zero_particle_fields(struct cell *c) { +#ifdef SHADOWFAX_SPH + struct hydro_space hs; + hs.anchor[0] = 0.; + hs.anchor[1] = 0.; + hs.anchor[2] = 0.; + hs.side[0] = 1.; + hs.side[1] = 1.; + hs.side[2] = 1.; + struct hydro_space *hspointer = &hs; +#else + struct hydro_space *hspointer = NULL; +#endif for (int pid = 0; pid < c->count; pid++) { - hydro_init_part(&c->parts[pid], NULL); + hydro_init_part(&c->parts[pid], hspointer); } } -- GitLab