Skip to content

Commit 6fe9d5b

Browse files
committed
Update bindings for jigsaw-0.9.14.xx
- Improved file i/o: faster + consistent %.17g sprintf-style float format. - Inc. new file i/o "tags" for additional control: precision, file type, etc.
1 parent 3114433 commit 6fe9d5b

11 files changed

Lines changed: 768 additions & 649 deletions

File tree

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# jigsaw things
2+
*
3+
!/**/
4+
!*.*
5+
*.exe
6+
*.dll
7+
*.so
8+
*.dylib
9+
cache/*.log
10+
cache/*.jig
11+
cache/*.msh
12+
13+
# python things
14+
__pycache__/
15+
*.py[cod]
16+
17+
jigsawpy/_bin/
18+
jigsawpy/_lib/
19+
20+
build/
21+
develop-eggs/
22+
dist/
23+
eggs/
24+
parts/
25+
sdist/
26+
var/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
31+
# data files, etc
32+
*.nc
33+
*.grd
34+
*.vtk
35+
*.off
36+
*.obj
37+
*.stl

jigsawpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* JIGSAW: Interface to the JIGSAW meshing library.
1414
------------------------------------------------------------
1515
*
16-
* Last updated: 03 September, 2020
16+
* Last updated: 23 September, 2020
1717
*
1818
* Copyright 2019-2020
1919
* Darren Engwirda

jigsawpy/jig_t.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ def __init__(self):
223223

224224
#------------------------------------------ INIT options
225225
self.init_file = None
226+
self.init_tags = None
226227
self.init_near = None
227228

228229
#------------------------------------------ GEOM options
229230
self.geom_file = None
231+
self.geom_tags = None
230232

231233
self.geom_seed = None
232234

@@ -240,6 +242,7 @@ def __init__(self):
240242

241243
#------------------------------------------ HFUN options
242244
self.hfun_file = None
245+
self.hfun_tags = None
243246

244247
self.hfun_scal = None
245248

@@ -248,6 +251,7 @@ def __init__(self):
248251

249252
#------------------------------------------ MESH options
250253
self.mesh_file = None
254+
self.mesh_tags = None
251255

252256
self.mesh_kern = None
253257
self.bnds_kern = None

jigsawpy/jigsaw.py

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def jitter(opts, imax, ibad, mesh=None):
309309

310310
if (next.tria3 is not None and
311311
next.tria3.size != +0):
312-
313312
#------------------------------ mark any irregular nodes
314313
vdeg = trideg2(
315314
next.point["coord"],
@@ -330,9 +329,8 @@ def jitter(opts, imax, ibad, mesh=None):
330329

331330
keep[next.edge2["index"][:, :]] = True
332331

333-
#------------------------------ don't delete everything!
334332
if (np.count_nonzero(keep) <= +8):
335-
333+
#------------------------------ don't delete everything!
336334
keep = np.full(
337335
(nvrt), True, dtype=bool)
338336

@@ -342,7 +340,8 @@ def jitter(opts, imax, ibad, mesh=None):
342340
init = jigsaw_msh_t()
343341
init.point = next.point[keep]
344342

345-
savemsh(OPTS.init_file, init)
343+
savemsh(OPTS.init_file, init,
344+
OPTS.mesh_tags)
346345

347346
#------------------------------ call JIGSAW with new ICs
348347
jigsaw (OPTS, next) # noqa
@@ -419,11 +418,11 @@ def tetris(opts, nlev, mesh=None):
419418
#---------------------------- call JIGSAW via inc. bisection
420419
SCAL = +2. ** nlev
421420
OPTS = copy.deepcopy(opts)
421+
flag = +1
422422

423423
while (nlev >= +0):
424424

425425
if (opts.optm_qlim is not None):
426-
427426
#------------------------ create/write current QLIM data
428427
scal = min(
429428
2.0, (nlev + 1) ** (1. / 4.))
@@ -433,7 +432,6 @@ def tetris(opts, nlev, mesh=None):
433432
OPTS.optm_qlim = QLIM / scal
434433

435434
else:
436-
437435
scal = min(
438436
2.0, (nlev + 1) ** (1. / 4.))
439437

@@ -442,24 +440,20 @@ def tetris(opts, nlev, mesh=None):
442440
OPTS.optm_qlim = QLIM / scal
443441

444442
if (opts.optm_dual is not None):
445-
446443
#------------------------ create/write current DUAL data
447444
OPTS.optm_dual = nlev == 0
448445

449446
if (opts.hfun_hmax is not None):
450-
451447
#------------------------ create/write current HMAX data
452448
OPTS.hfun_hmax = \
453449
opts.hfun_hmax * SCAL
454450

455451
if (opts.hfun_hmin is not None):
456-
457452
#------------------------ create/write current HMIN data
458453
OPTS.hfun_hmin = \
459454
opts.hfun_hmin * SCAL
460455

461456
if (opts.hfun_file is not None):
462-
463457
#------------------------ create/write current HFUN data
464458
path = Path(opts.hfun_file).parent
465459
name = Path(opts.hfun_file).stem
@@ -477,28 +471,31 @@ def tetris(opts, nlev, mesh=None):
477471

478472
HFUN.value = HFUN.value * SCAL
479473

480-
savemsh(OPTS.hfun_file, HFUN)
474+
savemsh(OPTS.hfun_file, HFUN,
475+
OPTS.hfun_tags)
481476

477+
if (nlev == 0 or flag == 0):
482478
#------------------------ call JIGSAW kernel at this lev
483-
if (nlev % 2 != 0):
479+
ninc = min(64, nlev * nlev)
484480

485-
ninc = nlev * (-1 + nlev)
481+
flag = +1
486482

487-
jitter(OPTS, 3 + ninc, 2, mesh)
483+
jitter(OPTS, 3 + ninc, 3, mesh)
488484

489485
else:
490486

491-
ninc = nlev * (-1 + nlev)
487+
ninc = min(64, nlev * nlev)
492488

493-
jitter(OPTS, 3 + ninc, 3, mesh)
489+
flag = +0
490+
491+
jitter(OPTS, 3 + ninc, 2, mesh)
494492

495493
nlev = nlev - 1
496494
SCAL = SCAL / 2.
497495

498496
if (nlev < +0): break
499497

500498
if (opts.init_file is not None):
501-
502499
#------------------------ create/write current INIT data
503500
path = Path(opts.init_file).parent
504501
name = Path(opts.init_file).stem
@@ -513,10 +510,10 @@ def tetris(opts, nlev, mesh=None):
513510
bisect(mesh)
514511
attach(mesh)
515512

516-
savemsh(OPTS.init_file, mesh)
513+
savemsh(OPTS.init_file, mesh,
514+
OPTS.init_tags)
517515

518516
else:
519-
520517
#------------------------ create/write current INIT data
521518
path = Path(opts.mesh_file).parent
522519
name = Path(opts.mesh_file).stem
@@ -531,7 +528,8 @@ def tetris(opts, nlev, mesh=None):
531528
bisect(mesh)
532529
attach(mesh)
533530

534-
savemsh(OPTS.init_file, mesh)
531+
savemsh(OPTS.init_file, mesh,
532+
OPTS.mesh_tags)
535533

536534
return
537535

@@ -550,15 +548,13 @@ def refine(opts, nlev, mesh=None):
550548
raise Exception("Incorrect type: MESH.")
551549

552550
#---------------------------- call JIGSAW via inc. bisection
553-
554551
opts.mesh_iter = +0
555552
opts.optm_div_ = False
556553
opts.optm_zip_ = False
557554

558555
for ilev in reversed(range(nlev + 1)):
559556

560557
if (opts.optm_dual is not None):
561-
562558
#------------------------ create/write current DUAL data
563559
opts.optm_dual = ilev == 0
564560

@@ -568,7 +564,6 @@ def refine(opts, nlev, mesh=None):
568564
if (ilev <= +0): break
569565

570566
if (opts.mesh_file is not None):
571-
572567
#------------------------ create/write current INIT data
573568
path = Path(opts.mesh_file).parent
574569
name = Path(opts.mesh_file).stem
@@ -583,7 +578,8 @@ def refine(opts, nlev, mesh=None):
583578
bisect(mesh)
584579
attach(mesh)
585580

586-
savemsh(opts.init_file, mesh)
581+
savemsh(opts.init_file, mesh,
582+
opts.mesh_tags)
587583

588584
return
589585

@@ -625,13 +621,11 @@ def icosahedron(opts, nlev, mesh):
625621
(+8.0 * lo, +1.0 * la),
626622
(+9.0 * lo, -1.0 * la)])
627623

628-
mesh.vert3 = np.zeros(
629-
+12, dtype=mesh.VERT3_t)
624+
mesh.vert3 = np.zeros(+12, dtype=mesh.VERT3_t)
630625

631-
mesh.vert3["coord"] = \
632-
S2toR3(geom.radii, apos)
626+
mesh.vert3["coord"] = S2toR3(geom.radii, apos)
633627

634-
mesh.vert3["IDtag"] = -1 # fix "corners"
628+
mesh.vert3["IDtag"] = - 1 # fix "corners"
635629

636630
#-------------------------------- setup icosahedron topology
637631
mesh.tria3 = np.array([
@@ -699,13 +693,11 @@ def cubedsphere(opts, nlev, mesh):
699693
(-0.75 * np.pi, +aval),
700694
(-0.25 * np.pi, +aval)])
701695

702-
mesh.vert3 = np.zeros(
703-
+ 8, dtype=mesh.VERT3_t)
696+
mesh.vert3 = np.zeros(+ 8, dtype=mesh.VERT3_t)
704697

705-
mesh.vert3["coord"] = \
706-
S2toR3(geom.radii, apos)
698+
mesh.vert3["coord"] = S2toR3(geom.radii, apos)
707699

708-
mesh.vert3["IDtag"] = -1 # fix "corners"
700+
mesh.vert3["IDtag"] = - 1 # fix "corners"
709701

710702
#-------------------------------- setup cubedsphere topology
711703
mesh.quad4 = np.array([

0 commit comments

Comments
 (0)