hydro_part.h 5.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*******************************************************************************
 * This file is part of SWIFT.
 * Coypright (c) 2019 Josh Borrow (joshua.borrow@durham.ac.uk) &
 *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
 *
 * 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/>.
 *
 ******************************************************************************/
Josh Borrow's avatar
Josh Borrow committed
20
21
#ifndef SWIFT_SPHENIX_HYDRO_PART_H
#define SWIFT_SPHENIX_HYDRO_PART_H
22
23

/**
Josh Borrow's avatar
Josh Borrow committed
24
 * @file SPHENIX/hydro_part.h
25
 * @brief Density-Energy conservative implementation of SPH,
Josh Borrow's avatar
Josh Borrow committed
26
 *        with added SPHENIX physics (Borrow 2020) (particle definition)
27
28
 */

29
#include "black_holes_struct.h"
30
31
#include "chemistry_struct.h"
#include "cooling_struct.h"
Loic Hausammann's avatar
Loic Hausammann committed
32
#include "pressure_floor_struct.h"
33
#include "star_formation_struct.h"
34
#include "timestep_limiter_struct.h"
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "tracers_struct.h"

/**
 * @brief Particle fields not needed during the SPH loops over neighbours.
 *
 * This structure contains the particle fields that are not used in the
 * density or force loops. Quantities should be used in the kick, drift and
 * potentially ghost tasks only.
 */
struct xpart {

  /*! Offset between current position and position at last tree rebuild. */
  float x_diff[3];

  /*! Offset between the current position and position at the last sort. */
  float x_diff_sort[3];

  /*! Velocity at the last full step. */
  float v_full[3];

  /*! Gravitational acceleration at the last full step. */
  float a_grav[3];

  /*! Internal energy at the last full step. */
  float u_full;

  /*! Additional data used to record cooling information */
  struct cooling_xpart_data cooling_data;

  /* Additional data used by the tracers */
  struct tracers_xpart_data tracers_data;

  /* Additional data used by the tracers */
  struct star_formation_xpart_data sf_data;

} SWIFT_STRUCT_ALIGN;

/**
 * @brief Particle fields for the SPH particles
 *
 * The density and force substructures are used to contain variables only used
 * within the density and force loops over neighbours. All more permanent
 * variables should be declared in the main part of the part structure,
 */
struct part {

  /*! Particle unique ID. */
  long long id;

  /*! Pointer to corresponding gravity part. */
  struct gpart* gpart;

  /*! Particle position. */
  double x[3];

  /*! Particle predicted velocity. */
  float v[3];

  /*! Particle acceleration. */
  float a_hydro[3];

  /*! Particle mass. */
  float mass;

  /*! Particle smoothing length. */
  float h;

  /*! Particle internal energy. */
  float u;

  /*! Time derivative of the internal energy. */
  float u_dt;

  /*! Particle density. */
  float rho;

  /* Store viscosity information in a separate struct. */
  struct {

    /*! Particle velocity divergence */
    float div_v;

    /*! Particle velocity divergence from previous step */
    float div_v_previous_step;

    /*! Artificial viscosity parameter */
    float alpha;

    /*! Signal velocity */
    float v_sig;

  } viscosity;

  /* Store thermal diffusion information in a separate struct. */
  struct {

    /*! del^2 u, a smoothed quantity */
    float laplace_u;

    /*! Thermal diffusion coefficient */
    float alpha;

  } diffusion;

  /* Store density/force specific stuff. */
  union {

    /**
     * @brief Structure for the variables only used in the density loop over
     * neighbours.
     *
     * Quantities in this sub-structure should only be accessed in the density
     * loop over neighbours and the ghost task.
     */
    struct {

      /*! Neighbour number count. */
      float wcount;

      /*! Derivative of the neighbour number with respect to h. */
      float wcount_dh;

      /*! Derivative of density with respect to h */
      float rho_dh;

      /*! Particle velocity curl. */
      float rot_v[3];

    } density;

    /**
     * @brief Structure for the variables only used in the force loop over
     * neighbours.
     *
     * Quantities in this sub-structure should only be accessed in the force
     * loop over neighbours and the ghost, drift and kick tasks.
     */
    struct {

      /*! "Grad h" term -- only partial in P-U */
      float f;

      /*! Particle pressure. */
      float pressure;

      /*! Particle soundspeed. */
      float soundspeed;

      /*! Time derivative of smoothing length  */
      float h_dt;

      /*! Balsara switch */
      float balsara;

189
190
191
      /*! Maximal alpha (viscosity) over neighbours */
      float alpha_visc_max_ngb;

192
193
194
195
196
197
    } force;
  };

  /* Chemistry information */
  struct chemistry_part_data chemistry_data;

198
199
200
  /*! Black holes information (e.g. swallowing ID) */
  struct black_holes_part_data black_holes_data;

Loic Hausammann's avatar
Loic Hausammann committed
201
202
203
  /* Additional data used by the pressure floor */
  struct pressure_floor_part_data pressure_floor_data;

204
205
206
  /*! Time-step length */
  timebin_t time_bin;

207
208
  /*! Time-step limiter information */
  struct timestep_limiter_data limiter_data;
209

210
211
212
213
214
215
216
217
218
219
220
221
#ifdef SWIFT_DEBUG_CHECKS

  /* Time of the last drift */
  integertime_t ti_drift;

  /* Time of the last kick */
  integertime_t ti_kick;

#endif

} SWIFT_STRUCT_ALIGN;

Josh Borrow's avatar
Josh Borrow committed
222
#endif /* SWIFT_SPHENIX_HYDRO_PART_H */