From df9e7d53aebf32cc9831b3efb032e9b87aea72c1 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Mon, 1 Jul 2019 13:58:52 +0200 Subject: [PATCH] Move the part-related swallowing functions to the black_holes_struct file. Added a structure for the merging of BHs. --- src/black_holes/Default/black_holes.h | 36 ---------------- src/black_holes/Default/black_holes_part.h | 3 ++ src/black_holes/Default/black_holes_struct.h | 41 ++++++++++++++++++ src/black_holes/EAGLE/black_holes.h | 35 ---------------- src/black_holes/EAGLE/black_holes_part.h | 3 ++ src/black_holes/EAGLE/black_holes_struct.h | 44 ++++++++++++++++++++ 6 files changed, 91 insertions(+), 71 deletions(-) diff --git a/src/black_holes/Default/black_holes.h b/src/black_holes/Default/black_holes.h index ebc5a36841..a87f5dd902 100644 --- a/src/black_holes/Default/black_holes.h +++ b/src/black_holes/Default/black_holes.h @@ -156,42 +156,6 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_part( /* Nothing to do here: No swallowing in the default model */ } -/** - * @brief Update a given #part's BH data field to mark the particle has - * not yet been swallowed. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static void -black_holes_mark_as_not_swallowed(struct black_holes_part_data* p_data) { - - /* Nothing to do here: No swallowing in the default model */ -} - -/** - * @brief Update a given #part's BH data field to mark the particle has - * having been been swallowed. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static void black_holes_mark_as_swallowed( - struct black_holes_part_data* p_data) { - - /* Nothing to do here: No swallowing in the default model */ -} - -/** - * @brief Return the ID of the BH that should swallow this #part. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static long long -black_holes_get_swallow_id(struct black_holes_part_data* p_data) { - - /* Return a non-existing ID */ - return -1; -} - /** * @brief Compute the accretion rate of the black hole and all the quantites * required for the feedback loop. diff --git a/src/black_holes/Default/black_holes_part.h b/src/black_holes/Default/black_holes_part.h index db8c9b18cb..5d614aa873 100644 --- a/src/black_holes/Default/black_holes_part.h +++ b/src/black_holes/Default/black_holes_part.h @@ -66,6 +66,9 @@ struct bpart { * content, etc.) */ struct chemistry_bpart_data chemistry_data; + /*! Black holes merger information (e.g. merging ID) */ + struct black_holes_bpart_data merger_data; + #ifdef SWIFT_DEBUG_CHECKS /* Time of the last drift */ diff --git a/src/black_holes/Default/black_holes_struct.h b/src/black_holes/Default/black_holes_struct.h index 3fdb0ee882..7c922a69a2 100644 --- a/src/black_holes/Default/black_holes_struct.h +++ b/src/black_holes/Default/black_holes_struct.h @@ -24,4 +24,45 @@ */ struct black_holes_part_data {}; +/** + * @brief Black holes-related fields carried by each *BH* particle. + */ +struct black_holes_bpart_data {}; + +/** + * @brief Update a given #part's BH data field to mark the particle has + * not yet been swallowed. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static void +black_holes_mark_as_not_swallowed(struct black_holes_part_data* p_data) { + + /* Nothing to do here: No swallowing in the default model */ +} + +/** + * @brief Update a given #part's BH data field to mark the particle has + * having been been swallowed. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static void black_holes_mark_as_swallowed( + struct black_holes_part_data* p_data) { + + /* Nothing to do here: No swallowing in the default model */ +} + +/** + * @brief Return the ID of the BH that should swallow this #part. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static long long +black_holes_get_swallow_id(struct black_holes_part_data* p_data) { + + /* Return a non-existing ID */ + return -1; +} + #endif /* SWIFT_BLACK_HOLES_STRUCT_DEFAULT_H */ diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index a9a40b1cfb..88178da8c4 100644 --- a/src/black_holes/EAGLE/black_holes.h +++ b/src/black_holes/EAGLE/black_holes.h @@ -234,41 +234,6 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_part( bp->ngb_mass -= gas_mass; } -/** - * @brief Update a given #part's BH data field to mark the particle has - * not yet been swallowed. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static void -black_holes_mark_as_not_swallowed(struct black_holes_part_data* p_data) { - - p_data->swallow_id = -1; -} - -/** - * @brief Update a given #part's BH data field to mark the particle has - * having been been swallowed. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static void black_holes_mark_as_swallowed( - struct black_holes_part_data* p_data) { - - p_data->swallow_id = -2; -} - -/** - * @brief Return the ID of the BH that should swallow this #part. - * - * @param p_data The #part's #black_holes_part_data structure. - */ -__attribute__((always_inline)) INLINE static long long -black_holes_get_swallow_id(struct black_holes_part_data* p_data) { - - return p_data->swallow_id; -} - /** * @brief Compute the accretion rate of the black hole and all the quantites * required for the feedback loop. diff --git a/src/black_holes/EAGLE/black_holes_part.h b/src/black_holes/EAGLE/black_holes_part.h index 598edffeca..3c10fb8963 100644 --- a/src/black_holes/EAGLE/black_holes_part.h +++ b/src/black_holes/EAGLE/black_holes_part.h @@ -118,6 +118,9 @@ struct bpart { * content, etc.) */ struct chemistry_bpart_data chemistry_data; + /*! Black holes merger information (e.g. merging ID) */ + struct black_holes_bpart_data merger_data; + #ifdef SWIFT_DEBUG_CHECKS /* Time of the last drift */ diff --git a/src/black_holes/EAGLE/black_holes_struct.h b/src/black_holes/EAGLE/black_holes_struct.h index cf0e9c3975..d85dc44298 100644 --- a/src/black_holes/EAGLE/black_holes_struct.h +++ b/src/black_holes/EAGLE/black_holes_struct.h @@ -28,4 +28,48 @@ struct black_holes_part_data { long long swallow_id; }; +/** + * @brief Black holes-related fields carried by each *BH* particle. + */ +struct black_holes_bpart_data { + + /*! ID of the black-hole that will swallow this #bpart. */ + long long swallow_id; +}; + +/** + * @brief Update a given #part's BH data field to mark the particle has + * not yet been swallowed. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static void +black_holes_mark_as_not_swallowed(struct black_holes_part_data* p_data) { + + p_data->swallow_id = -1; +} + +/** + * @brief Update a given #part's BH data field to mark the particle has + * having been been swallowed. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static void black_holes_mark_as_swallowed( + struct black_holes_part_data* p_data) { + + p_data->swallow_id = -2; +} + +/** + * @brief Return the ID of the BH that should swallow this #part. + * + * @param p_data The #part's #black_holes_part_data structure. + */ +__attribute__((always_inline)) INLINE static long long +black_holes_get_swallow_id(struct black_holes_part_data* p_data) { + + return p_data->swallow_id; +} + #endif /* SWIFT_BLACK_HOLES_STRUCT_EAGLE_H */ -- GitLab