-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticle.h
64 lines (53 loc) · 1.33 KB
/
Particle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "MyVec2.h"
#if defined(__CUDACC__) // NVCC
#define MY_ALIGN(n) __align__(n)
#elif defined(__GNUC__) // GCC
#define MY_ALIGN(n) __attribute__((aligned(n)))
#elif defined(_MSC_VER) // MSVC
#define MY_ALIGN(n) __declspec(align(n))
#else
#error "Please provide a definition for MY_ALIGN macro for your host compiler!"
#endif
/// <summary>
/// Struct representing particle of SPH simulation
/// </summary>
struct Particle {
/// <summary> Position in 2D </summary>
MyVec2 position;
/// <summary> Velocity of particle </summary>
MyVec2 velocity;
/// <summary> Force action on particle </summary>
MyVec2 force;
/// <summary> Particle density </summary>
float rho;
/// <summary> Pressure </summary>
float p;
/// <summary> Index of paricle in particle array </summary>
int id;
/// <summary> Index of grid cell in grid cell indices array </summary>
int gridCellID;
/// <summary> Next particle in grid (grid is represented as linked list, -1 when none) </summary>
int nextParticle;
Particle() {
position = MyVec2();
velocity = MyVec2();
force = MyVec2();
rho = 0.0f;
p = 0.0f;
id = -1;
nextParticle = -1;
gridCellID = -1;
}
Particle(float _x, float _y, int _id) :
position(_x, _y),
velocity(0.f, 0.f),
force(0.f, 0.f),
rho(0),
p(0.0f),
id(_id)
{
nextParticle = -1;
gridCellID = 0;
}
};