Skip to content

Commit eda3b7d

Browse files
committed
Initial bindings for jigsaw-0.9.12.xx
- PEP8 police...
1 parent 8546e6c commit eda3b7d

40 files changed

Lines changed: 3457 additions & 3337 deletions

README.md

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,82 @@
1-
## `JIGSAW(GEO): Mesh generation for geoscientific modelling`
1+
## `JIGSAW: An unstructured mesh generator`
22

33
<p align="center">
4-
<img src = "image/voro.jpg">
4+
<img src = "../master/external/jigsaw/img/bunny-TRIA3-1.png"> &nbsp
5+
<img src = "../master/external/jigsaw/img/bunny-TRIA3-2.png"> &nbsp
6+
<img src = "../master/external/jigsaw/img/bunny-TRIA3-3.png"> &nbsp
7+
<img src = "../master/external/jigsaw/img/bunny-TRIA4-3.png">
58
</p>
69

7-
`JIGSAW(GEO)` is a set of algorithms designed to generate unstructured grids for geoscientific modelling. Applications include: large-scale atmospheric simulation and numerical weather prediction, global and coastal ocean-modelling, and ice-sheet dynamics.
10+
`JIGSAW` is an unstructured mesh generator and tessellation library; designed to generate high-quality triangulations and polyhedral decompositions of general planar, surface and volumetric domains. `JIGSAW` includes refinement-based algorithms for the construction of new meshes, optimisation-driven techniques for the improvement of existing grids, as well as routines to assemble (restricted) Delaunay tessellations, Voronoi complexes and Power diagrams.
811

9-
`JIGSAW(GEO)` can be used to produce high-quality 'generalised' Delaunay / Voronoi tessellations for unstructured finite-volume / element type models. Grids can be generated in local two-dimensional domains, and over general spheroidal surfaces. Mesh resolution can be adapted to follow complex user-defined metrics, including: topographic contours, discrete solution profiles or coastal features. These features enable the generation of complex, multi-resolution climate process models, with simulation fidelity enhanced in regions of interest.
12+
This package provides a <a href="http://www.python.org">`Python`</a> based scripting interface to the underlying `JIGSAW` mesh generator, including a range of additional facilities for file I/O, mesh visualisation and post-processing operations.
1013

11-
`JIGSAW(GEO)` is a stand-alone mesh generator written in `c++`, based on <a href="https://github.com/dengwirda/jigsaw">`JIGSAW`</a> - a general purpose meshing package. This toolbox provides a <a href="https://www.python.org/">`Python`</a> based interface, including `file I/O`, `mesh visualisation` and `post-processing` facilities. The underlying `JIGSAW` library is a collection of unstructured triangle- and tetrahedron-based meshing algorithms, designed to produce high quality Delaunay-based grids for computational simulation. `JIGSAW` includes both Delaunay-refinement based algorithms for the construction of new meshes, as well as optimisation driven methods for the improvement of existing grids.
14+
`JIGSAW` has been compiled and tested on various `64-bit` `Linux` , `Windows` and `Mac` based platforms.
1215

13-
`JIGSAW(GEO)` is typically able to produce the very high-quality staggered unstructured grids required by contemporary unstructued general circulation models (i.e. <a href="https://github.com/MPAS-Dev/MPAS-Release">`MPAS`</a>, <a href="https://research.csiro.au/cem/software/ems/hydro/unstructured-compas/">`COMPAS`</a>, <a href="http://fesom.de/">`FESOM`</a>, <a href="https://www.mpimet.mpg.de/en/science/models/icon-esm/">`ICON`</a>, etc), generating highly optimised, multi-resolution meshes that are `locally-orthogonal`, `mutually-centroidal` and `self-centred`.
16+
### `Quickstart`
1417

