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
6b0ab1f9
Commit
6b0ab1f9
authored
Nov 19, 2018
by
Jonathan Lambrechts
Browse files
numpy -> np
parent
21998c98
Pipeline
#4633
passed with stage
in 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
python/fluid.py
View file @
6b0ab1f9
...
...
@@ -29,16 +29,15 @@
"""
from
ctypes
import
*
import
numpy
from
numpy
import
ctypeslib
import
numpy
as
np
import
signal
import
os
import
sys
from
.
import
VTK
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
lib2
=
ctypeslib
.
load_library
(
"libmbfluid2"
,
dir_path
)
lib3
=
ctypeslib
.
load_library
(
"libmbfluid3"
,
dir_path
)
lib2
=
np
.
ctypeslib
.
load_library
(
"libmbfluid2"
,
dir_path
)
lib3
=
np
.
ctypeslib
.
load_library
(
"libmbfluid3"
,
dir_path
)
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
...
...
@@ -49,8 +48,8 @@ class _Bnd :
self
.
_dim
=
dim
def
apply
(
self
,
n
,
xp
,
vp
)
:
nv
=
len
(
self
.
_b
)
x
=
n
umpy
.
frombuffer
(
cast
(
xp
,
POINTER
(
int
(
n
)
*
self
.
_dim
*
c_double
)).
contents
).
reshape
([
n
,
-
1
])
v
=
n
umpy
.
frombuffer
(
cast
(
vp
,
POINTER
(
int
(
n
)
*
nv
*
c_double
)).
contents
).
reshape
([
n
,
nv
])
x
=
n
p
.
frombuffer
(
cast
(
xp
,
POINTER
(
int
(
n
)
*
self
.
_dim
*
c_double
)).
contents
).
reshape
([
n
,
-
1
])
v
=
n
p
.
frombuffer
(
cast
(
vp
,
POINTER
(
int
(
n
)
*
nv
*
c_double
)).
contents
).
reshape
([
n
,
nv
])
for
i
in
range
(
nv
):
if
callable
(
self
.
_b
[
i
])
:
v
[:,
i
]
=
self
.
_b
[
i
](
x
)
...
...
@@ -84,7 +83,7 @@ class FluidProblem :
self
.
strong_cb_ref
=
[]
self
.
weak_cb_ref
=
[]
def
np2c
(
a
)
:
tmp
=
n
umpy
.
require
(
a
,
"float"
,
"C"
)
tmp
=
n
p
.
require
(
a
,
"float"
,
"C"
)
r
=
c_void_p
(
tmp
.
ctypes
.
data
)
r
.
tmp
=
tmp
return
r
...
...
@@ -95,7 +94,7 @@ class FluidProblem :
else
:
raise
ValueError
(
"dim should be 2 or 3."
)
self
.
_lib
.
fluid_problem_new
.
restype
=
c_void_p
n_fluids
=
n
umpy
.
require
(
rho
,
"float"
,
"C"
).
reshape
([
-
1
]).
shape
[
0
]
n_fluids
=
n
p
.
require
(
rho
,
"float"
,
"C"
).
reshape
([
-
1
]).
shape
[
0
]
self
.
_n_fluids
=
n_fluids
self
.
_dim
=
dim
self
.
_fp
=
c_void_p
(
self
.
_lib
.
fluid_problem_new
(
c_double
(
g
),
n_fluids
,
np2c
(
mu
),
np2c
(
rho
),
c_double
(
coeff_stab
),
petsc_solver_type
.
encode
()))
...
...
@@ -195,7 +194,7 @@ class FluidProblem :
"""
v
=
self
.
solution
()[:,:
self
.
_dim
]
if
self
.
_dim
==
2
:
v
=
n
umpy
.
insert
(
v
,
self
.
_dim
,
0
,
axis
=
1
)
v
=
n
p
.
insert
(
v
,
self
.
_dim
,
0
,
axis
=
1
)
data
=
[
(
"pressure"
,
self
.
solution
()[:,[
self
.
_dim
]]),
(
"velocity"
,
v
),
...
...
@@ -210,8 +209,8 @@ class FluidProblem :
field_data
.
append
((
b
"Physical %i %i %s"
%
(
dim
,
pid
,
name
),
nodes
[:,
None
]))
field_data
.
append
((
b
"Boundary %i %i %s"
%
(
dim
,
pid
,
name
),
bnd
))
connectivity
=
self
.
elements
()
types
=
n
umpy
.
repeat
([
5
if
self
.
_dim
==
2
else
10
],
connectivity
.
shape
[
0
])
offsets
=
n
umpy
.
cumsum
(
n
umpy
.
repeat
([
self
.
_dim
+
1
],
connectivity
.
shape
[
0
]))
types
=
n
p
.
repeat
([
5
if
self
.
_dim
==
2
else
10
],
connectivity
.
shape
[
0
])
offsets
=
n
p
.
cumsum
(
n
p
.
repeat
([
self
.
_dim
+
1
],
connectivity
.
shape
[
0
]))
VTK
.
write
(
output_dir
+
"/fluid"
,
it
,
t
,(
types
,
connectivity
,
offsets
),
self
.
coordinates
(),
data
,
field_data
)
def
import_vtk
(
self
,
filename
)
:
...
...
@@ -221,15 +220,15 @@ class FluidProblem :
filename -- name of the file to read
"""
def
np2c
(
a
,
dtype
)
:
tmp
=
n
umpy
.
require
(
a
,
dtype
,
"C"
)
tmp
=
n
p
.
require
(
a
,
dtype
,
"C"
)
r
=
c_void_p
(
tmp
.
ctypes
.
data
)
r
.
tmp
=
tmp
return
r
x
,
cells
,
data
,
cdata
,
fdata
=
VTK
.
read
(
filename
)
el
=
cells
[
"connectivity"
].
reshape
([
-
1
,
self
.
_dim
+
1
])
self
.
_lib
.
fluid_problem_private_set_elements
(
self
.
_fp
,
c_int
(
x
.
shape
[
0
]),
np2c
(
x
,
n
umpy
.
float64
),
c_int
(
el
.
shape
[
0
]),
np2c
(
el
,
n
umpy
.
int32
))
c_int
(
x
.
shape
[
0
]),
np2c
(
x
,
n
p
.
float64
),
c_int
(
el
.
shape
[
0
]),
np2c
(
el
,
n
p
.
int32
))
phys
=
{}
bnds
=
{}
for
n
,
d
in
fdata
.
items
()
:
...
...
@@ -242,8 +241,8 @@ class FluidProblem :
bnd
=
bnds
[(
dim
,
pid
)]
self
.
_lib
.
fluid_problem_private_add_physical
(
self
.
_fp
,
c_int
(
int
(
pid
)),
c_int
(
int
(
dim
)),
c_char_p
(
name
.
encode
(
"utf-8"
)),
c_int
(
nodes
.
shape
[
0
]),
np2c
(
nodes
,
n
umpy
.
int32
),
c_int
(
bnd
.
shape
[
0
]),
np2c
(
bnd
,
n
umpy
.
int32
))
c_int
(
nodes
.
shape
[
0
]),
np2c
(
nodes
,
n
p
.
int32
),
c_int
(
bnd
.
shape
[
0
]),
np2c
(
bnd
,
n
p
.
int32
))
sol
=
self
.
solution
()
sol
[:,:
self
.
_dim
]
=
data
[
"velocity"
][:,:
self
.
_dim
]
sol
[:,[
self
.
_dim
]]
=
data
[
"pressure"
]
...
...
@@ -259,7 +258,7 @@ class FluidProblem :
Keyword arguments:
dt -- computation time step
"""
forces
=
n
umpy
.
ndarray
([
self
.
n_particles
,
self
.
_dim
],
"d"
,
order
=
"C"
)
forces
=
n
p
.
ndarray
([
self
.
n_particles
,
self
.
_dim
],
"d"
,
order
=
"C"
)
self
.
_lib
.
fluid_problem_compute_node_particle_force
(
self
.
_fp
,
c_double
(
dt
),
c_void_p
(
forces
.
ctypes
.
data
))
return
forces
...
...
@@ -285,7 +284,7 @@ class FluidProblem :
reload -- optional arguments specifying if the simulation is reloaded or if it is the first iteration
"""
def
np2c
(
a
)
:
tmp
=
n
umpy
.
require
(
a
,
"float"
,
"C"
)
tmp
=
n
p
.
require
(
a
,
"float"
,
"C"
)
r
=
c_void_p
(
tmp
.
ctypes
.
data
)
r
.
tmp
=
tmp
return
r
...
...
@@ -295,7 +294,7 @@ class FluidProblem :
def
_get_matrix
(
self
,
f_name
,
nrow
,
ncol
,
typec
=
c_double
)
:
f
=
getattr
(
self
.
_lib
,
"fluid_problem_"
+
f_name
)
f
.
restype
=
POINTER
(
typec
)
return
n
umpy
.
ctypeslib
.
as_array
(
f
(
self
.
_fp
),
shape
=
(
nrow
,
ncol
))
return
n
p
.
ctypeslib
.
as_array
(
f
(
self
.
_fp
),
shape
=
(
nrow
,
ncol
))
def
solution
(
self
)
:
"""Give access to the fluid field value at the mesh nodes."""
...
...
@@ -341,7 +340,7 @@ class FluidProblem :
ptr
=
f
(
self
.
_fp
)
size
=
fs
(
self
.
_fp
)
buf
=
(
size
*
c_int
).
from_address
(
ptr
)
return
n
umpy
.
ctypeslib
.
as_array
(
buf
)
return
n
p
.
ctypeslib
.
as_array
(
buf
)
def
_n_physicals
(
self
):
f
=
self
.
_lib
.
fluid_problem_private_n_physical
...
...
@@ -358,7 +357,7 @@ class FluidProblem :
phys_n_boundaries
=
c_int
()
phys_boundaries
=
POINTER
(
c_int
)()
f
(
self
.
_fp
,
c_int
(
ibnd
),
byref
(
phys_name
),
byref
(
phys_dim
),
byref
(
phys_id
),
byref
(
phys_n_nodes
),
byref
(
phys_nodes
),
byref
(
phys_n_boundaries
),
byref
(
phys_boundaries
))
nodes
=
n
umpy
.
ctypeslib
.
as_array
(
phys_nodes
,
shape
=
(
phys_n_nodes
.
value
,))
if
phys_nodes
else
n
umpy
.
ndarray
([
0
],
n
umpy
.
int32
)
bnd
=
n
umpy
.
ctypeslib
.
as_array
(
phys_boundaries
,
shape
=
(
phys_n_boundaries
.
value
,
2
))
if
phys_boundaries
else
n
umpy
.
ndarray
([
2
,
0
],
n
umpy
.
int32
)
nodes
=
n
p
.
ctypeslib
.
as_array
(
phys_nodes
,
shape
=
(
phys_n_nodes
.
value
,))
if
phys_nodes
else
n
p
.
ndarray
([
0
],
n
p
.
int32
)
bnd
=
n
p
.
ctypeslib
.
as_array
(
phys_boundaries
,
shape
=
(
phys_n_boundaries
.
value
,
2
))
if
phys_boundaries
else
n
p
.
ndarray
([
2
,
0
],
n
p
.
int32
)
return
phys_name
.
value
,
phys_dim
.
value
,
phys_id
.
value
,
nodes
,
bnd
python/scontact.py
View file @
6b0ab1f9
...
...
@@ -32,23 +32,22 @@ from __future__ import division
from
.
import
mesh
from
.
import
VTK
import
shutil
import
numpy
import
numpy
as
np
import
os
import
sys
from
ctypes
import
*
import
signal
from
numpy
import
ctypeslib
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
lib2
=
ctypeslib
.
load_library
(
"libscontact2"
,
dir_path
)
lib3
=
ctypeslib
.
load_library
(
"libscontact3"
,
dir_path
)
lib2
=
np
.
ctypeslib
.
load_library
(
"libscontact2"
,
dir_path
)
lib3
=
np
.
ctypeslib
.
load_library
(
"libscontact3"
,
dir_path
)
is_64bits
=
sys
.
maxsize
>
2
**
32
def
_np2c
(
a
,
dtype
=
n
umpy
.
float64
)
:
tmp
=
n
umpy
.
require
(
a
,
dtype
,
"C"
)
def
_np2c
(
a
,
dtype
=
n
p
.
float64
)
:
tmp
=
n
p
.
require
(
a
,
dtype
,
"C"
)
r
=
c_void_p
(
tmp
.
ctypes
.
data
)
r
.
tmp
=
tmp
return
r
...
...
@@ -62,7 +61,7 @@ class ParticleProblem :
ptr
=
f
(
self
.
_p
)
size
=
cast
(
ptr
-
(
8
if
is_64bits
else
4
),
POINTER
(
c_size_t
)).
contents
.
value
//
8
buf
=
(
size
*
c_double
).
from_address
(
ptr
)
return
n
umpy
.
ctypeslib
.
as_array
(
buf
).
reshape
([
-
1
,
ncol
])
return
n
p
.
ctypeslib
.
as_array
(
buf
).
reshape
([
-
1
,
ncol
])
def
_get_idx
(
self
,
fName
)
:
f
=
getattr
(
self
.
_lib
,
"particleProblem"
+
fName
)
...
...
@@ -70,7 +69,7 @@ class ParticleProblem :
ptr
=
f
(
self
.
_p
)
size
=
cast
(
ptr
-
(
8
if
is_64bits
else
4
),
POINTER
(
c_size_t
)).
contents
.
value
//
4
buf
=
(
size
*
c_int
).
from_address
(
ptr
)
return
n
umpy
.
ctypeslib
.
as_array
(
buf
)
return
n
p
.
ctypeslib
.
as_array
(
buf
)
def
__init__
(
self
,
dim
)
:
"""Build the particles contanier structure.
...
...
@@ -104,9 +103,9 @@ class ParticleProblem :
def
volume
(
self
):
"""Return the list of particle volumes."""
if
self
.
_dim
==
2
:
return
n
umpy
.
pi
*
self
.
_get_matrix
(
"Particle"
,
2
)[:,
[
0
]]
**
2
return
n
p
.
pi
*
self
.
_get_matrix
(
"Particle"
,
2
)[:,
[
0
]]
**
2
else
:
return
4.
/
3.
*
n
umpy
.
pi
*
self
.
_get_matrix
(
"Particle"
,
2
)[:,
[
0
]]
**
3
return
4.
/
3.
*
n
p
.
pi
*
self
.
_get_matrix
(
"Particle"
,
2
)[:,
[
0
]]
**
3
def
r
(
self
)
:
"""Return the list of particle radii."""
...
...
@@ -141,13 +140,13 @@ class ParticleProblem :
if
self
.
_dim
==
3
:
return
self
.
_get_matrix
(
"Triangle"
,
12
)
else
:
return
n
umpy
.
ndarray
([
0
,
12
])
return
n
p
.
ndarray
([
0
,
12
])
def
triangle_tag
(
self
):
if
self
.
_dim
==
3
:
return
self
.
_get_idx
(
"TriangleTag"
)
else
:
return
n
umpy
.
array
([],
n
umpy
.
int32
)
return
n
p
.
array
([],
n
p
.
int32
)
def
set_boundary_velocity
(
self
,
tag
,
v
)
:
self
.
_lib
.
particleProblemGetTagId
.
restype
=
c_size_t
...
...
@@ -172,7 +171,7 @@ class ParticleProblem :
tol -- optional argument defining the interpenetration tolerance to stop the NLGS iterations of the NSCD
"""
self
.
_get_matrix
(
"ExternalForces"
,
self
.
_dim
)[:]
=
forces
self
.
_lib
.
particleProblemIterate
(
self
.
_p
,
c_double
(
n
umpy
.
min
(
self
.
r
())),
c_double
(
dt
),
c_double
(
tol
),
c_int
(
-
1
))
self
.
_lib
.
particleProblemIterate
(
self
.
_p
,
c_double
(
n
p
.
min
(
self
.
r
())),
c_double
(
dt
),
c_double
(
tol
),
c_int
(
-
1
))
def
write_vtk
(
self
,
odir
,
i
,
t
)
:
"""Write output files for post-visualization."""
...
...
@@ -180,8 +179,8 @@ class ParticleProblem :
v
=
self
.
velocity
()
x
=
self
.
position
()
if
self
.
_dim
==
2
:
v
=
n
umpy
.
insert
(
v
,
self
.
_dim
,
0
,
axis
=
1
)
x
=
n
umpy
.
insert
(
x
,
self
.
_dim
,
0
,
axis
=
1
)
v
=
n
p
.
insert
(
v
,
self
.
_dim
,
0
,
axis
=
1
)
x
=
n
p
.
insert
(
x
,
self
.
_dim
,
0
,
axis
=
1
)
data
=
[(
"Mass"
,
self
.
mass
()),
(
"Radius"
,
self
.
radius
()),(
"Velocity"
,
v
)]
VTK
.
write
(
odir
+
"/particles"
,
i
,
t
,
None
,
x
,
data
,
vtktype
=
"vtp"
)
...
...
@@ -191,25 +190,25 @@ class ParticleProblem :
ns
=
xsegment
.
shape
[
0
]
/
2
xtriangles
=
self
.
triangles
()[:,:
self
.
_dim
*
3
].
reshape
([
-
1
,
self
.
_dim
])
nt
=
xtriangles
.
shape
[
0
]
/
3
x
=
n
umpy
.
vstack
([
xdisk
,
xsegment
,
xtriangles
])
x
=
n
p
.
vstack
([
xdisk
,
xsegment
,
xtriangles
])
if
self
.
_dim
==
2
:
x
=
n
umpy
.
insert
(
x
,
self
.
_dim
,
0
,
axis
=
1
)
connectivity
=
n
umpy
.
arange
(
0
,
x
.
shape
[
0
],
dtype
=
n
umpy
.
int32
)
types
=
n
umpy
.
repeat
(
n
umpy
.
array
([
1
,
3
,
5
],
dtype
=
n
umpy
.
int32
),[
nd
,
ns
,
nt
])
offsets
=
n
umpy
.
cumsum
(
n
umpy
.
repeat
([
1
,
2
,
3
],[
nd
,
ns
,
nt
]),
dtype
=
n
umpy
.
int32
)
tags
=
n
umpy
.
array
(
n
umpy
.
hstack
([
self
.
disk_tag
(),
self
.
segment_tag
(),
self
.
triangle_tag
()]),
dtype
=
n
umpy
.
float64
)
x
=
n
p
.
insert
(
x
,
self
.
_dim
,
0
,
axis
=
1
)
connectivity
=
n
p
.
arange
(
0
,
x
.
shape
[
0
],
dtype
=
n
p
.
int32
)
types
=
n
p
.
repeat
(
n
p
.
array
([
1
,
3
,
5
],
dtype
=
n
p
.
int32
),[
nd
,
ns
,
nt
])
offsets
=
n
p
.
cumsum
(
n
p
.
repeat
([
1
,
2
,
3
],[
nd
,
ns
,
nt
]),
dtype
=
n
p
.
int32
)
tags
=
n
p
.
array
(
n
p
.
hstack
([
self
.
disk_tag
(),
self
.
segment_tag
(),
self
.
triangle_tag
()]),
dtype
=
n
p
.
float64
)
VTK
.
write
(
odir
+
"/boundaries"
,
i
,
t
,(
types
,
connectivity
,
offsets
),
x
,
cell_data
=
[(
"Tag"
,
tags
.
reshape
([
-
1
,
1
]))])
self
.
_lib
.
particleProblemContactN
.
restype
=
c_size_t
fdata
=
[]
for
(
ctype
,
name
)
in
((
0
,
b
"particle_particle"
),(
1
,
b
"particle_disk"
),(
2
,
b
"particle_segment"
),(
3
,
b
"particle_triangle"
))
:
n
=
self
.
_lib
.
particleProblemContactN
(
self
.
_p
,
c_int
(
ctype
))
v
=
n
umpy
.
ndarray
((
n
,
1
),
dtype
=
n
umpy
.
float64
,
order
=
"C"
)
o
=
n
umpy
.
ndarray
((
n
,
2
),
dtype
=
n
umpy
.
uint64
,
order
=
"C"
)
v
=
n
p
.
ndarray
((
n
,
1
),
dtype
=
n
p
.
float64
,
order
=
"C"
)
o
=
n
p
.
ndarray
((
n
,
2
),
dtype
=
n
p
.
uint64
,
order
=
"C"
)
self
.
_lib
.
particleProblemContact
(
self
.
_p
,
c_int
(
ctype
),
c_void_p
(
o
.
ctypes
.
data
),
c_void_p
(
v
.
ctypes
.
data
))
fdata
.
append
((
name
,
v
))
fdata
.
append
((
name
+
b
"_idx"
,
o
))
x
=
n
umpy
.
array
([[
0.
,
0.
,
0.
]])
x
=
n
p
.
array
([[
0.
,
0.
,
0.
]])
VTK
.
write
(
odir
+
"/contacts"
,
i
,
t
,
None
,
x
,
field_data
=
fdata
,
vtktype
=
"vtp"
)
VTK
.
write_multipart
(
odir
+
"/particle_problem"
,[
"pyparticles_%05d.vtp"
%
i
,
"pybnd_%05d.vtu"
%
i
,
"pycontact_%05d.vtp"
%
i
],
i
,
t
)
...
...
@@ -223,19 +222,19 @@ class ParticleProblem :
x
,
cells
,
d
,
cdata
,
fdata
=
VTK
.
read
(
dirname
+
"/boundaries_%05d.vtu"
%
i
)
self
.
_lib
.
particleProblemClearBoundaries
(
self
.
_p
)
offsets
=
n
umpy
.
hstack
([[
0
],
cells
[
"offsets"
]])
offsets
=
n
p
.
hstack
([[
0
],
cells
[
"offsets"
]])
el
=
cells
[
"connectivity"
]
tags
=
cdata
[
"Tag"
]
for
idx
in
n
umpy
.
where
(
cells
[
"types"
]
==
1
)[
0
]
:
for
idx
in
n
p
.
where
(
cells
[
"types"
]
==
1
)[
0
]
:
x0
=
x
[
el
[
offsets
[
idx
]],:
self
.
_dim
]
t
=
int
(
tags
[
idx
,
0
])
self
.
_lib
.
particleProblemAddBoundaryDiskTagId
(
self
.
_p
,
self
.
_coord_type
(
*
x0
),
c_double
(
0.
),
c_int
(
t
))
for
idx
in
n
umpy
.
where
(
cells
[
"types"
]
==
3
)[
0
]
:
for
idx
in
n
p
.
where
(
cells
[
"types"
]
==
3
)[
0
]
:
x0
=
x
[
el
[
offsets
[
idx
]],:
self
.
_dim
]
x1
=
x
[
el
[
offsets
[
idx
]
+
1
],:
self
.
_dim
]
t
=
int
(
tags
[
idx
,
0
])
self
.
_lib
.
particleProblemAddBoundarySegmentTagId
(
self
.
_p
,
self
.
_coord_type
(
*
x0
),
self
.
_coord_type
(
*
x1
),
c_int
(
t
))
for
idx
in
n
umpy
.
where
(
cells
[
"types"
]
==
5
)[
0
]
:
for
idx
in
n
p
.
where
(
cells
[
"types"
]
==
5
)[
0
]
:
x0
=
x
[
el
[
offsets
[
idx
]],:
self
.
_dim
]
x1
=
x
[
el
[
offsets
[
idx
]
+
1
],:
self
.
_dim
]
x2
=
x
[
el
[
offsets
[
idx
]
+
2
],:
self
.
_dim
]
...
...
@@ -243,10 +242,10 @@ class ParticleProblem :
self
.
_lib
.
particleProblemAddBoundaryTriangleTagId
(
self
.
_p
,
self
.
_coord_type
(
*
x0
),
self
.
_coord_type
(
*
x1
),
self
.
_coord_type
(
*
x2
),
c_int
(
t
))
_
,
_
,
_
,
_
,
fdata
=
VTK
.
read
(
dirname
+
"/contacts_%05d.vtp"
%
i
)
ks
=
(
"particle_particle"
,
"particle_disk"
,
"particle_segment"
,
"particle_triangle"
)
v
=
n
umpy
.
vstack
([
fdata
[
k
]
for
k
in
ks
])
o
=
n
umpy
.
vstack
([
fdata
[
k
+
"_idx"
]
for
k
in
ks
])
t
=
n
umpy
.
repeat
([
0
,
1
,
2
,
3
],[
fdata
[
k
].
shape
[
0
]
for
k
in
ks
])
self
.
_lib
.
particleProblemSetContacts
(
self
.
_p
,
c_int
(
t
.
shape
[
0
]),
_np2c
(
o
,
n
umpy
.
uint64
),
_np2c
(
v
),
_np2c
(
t
,
n
umpy
.
int32
))
v
=
n
p
.
vstack
([
fdata
[
k
]
for
k
in
ks
])
o
=
n
p
.
vstack
([
fdata
[
k
+
"_idx"
]
for
k
in
ks
])
t
=
n
p
.
repeat
([
0
,
1
,
2
,
3
],[
fdata
[
k
].
shape
[
0
]
for
k
in
ks
])
self
.
_lib
.
particleProblemSetContacts
(
self
.
_p
,
c_int
(
t
.
shape
[
0
]),
_np2c
(
o
,
n
p
.
uint64
),
_np2c
(
v
),
_np2c
(
t
,
n
p
.
int32
))
def
add_boundary_disk
(
self
,
x0
,
r
,
tag
)
:
self
.
_lib
.
particleProblemAddBoundaryDisk
.
restype
=
c_size_t
...
...
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