hydro_part.h 4.96 KB
Newer Older
1
2
/*******************************************************************************
 * This file is part of SWIFT.
3
 * Copyright (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/>.
 *
 ******************************************************************************/
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef SWIFT_MINIMAL_HYDRO_PART_H
#define SWIFT_MINIMAL_HYDRO_PART_H

/**
 * @file Minimal/hydro_part.h
 * @brief Minimal conservative implementation of SPH (Particle definition)
 *
 * The thermal variable is the internal energy (u). Simple constant
 * viscosity term without switches is implemented. No thermal conduction
 * term is implemented.
 *
 * This corresponds to equations (43), (44), (45), (101), (103)  and (104) with
31
32
 * \f$\beta=3\f$ and \f$\alpha_u=0\f$ of Price, D., Journal of Computational
 * Physics, 2012, Volume 231, Issue 3, pp. 759-794.
33
 */
34

35
#include "chemistry_struct.h"
36
#include "cooling_struct.h"
37
#include "star_formation_struct.h"
38
#include "tracers_struct.h"
39

40
41
42
43
44
45
46
/**
 * @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.
 */
47
48
struct xpart {

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

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

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

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

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

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

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

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

73
} SWIFT_STRUCT_ALIGN;
74

75
76
77
78
79
80
81
/**
 * @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,
 */
82
83
struct part {

84
85
86
87
88
89
  /*! Particle unique ID. */
  long long id;

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

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

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

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

99
100
  /*! Particle mass. */
  float mass;
101

102
103
  /*! Particle smoothing length. */
  float h;
104

105
106
  /*! Particle internal energy. */
  float u;
107

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

111
112
  /*! Particle density. */
  float rho;
113
114

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

117
118
119
120
121
122
123
    /**
     * @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.
     */
124
    struct {
125

126
127
128
129
130
      /*! Neighbour number count. */
      float wcount;

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

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

Josh Borrow's avatar
Josh Borrow committed
135
136
137
138
139
140
      /*! Velocity divergence */
      float div_v;

      /*! Velocity curl */
      float rot_v[3];

141
    } density;
142

143
144
145
146
147
    /**
     * @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
148
     * loop over neighbours and the ghost, drift and kick tasks.
149
     */
150
    struct {
151

152
153
154
      /*! "Grad h" term */
      float f;

155
156
      /*! Particle pressure. */
      float pressure;
157

158
159
160
      /*! Particle soundspeed. */
      float soundspeed;

161
162
      /*! Particle signal velocity */
      float v_sig;
163

164
165
      /*! Time derivative of smoothing length  */
      float h_dt;
166

Josh Borrow's avatar
Josh Borrow committed
167
168
169
      /*! Balsara switch */
      float balsara;

170
171
    } force;
  };
172

173
174
175
  /* Chemistry information */
  struct chemistry_part_data chemistry_data;

176
177
  /*! Time-step length */
  timebin_t time_bin;
178

179
  /* Need waking-up ? */
Josh Borrow's avatar
Josh Borrow committed
180
  timebin_t wakeup;
181

182
183
184
185
186
187
188
189
190
#ifdef SWIFT_DEBUG_CHECKS

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

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

#endif
191

192
} SWIFT_STRUCT_ALIGN;
193
194

#endif /* SWIFT_MINIMAL_HYDRO_PART_H */