hydro_part.h 4.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@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/>.
 *
 ******************************************************************************/
19
20
#ifndef SWIFT_GADGET2_HYDRO_PART_H
#define SWIFT_GADGET2_HYDRO_PART_H
21

22
23
24
25
26
27
28
29
30
31
32
33
/**
 * @file Gadget2/hydro_part.h
 * @brief SPH interaction functions following the Gadget-2 version of SPH.
 *
 * The interactions computed here are the ones presented in the Gadget-2 paper
 * Springel, V., MNRAS, Volume 364, Issue 4, pp. 1105-1134.
 * We use the same numerical coefficients as the Gadget-2 code. When used with
 * the Spline-3 kernel, the results should be equivalent to the ones obtained
 * with Gadget-2 up to the rounding errors and interactions missed by the
 * Gadget-2 tree-code neighbours search.
 */

lhausamm's avatar
lhausamm committed
34
#include "chemistry_struct.h"
lhausamm's avatar
lhausamm committed
35
#include "cooling_struct.h"
Loic Hausammann's avatar
Loic Hausammann committed
36
#include "logger.h"
37
#include "tracers_struct.h"
38

39
/* Extra particle data not needed during the SPH loops over neighbours. */
40
41
struct xpart {

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

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

48
49
  /* Velocity at the last full step. */
  float v_full[3];
Matthieu Schaller's avatar
Matthieu Schaller committed
50

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

54
55
56
  /* Entropy at the last full step. */
  float entropy_full;

57
58
59
  /* Additional data used to record cooling information */
  struct cooling_xpart_data cooling_data;

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

lhausamm's avatar
lhausamm committed
63
#ifdef WITH_LOGGER
64
  /* Additional data for the particle logger */
lhausamm's avatar
lhausamm committed
65
  struct logger_part_data logger_data;
lhausamm's avatar
lhausamm committed
66
#endif
lhausamm's avatar
lhausamm committed
67

68
} SWIFT_STRUCT_ALIGN;
69
70
71
72

/* Data of a single particle. */
struct part {

73
74
75
76
77
78
  /* Particle ID. */
  long long id;

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

79
80
81
82
83
84
85
  /* Particle position. */
  double x[3];

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

  /* Particle acceleration. */
Matthieu Schaller's avatar
Matthieu Schaller committed
86
  float a_hydro[3];
87
88
89
90

  /* Particle cutoff radius. */
  float h;

91
92
  /* Particle mass. */
  float mass;
93

94
95
96
  /* Particle density. */
  float rho;

97
98
  /* Particle entropy. */
  float entropy;
99

100
101
102
  /* Entropy time derivative */
  float entropy_dt;

Matthieu Schaller's avatar
Matthieu Schaller committed
103
104
  union {

105
106
    struct {

107
      /* Number of neighbours. */
108
      float wcount;
Matthieu Schaller's avatar
Matthieu Schaller committed
109

110
      /* Number of neighbours spatial derivative. */
111
      float wcount_dh;
Matthieu Schaller's avatar
Matthieu Schaller committed
112

113
114
115
      /* Derivative of the density with respect to h. */
      float rho_dh;

116
      /* Particle velocity curl. */
117
      float rot_v[3];
Matthieu Schaller's avatar
Matthieu Schaller committed
118

119
120
121
      /* Particle velocity divergence. */
      float div_v;

122
123
124
    } density;

    struct {
Matthieu Schaller's avatar
Matthieu Schaller committed
125

126
127
      /* Balsara switch */
      float balsara;
128

129
130
131
      /*! "Grad h" term */
      float f;

132
      /* Pressure over density squared  */
Matthieu Schaller's avatar
Matthieu Schaller committed
133
      float P_over_rho2;
134

135
      /* Particle sound speed. */
136
      float soundspeed;
Matthieu Schaller's avatar
Matthieu Schaller committed
137

Matthieu Schaller's avatar
Matthieu Schaller committed
138
139
      /* Signal velocity. */
      float v_sig;
140

141
142
143
      /* Time derivative of the smoothing length */
      float h_dt;

144
145
    } force;
  };
Matthieu Schaller's avatar
Matthieu Schaller committed
146

147
148
149
  /* Chemistry information */
  struct chemistry_part_data chemistry_data;

150
151
  /* Time-step length */
  timebin_t time_bin;
152

153
154
155
  /* Need waking-up ? */
  char wakeup;

156
157
158
159
160
161
162
163
164
165
#ifdef SWIFT_DEBUG_CHECKS

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

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

#endif

166
#ifdef DEBUG_INTERACTIONS_SPH
167
  /*! List of interacting particles in the density SELF and PAIR */
168
  long long ids_ngbs_density[MAX_NUM_OF_NEIGHBOURS];
169
170

  /*! List of interacting particles in the force SELF and PAIR */
171
  long long ids_ngbs_force[MAX_NUM_OF_NEIGHBOURS];
172
173
174
175
176
177
178
179

  /*! Number of interactions in the density SELF and PAIR */
  int num_ngb_density;

  /*! Number of interactions in the force SELF and PAIR */
  int num_ngb_force;
#endif

180
} SWIFT_STRUCT_ALIGN;
181
182

#endif /* SWIFT_GADGET2_HYDRO_PART_H */