15-
`JIGSAW(GEO)` has been compiled and tested on various `64-bit` `Linux` , `Windows` and `Mac` based platforms.
18+
Ensure you have a c++ compiler and the cmake utility installed.
19+
Clone/download + unpack this repository.
20+
python3 setup.py build_external
21+
python3 setup.py install
22+
python3 example.py --IDnumber=0
23+
24+
Note: installation of `JIGSAW` requires a `c++` compiler and the `cmake` utility. `JIGSAW` may also be installed as a `conda` package. See <a href="https://github.com/dengwirda/jigsaw">here</a> for details.
25+
26+
### `Function Listing`
1627

17-
## `Getting Started`
28+
See `jigsawpy` for a description of the various functions available.
1829

19-
The first step is to compile and configure the underlying `JIGSAW` `c++` library. `JIGSAW` can either be built directly from src, or installed using the <a href="https://anaconda.org/conda-forge/jigsaw">`conda`</a> package manager. More details can be found <a href="https://github.com/dengwirda/jigsaw">here</a>.
30+
setup.py - compile and install JIGSAW's c++ backend using cmake.
31+
example.py - a list of demo programs.
32+
33+
jigsaw.py - cmd-line interface to JIGSAW's backend
34+
libsaw.py - api-lib. interface to JIGSAW's backend
35+
36+
loadmsh.py - load *.msh files.
37+
savemsh.py - save *.msh files.
38+
loadjig.py - load *.jig files.
39+
savejig.py - save *.jig files.
2040

41+
project.py - apply cartographic projection operators to mesh obj.
2142

22-
## `Example Problems`
43+
bisect.py - refine a mesh obj. via bisection.
44+
extrude.py - create a mesh obj. via extrusion.
2345

24-
After downloading and building the code, navigate to the root `JIGSAW(GEO)` directory to run the set of examples contained in `example.py`:
25-
````
26-
example(1); % simple 2-dim. examples to get stated.
27-
example(2); % a multi-resolution grid for the Australian region.
28-
example(3); % a multi-part grid of the (contiguous) USA.
29-
example(4); % a uniform-resolution spheroidal grid.
30-
example(5); % a spheroidal grid with a regional "patch".
31-
example(6); % a spheroidal grid with complex grid-spacing constraints.
32-
````
46+
### `Example Problems`
3347

34-
## `License`
48+
The following set of example problems are available in `example.py`:
49+
50+
example: 0; # simple 2-dim. examples to get started
51+
example: 1; # simple 3-dim. examples to get started
52+
example: 2; # frontal-delaunay methods in the plane
53+
example: 3; # frontal-delaunay methods for surfaces
54+
example: 4; # frontal-delaunay methods for volumes
55+
example: 5; # user-defined mesh-spacing constraints
56+
example: 6; # dealing with sharp-features in piecewise smooth domains
57+
example: 7; # dealing with sharp-features in piecewise smooth domains
58+
example: 8; # (re)mesh marching-cubes style outputs
59+
example: 9; # creating prismatic volumes via extrusion
60+
61+
Run `python3 example.py --IDnumber=N` to call the `N-th` example. `*.vtk` output is saved to `../cache` and can be visualised with, for example, <a href=https://www.paraview.org/>Paraview</a>.
62+
63+
### `License`
3564

3665
This program may be freely redistributed under the condition that the copyright notices (including this entire header) are not removed, and no compensation is received through use of the software. Private, research, and institutional use is free. You may distribute modified versions of this code `UNDER THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR NOTICE IS GIVEN OF THE MODIFICATIONS`. Distribution of this code as part of a commercial system is permissible `ONLY BY DIRECT ARRANGEMENT WITH THE AUTHOR`. (If you are not directly supplying this code to a customer, and you are instead telling them how they can obtain it for free, then you are not required to make any arrangement with me.)
3766

3867
`DISCLAIMER`: Neither I nor: Columbia University, the Massachusetts Institute of Technology, the University of Sydney, nor the National Aeronautics and Space Administration warrant this code in any way whatsoever. This code is provided "as-is" to be used at your own risk.
3968

40-
## `References`
69+
### `References`
4170

