stars.h 4.5 KB
Newer Older
1
2
/*******************************************************************************
 * This file is part of SWIFT.
3
 * Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 *
 * 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/>.
 *
 ******************************************************************************/
Loic Hausammann's avatar
Loic Hausammann committed
19
20
#ifndef SWIFT_DEFAULT_STARS_H
#define SWIFT_DEFAULT_STARS_H
21
22
23
24
25

#include <float.h>
#include "minmax.h"

/**
26
 * @brief Computes the gravity time-step of a given star particle.
27
 *
28
 * @param sp Pointer to the s-particle data.
29
 */
Loic Hausammann's avatar
Loic Hausammann committed
30
__attribute__((always_inline)) INLINE static float stars_compute_timestep(
31
    const struct spart* const sp) {
32

33
  return FLT_MAX;
34
35
36
}

/**
37
 * @brief Initialises the s-particles for the first time
38
39
40
41
 *
 * This function is called only once just after the ICs have been
 * read in to do some conversions.
 *
42
 * @param sp The particle to act upon
43
 */
Loic Hausammann's avatar
Loic Hausammann committed
44
__attribute__((always_inline)) INLINE static void stars_first_init_spart(
45
    struct spart* sp) {
46

47
  sp->time_bin = 0;
48
49
50
}

/**
51
 * @brief Prepares a s-particle for its interactions
52
 *
53
 * @param sp The particle to act upon
54
 */
Loic Hausammann's avatar
Loic Hausammann committed
55
__attribute__((always_inline)) INLINE static void stars_init_spart(
56
  struct spart* sp) {
Loic Hausammann's avatar
Loic Hausammann committed
57

58
59
#ifdef DEBUG_INTERACTIONS_STARS
  for (int i = 0; i < MAX_NUM_OF_NEIGHBOURS_STARS; ++i) sp->ids_ngbs_density[i] = -1;
Loic Hausammann's avatar
Loic Hausammann committed
60
61
62
  sp->num_ngb_density = 0;
#endif

63
64
  sp->density.wcount = 0.f;
  sp->density.wcount_dh = 0.f;
Loic Hausammann's avatar
Loic Hausammann committed
65
}
66

67
68
69
70
/**
 * @brief Sets the values to be predicted in the drifts to their values at a
 * kick time
 *
71
 * @param sp The particle.
72
 */
Loic Hausammann's avatar
Loic Hausammann committed
73
__attribute__((always_inline)) INLINE static void stars_reset_predicted_values(
74
75
    struct spart* restrict sp) {}

76
/**
77
 * @brief Finishes the calculation of (non-gravity) forces acting on stars
78
79
80
 *
 * Multiplies the forces and accelerations by the appropiate constants
 *
81
 * @param sp The particle to act upon
82
 */
Loic Hausammann's avatar
Loic Hausammann committed
83
__attribute__((always_inline)) INLINE static void stars_end_force(
84
    struct spart* sp) {}
85
86
87
88

/**
 * @brief Kick the additional variables
 *
89
 * @param sp The particle to act upon
90
91
 * @param dt The time-step for this kick
 */
Loic Hausammann's avatar
Loic Hausammann committed
92
__attribute__((always_inline)) INLINE static void stars_kick_extra(
93
    struct spart* sp, float dt) {}
94

Loic Hausammann's avatar
Loic Hausammann committed
95
96
97
98
99
/**
 * @brief Finishes the calculation of density on stars
 *
 * @param sp The particle to act upon
 */
Loic Hausammann's avatar
Loic Hausammann committed
100
__attribute__((always_inline)) INLINE static void stars_end_density(
Loic Hausammann's avatar
Loic Hausammann committed
101
    struct spart* sp, const struct cosmology* cosmo) {
Loic Hausammann's avatar
Loic Hausammann committed
102
103
104
105
106
107
108
109

  /* Some smoothing length multiples. */
  const float h = sp->h;
  const float h_inv = 1.0f / h;                       /* 1/h */
  const float h_inv_dim = pow_dimension(h_inv);       /* 1/h^d */
  const float h_inv_dim_plus_one = h_inv_dim * h_inv; /* 1/h^(d+1) */

  /* Finish the calculation by inserting the missing h-factors */
110
111
  sp->density.wcount *= h_inv_dim;
  sp->density.wcount_dh *= h_inv_dim_plus_one;
Loic Hausammann's avatar
Loic Hausammann committed
112
113
114
115
116
117
118
119
120
}


/**
 * @brief Sets all particle fields to sensible values when the #spart has 0 ngbs.
 *
 * @param sp The particle to act upon
 * @param cosmo The current cosmological model.
 */
Loic Hausammann's avatar
Loic Hausammann committed
121
__attribute__((always_inline)) INLINE static void stars_spart_has_no_neighbours(
Loic Hausammann's avatar
Loic Hausammann committed
122
123
124
125
126
127
128
129
    struct spart *restrict sp, const struct cosmology *cosmo) {

  /* Some smoothing length multiples. */
  const float h = sp->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 */
130
131
  sp->density.wcount = kernel_root * h_inv_dim;
  sp->density.wcount_dh = 0.f;
Loic Hausammann's avatar
Loic Hausammann committed
132
133
134
}

/**
Loic Hausammann's avatar
Loic Hausammann committed
135
 * @brief Evolve the stellar properties of a #spart.
Loic Hausammann's avatar
Loic Hausammann committed
136
 *
Loic Hausammann's avatar
Loic Hausammann committed
137
138
 * This function allows for example to compute the SN rate before sending
 * this information to a different MPI rank.
Loic Hausammann's avatar
Loic Hausammann committed
139
140
141
 *
 * @param sp The particle to act upon
 * @param cosmo The current cosmological model.
Loic Hausammann's avatar
Loic Hausammann committed
142
 * @param stars_properties The #stars_props
Loic Hausammann's avatar
Loic Hausammann committed
143
 */
Loic Hausammann's avatar
Loic Hausammann committed
144
145
146
__attribute__((always_inline)) INLINE static void stars_evolve_spart(
    struct spart *restrict sp, const struct stars_props *stars_properties,
    const struct cosmology *cosmo) {}
Loic Hausammann's avatar
Loic Hausammann committed
147
148


Loic Hausammann's avatar
Loic Hausammann committed
149
#endif /* SWIFT_DEFAULT_STARS_H */