質問編集履歴
8
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -462,7 +462,7 @@
|
|
462
462
|
|
463
463
|
|
464
464
|
|
465
|
-
oindices.append(i)
|
465
|
+
oindices.append(i)
|
466
466
|
|
467
467
|
|
468
468
|
|
@@ -472,7 +472,7 @@
|
|
472
472
|
|
473
473
|
```
|
474
474
|
|
475
|
-
としてみたのですが、
|
475
|
+
としてみたのですが、TypeError: unsupported operand type(s) for -: 'str' and 'str'
|
476
476
|
|
477
477
|
となってしまい実行できません。この場合最後のif文のループに問題があるのでしょうか?
|
478
478
|
|
7
コード訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,6 +26,250 @@
|
|
26
26
|
|
27
27
|
# save the geometry detail
|
28
28
|
|
29
|
+
self.container_length = container_length
|
30
|
+
|
31
|
+
self.container_width = container_width
|
32
|
+
|
33
|
+
self.container_height = container_height
|
34
|
+
|
35
|
+
self.fluid_column_length=fluid_column_length
|
36
|
+
|
37
|
+
self.fluid_column_width=fluid_column_width
|
38
|
+
|
39
|
+
self.fluid_column_height=fluid_column_height
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
self.obstacle0_center_x = obstacle0_center_x
|
46
|
+
|
47
|
+
self.obstacle0_center_y = obstacle0_center_y
|
48
|
+
|
49
|
+
self.obstacle0_r = obstacle0_r
|
50
|
+
|
51
|
+
self.obstacle0_height = obstacle0_height
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
self.obstacle1_center_x = obstacle1_center_x
|
56
|
+
|
57
|
+
self.obstacle1_center_y = obstacle1_center_y
|
58
|
+
|
59
|
+
self.obstacle1_r = obstacle1_r
|
60
|
+
|
61
|
+
self.obstacle1_height = obstacle1_height
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
self.nboundary_layers=nboundary_layers
|
68
|
+
|
69
|
+
self.dx=dx
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
self.hdx = hdx
|
74
|
+
|
75
|
+
self.rho0 = rho0
|
76
|
+
|
77
|
+
self.with_obstacle0 = with_obstacle0
|
78
|
+
|
79
|
+
self.with_obstacle1 = with_obstacle1
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
def create_particles(self, **kwargs):
|
84
|
+
|
85
|
+
fluid_column_height=self.fluid_column_height
|
86
|
+
|
87
|
+
fluid_column_width=self.fluid_column_width
|
88
|
+
|
89
|
+
fluid_column_length=self.fluid_column_length
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
container_height = self.container_height
|
94
|
+
|
95
|
+
container_length = self.container_length
|
96
|
+
|
97
|
+
container_width = self.container_width
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
obstacle0_center_x = self.obstacle0_center_x
|
102
|
+
|
103
|
+
obstacle0_center_y = self.obstacle0_center_y
|
104
|
+
|
105
|
+
obstacle0_r = self.obstacle0_r
|
106
|
+
|
107
|
+
obstacle0_height = self.obstacle0_height
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
nboundary_layers = self.nboundary_layers
|
116
|
+
|
117
|
+
dx = self.dx
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
# get the domain limits
|
122
|
+
|
123
|
+
ghostlims = nboundary_layers * dx
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
128
|
+
|
129
|
+
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
cw2 = 0.5 * container_width
|
134
|
+
|
135
|
+
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
# create all particles
|
140
|
+
|
141
|
+
eps = 0.1 * dx
|
142
|
+
|
143
|
+
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
144
|
+
|
145
|
+
ymin:ymax+eps:dx,
|
146
|
+
|
147
|
+
zmin:zmax+eps:dx]
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
# create a dummy particle array from which we'll sort
|
156
|
+
|
157
|
+
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
# get the individual arrays
|
162
|
+
|
163
|
+
indices = []
|
164
|
+
|
165
|
+
findices = []
|
166
|
+
|
167
|
+
oindices = []
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
obr0 = 2**obstacle0_r
|
176
|
+
|
177
|
+
obh0 = obstacle0_height
|
178
|
+
|
179
|
+
ocx0 = obstacle0_center_x
|
180
|
+
|
181
|
+
ocy0 = obstacle0_center_y
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
obr1 = 2**obstacle1_r
|
190
|
+
|
191
|
+
obh1 = obstacle1_height
|
192
|
+
|
193
|
+
ocx1 = obstacle1_center_x
|
194
|
+
|
195
|
+
ocy1 = obstacle1_center_y
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
for i in range(x.size):
|
202
|
+
|
203
|
+
xi = x[i]; yi = y[i]; zi = z[i]
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
# fluid
|
208
|
+
|
209
|
+
if ( (0 < xi <= fluid_column_length) and \
|
210
|
+
|
211
|
+
(-cw2 < yi < cw2) and \
|
212
|
+
|
213
|
+
(0 < zi <= fluid_column_height) ):
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
findices.append(i)
|
218
|
+
|
219
|
+
#obstacle
|
220
|
+
|
221
|
+
if ( (ocx0 - xi)**2 + (ocy0 - yi)**2 <= obr0 and \
|
222
|
+
|
223
|
+
(0 < zi <= obh0) ):
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
oindices.append(i)
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
if ( (ocx1 - xi)**2 + (ocy1 - yi)**2 <= obr1 and \
|
232
|
+
|
233
|
+
(0 < zi <= obh1) ):
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
oindices.append(i)
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
というコードがあり、これはまず円柱、箱、水の位置を定義しその範囲内に粒子を詰めることにより物理的影響などを計算するというものです。
|
244
|
+
|
245
|
+
この円柱を増やしたいためfor文で
|
246
|
+
|
247
|
+
```python
|
248
|
+
|
249
|
+
class DamBreak3DGeometry(object):
|
250
|
+
|
251
|
+
def __init__(
|
252
|
+
|
253
|
+
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
254
|
+
|
255
|
+
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
256
|
+
|
257
|
+
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
258
|
+
|
259
|
+
obstacle0_r=0.05, obstacle0_height=0.8,
|
260
|
+
|
261
|
+
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
262
|
+
|
263
|
+
obstacle1_r=0.05, obstacle1_height=0.8,
|
264
|
+
|
265
|
+
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
266
|
+
|
267
|
+
dx=0.02, hdx=1.2, rho0=1000.0):
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
# save the geometry detail
|
272
|
+
|
29
273
|
self.container_r = container_r
|
30
274
|
|
31
275
|
self.container_height = container_height
|
@@ -36,30 +280,28 @@
|
|
36
280
|
|
37
281
|
self.fluid_column_height=fluid_column_height
|
38
282
|
|
283
|
+
|
284
|
+
|
39
|
-
|
285
|
+
for k in range (1):
|
286
|
+
|
287
|
+
center_x = "obstacle%d_center_x"%(k)
|
288
|
+
|
289
|
+
self.center_x = center_x
|
290
|
+
|
291
|
+
center_y = "obstacle%d_center_y"%(k)
|
292
|
+
|
293
|
+
self.center_y = center_y
|
294
|
+
|
295
|
+
r = "obstacle%d_r%"(k)
|
296
|
+
|
297
|
+
self.r = r
|
298
|
+
|
299
|
+
height = "obstacle%d_height"%(k)
|
300
|
+
|
301
|
+
self.height = height
|
40
302
|
|
41
303
|
|
42
304
|
|
43
|
-
self.obstacle0_center_x = obstacle0_center_x
|
44
|
-
|
45
|
-
self.obstacle0_center_y = obstacle0_center_y
|
46
|
-
|
47
|
-
self.obstacle0_r = obstacle0_r
|
48
|
-
|
49
|
-
self.obstacle0_height = obstacle0_height
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
self.obstacle1_center_x = obstacle1_center_x
|
54
|
-
|
55
|
-
self.obstacle1_center_y = obstacle1_center_y
|
56
|
-
|
57
|
-
self.obstacle1_r = obstacle1_r
|
58
|
-
|
59
|
-
self.obstacle1_height = obstacle1_height
|
60
|
-
|
61
|
-
|
62
|
-
|
63
305
|
|
64
306
|
|
65
307
|
self.nboundary_layers=nboundary_layers
|
@@ -94,19 +336,29 @@
|
|
94
336
|
|
95
337
|
container_width = self.container_width
|
96
338
|
|
339
|
+
|
340
|
+
|
97
|
-
|
341
|
+
for k in range (1):
|
342
|
+
|
98
|
-
|
343
|
+
center_x = "obstacle%d_center_x"%(k)
|
344
|
+
|
99
|
-
|
345
|
+
center_x = self.center_x
|
346
|
+
|
100
|
-
|
347
|
+
center_y = "obstacle%d_center_y"%(k)
|
348
|
+
|
101
|
-
|
349
|
+
center_y = self.center_y
|
102
|
-
|
350
|
+
|
103
|
-
|
351
|
+
r = "obstacle%d_r"%(k)
|
352
|
+
|
104
|
-
|
353
|
+
r = self.r
|
354
|
+
|
105
|
-
|
355
|
+
height = "obstacle%d_height"%(k)
|
356
|
+
|
106
|
-
|
357
|
+
height = self.height
|
107
|
-
|
108
|
-
|
109
|
-
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
110
362
|
|
111
363
|
|
112
364
|
|
@@ -164,33 +416,19 @@
|
|
164
416
|
|
165
417
|
oindices = []
|
166
418
|
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
167
|
-
|
423
|
+
for k in range (1):
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
424
|
+
|
173
|
-
|
425
|
+
obrk = "2 ** obstacle%d_r"%(k)
|
174
|
-
|
426
|
+
|
175
|
-
obh
|
427
|
+
obhk = "obstacle%d_height"%(k)
|
176
|
-
|
428
|
+
|
177
|
-
|
429
|
+
ocxk = "obstacle%d_center_x"%(k)
|
178
|
-
|
430
|
+
|
179
|
-
|
431
|
+
ocyk = "obstacle%d_center_y"%(k)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
obr1 = 2 ** obstacle1_r
|
188
|
-
|
189
|
-
obh1 = obstacle1_height
|
190
|
-
|
191
|
-
ocx1 = obstacle1_center_x
|
192
|
-
|
193
|
-
ocy1 = obstacle1_center_y
|
194
432
|
|
195
433
|
|
196
434
|
|
@@ -214,11 +452,13 @@
|
|
214
452
|
|
215
453
|
findices.append(i)
|
216
454
|
|
217
|
-
|
455
|
+
for k in range (1):
|
218
|
-
|
456
|
+
|
457
|
+
|
458
|
+
|
219
|
-
if ( (ocx
|
459
|
+
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
220
|
-
|
460
|
+
|
221
|
-
(0 < zi <= obh
|
461
|
+
(0 < zi <= obh) ):
|
222
462
|
|
223
463
|
|
224
464
|
|
@@ -226,250 +466,12 @@
|
|
226
466
|
|
227
467
|
|
228
468
|
|
229
|
-
|
469
|
+
|
230
|
-
|
231
|
-
(0 < zi <= obh1) ):
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
oindices.append(i)
|
236
470
|
|
237
471
|
|
238
472
|
|
239
473
|
```
|
240
474
|
|
241
|
-
というコードがあり、これはまず円柱、箱、水の位置を定義しその範囲内に粒子を詰めることにより物理的影響などを計算するというものです。
|
242
|
-
|
243
|
-
この円柱を増やしたいためfor文で
|
244
|
-
|
245
|
-
```python
|
246
|
-
|
247
|
-
class DamBreak3DGeometry(object):
|
248
|
-
|
249
|
-
def __init__(
|
250
|
-
|
251
|
-
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
252
|
-
|
253
|
-
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
254
|
-
|
255
|
-
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
256
|
-
|
257
|
-
obstacle0_r=0.05, obstacle0_height=0.8,
|
258
|
-
|
259
|
-
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
260
|
-
|
261
|
-
obstacle1_r=0.05, obstacle1_height=0.8,
|
262
|
-
|
263
|
-
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
264
|
-
|
265
|
-
dx=0.02, hdx=1.2, rho0=1000.0):
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
# save the geometry detail
|
270
|
-
|
271
|
-
self.container_r = container_r
|
272
|
-
|
273
|
-
self.container_height = container_height
|
274
|
-
|
275
|
-
self.fluid_column_length=fluid_column_length
|
276
|
-
|
277
|
-
self.fluid_column_width=fluid_column_width
|
278
|
-
|
279
|
-
self.fluid_column_height=fluid_column_height
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
for k in range (1):
|
284
|
-
|
285
|
-
center_x = "obstacle%d_center_x"%(k)
|
286
|
-
|
287
|
-
self.center_x = center_x
|
288
|
-
|
289
|
-
center_y = "obstacle%d_center_y"%(k)
|
290
|
-
|
291
|
-
self.center_y = center_y
|
292
|
-
|
293
|
-
r = "obstacle%d_r%"(k)
|
294
|
-
|
295
|
-
self.r = r
|
296
|
-
|
297
|
-
height = "obstacle%d_height"%(k)
|
298
|
-
|
299
|
-
self.height = height
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
self.nboundary_layers=nboundary_layers
|
306
|
-
|
307
|
-
self.dx=dx
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
self.hdx = hdx
|
312
|
-
|
313
|
-
self.rho0 = rho0
|
314
|
-
|
315
|
-
self.with_obstacle0 = with_obstacle0
|
316
|
-
|
317
|
-
self.with_obstacle1 = with_obstacle1
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
def create_particles(self, **kwargs):
|
322
|
-
|
323
|
-
fluid_column_height=self.fluid_column_height
|
324
|
-
|
325
|
-
fluid_column_width=self.fluid_column_width
|
326
|
-
|
327
|
-
fluid_column_length=self.fluid_column_length
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
container_height = self.container_height
|
332
|
-
|
333
|
-
container_length = self.container_length
|
334
|
-
|
335
|
-
container_width = self.container_width
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
for k in range (1):
|
340
|
-
|
341
|
-
center_x = "obstacle%d_center_x"%(k)
|
342
|
-
|
343
|
-
center_x = self.center_x
|
344
|
-
|
345
|
-
center_y = "obstacle%d_center_y"%(k)
|
346
|
-
|
347
|
-
center_y = self.center_y
|
348
|
-
|
349
|
-
r = "obstacle%d_r"%(k)
|
350
|
-
|
351
|
-
r = self.r
|
352
|
-
|
353
|
-
height = "obstacle%d_height"%(k)
|
354
|
-
|
355
|
-
height = self.height
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
nboundary_layers = self.nboundary_layers
|
364
|
-
|
365
|
-
dx = self.dx
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
# get the domain limits
|
370
|
-
|
371
|
-
ghostlims = nboundary_layers * dx
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
376
|
-
|
377
|
-
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
cw2 = 0.5 * container_width
|
382
|
-
|
383
|
-
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
# create all particles
|
388
|
-
|
389
|
-
eps = 0.1 * dx
|
390
|
-
|
391
|
-
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
392
|
-
|
393
|
-
ymin:ymax+eps:dx,
|
394
|
-
|
395
|
-
zmin:zmax+eps:dx]
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
# create a dummy particle array from which we'll sort
|
404
|
-
|
405
|
-
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
# get the individual arrays
|
410
|
-
|
411
|
-
indices = []
|
412
|
-
|
413
|
-
findices = []
|
414
|
-
|
415
|
-
oindices = []
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
for k in range (1):
|
422
|
-
|
423
|
-
obrk = "2 ** obstacle%d_r"%(k)
|
424
|
-
|
425
|
-
obhk = "obstacle%d_height"%(k)
|
426
|
-
|
427
|
-
ocxk = "obstacle%d_center_x"%(k)
|
428
|
-
|
429
|
-
ocyk = "obstacle%d_center_y"%(k)
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
for i in range(x.size):
|
436
|
-
|
437
|
-
xi = x[i]; yi = y[i]; zi = z[i]
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
# fluid
|
442
|
-
|
443
|
-
if ( (0 < xi <= fluid_column_length) and \
|
444
|
-
|
445
|
-
(-cw2 < yi < cw2) and \
|
446
|
-
|
447
|
-
(0 < zi <= fluid_column_height) ):
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
findices.append(i)
|
452
|
-
|
453
|
-
for k in range (1):
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
458
|
-
|
459
|
-
(0 < zi <= obh) ):
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
oindices.append(i)
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
```
|
472
|
-
|
473
475
|
としてみたのですが、IndentationError: expected an indented block
|
474
476
|
|
475
477
|
となってしまい実行できません。この場合最後のif文のループに問題があるのでしょうか?
|
6
段落ずれ
test
CHANGED
File without changes
|
test
CHANGED
@@ -170,13 +170,13 @@
|
|
170
170
|
|
171
171
|
|
172
172
|
|
173
|
-
|
173
|
+
obr0 = 2 ** obstacle0_r
|
174
|
-
|
174
|
+
|
175
|
-
obh0 = obstacle0_height
|
175
|
+
obh0 = obstacle0_height
|
176
|
-
|
176
|
+
|
177
|
-
|
177
|
+
ocx0 = obstacle0_center_x
|
178
|
-
|
178
|
+
|
179
|
-
|
179
|
+
ocy0 = obstacle0_center_y
|
180
180
|
|
181
181
|
|
182
182
|
|
5
コード訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
|
3
3
|
```python
|
4
4
|
|
5
|
-
|
5
|
+
class DamBreak3DGeometry(object):
|
6
|
-
|
6
|
+
|
7
|
-
def __init__(
|
7
|
+
def __init__(
|
8
|
+
|
8
|
-
|
9
|
+
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
10
|
+
|
11
|
+
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
12
|
+
|
9
|
-
obstacle0_center_x=
|
13
|
+
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
10
|
-
|
14
|
+
|
11
|
-
obstacle0_r=0.0
|
15
|
+
obstacle0_r=0.05, obstacle0_height=0.8,
|
12
|
-
|
16
|
+
|
13
|
-
obstacle1_center_x=
|
17
|
+
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
14
|
-
|
18
|
+
|
15
|
-
obstacle1_r=0.0
|
19
|
+
obstacle1_r=0.05, obstacle1_height=0.8,
|
16
20
|
|
17
21
|
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
18
22
|
|
@@ -20,73 +24,411 @@
|
|
20
24
|
|
21
25
|
|
22
26
|
|
27
|
+
# save the geometry detail
|
28
|
+
|
29
|
+
self.container_r = container_r
|
30
|
+
|
31
|
+
self.container_height = container_height
|
32
|
+
|
33
|
+
self.fluid_column_length=fluid_column_length
|
34
|
+
|
35
|
+
self.fluid_column_width=fluid_column_width
|
36
|
+
|
37
|
+
self.fluid_column_height=fluid_column_height
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
23
43
|
self.obstacle0_center_x = obstacle0_center_x
|
24
44
|
|
25
45
|
self.obstacle0_center_y = obstacle0_center_y
|
26
46
|
|
47
|
+
self.obstacle0_r = obstacle0_r
|
48
|
+
|
49
|
+
self.obstacle0_height = obstacle0_height
|
50
|
+
|
51
|
+
|
52
|
+
|
27
53
|
self.obstacle1_center_x = obstacle1_center_x
|
28
54
|
|
29
55
|
self.obstacle1_center_y = obstacle1_center_y
|
30
56
|
|
57
|
+
self.obstacle1_r = obstacle1_r
|
58
|
+
|
59
|
+
self.obstacle1_height = obstacle1_height
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
self.nboundary_layers=nboundary_layers
|
66
|
+
|
67
|
+
self.dx=dx
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
self.hdx = hdx
|
72
|
+
|
73
|
+
self.rho0 = rho0
|
74
|
+
|
75
|
+
self.with_obstacle0 = with_obstacle0
|
76
|
+
|
77
|
+
self.with_obstacle1 = with_obstacle1
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
def create_particles(self, **kwargs):
|
82
|
+
|
83
|
+
fluid_column_height=self.fluid_column_height
|
84
|
+
|
85
|
+
fluid_column_width=self.fluid_column_width
|
86
|
+
|
87
|
+
fluid_column_length=self.fluid_column_length
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
container_height = self.container_height
|
92
|
+
|
93
|
+
container_length = self.container_length
|
94
|
+
|
95
|
+
container_width = self.container_width
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
obstacle0_center_x = self.obstacle0_center_x
|
100
|
+
|
101
|
+
obstacle0_center_y = self.obstacle0_center_y
|
102
|
+
|
103
|
+
obstacle0_r = self.obstacle0_r
|
104
|
+
|
105
|
+
obstacle0_height = self.obstacle0_height
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
nboundary_layers = self.nboundary_layers
|
114
|
+
|
115
|
+
dx = self.dx
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
# get the domain limits
|
120
|
+
|
121
|
+
ghostlims = nboundary_layers * dx
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
126
|
+
|
127
|
+
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
cw2 = 0.5 * container_width
|
132
|
+
|
133
|
+
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
# create all particles
|
138
|
+
|
139
|
+
eps = 0.1 * dx
|
140
|
+
|
141
|
+
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
142
|
+
|
143
|
+
ymin:ymax+eps:dx,
|
144
|
+
|
145
|
+
zmin:zmax+eps:dx]
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
# create a dummy particle array from which we'll sort
|
154
|
+
|
155
|
+
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
# get the individual arrays
|
160
|
+
|
161
|
+
indices = []
|
162
|
+
|
163
|
+
findices = []
|
164
|
+
|
165
|
+
oindices = []
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
obr0 = 2 ** obstacle0_r
|
174
|
+
|
175
|
+
obh0 = obstacle0_height
|
176
|
+
|
177
|
+
ocx0 = obstacle0_center_x
|
178
|
+
|
179
|
+
ocy0 = obstacle0_center_y
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
obr1 = 2 ** obstacle1_r
|
188
|
+
|
189
|
+
obh1 = obstacle1_height
|
190
|
+
|
191
|
+
ocx1 = obstacle1_center_x
|
192
|
+
|
193
|
+
ocy1 = obstacle1_center_y
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
for i in range(x.size):
|
200
|
+
|
201
|
+
xi = x[i]; yi = y[i]; zi = z[i]
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
# fluid
|
206
|
+
|
207
|
+
if ( (0 < xi <= fluid_column_length) and \
|
208
|
+
|
209
|
+
(-cw2 < yi < cw2) and \
|
210
|
+
|
211
|
+
(0 < zi <= fluid_column_height) ):
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
findices.append(i)
|
216
|
+
|
217
|
+
#obstacle
|
218
|
+
|
219
|
+
if ( (ocx0 - xi)**2 + (ocy0 - yi)**2 <= obr0 and \
|
220
|
+
|
221
|
+
(0 < zi <= obh0) ):
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
oindices.append(i)
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
if ( (ocx1 - xi)**2 + (ocy1 - yi)**2 <= obr1 and \
|
230
|
+
|
231
|
+
(0 < zi <= obh1) ):
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
oindices.append(i)
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
240
|
+
|
241
|
+
というコードがあり、これはまず円柱、箱、水の位置を定義しその範囲内に粒子を詰めることにより物理的影響などを計算するというものです。
|
242
|
+
|
243
|
+
この円柱を増やしたいためfor文で
|
244
|
+
|
245
|
+
```python
|
246
|
+
|
247
|
+
class DamBreak3DGeometry(object):
|
248
|
+
|
249
|
+
def __init__(
|
250
|
+
|
251
|
+
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
252
|
+
|
253
|
+
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
254
|
+
|
255
|
+
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
256
|
+
|
257
|
+
obstacle0_r=0.05, obstacle0_height=0.8,
|
258
|
+
|
259
|
+
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
260
|
+
|
261
|
+
obstacle1_r=0.05, obstacle1_height=0.8,
|
262
|
+
|
263
|
+
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
264
|
+
|
265
|
+
dx=0.02, hdx=1.2, rho0=1000.0):
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
# save the geometry detail
|
270
|
+
|
271
|
+
self.container_r = container_r
|
272
|
+
|
273
|
+
self.container_height = container_height
|
274
|
+
|
275
|
+
self.fluid_column_length=fluid_column_length
|
276
|
+
|
277
|
+
self.fluid_column_width=fluid_column_width
|
278
|
+
|
279
|
+
self.fluid_column_height=fluid_column_height
|
280
|
+
|
31
281
|
|
32
282
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
self.
|
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
|
-
obstacle
|
66
|
-
|
67
|
-
|
283
|
+
for k in range (1):
|
284
|
+
|
285
|
+
center_x = "obstacle%d_center_x"%(k)
|
286
|
+
|
287
|
+
self.center_x = center_x
|
288
|
+
|
289
|
+
center_y = "obstacle%d_center_y"%(k)
|
290
|
+
|
291
|
+
self.center_y = center_y
|
292
|
+
|
293
|
+
r = "obstacle%d_r%"(k)
|
294
|
+
|
295
|
+
self.r = r
|
296
|
+
|
297
|
+
height = "obstacle%d_height"%(k)
|
298
|
+
|
299
|
+
self.height = height
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
self.nboundary_layers=nboundary_layers
|
306
|
+
|
307
|
+
self.dx=dx
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
self.hdx = hdx
|
312
|
+
|
313
|
+
self.rho0 = rho0
|
314
|
+
|
315
|
+
self.with_obstacle0 = with_obstacle0
|
316
|
+
|
317
|
+
self.with_obstacle1 = with_obstacle1
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
def create_particles(self, **kwargs):
|
322
|
+
|
323
|
+
fluid_column_height=self.fluid_column_height
|
324
|
+
|
325
|
+
fluid_column_width=self.fluid_column_width
|
326
|
+
|
327
|
+
fluid_column_length=self.fluid_column_length
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
container_height = self.container_height
|
332
|
+
|
333
|
+
container_length = self.container_length
|
334
|
+
|
335
|
+
container_width = self.container_width
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
for k in range (1):
|
340
|
+
|
341
|
+
center_x = "obstacle%d_center_x"%(k)
|
342
|
+
|
343
|
+
center_x = self.center_x
|
344
|
+
|
345
|
+
center_y = "obstacle%d_center_y"%(k)
|
346
|
+
|
347
|
+
center_y = self.center_y
|
348
|
+
|
349
|
+
r = "obstacle%d_r"%(k)
|
350
|
+
|
351
|
+
r = self.r
|
352
|
+
|
353
|
+
height = "obstacle%d_height"%(k)
|
354
|
+
|
355
|
+
height = self.height
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
nboundary_layers = self.nboundary_layers
|
364
|
+
|
365
|
+
dx = self.dx
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
# get the domain limits
|
370
|
+
|
371
|
+
ghostlims = nboundary_layers * dx
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
376
|
+
|
377
|
+
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
cw2 = 0.5 * container_width
|
382
|
+
|
383
|
+
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
# create all particles
|
388
|
+
|
389
|
+
eps = 0.1 * dx
|
390
|
+
|
391
|
+
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
392
|
+
|
393
|
+
ymin:ymax+eps:dx,
|
394
|
+
|
395
|
+
zmin:zmax+eps:dx]
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
# create a dummy particle array from which we'll sort
|
404
|
+
|
405
|
+
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
# get the individual arrays
|
410
|
+
|
411
|
+
indices = []
|
412
|
+
|
413
|
+
findices = []
|
68
414
|
|
69
415
|
oindices = []
|
70
416
|
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
71
|
-
|
421
|
+
for k in range (1):
|
72
|
-
|
422
|
+
|
73
|
-
obr
|
423
|
+
obrk = "2 ** obstacle%d_r"%(k)
|
74
|
-
|
424
|
+
|
75
|
-
obh
|
425
|
+
obhk = "obstacle%d_height"%(k)
|
76
|
-
|
426
|
+
|
77
|
-
ocx
|
427
|
+
ocxk = "obstacle%d_center_x"%(k)
|
78
|
-
|
428
|
+
|
79
|
-
ocy
|
429
|
+
ocyk = "obstacle%d_center_y"%(k)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
430
|
+
|
84
|
-
|
85
|
-
|
431
|
+
|
86
|
-
|
87
|
-
ocx1 = obstacle1_center_x
|
88
|
-
|
89
|
-
ocy1 = obstacle1_center_y
|
90
432
|
|
91
433
|
|
92
434
|
|
@@ -96,9 +438,25 @@
|
|
96
438
|
|
97
439
|
|
98
440
|
|
441
|
+
# fluid
|
442
|
+
|
443
|
+
if ( (0 < xi <= fluid_column_length) and \
|
444
|
+
|
445
|
+
(-cw2 < yi < cw2) and \
|
446
|
+
|
447
|
+
(0 < zi <= fluid_column_height) ):
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
findices.append(i)
|
452
|
+
|
453
|
+
for k in range (1):
|
454
|
+
|
455
|
+
|
456
|
+
|
99
|
-
if ( (ocx
|
457
|
+
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
100
|
-
|
458
|
+
|
101
|
-
(0 < zi <= obh
|
459
|
+
(0 < zi <= obh) ):
|
102
460
|
|
103
461
|
|
104
462
|
|
@@ -106,248 +464,12 @@
|
|
106
464
|
|
107
465
|
|
108
466
|
|
109
|
-
|
467
|
+
|
110
|
-
|
111
|
-
(0 < zi <= obh0) ):
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
oindices.append(i)
|
116
468
|
|
117
469
|
|
118
470
|
|
119
471
|
```
|
120
472
|
|
121
|
-
というコードがあり、この円柱を増やしたいためfor文で
|
122
|
-
|
123
|
-
```python
|
124
|
-
|
125
|
-
class DamBreak3DGeometry(object):
|
126
|
-
|
127
|
-
def __init__(
|
128
|
-
|
129
|
-
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
130
|
-
|
131
|
-
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
132
|
-
|
133
|
-
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
134
|
-
|
135
|
-
obstacle0_r=0.05, obstacle0_height=0.8,
|
136
|
-
|
137
|
-
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
138
|
-
|
139
|
-
obstacle1_r=0.05, obstacle1_height=0.8,
|
140
|
-
|
141
|
-
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
142
|
-
|
143
|
-
dx=0.02, hdx=1.2, rho0=1000.0):
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
# save the geometry detail
|
148
|
-
|
149
|
-
self.container_r = container_r
|
150
|
-
|
151
|
-
self.container_height = container_height
|
152
|
-
|
153
|
-
self.fluid_column_length=fluid_column_length
|
154
|
-
|
155
|
-
self.fluid_column_width=fluid_column_width
|
156
|
-
|
157
|
-
self.fluid_column_height=fluid_column_height
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
for k in range (1):
|
162
|
-
|
163
|
-
center_x = "obstacle%d_center_x"%(k)
|
164
|
-
|
165
|
-
self.center_x = center_x
|
166
|
-
|
167
|
-
center_y = "obstacle%d_center_y"%(k)
|
168
|
-
|
169
|
-
self.center_y = center_y
|
170
|
-
|
171
|
-
r = "obstacle%d_r%"(k)
|
172
|
-
|
173
|
-
self.r = r
|
174
|
-
|
175
|
-
height = "obstacle%d_height"%(k)
|
176
|
-
|
177
|
-
self.height = height
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
self.nboundary_layers=nboundary_layers
|
184
|
-
|
185
|
-
self.dx=dx
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
self.hdx = hdx
|
190
|
-
|
191
|
-
self.rho0 = rho0
|
192
|
-
|
193
|
-
self.with_obstacle0 = with_obstacle0
|
194
|
-
|
195
|
-
self.with_obstacle1 = with_obstacle1
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
def create_particles(self, **kwargs):
|
200
|
-
|
201
|
-
fluid_column_height=self.fluid_column_height
|
202
|
-
|
203
|
-
fluid_column_width=self.fluid_column_width
|
204
|
-
|
205
|
-
fluid_column_length=self.fluid_column_length
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
container_height = self.container_height
|
210
|
-
|
211
|
-
container_length = self.container_length
|
212
|
-
|
213
|
-
container_width = self.container_width
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
for k in range (1):
|
218
|
-
|
219
|
-
center_x = "obstacle%d_center_x"%(k)
|
220
|
-
|
221
|
-
center_x = self.center_x
|
222
|
-
|
223
|
-
center_y = "obstacle%d_center_y"%(k)
|
224
|
-
|
225
|
-
center_y = self.center_y
|
226
|
-
|
227
|
-
r = "obstacle%d_r"%(k)
|
228
|
-
|
229
|
-
r = self.r
|
230
|
-
|
231
|
-
height = "obstacle%d_height"%(k)
|
232
|
-
|
233
|
-
height = self.height
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
nboundary_layers = self.nboundary_layers
|
242
|
-
|
243
|
-
dx = self.dx
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
# get the domain limits
|
248
|
-
|
249
|
-
ghostlims = nboundary_layers * dx
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
254
|
-
|
255
|
-
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
cw2 = 0.5 * container_width
|
260
|
-
|
261
|
-
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
# create all particles
|
266
|
-
|
267
|
-
eps = 0.1 * dx
|
268
|
-
|
269
|
-
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
270
|
-
|
271
|
-
ymin:ymax+eps:dx,
|
272
|
-
|
273
|
-
zmin:zmax+eps:dx]
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
# create a dummy particle array from which we'll sort
|
282
|
-
|
283
|
-
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
# get the individual arrays
|
288
|
-
|
289
|
-
indices = []
|
290
|
-
|
291
|
-
findices = []
|
292
|
-
|
293
|
-
oindices = []
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
for k in range (1):
|
300
|
-
|
301
|
-
obrk = "2 ** obstacle%d_r"%(k)
|
302
|
-
|
303
|
-
obhk = "obstacle%d_height"%(k)
|
304
|
-
|
305
|
-
ocxk = "obstacle%d_center_x"%(k)
|
306
|
-
|
307
|
-
ocyk = "obstacle%d_center_y"%(k)
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
for i in range(x.size):
|
314
|
-
|
315
|
-
xi = x[i]; yi = y[i]; zi = z[i]
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
# fluid
|
320
|
-
|
321
|
-
if ( (0 < xi <= fluid_column_length) and \
|
322
|
-
|
323
|
-
(-cw2 < yi < cw2) and \
|
324
|
-
|
325
|
-
(0 < zi <= fluid_column_height) ):
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
findices.append(i)
|
330
|
-
|
331
|
-
for k in range (1):
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
336
|
-
|
337
|
-
(0 < zi <= obh) ):
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
oindices.append(i)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
```
|
350
|
-
|
351
473
|
としてみたのですが、IndentationError: expected an indented block
|
352
474
|
|
353
475
|
となってしまい実行できません。この場合最後のif文のループに問題があるのでしょうか?
|
4
コード訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -298,7 +298,7 @@
|
|
298
298
|
|
299
299
|
for k in range (1):
|
300
300
|
|
301
|
-
obrk = "2 * obstacle%d_r"%(k)
|
301
|
+
obrk = "2 ** obstacle%d_r"%(k)
|
302
302
|
|
303
303
|
obhk = "obstacle%d_height"%(k)
|
304
304
|
|
3
コード訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -122,22 +122,40 @@
|
|
122
122
|
|
123
123
|
```python
|
124
124
|
|
125
|
-
|
125
|
+
class DamBreak3DGeometry(object):
|
126
|
-
|
126
|
+
|
127
|
-
def __init__(
|
127
|
+
def __init__(
|
128
|
+
|
128
|
-
|
129
|
+
self, container_height=1.0, container_width=0.6, container_length=11.0,
|
130
|
+
|
131
|
+
fluid_column_height=0.50, fluid_column_width=0.6, fluid_column_length=1.60,
|
132
|
+
|
129
|
-
obstacle0_center_x=
|
133
|
+
obstacle0_center_x=8.00, obstacle0_center_y=0,
|
130
|
-
|
134
|
+
|
131
|
-
obstacle0_r=0.0
|
135
|
+
obstacle0_r=0.05, obstacle0_height=0.8,
|
132
|
-
|
136
|
+
|
133
|
-
obstacle1_center_x=
|
137
|
+
obstacle1_center_x=8.00, obstacle1_center_y=-0.06,
|
134
|
-
|
138
|
+
|
135
|
-
obstacle1_r=0.0
|
139
|
+
obstacle1_r=0.05, obstacle1_height=0.8,
|
136
140
|
|
137
141
|
nboundary_layers=5, with_obstacle0=True,with_obstacle1=True,
|
138
142
|
|
139
143
|
dx=0.02, hdx=1.2, rho0=1000.0):
|
140
144
|
|
145
|
+
|
146
|
+
|
147
|
+
# save the geometry detail
|
148
|
+
|
149
|
+
self.container_r = container_r
|
150
|
+
|
151
|
+
self.container_height = container_height
|
152
|
+
|
153
|
+
self.fluid_column_length=fluid_column_length
|
154
|
+
|
155
|
+
self.fluid_column_width=fluid_column_width
|
156
|
+
|
157
|
+
self.fluid_column_height=fluid_column_height
|
158
|
+
|
141
159
|
|
142
160
|
|
143
161
|
for k in range (1):
|
@@ -150,47 +168,137 @@
|
|
150
168
|
|
151
169
|
self.center_y = center_y
|
152
170
|
|
171
|
+
r = "obstacle%d_r%"(k)
|
172
|
+
|
173
|
+
self.r = r
|
174
|
+
|
175
|
+
height = "obstacle%d_height"%(k)
|
176
|
+
|
177
|
+
self.height = height
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
self.nboundary_layers=nboundary_layers
|
184
|
+
|
185
|
+
self.dx=dx
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
self.hdx = hdx
|
190
|
+
|
191
|
+
self.rho0 = rho0
|
192
|
+
|
193
|
+
self.with_obstacle0 = with_obstacle0
|
194
|
+
|
195
|
+
self.with_obstacle1 = with_obstacle1
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
def create_particles(self, **kwargs):
|
200
|
+
|
201
|
+
fluid_column_height=self.fluid_column_height
|
202
|
+
|
203
|
+
fluid_column_width=self.fluid_column_width
|
204
|
+
|
205
|
+
fluid_column_length=self.fluid_column_length
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
container_height = self.container_height
|
210
|
+
|
211
|
+
container_length = self.container_length
|
212
|
+
|
213
|
+
container_width = self.container_width
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
for k in range (1):
|
218
|
+
|
219
|
+
center_x = "obstacle%d_center_x"%(k)
|
220
|
+
|
221
|
+
center_x = self.center_x
|
222
|
+
|
223
|
+
center_y = "obstacle%d_center_y"%(k)
|
224
|
+
|
225
|
+
center_y = self.center_y
|
226
|
+
|
153
227
|
r = "obstacle%d_r"%(k)
|
154
228
|
|
155
|
-
self.r
|
229
|
+
r = self.r
|
156
230
|
|
157
231
|
height = "obstacle%d_height"%(k)
|
158
232
|
|
159
|
-
self.height = height
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
#円柱の形にそって粒子を詰める
|
164
|
-
|
165
|
-
def create_particles(self, **kwargs):
|
166
|
-
|
167
|
-
for k in range (1):
|
168
|
-
|
169
|
-
center_x = "obstacle%d_center_x"%(k)
|
170
|
-
|
171
|
-
center_x = self.center_x
|
172
|
-
|
173
|
-
center_y = "obstacle%d_center_y"%(k)
|
174
|
-
|
175
|
-
center_y = self.center_y
|
176
|
-
|
177
|
-
r = "obstacle%d_r"%(k)
|
178
|
-
|
179
|
-
r = self.r
|
180
|
-
|
181
|
-
height = "obstacle%d_height"%(k)
|
182
|
-
|
183
233
|
height = self.height
|
184
234
|
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
185
|
-
|
241
|
+
nboundary_layers = self.nboundary_layers
|
242
|
+
|
243
|
+
dx = self.dx
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
# get the domain limits
|
248
|
+
|
249
|
+
ghostlims = nboundary_layers * dx
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
xmin, xmax = 0.0 -ghostlims, container_length + ghostlims
|
254
|
+
|
255
|
+
zmin, zmax = 0.0 - ghostlims, container_height + ghostlims
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
cw2 = 0.5 * container_width
|
260
|
+
|
261
|
+
ymin, ymax = -cw2 - ghostlims, cw2 + ghostlims
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
# create all particles
|
266
|
+
|
267
|
+
eps = 0.1 * dx
|
268
|
+
|
269
|
+
xx, yy, zz = numpy.mgrid[xmin:xmax+eps:dx,
|
270
|
+
|
271
|
+
ymin:ymax+eps:dx,
|
272
|
+
|
273
|
+
zmin:zmax+eps:dx]
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
x = xx.ravel(); y = yy.ravel(); z = zz.ravel()
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
# create a dummy particle array from which we'll sort
|
282
|
+
|
283
|
+
pa = get_particle_array_wcsph(name='block', x=x, y=y, z=z)
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
# get the individual arrays
|
288
|
+
|
289
|
+
indices = []
|
290
|
+
|
291
|
+
findices = []
|
186
292
|
|
187
293
|
oindices = []
|
188
294
|
|
189
|
-
|
295
|
+
|
296
|
+
|
297
|
+
|
190
298
|
|
191
299
|
for k in range (1):
|
192
300
|
|
193
|
-
ob
|
301
|
+
obrk = "2 * obstacle%d_r"%(k)
|
194
302
|
|
195
303
|
obhk = "obstacle%d_height"%(k)
|
196
304
|
|
@@ -200,17 +308,33 @@
|
|
200
308
|
|
201
309
|
|
202
310
|
|
311
|
+
|
312
|
+
|
203
313
|
for i in range(x.size):
|
204
314
|
|
205
315
|
xi = x[i]; yi = y[i]; zi = z[i]
|
206
316
|
|
207
317
|
|
208
318
|
|
319
|
+
# fluid
|
320
|
+
|
321
|
+
if ( (0 < xi <= fluid_column_length) and \
|
322
|
+
|
323
|
+
(-cw2 < yi < cw2) and \
|
324
|
+
|
325
|
+
(0 < zi <= fluid_column_height) ):
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
findices.append(i)
|
330
|
+
|
209
|
-
for k in range (
|
331
|
+
for k in range (1):
|
210
|
-
|
332
|
+
|
333
|
+
|
334
|
+
|
211
|
-
|
335
|
+
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
212
|
-
|
336
|
+
|
213
|
-
(0 < zi <= obh
|
337
|
+
(0 < zi <= obh) ):
|
214
338
|
|
215
339
|
|
216
340
|
|
@@ -227,3 +351,9 @@
|
|
227
351
|
としてみたのですが、IndentationError: expected an indented block
|
228
352
|
|
229
353
|
となってしまい実行できません。この場合最後のif文のループに問題があるのでしょうか?
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
コードについて修正させていただきました。
|
358
|
+
|
359
|
+
cotainarのなかにおいたobstacleに対しfluidがどのように作用するか、というプログラミングの一部抜粋です。
|
2
段落ずれ
test
CHANGED
File without changes
|
test
CHANGED
@@ -208,7 +208,7 @@
|
|
208
208
|
|
209
209
|
for k in range (29):
|
210
210
|
|
211
|
-
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
211
|
+
if ( (ocxk - xi)**2 + (ocyk - yi)**2 <= obrk and \
|
212
212
|
|
213
213
|
(0 < zi <= obhk) ):
|
214
214
|
|
1
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -174,13 +174,9 @@
|
|
174
174
|
|
175
175
|
center_y = self.center_y
|
176
176
|
|
177
|
-
|
177
|
+
r = "obstacle%d_r"%(k)
|
178
|
-
|
178
|
+
|
179
|
-
|
179
|
+
r = self.r
|
180
|
-
|
181
|
-
length = "obstacle%d_length"%(k)
|
182
|
-
|
183
|
-
length = self.length
|
184
180
|
|
185
181
|
height = "obstacle%d_height"%(k)
|
186
182
|
|