42-
There are a number of publications that describe the algorithms used in `JIGSAW(GEO)` in detail. Additional information and references regarding the formulation of the underlying `JIGSAW` mesh-generator can also be found <a href="https://github.com/dengwirda/jigsaw">here</a>. If you make use of `JIGSAW` in your work, please consider including a reference to the following:
71+
There are a number of publications that describe the algorithms used in `JIGSAW` in detail. If you make use of `JIGSAW` in your work, please consider including a reference to the following:
4372

4473
`[1]` - Darren Engwirda: Generalised primal-dual grids for unstructured co-volume schemes, J. Comp. Phys., 375, pp. 155-176, https://doi.org/10.1016/j.jcp.2018.07.025, 2018.
4574

46-
`[2]` - Darren Engwirda: JIGSAW-GEO (1.0): locally orthogonal staggered unstructured grid generation for general circulation modelling on the sphere, Geosci. Model Dev., 10, pp. 2117-2140, https://doi.org/10.5194/gmd-10-2117-2017, 2017.
75+
`[2]` - Darren Engwirda, Conforming Restricted Delaunay Mesh Generation for Piecewise Smooth Complexes, Procedia Engineering, 163, pp. 84-96, https://doi.org/10.1016/j.proeng.2016.11.024, 2016.
4776

48-
`[3]` - Darren Engwirda, David Ivers, Off-centre Steiner points for Delaunay-refinement on curved surfaces, Computer-Aided Design, 72, pp. 157-171, http://dx.doi.org/10.1016/j.cad.2015.10.007, 2016.
77+
`[3]` - Darren Engwirda, Voronoi-based Point-placement for Three-dimensional Delaunay-refinement, Procedia Engineering, 124, pp. 330-342, http://dx.doi.org/10.1016/j.proeng.2015.10.143, 2015.
4978

50-
`[4]` - Darren Engwirda: Multi-resolution unstructured grid-generation for geophysical applications on the sphere, Research note, Proceedings of the 24th International Meshing Roundtable, https://arxiv.org/abs/1512.00307, 2015.
79+
`[4]` - Darren Engwirda, David Ivers, Off-centre Steiner points for Delaunay-refinement on curved surfaces, Computer-Aided Design, 72, pp. 157-171, http://dx.doi.org/10.1016/j.cad.2015.10.007, 2016.
5180

5281
`[5]` - Darren Engwirda, Locally-optimal Delaunay-refinement and optimisation-based mesh generation, Ph.D. Thesis, School of Mathematics and Statistics, The University of Sydney, http://hdl.handle.net/2123/13148, 2014.
5382

54-

example.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

3-
import jigsawpy
3+
import os
4+
import argparse
45

56
from tests.case_0_ import case_0_
67
from tests.case_1_ import case_1_
@@ -11,52 +12,46 @@
1112
from tests.case_6_ import case_6_
1213
from tests.case_7_ import case_7_
1314
from tests.case_8_ import case_8_
14-
from tests.case_9_ import case_9_
1515

16-
import os
17-
import argparse
1816

1917
def example(IDnumber=0):
2018

2119
#--------------- delegate to the individual example cases...
22-
20+
2321
src_path = os.path.join(
2422
os.path.abspath(
25-
os.path.dirname(__file__)),"files")
23+
os.path.dirname(__file__)), "files")
2624

2725
dst_path = os.path.join(
2826
os.path.abspath(
29-
os.path.dirname(__file__)),"cache")
30-
27+
os.path.dirname(__file__)), "cache")
28+
3129
if (IDnumber == +0):
32-
case_0_(src_path,dst_path)
30+
case_0_(src_path, dst_path)
3331

3432
elif (IDnumber == +1):
35-
case_1_(src_path,dst_path)
33+
case_1_(src_path, dst_path)
3634

3735
elif (IDnumber == +2):
38-
case_2_(src_path,dst_path)
36+
case_2_(src_path, dst_path)
3937

4038
elif (IDnumber == +3):
41-
case_3_(src_path,dst_path)
39+
case_3_(src_path, dst_path)
4240

