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
Daniel Boeckenhoff
tfields
Commits
fbb46f42
Commit
fbb46f42
authored
Oct 16, 2019
by
Daniel Boeckenhoff
Browse files
performance bounding box debugged
parent
5385017b
Changes
2
Hide whitespace changes
Inline
Side-by-side
make
@
96a8a33f
Compare
acb8a624
...
96a8a33f
Subproject commit
acb8a624b9fd639569c0
e8
a
8d
52abd54aa8ded0b
Subproject commit
96a8a33f
e8
b
8d
800853f8ee2cbf7a1e5814bef91
performance/performance_bounding_box.py
View file @
fbb46f42
import
loggingTools
import
tfields
import
numpy
as
np
import
cPickle
as
pickle
with
tfields
.
lib
.
log
.
timeit
(
"Building Grid"
):
mesh
=
tfields
.
Mesh3D
.
grid
((
0
,
1
,
10
),
(
2
,
1
,
10
),
(
2
,
3
,
20
))
# mesh = tfields.Mesh3D.grid((0, 1, 50), (2, 1, 20), (2, 3, 50))
print
mesh
.
nfaces
()
with
open
(
tfields
.
lib
.
in_out
.
resolve
(
'~/tmp/node.pickle'
),
'r'
)
as
f
:
tree
=
pickle
.
load
(
f
)
# with tfields.lib.log.timeit("SEARCHING TREE OFFSET"):
# # tree = tfields.bounding_box.Searcher(mesh, n_sections=[2, 1, 2])
tree
=
tfields
.
bounding_box
.
Searcher
(
mesh
)
points
=
tfields
.
Tensors
([[
0.5
,
1
,
2.1
],
[
0.5
,
0
,
0
],
[
0.5
,
2
,
2
]])
with
tfields
.
lib
.
log
.
timeit
(
"SEARCHING TREE METHOD"
):
box_res
=
tree
.
in_faces
(
points
,
delta
=
0.0001
)
with
tfields
.
lib
.
log
.
timeit
(
"STANDARD METHOD"
):
usual_res
=
mesh
.
in_faces
(
points
,
delta
=
0.0001
)
assert
np
.
array_equal
(
box_res
,
usual_res
)
with
open
(
tfields
.
lib
.
in_out
.
resolve
(
'~/tmp/node.pickle'
),
'w'
)
as
f
:
pickle
.
dump
(
tree
,
f
)
#
import cPickle as pickle
#
#
with tfields.lib.log.timeit("Building Grid"):
#
mesh = tfields.Mesh3D.grid((0, 1, 10), (2, 1, 10), (2, 3, 20))
#
# mesh = tfields.Mesh3D.grid((0, 1, 50), (2, 1, 20), (2, 3, 50))
#
print
(
mesh.nfaces()
)
#
#
with open(tfields.lib.in_out.resolve('~/tmp/node.pickle'), 'r') as f:
#
tree = pickle.load(f)
#
#
# with tfields.lib.log.timeit("SEARCHING TREE OFFSET"):
#
# # tree = tfields.bounding_box.Searcher(mesh, n_sections=[2, 1, 2])
#
tree = tfields.bounding_box.Searcher(mesh)
#
#
points = tfields.Tensors([[0.5, 1, 2.1],
#
[0.5, 0, 0],
#
[0.5, 2, 2]])
#
with tfields.lib.log.timeit("SEARCHING TREE METHOD"):
#
box_res = tree.in_faces(points, delta=0.0001)
#
with tfields.lib.log.timeit("STANDARD METHOD"):
#
usual_res = mesh.in_faces(points, delta=0.0001)
#
assert np.array_equal(box_res, usual_res)
#
#
with open(tfields.lib.in_out.resolve('~/tmp/node.pickle'), 'w') as f:
#
pickle.dump(tree, f)
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