From af100ef5ec520d1703cb40f747dc95f751fa82a3 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 2 Jun 2017 12:39:26 +0100 Subject: [PATCH] Also set the value of rho and wcount to sensible values when no neighbours are found. --- src/hydro/Default/hydro.h | 7 +++++++ src/hydro/Gadget2/hydro.h | 7 +++++++ src/hydro/Gizmo/hydro.h | 6 ++++++ src/hydro/Minimal/hydro.h | 7 +++++++ src/hydro/PressureEntropy/hydro.h | 8 ++++++++ src/hydro/Shadowswift/hydro.h | 6 ++++++ 6 files changed, 41 insertions(+) diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index 5f67320bc5..31f0c41720 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -228,7 +228,14 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part *restrict p, struct xpart *restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->rho = p->mass * kernel_root * h_inv_dim; + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->rho_dh = 0.f; p->density.wcount_dh = 0.f; p->density.div_v = 0.f; diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index d812a1c700..24cf766d1c 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -233,7 +233,14 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part *restrict p, struct xpart *restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->rho = p->mass * kernel_root * h_inv_dim; + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->density.rho_dh = 0.f; p->density.wcount_dh = 0.f; p->density.div_v = 0.f; diff --git a/src/hydro/Gizmo/hydro.h b/src/hydro/Gizmo/hydro.h index d2122a6e29..5b38637c8c 100644 --- a/src/hydro/Gizmo/hydro.h +++ b/src/hydro/Gizmo/hydro.h @@ -375,7 +375,13 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part* restrict p, struct xpart* restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->density.wcount_dh = 0.f; } diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index ab2eb30f4c..9fffc6d888 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -236,7 +236,14 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part *restrict p, struct xpart *restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->rho = p->mass * kernel_root * h_inv_dim; + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->density.rho_dh = 0.f; p->density.wcount_dh = 0.f; } diff --git a/src/hydro/PressureEntropy/hydro.h b/src/hydro/PressureEntropy/hydro.h index 289640722a..d3de13b8a3 100644 --- a/src/hydro/PressureEntropy/hydro.h +++ b/src/hydro/PressureEntropy/hydro.h @@ -245,7 +245,15 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part *restrict p, struct xpart *restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->rho = p->mass * kernel_root * h_inv_dim; + p->rho_bar = p->mass * p->entropy_one_over_gamma * kernel_root * h_inv_dim; + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->density.rho_dh = 0.f; p->density.wcount_dh = 0.f; p->density.pressure_dh = 0.f; // MATTHIEU: to be checked diff --git a/src/hydro/Shadowswift/hydro.h b/src/hydro/Shadowswift/hydro.h index 51b5fcd87f..abbcdcd2f7 100644 --- a/src/hydro/Shadowswift/hydro.h +++ b/src/hydro/Shadowswift/hydro.h @@ -247,7 +247,13 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours( struct part* restrict p, struct xpart* restrict xp) { + /* Some smoothing length multiples. */ + const float h = p->h; + const float h_inv = 1.0f / h; /* 1/h */ + const float h_inv_dim = pow_dimension(h_inv); /* 1/h^d */ + /* Re-set problematic values */ + p->density.wcount = kernel_root * kernel_norm * h_inv_dim; p->density.wcount_dh = 0.f; } -- GitLab