Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fluidparticles
MigFlow
Commits
5e2ba99c
Commit
5e2ba99c
authored
Apr 22, 2021
by
Jonathan Lambrechts
Browse files
reproductible tetris
parent
72a8971c
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
testcases/bodies/gen_tetris.py
0 → 100644
View file @
5e2ba99c
import
numpy
as
np
import
random
models
=
[
[[
1
,
0
,
0
,
0
],
[
1
,
1
,
1
,
0
]],
[[
0
,
0
,
0
,
1
],
[
0
,
1
,
1
,
1
]],
[[
1
,
1
,
1
,
1
],
[
0
,
0
,
0
,
0
]],
[[
0
,
1
,
1
,
0
],
[
0
,
1
,
1
,
0
]],
[[
0
,
0
,
1
,
1
],
[
0
,
1
,
1
,
0
]],
[[
0
,
1
,
0
,
0
],
[
1
,
1
,
1
,
0
]],
[[
0
,
1
,
1
,
0
],
[
0
,
0
,
1
,
1
]]
]
with
open
(
"pieces.txt"
,
"w"
)
as
f
:
for
i
in
range
(
100
):
r
=
0.05
omega
=
10
*
np
.
pi
*
(
-
1
+
2
*
random
.
random
())
piece
=
random
.
choice
(
models
)
Y
,
X
=
np
.
where
(
piece
)
X
=
r
*
(
-
3
+
2
*
X
)
Y
=
r
*
(
40
+
2
*
Y
)
f
.
write
(
f
"
{
omega
:
8.3
f
}
"
+
" "
.
join
(
f
"
{
x
:
6.3
f
}
{
y
:
6.3
f
}
"
for
x
,
y
in
zip
(
X
,
Y
))
+
"
\n
"
)
testcases/bodies/pieces.txt
0 → 100644
View file @
5e2ba99c
18.436 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
-16.644 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-22.148 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
14.766 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
23.417 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-25.529 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
12.204 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-17.152 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-22.345 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
19.521 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
30.482 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
5.080 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
-16.605 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
23.052 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
30.765 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
12.822 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
29.323 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
29.273 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
7.277 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
15.639 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
29.114 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
10.342 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-10.283 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
-16.552 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
24.964 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
24.909 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-29.747 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
9.529 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
2.074 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
17.155 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
-12.186 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-13.085 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
1.558 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-9.364 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
28.192 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-8.910 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
14.197 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
18.484 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-0.866 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-24.632 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-13.176 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-2.574 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
11.775 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
-23.059 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
29.109 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
19.883 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
-24.979 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
2.742 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
-16.142 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
18.615 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-13.817 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
17.515 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
8.801 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
0.772 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-13.312 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
11.490 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
12.866 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-13.837 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-9.433 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
-19.904 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
19.042 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
8.712 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
-8.316 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-10.168 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
20.406 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-8.509 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
30.556 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
16.017 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-6.678 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-28.908 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-9.403 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
7.172 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-2.018 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
23.600 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-25.243 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-3.436 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
27.233 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
30.619 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
-24.623 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
31.322 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
29.354 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-10.000 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-11.686 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
5.081 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-8.620 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
27.273 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
-4.000 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
15.039 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
13.572 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
16.276 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
7.071 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
9.115 -0.150 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
31.014 0.050 2.000 0.150 2.000 -0.050 2.100 0.050 2.100
1.461 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-12.342 0.150 2.000 -0.050 2.100 0.050 2.100 0.150 2.100
-5.733 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-25.846 -0.050 2.000 0.050 2.000 -0.050 2.100 0.050 2.100
-0.680 -0.050 2.000 -0.150 2.100 -0.050 2.100 0.050 2.100
20.277 -0.150 2.000 -0.050 2.000 0.050 2.000 0.150 2.000
-4.811 -0.050 2.000 0.050 2.000 0.050 2.100 0.150 2.100
testcases/bodies/tetris.pvsm
0 → 100644
View file @
5e2ba99c
This diff is collapsed.
Click to expand it.
testcases/bodies/tetris.py
View file @
5e2ba99c
...
...
@@ -4,27 +4,17 @@ import os
import
numpy
as
np
os
.
makedirs
(
"output"
,
exist_ok
=
True
)
pieces
=
np
.
genfromtxt
(
"pieces.txt"
)
pieces_omega
=
pieces
[:,
0
]
pieces_coord
=
pieces
[:,
1
:].
reshape
([
-
1
,
4
,
2
])
pieces
=
np
.
array
([
[[
1
,
0
,
0
,
0
],[
1
,
1
,
1
,
0
]],
[[
0
,
0
,
0
,
1
],[
0
,
1
,
1
,
1
]],
[[
1
,
1
,
1
,
1
],[
0
,
0
,
0
,
0
]],
[[
0
,
1
,
1
,
0
],[
0
,
1
,
1
,
0
]],
[[
0
,
0
,
1
,
1
],[
0
,
1
,
1
,
0
]],
[[
0
,
1
,
0
,
0
],[
1
,
1
,
1
,
0
]],
[[
0
,
1
,
1
,
0
],[
0
,
0
,
1
,
1
]]
])
def
add_random_piece
(
p
):
pmodel
=
random
.
choice
(
range
(
len
(
pieces
)))
print
(
pmodel
)
piece
=
pieces
[
pmodel
]
y
,
x
=
np
.
where
(
piece
)
R
=
np
.
repeat
(
r
,
y
.
size
)
coord
=
r
*
2
*
np
.
column_stack
((
x
-
2.5
+
2
*
random
.
random
(),
y
+
20
))
p
.
add_body
(
coord
,
R
,
np
.
pi
*
R
**
2
*
rho
,
material
=
str
(
pmodel
),
forced
=
0
)
p
.
omega
()[
-
1
,
0
]
=
10
*
np
.
pi
*
(
-
1
+
2
*
np
.
random
.
random
())
p
.
velocity
()[
-
1
,
1
]
=
-
0.1
def
add_piece
(
p
,
i
):
if
i
>=
pieces_coord
.
shape
[
0
]:
return
coord
=
pieces_coord
[
i
]
R
=
np
.
repeat
(
0.05
,
4
)
p
.
add_body
(
coord
,
R
,
np
.
pi
*
R
**
2
*
rho
,
material
=
"Sand"
,
forced
=
0
)
p
.
omega
()[
-
1
,
0
]
=
pieces_omega
[
i
]
#p.velocity()[-1,1] = -0.1
n_inserted_pieces
=
0
p
=
scontact
.
ParticleProblem
(
2
,
friction_enabled
=
False
,
rotation_enabled
=
True
)
...
...
@@ -35,20 +25,24 @@ rho = 1000
p
.
add_boundary_segment
([
-
a
,
-
a
],[
-
a
,
a
],
"bnd"
,
material
=
"Steel"
)
#p.add_boundary_segment([-a,a],[a,a],"bnd",material="Steel")
p
.
add_boundary_segment
([
a
,
a
],[
a
,
-
a
],
"bnd"
,
material
=
"Steel"
)
p
.
add_boundary_segment
([
a
,
-
a
],[
0
,
-
0.7
],
"bnd"
,
material
=
"Steel"
)
p
.
add_boundary_segment
([
0
,
-
0.7
],[
-
a
,
-
a
],
"bnd"
,
material
=
"Steel"
)
p
.
add_boundary_disk
([
0
,
-
0.7
],
0
,
"bnd"
,
"Steel"
)
tend
=
300
p
.
add_boundary_segment
([
a
,
-
a
],[
-
a
,
-
a
],
"bnd"
,
material
=
"Steel"
)
#p.add_boundary_segment([a,-a],[0,-0.7],"bnd",material="Steel")
#p.add_boundary_segment([0,-0.7],[-a,-a],"bnd",material="Steel")
#p.add_boundary_disk([0,-0.7],0,"bnd","Steel")
p
.
add_boundary_disk
([
-
a
,
a
],
0
,
"bnd"
,
"Steel"
)
p
.
add_boundary_disk
([
a
,
a
],
0
,
"bnd"
,
"Steel"
)
tend
=
30
#p.set_friction_coefficient(.2,"Sand","Sand")
#p.set_friction_coefficient(.5,"Sand","Steel")
i
=
0
p
.
write_vtk
(
"output"
,
0
,
0
)
dt
=
0.00
3
dt
=
0.00
25
outf
=
3
t
=
0
while
t
<
tend
:
if
t
*
4
>
n_inserted_pieces
:
add_random_piece
(
p
)
print
(
i
)
if
i
%
100
==
0
:
add_piece
(
p
,
n_inserted_pieces
)
n_inserted_pieces
+=
1
t
+=
dt
f
=
g
*
(
np
.
pi
*
p
.
r
()
**
2
*
rho
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment