Tetrahedralize#

[1]:
from pathlib import Path
from project_heart.lv import LV
from project_heart.utils import set_jupyter_backend
from project_heart.enums import *

set_jupyter_backend("pythreejs")
[2]:
sample_file = Path("../sample_files/lvsample.stl")

Tetrahedralize with WILDMESHING backend#

[3]:
lv = LV.from_file(sample_file)
lv.mesh
[3]:
PolyDataInformation
N Cells104390
N Points52193
X Bounds-2.198e+01, 5.639e+01
Y Bounds-3.899e+01, 4.336e+01
Z Bounds-4.722e+01, 3.682e+01
N Arrays0
[4]:
%%capture
lv.tetrahedralize(backend=TETRA_BACKEND.WILDMESHING, stop_quality=500);
TBB threads 2
bbox_diag_length = 141.371
ideal_edge_length = 7.06855
stage = 2
eps_input = 0.141371
eps = 0.0782616
eps_simplification = 0.0626093
eps_coplanar = 0.000141371
dd = 0.0942474
dd_simplification = 0.0753979
[2022-06-03 11:07:01.110] [float-tetwild] [info] remove duplicates:
[2022-06-03 11:07:01.110] [float-tetwild] [info] #v: 52193 -> 52193
[2022-06-03 11:07:01.110] [float-tetwild] [info] #f: 104390 -> 104390
collapsing 11.0795
swapping 0.040881
[2022-06-03 11:07:12.269] [float-tetwild] [info] remove duplicates:
[2022-06-03 11:07:12.269] [float-tetwild] [info] #v: 5967 -> 5967
[2022-06-03 11:07:12.269] [float-tetwild] [info] #f: 11938 -> 11938
[2022-06-03 11:07:12.270] [float-tetwild] [info] #v = 5967
[2022-06-03 11:07:12.270] [float-tetwild] [info] #f = 11938
#boundary_e1 = 0
#boundary_e2 = 4
[2022-06-03 11:07:12.315] [float-tetwild] [info] preprocessing 11.2357s
[2022-06-03 11:07:12.315] [float-tetwild] [info]
[2022-06-03 11:07:12.413] [float-tetwild] [info] #v = 7126
[2022-06-03 11:07:12.413] [float-tetwild] [info] #t = 41664
[2022-06-03 11:07:12.413] [float-tetwild] [info] tetrahedralizing 0.09833s
[2022-06-03 11:07:12.413] [float-tetwild] [info]
[2022-06-03 11:07:12.414] [float-tetwild] [info] triangle insertion start, #f = 11938, #v = 7126, #t = 41664
[2022-06-03 11:07:12.437] [float-tetwild] [info] matched #f = 9007, uninserted #f = 2931
[2022-06-03 11:07:14.015] [float-tetwild] [info] insert_one_triangle * n done, #v = 15925, #t = 87528
[2022-06-03 11:07:14.015] [float-tetwild] [info] uninserted #f = 0/2931
[2022-06-03 11:07:14.015] [float-tetwild] [info] total timing: 0s
[2022-06-03 11:07:14.082] [float-tetwild] [info] pair_track_surface_fs done
#boundary_e1 = 0
#boundary_e2 = 4
[2022-06-03 11:07:14.091] [float-tetwild] [info] find_boundary_edges done
[2022-06-03 11:07:14.100] [float-tetwild] [info] time1 = 0.009439
[2022-06-03 11:07:14.100] [float-tetwild] [info] uninsert boundary #e = 0/4
[2022-06-03 11:07:14.100] [float-tetwild] [info] time2 = 0
[2022-06-03 11:07:14.100] [float-tetwild] [info] time3 = 7.8e-05
[2022-06-03 11:07:14.100] [float-tetwild] [info] time4 = 0
[2022-06-03 11:07:14.100] [float-tetwild] [info] time5 = 0
[2022-06-03 11:07:14.100] [float-tetwild] [info] time6 = 0
[2022-06-03 11:07:14.101] [float-tetwild] [info] uninserted #f = 0/2931
known_surface_fs.size = 0
known_not_surface_fs.size = 0
[2022-06-03 11:07:15.462] [float-tetwild] [info] mark_surface_fs done
[2022-06-03 11:07:15.469] [float-tetwild] [info] #b_edge1 = 4, #b_edges2 = 0
[2022-06-03 11:07:15.473] [float-tetwild] [info] cutting 3.05972s
[2022-06-03 11:07:15.473] [float-tetwild] [info]
initializing...
edge collapsing...
fixed 0 tangled element
success(env) = 7430
success = 9188(71541)
success(env) = 248
success = 301(46597)
success(env) = 15
success = 17(14876)
success(env) = 3
success = 3(1702)
success(env) = 1
success = 1(168)
success(env) = 0
success = 0(81)
edge collapsing done!
time = 2.82035s
#v = 6286
#t = 36812
max_energy = 2404.15
avg_energy = 9.49347
//////////////// pass 0 ////////////////
edge splitting...
fixed 0 tangled element
success = 10315(10315)
edge splitting done!
time = 0.108094s
#v = 16601
#t = 91818
max_energy = 2404.15
avg_energy = 7.85002
edge collapsing...
fixed 0 tangled element
success(env) = 42
success = 7994(80323)
success(env) = 17
success = 248(39364)
success(env) = 1
success = 21(9272)
success(env) = 0
success = 5(707)
success(env) = 0
success = 5(172)
success(env) = 0
success = 0(168)
edge collapsing done!
time = 1.39444s
#v = 8328
#t = 46861
max_energy = 2404.15
avg_energy = 7.5425
edge swapping...
fixed 0 tangled element
success3 = 3516
success4 = 5142
success5 = 665
success = 9323(44258)
edge swapping done!
time = 0.447373s
#v = 8328
#t = 44010
max_energy = 339.822
avg_energy = 6.02035
vertex smoothing...
success = 4650(7198)
vertex smoothing done!
time = 0.986962s
#v = 8328
#t = 44010
max_energy = 330.865
avg_energy = 5.36725
//////////////// postprocessing ////////////////
edge collapsing...
fixed 0 tangled element
success(env) = 294
success = 408(55739)
success(env) = 11
success = 18(23249)
success(env) = 0
success = 1(1117)
success(env) = 0
success = 0(28)
edge collapsing done!
time = 0.732833s
#v = 7901
#t = 41740
max_energy = 214.682
avg_energy = 5.243
[2022-06-03 11:07:21.976] [float-tetwild] [info] mesh optimization 6.50074s
[2022-06-03 11:07:21.976] [float-tetwild] [info]
[2022-06-03 11:07:22.011] [float-tetwild] [info] correct_tracked_surface_orientation done
[2022-06-03 11:07:22.253] [float-tetwild] [info] after winding number
[2022-06-03 11:07:22.253] [float-tetwild] [info] #v = 4891
[2022-06-03 11:07:22.253] [float-tetwild] [info] #t = 14735
[2022-06-03 11:07:22.253] [float-tetwild] [info] winding number 1.65425e+09s
[2022-06-03 11:07:22.253] [float-tetwild] [info]
[5]:
lv.plot(show_edges=True)
[6]:
lv.mesh
[6]:
UnstructuredGridInformation
N Cells14735
N Points4891
X Bounds-2.197e+01, 5.636e+01
Y Bounds-3.897e+01, 4.331e+01
Z Bounds-4.717e+01, 3.676e+01
N Arrays0

Tetrahedralize with TETGEN backend#

[7]:
lv = LV.from_file(sample_file)
lv.mesh
[7]:
PolyDataInformation
N Cells104390
N Points52193
X Bounds-2.198e+01, 5.639e+01
Y Bounds-3.899e+01, 4.336e+01
Z Bounds-4.722e+01, 3.682e+01
N Arrays0
[8]:
%%capture
lv.tetrahedralize(backend=TETRA_BACKEND.TETGEN, order=1, mindihedral=10.0, minratio=3.0)
[9]:
lv.plot(show_edges=True)
[10]:
lv.mesh
[10]:
UnstructuredGridInformation
N Cells247663
N Points68835
X Bounds-2.198e+01, 5.639e+01
Y Bounds-3.899e+01, 4.336e+01
Z Bounds-4.722e+01, 3.682e+01
N Arrays0