hydro_part.h 3.43 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.
 */

34
35
#include "cooling_struct.h"

36
/* Extra particle data not needed during the SPH loops over neighbours. */
37
38
struct xpart {

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

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

45
46
47
  /* Entropy at the last full step. */
  float entropy_full;

48
49
50
  /* Additional data used to record cooling information */
  struct cooling_xpart_data cooling_data;

51
} SWIFT_STRUCT_ALIGN;
52
53
54
55

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

56
57
58
59
60
61
  /* Particle ID. */
  long long id;

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

62
63
64
65
66
67
68
  /* Particle position. */
  double x[3];

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

  /* Particle acceleration. */
Matthieu Schaller's avatar
Matthieu Schaller committed
69
  float a_hydro[3];
70
71
72
73

  /* Particle cutoff radius. */
  float h;

74
75
  /* Particle mass. */
  float mass;
76

77
78
79
  /* Particle density. */
  float rho;

80
81
  /* Particle entropy. */
  float entropy;
82

83
84
85
  /* Entropy time derivative */
  float entropy_dt;

Matthieu Schaller's avatar
Matthieu Schaller committed
86
87
  union {

88
89
    struct {

90
      /* Number of neighbours. */
91
      float wcount;
Matthieu Schaller's avatar
Matthieu Schaller committed
92

93
      /* Number of neighbours spatial derivative. */
94
      float wcount_dh;
Matthieu Schaller's avatar
Matthieu Schaller committed
95

96
97
98
      /* Derivative of the density with respect to h. */
      float rho_dh;

99
      /* Particle velocity curl. */
100
      float rot_v[3];
Matthieu Schaller's avatar
Matthieu Schaller committed
101

102
103
104
      /* Particle velocity divergence. */
      float div_v;

105
106
107
    } density;

    struct {
Matthieu Schaller's avatar
Matthieu Schaller committed
108

109
110
      /* Balsara switch */
      float balsara;
111

112
113
114
      /*! "Grad h" term */
      float f;

115
      /* Pressure over density squared  */
Matthieu Schaller's avatar
Matthieu Schaller committed
116
      float P_over_rho2;
117

118
      /* Particle sound speed. */
119
      float soundspeed;
Matthieu Schaller's avatar
Matthieu Schaller committed
120

Matthieu Schaller's avatar
Matthieu Schaller committed
121
122
      /* Signal velocity. */
      float v_sig;
123

124
125
126
      /* Time derivative of the smoothing length */
      float h_dt;

127
128
    } force;
  };
Matthieu Schaller's avatar
Matthieu Schaller committed
129

130
131
  /* Time-step length */
  timebin_t time_bin;
132

133
134
135
136
137
138
139
140
141
142
#ifdef SWIFT_DEBUG_CHECKS

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

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

#endif

143
} SWIFT_STRUCT_ALIGN;
144
145

#endif /* SWIFT_GADGET2_HYDRO_PART_H */