hydro_part.h 5.03 KB
Newer Older
1
2
/*******************************************************************************
 * This file is part of SWIFT.
3
4
 * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) &
 *                    Josh Borrow (joshua.borrow@durham.ac.uk)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * 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/>.
 *
 ******************************************************************************/
#ifndef SWIFT_PRESSURE_ENERGY_HYDRO_PART_H
#define SWIFT_PRESSURE_ENERGY_HYDRO_PART_H
/**
23
24
 * @file PressureEnergy/hydro_part.h
 * @brief P-U implementation of SPH (Particle definition)
25
 *
26
27
 * The thermal variable is the internal energy (u). A simple constant
 * viscosity term with a Balsara switch is implemented.
28
 *
29
30
31
 * No thermal conduction term is implemented.
 *
 * See PressureEnergy/hydro.h for references.
32
33
 */

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

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

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

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

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

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

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

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

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

69
70
71
  /*! Additional data used by the star formation */
  struct star_formation_xpart_data sf_data;

72
73
} SWIFT_STRUCT_ALIGN;

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

83
  /*! Particle unique ID. */
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  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];

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

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

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

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

110
111
  /*! Particle density. */
  float rho;
Josh Borrow's avatar
Josh Borrow committed
112

113
114
  /*! Particle pressure (weighted) */
  float pressure_bar;
115

116
  /* Store density/force specific stuff. */
Josh Borrow's avatar
Josh Borrow committed
117
  union {
118

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

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

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

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

Josh Borrow's avatar
Josh Borrow committed
137
      /*! Derivative of the weighted pressure with respect to h */
138
      float pressure_bar_dh;
Josh Borrow's avatar
Josh Borrow committed
139

Josh Borrow's avatar
Josh Borrow committed
140
141
      /*! Particle velocity curl. */
      float rot_v[3];
142

Josh Borrow's avatar
Josh Borrow committed
143
144
      /*! Particle velocity divergence. */
      float div_v;
145
146
    } density;

147
148
149
150
151
152
153
    /**
     * @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.
     */
154
155
    struct {

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

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

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

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

Josh Borrow's avatar
Josh Borrow committed
168
169
      /*! Balsara switch */
      float balsara;
170
    } force;
Josh Borrow's avatar
Josh Borrow committed
171
  };
172
173
174

  /* Chemistry information */
  struct chemistry_part_data chemistry_data;
175

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

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
191
192
193
#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;

194
#endif /* SWIFT_MINIMAL_HYDRO_PART_H */