4341
elif (IDnumber == +4):
44-
case_4_(src_path,dst_path)
42+
case_4_(src_path, dst_path)
4543

4644
elif (IDnumber == +5):
47-
case_5_(src_path,dst_path)
45+
case_5_(src_path, dst_path)
4846

4947
elif (IDnumber == +6):
50-
case_6_(src_path,dst_path)
48+
case_6_(src_path, dst_path)
5149

5250
elif (IDnumber == +7):
53-
case_7_(src_path,dst_path)
51+
case_7_(src_path, dst_path)
5452

5553
elif (IDnumber == +8):
56-
case_8_(src_path,dst_path)
57-
58-
elif (IDnumber == +9):
59-
case_9_(src_path,dst_path)
54+
case_8_(src_path, dst_path)
6055

6156
return
6257

@@ -70,7 +65,7 @@ def example(IDnumber=0):
7065

7166
args = parser.parse_args()
7267

73-
example(IDnumber = args.IDnumber)
68+
example(IDnumber=args.IDnumber)
7469

7570

7671

external/jigsaw/bin/jigsaw

2.01 MB
Binary file not shown.

external/jigsaw/bin/marche

231 KB
Binary file not shown.

external/jigsaw/bin/tripod

483 KB
Binary file not shown.

external/jigsaw/lib/libjigsaw.so

2.08 MB
Binary file not shown.

