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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
|
class RayleighTaylor3D : public Scene
{
public:
RayleighTaylor3D(const char* name) : Scene(name) {}
int base;
int width;
int height;
int depth;
virtual void Initialize()
{
float radius = 0.05f;
float restDistance = radius*0.5f;
width = 128;
height = 24;
depth = 24;
base = 4;
float sep = restDistance*0.9f;
int group = 0;
CreateParticleGrid(Vec3(0.0f, 0.0f, 0.0f), width, base, depth, sep, Vec3(0.0f), 0.0f, false, 0.0f, NvFlexMakePhase(group++, 0), 0.0f);
CreateParticleGrid(Vec3(0.0f, base*sep, 0.0f), width, height, depth, sep, Vec3(0.0f), 0.24f, false, 0.0f, NvFlexMakePhase(group++, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid), restDistance*0.01f);
CreateParticleGrid(Vec3(0.0f, sep*height + base*sep, 0.0f), width, height, depth, sep, Vec3(0.0f), 0.25f, false, 0.0f, NvFlexMakePhase(group++, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid), restDistance*0.01f);
g_params.gravity[1] = -9.f;
g_params.radius = radius;
g_params.dynamicFriction = 0.00f;
g_params.viscosity = 2.0f;
g_params.numIterations = 10;
g_params.vorticityConfinement = 0.0f;
g_params.smoothing = 1.f;
g_params.fluidRestDistance = restDistance;
g_params.numPlanes = 5;
g_params.cohesion = 0.0002125f;
g_params.surfaceTension = 0.0f;
g_params.collisionDistance = 0.001f;//restDistance*0.5f;
//g_params.solidPressure = 0.2f;
g_params.relaxationFactor = 20.0f;
g_numSubsteps = 5;
g_fluidColor = Vec4(0.2f, 0.6f, 0.9f, 1.0f);
g_lightDistance *= 0.85f;
// draw options
g_drawDensity = true;
g_drawDiffuse = false;
g_drawEllipsoids = false;
g_drawPoints = true;
g_blur = 2.0f;
g_warmup = true;
}
virtual void Update()
{
if (g_params.numPlanes == 4)
g_params.dynamicFriction = 0.2f;
if (g_frame == 32)
{
int layer1start = width*depth*base;
int layer1end = layer1start + width*height*depth;
for (int i = layer1start; i < layer1end; ++i)
g_buffers->positions[i].w = 1.0f;
}
}
};
class RayleighTaylor2D : public Scene
{
public:
RayleighTaylor2D(const char* name) : Scene(name) {}
int base;
int width;
int height;
int depth;
virtual void Initialize()
{
float radius = 0.05f;
float restDistance = radius*0.5f;
width = 128;
height = 24;
depth = 1;
base = 4;
float sep = restDistance*0.7f;
int group = 0;
CreateParticleGrid(Vec3(0.0f, 0.0f, 0.0f), width, base, depth, sep, Vec3(0.0f), 0.0f, false, 0.0f, NvFlexMakePhase(group++, 0), 0.0f);
CreateParticleGrid(Vec3(0.0f, base*sep, 0.0f), width, height, depth, sep, Vec3(0.0f), 1.0f, false, 0.0f, NvFlexMakePhase(group++, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid), restDistance*0.01f);
CreateParticleGrid(Vec3(0.0f, sep*height + base*sep, 0.0f), width, height, depth, sep, Vec3(0.0f), 0.25f, false, 0.0f, NvFlexMakePhase(group++, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid), restDistance*0.01f);
g_params.gravity[1] = -9.f;
g_params.radius = radius;
g_params.dynamicFriction = 0.00f;
g_params.viscosity = 0.0f;
g_params.numIterations = 10;
g_params.vorticityConfinement = 0.0f;
g_params.smoothing = 1.f;
g_params.fluidRestDistance = restDistance;
g_params.numPlanes = 5;
g_params.cohesion = 0.0025f;
g_params.surfaceTension = 0.0f;
g_params.collisionDistance = 0.001f;
g_params.restitution = 0.0f;
g_params.relaxationFactor = 1.0f;
g_numSubsteps = 10;
g_fluidColor = Vec4(0.2f, 0.6f, 0.9f, 1.0f);
g_lightDistance *= 0.85f;
// draw options
g_drawDensity = false;
g_drawDiffuse = false;
g_drawEllipsoids = false;
g_drawPoints = true;
g_pointScale = 0.9f;
g_blur = 2.0f;
g_warmup = true;
}
};
|