black_holes_struct.h 3.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (c) 2019 Matthieu Schaller (schaller@strw.leidenuniv.nl)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/
#ifndef SWIFT_BLACK_HOLES_STRUCT_EAGLE_H
#define SWIFT_BLACK_HOLES_STRUCT_EAGLE_H

Matthieu Schaller's avatar
Matthieu Schaller committed
22
23
24
25
/* Standard headers */
#include <float.h>

/* Local includes */
26
27
#include "inline.h"

28
29
30
31
32
33
34
/**
 * @brief Black holes-related fields carried by each *gas* particle.
 */
struct black_holes_part_data {

  /*! ID of the black-hole that will swallow this #part. */
  long long swallow_id;
Matthieu Schaller's avatar
Matthieu Schaller committed
35
36
37

  /*! Gravitational potential of the particle (for repositioning) */
  float potential;
38
39
};

40
41
42
43
44
45
46
/**
 * @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;
47
48
49

  /*! Mass of the black-hole that will swallow this #bpart. */
  float swallow_mass;
50
51
52
53
54
55
56
57
58
};

/**
 * @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
59
black_holes_mark_part_as_not_swallowed(struct black_holes_part_data* p_data) {
60
61
62
63

  p_data->swallow_id = -1;
}

64
65
66
67
68
/**
 * @brief Reset the particle-carried potential at the start of a time-step.
 *
 * @param p_data The #part's black hole data.
 */
Matthieu Schaller's avatar
Matthieu Schaller committed
69
70
71
72
73
__attribute__((always_inline)) INLINE static void black_holes_init_potential(
    struct black_holes_part_data* p_data) {
  p_data->potential = FLT_MAX;
}

74
75
76
77
78
79
/**
 * @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.
 */
80
81
__attribute__((always_inline)) INLINE static void
black_holes_mark_part_as_swallowed(struct black_holes_part_data* p_data) {
82
83
84
85
86
87
88
89
90
91

  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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
black_holes_get_part_swallow_id(struct black_holes_part_data* p_data) {

  return p_data->swallow_id;
}

/**
 * @brief Update a given #bpart's BH data field to mark the particle has
 * not yet been swallowed.
 *
 * @param p_data The #bpart's #black_holes_bpart_data structure.
 */
__attribute__((always_inline)) INLINE static void
black_holes_mark_bpart_as_not_swallowed(struct black_holes_bpart_data* p_data) {

  p_data->swallow_id = -1;
107
  p_data->swallow_mass = 0.f;
108
109
110
111
112
113
114
115
116
}

/**
 * @brief Update a given #bpart's BH data field to mark the particle has
 * having been been swallowed.
 *
 * @param p_data The #bpart's #black_holes_bpart_data structure.
 */
__attribute__((always_inline)) INLINE static void
117
black_holes_mark_bpart_as_merged(struct black_holes_bpart_data* p_data) {
118
119

  p_data->swallow_id = -2;
120
  p_data->swallow_mass = -1.f;
121
122
123
124
125
126
127
128
129
}

/**
 * @brief Return the ID of the BH that should swallow this #bpart.
 *
 * @param p_data The #bpart's #black_holes_bpart_data structure.
 */
__attribute__((always_inline)) INLINE static long long
black_holes_get_bpart_swallow_id(struct black_holes_bpart_data* p_data) {
130
131
132
133

  return p_data->swallow_id;
}

134
#endif /* SWIFT_BLACK_HOLES_STRUCT_EAGLE_H */