jigsawpy/__init__.py

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
r"""
22
------------------------------------------------------------
33
*
4-
* ,o, ,o, /
4+
* ,o, ,o, /
55
* ` ` e88~88e d88~\ /~~~8e Y88b e /
6-
* 888 888 88 88 C888 88b Y88b d8b /
7-
* 888 888 "8b_d8" Y88b e88~-888 Y888/Y88b/
8-
* 888 888 / 888D C88 888 Y8/ Y8/
9-
* 88P 888 Cb \_88P "8b_-888 Y Y
10-
* \_8" Y8""8D
6+
* 888 888 88 88 C888 88b Y88b d8b /
7+
* 888 888 "8b_d8" Y88b e88~-888 Y888/Y88b/
8+
* 888 888 / 888D C88 888 Y8/ Y8/
9+
* 88P 888 Cb \_88P "8b_-888 Y Y
10+
* \_8" Y8""8D
1111
*
1212
------------------------------------------------------------
1313
* JIGSAW: Interface to the JIGSAW meshing library.
@@ -22,29 +22,29 @@
2222
*
2323
------------------------------------------------------------
2424
*
25-
* This program may be freely redistributed under the
26-
* condition that the copyright notices (including this
27-
* entire header) are not removed, and no compensation
28-
* is received through use of the software. Private,
29-
* research, and institutional use is free. You may
30-
* distribute modified versions of this code UNDER THE
31-
* CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE
32-
* TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE
33-
* ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE
34-
* MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR
35-
* NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution
36-
* of this code as part of a commercial system is
37-
* permissible ONLY BY DIRECT ARRANGEMENT WITH THE
38-
* AUTHOR. (If you are not directly supplying this
39-
* code to a customer, and you are instead telling them
40-
* how they can obtain it for free, then you are not
41-
* required to make any arrangement with me.)
25+
* This program may be freely redistributed under the
26+
* condition that the copyright notices (including this
27+
* entire header) are not removed, and no compensation
28+
* is received through use of the software. Private,
29+
* research, and institutional use is free. You may
30+
* distribute modified versions of this code UNDER THE
31+
* CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE
32+
* TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE
33+
* ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE
34+
* MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR
35+
* NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution
36+
* of this code as part of a commercial system is
37+
* permissible ONLY BY DIRECT ARRANGEMENT WITH THE
38+
* AUTHOR. (If you are not directly supplying this
39+
* code to a customer, and you are instead telling them
40+
* how they can obtain it for free, then you are not
41+
* required to make any arrangement with me.)
4242
*
4343
* Disclaimer: Neither I nor: Columbia University, The
44-
* Massachusetts Institute of Technology, The
44+
* Massachusetts Institute of Technology, The
4545
* University of Sydney, nor The National Aeronautics
46-
* and Space Administration warrant this code in any
47-
* way whatsoever. This code is provided "as-is" to be
46+
* and Space Administration warrant this code in any
47+
* way whatsoever. This code is provided "as-is" to be
4848
* used at your own risk.
4949
*
5050
------------------------------------------------------------
@@ -55,6 +55,8 @@
5555
from jigsawpy.def_t import jigsaw_def_t
5656
from jigsawpy.prj_t import jigsaw_prj_t
5757

58+
from jigsawpy import jigsaw, libsaw
59+
5860
from jigsawpy.loadmsh import loadmsh
5961
from jigsawpy.savemsh import savemsh
6062
from jigsawpy.loadjig import loadjig
@@ -63,11 +65,9 @@
6365
from jigsawpy.certify import certify
6466

6567
from jigsawpy.project import project
66-
from jigsawpy.bisect import bisect
68+
from jigsawpy.bisect import bisect
6769
from jigsawpy.extrude import extrude
6870

69-
from jigsawpy import jigsaw, libsaw
70-
7171
from jigsawpy.tools.predicate import trivol2, trivol3, \
7272
normal1, normal2, orient1, orient2
7373

@@ -82,58 +82,51 @@
8282
from jigsawpy.parse.savewav import savewav
8383
from jigsawpy.parse.savevtk import savevtk
8484

85+
8586
class cmd:
8687
#--------------------------------- expose cmd-line interface
87-
@staticmethod
88-
def jigsaw(opts,mesh=None):
89-
90-
return jigsaw.jigsaw(opts,mesh)
91-
9288
@staticmethod
93-
def tripod(opts,tria=None):
94-
95-
return jigsaw.tripod(opts,tria)
89+
def jigsaw(opts, mesh=None):
90+
91+
return jigsaw.jigsaw(opts, mesh)
9692

9793
@staticmethod
98-
def marche(opts,ffun=None):
99-
100-
return jigsaw.marche(opts,ffun)
94+
def tetris(opts, nlev, mesh=None):
95+
96+
return jigsaw.tetris(opts, nlev,
97+
mesh)
10198

10299
@staticmethod
103-
def jitter(opts,imax,ibad=1,
104-
mesh=None):
100+
def tripod(opts, tria=None):
105101

106-
return jigsaw.jitter(opts,imax,
107-
ibad,mesh)
102+
return jigsaw.tripod(opts, tria)
108103

109104
@staticmethod
110-
def tetris(opts,nlev,mesh=None):
105+
def marche(opts, ffun=None):
106+
107+
return jigsaw.marche(opts, ffun)
111108

112-
return jigsaw.tetris(opts,nlev,
113-
mesh)
114109

115110
class lib:
116111
#--------------------------------- expose api-lib. interface
117-
@staticmethod
118-
def jigsaw(opts,geom,mesh,
119-
init=None,
112+
@staticmethod
113+
def jigsaw(opts, geom, mesh, init=None,
120114
hfun=None):
121-
122-
return libsaw.jigsaw(opts,geom,
123-
mesh,init,
124-
hfun)
115+
116+
return libsaw.jigsaw(opts, geom,
117+
mesh,
118+
init, hfun)
125119

126120
@staticmethod
127-
def tripod(opts,init,tria,
128-
geom=None):
129-
130-
return libsaw.tripod(opts,init,
131-
tria,geom)
121+
def tripod(opts, init, tria, geom=None):
122+
123+
return libsaw.tripod(opts, init,
124+
tria, geom)
132125

133126
@staticmethod
134-
def marche(opts,ffun):
135-
136-
return libsaw.marche(opts,ffun)
127+
def marche(opts, ffun):
128+
129+
return libsaw.marche(opts, ffun)
137130

138131

139132

0 commit comments

Comments
 (0)