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

/* Some constants. */
23
24
25
26
#define part_maxwait 3
#define part_maxunlock 39
#define part_dtmax 10
#define part_align 64
27

28
29
30
/* Extra particle data not needed during the computation. */
struct xpart {

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  /* Old position, at last tree rebuild. */
  double x_old[3];

  /* Velocity at the half-step. */
  float v_hdt[3];

  /* Entropy at the half-step. */
  float u_hdt;

  /* Old density. */
  float omega;

  /* particle's current time-step. */
  float dt_curr;

} __attribute__((aligned(32)));

48
49
50
/* Gravity particle. */
struct gpart {

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
  /* Particle position. */
  double x[3];

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

  /* Particle acceleration. */
  float a[3];

  /* Particle mass. */
  float mass;

  /* Particle time step. */
  float dt;

  /* Anonymous union for id/part. */
  union {

    /* Particle ID. */
    size_t id;

    /* Pointer to corresponding SPH part. */
    struct part *part;
  };

} __attribute__((aligned(part_align)));
77

78
79
80
/* Data of a single particle. */
struct part {

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  /* Particle position. */
  double x[3];

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

  /* Particle acceleration. */
  float a[3];

  /* Particle cutoff radius. */
  float h;

  /* Particle time-step. */
  float dt;

  /* Particle internal energy. */
  float u;

  /* Particle density. */
  float rho;

  /* Derivative of the density with respect to this particle's smoothing length.
   */
  float rho_dh;
105
106

#ifndef LEGACY_GADGET2_SPH
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
  /* Particle viscosity parameter */
  float alpha;
#endif

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

    struct {

      /* Particle velocity divergence. */
      float div_v;

      /* Derivative of particle number density. */
      float wcount_dh;

      /* Particle velocity curl. */
      float curl_v[3];

      /* Particle number density. */
      float wcount;

    } density;

    struct {

      /* Balsara switch */
      float balsara;

      /* Aggregate quantities. */
      float POrho2;

      /* Change in particle energy over time. */
      float u_dt;

      /* Change in smoothing length over time. */
      float h_dt;

      /* Signal velocity */
      float v_sig;

      /* Sound speed */
      float c;

    } force;
  };

  /* Particle pressure. */
  // float P;

  /* Particle mass. */
  float mass;

  /* Particle ID. */
  unsigned long long id;

  /* Associated gravitas. */
  struct gpart *gpart;

} __attribute__((aligned(part_align)));
166

167
#endif /* SWIFT_PART_H */