Skip to content

Commit

Permalink
Merge pull request #22 from dengwirda/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dengwirda authored May 7, 2019
2 parents 08bebe4 + 6f0d3f7 commit ed6f4da
Show file tree
Hide file tree
Showing 76 changed files with 5,585 additions and 3,016 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required (VERSION 3.9.4)
project (JIGSAW)

add_subdirectory ("${PROJECT_SOURCE_DIR}/src")
115 changes: 77 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<img src = "../master/img/bunny-TRIA4-3.png">
</p>

`JIGSAW` is a computational library for unstructured mesh generation and tessellation; 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 and Voronoi complexes.
`JIGSAW` is a computational library for unstructured mesh generation and tessellation; 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.

This package provides the underlying `C++` source for `JIGSAW`; defining a basic command-line interface and a `C`-format `API`. A <a href="http://www.mathworks.com">`MATLAB`</a> / <a href="http://www.gnu.org/software/octave">`OCTAVE`</a> based scripting interface, including a range of additional facilities for file I/O, mesh visualisation and post-processing operations can be found <a href="https://github.com/dengwirda/jigsaw-matlab">here</a>.

`JIGSAW` has been compiled and tested on various `64-bit` `Linux` , `Windows` and `Mac` based platforms.
`JIGSAW` has been compiled and tested on various `64-bit` `Linux`, `Windows` and `MacOS` based platforms.

## `Code Structure`
### `Code Structure`

`JIGSAW` is written as a `header-only` library in `C++`. Both a basic command-line interface and a `C`-format `API` are defined:

Expand All @@ -26,68 +26,106 @@ This package provides the underlying `C++` source for `JIGSAW`; defining a basic
├── out -- default folder for JIGSAW output
└── uni -- unit tests and libjigsaw example programs

## `Getting Started`
### `Getting Started`

The first step is to compile the code! The `JIGSAW` src can be found in <a href="../master/src/">`../jigsaw/src/`</a>.
The first step is to compile and configure the code! `JIGSAW` can either be built directly from src, or installed using the <a href="https://anaconda.org/conda-forge/jigsaw">`conda`</a> package manager.

`JIGSAW` is a `header-only` package - there is only the single main `jigsaw.cpp` file that simply `#include`'s the rest of the library as headers. The resulting build process should be fairly straight-forward as a result. `JIGSAW` does not currently dependent on any external packages or libraries.
### `Building from src`

#### `On Linux/Mac`
The full `JIGSAW` src can be found in <a href="../master/src/">`../jigsaw/src/`</a>.

`JIGSAW` has been successfully built using various versions of the `g++` and `llvm` compilers. Since the build process is a simple one-liner, there's no `make` script - instead:
`JIGSAW` is a `header-only` package - the single main `jigsaw.cpp` file simply `#include`'s the rest of the library directly. `JIGSAW` does not currently dependent on any external packages or libraries.

g++ -std=c++11 -pedantic -Wall -s -O3 -flto -D NDEBUG
-D __cmd_jigsaw -static-libstdc++ jigsaw.cpp
-o jigsaw64r

will build the main `JIGSAW` cmd-line executable,
`JIGSAW` consists of several pieces: `(a)` a set of command-line utilities that read and write mesh data from/to file, and `(b)` a shared library, accessible via a `C`-format `API`.

g++ -std=c++11 -pedantic -Wall -s -O3 -flto -D NDEBUG
-D __cmd_tripod -static-libstdc++ jigsaw.cpp
-o tripod64r

will build the `TRIPOD` cmd-line utility (`JIGSAW`'s tessellation infrastructure) and,
#### `Using cmake`

g++ -std=c++11 -pedantic -Wall -O3 -flto -fPIC -D NDEBUG
-D __lib_jigsaw -static-libstdc++ jigsaw.cpp
-shared -o libjigsaw64r.so
`JIGSAW` can be built using the <a href="https://cmake.org/">`cmake`</a> utility. To build, follow the steps below:

will build `JIGSAW` as shared library. See the headers in <a href="../master/jigsaw/inc/">`../jigsaw/inc/`</a> for details on the `API`.
* Ensure you have the cmake utility installed.
* Clone or download this repository.
* Navigate to the root `../jigsaw/` directory.
* Create a new temporary directory BUILD (to store the cmake build files).
* Navigate into the temporary directory.
* Execute: cmake -D CMAKE_BUILD_TYPE=BUILD_MODE ..
* Execute: make
* Execute: make install
* Delete the temporary directory.

#### `On Windows`
This process will build a series of executables and the shared library: `jigsaw` itself - the main command-line meshing utility, `tripod` - `JIGSAW`'s tessellation infrastructure, as well as `libjigsaw` - `JIGSAW`'s shared `API`. `BUILD_MODE` can be used to select different compiler configurations and should be either `RELEASE` or `DEBUG`.

`JIGSAW` has been successfully built using various versions of the `msvc` compiler. I do not provide a sample `msvc` project, but the following steps can be used to create one:
See `example.jig` for documentation on calling the command-line executables, and the headers in <a href="../master/inc/">`../jigsaw/inc/`</a> for details on the `API`.

* Create a new, empty MSVC project.
* Import the jigsaw.cpp file, this contains the main() entry-point.
#### `Using g++ / llvm`

#### `Folder Structure`
`JIGSAW` has been successfully built using various versions of the `g++` and `llvm` compilers. The build process is a simple one-liner (from <a href="../master/src/">`../jigsaw/src/`</a>):
````
g++ -std=c++11 -pedantic -Wall -O3 -flto -D NDEBUG
-D __cmd_jigsaw jigsaw.cpp -o ../bin/jigsaw
````
will build the main `jigsaw` command-line executable,
````
g++ -std=c++11 -pedantic -Wall -O3 -flto -D NDEBUG
-D __cmd_tripod jigsaw.cpp -o ../bin/tripod
````
will build the `tripod` command-line utility (`JIGSAW`'s tessellation infrastructure) and,
````
g++ -std=c++11 -pedantic -Wall -O3 -flto -fPIC -D NDEBUG
-D __lib_jigsaw jigsaw.cpp -shared -o ../lib/libjigsaw.so
````
will build `JIGSAW` as a shared library (`libjigsaw`).

### `Install via conda`

`JIGSAW` is also available as a `conda` environment. To install and use, follow the steps below:

Once you have built the `JIGSAW` binaries, place them in the appropriate sub-folders in`../jigsaw/bin/` and/or `../jigsaw/lib/` directories, so that they can be found by the unit tests in `../jigsaw/uni/`.
* Ensure you have conda installed. If not, consider miniconda as a lightweight option.
* Add conda-forge as a channel: conda config --add channels conda-forge
* Create a jigsaw environment: conda create -n jigsaw jigsaw

## `A Simple Example`
Each time you want to use `JIGSAW` simply activate the environment using: `conda activate jigsaw`

After compiling the code, run the following command-line example to get started:
Once activated, the various `JIGSAW` command-line utilities will be available in your run path, `JIGSAW`'s shared library (`libjigsaw`) will be available in your library path and its include files in your include path.

### `CMD-LINE Examples`

After compiling the code, try running the following command-line example to get started:
````
On WIN-64 platforms:
On WIN platforms:
\bin\WIN-64\jigsaw64r.exe example.jig
\bin\jigsaw.exe example.jig
On LNX-64 platforms:
On LNX platforms:
/bin/LNX-64/jigsaw64r example.jig
/bin/jigsaw example.jig
````
In this example, a high-quality tetrahedral mesh is generated for the 'stanford-bunny' geometry and the result is written to file. The input geometry is specified as a triangulated surface, and is read from `../jigsaw/geo/bunny.msh`. The volume and surface mesh outputs are written to `../jigsaw/out/bunny.msh`. Edit `example.jig` for a description of `JIGSAW`'s configuration options.
In this example, a high-quality tetrahedral mesh is generated for the 'stanford-bunny' geometry and the result written to file. The input geometry is specified as a triangulated surface, and is read from `../jigsaw/geo/bunny.msh`. The volume and surface mesh outputs are written to `../jigsaw/out/bunny.msh`. See the `example.jig` text-file for a description of `JIGSAW`'s configuration options.

A repository of additional surface models generated using `JIGSAW` can be found <a href="https://github.com/dengwirda/jigsaw-models">here</a>.

### `LIBJIGSAW Scripts`

A set of unit-tests and `libjigsaw` example programs are contained in <a href="../master/uni/">`../uni/`</a>. The `JIGSAW-API` is documented via the header files in <a href="../master/inc/">`../inc/`</a>. A repository of 3D surface models generated using `JIGSAW` can be found <a href="https://github.com/dengwirda/jigsaw-models">here</a>.
A set of unit-tests and `libjigsaw` example programs are contained in <a href="../master/uni/">`../jigsaw/uni/`</a>. The `JIGSAW-API` is documented via the header files in <a href="../master/inc/">`../jigsaw/inc/`</a>.

## `License`
The unit-tests can be built using the <a href="https://cmake.org/">`cmake`</a> utility. To build, follow the steps below:

* Navigate to the `../jigsaw/uni/` directory.
* Create a new temporary directory BUILD (to store the cmake build files).
* Navigate into the temporary directory.
* Execute: cmake -D CMAKE_BUILD_TYPE=BUILD_MODE ..
* Execute: make
* Execute: make install
* Delete the temporary directory.

This process will build the unit-tests as a series of executables in <a href="../master/uni/">`../jigsaw/uni/`</a>. `BUILD_MODE` is a compiler configuration flag: either `RELEASE` or `DEBUG`.

### `License`

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.)

`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.

## `References`
### `References`

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:

Expand All @@ -101,3 +139,4 @@ There are a number of publications that describe the algorithms used in `JIGSAW`

`[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.


Empty file added bin/.keep
Empty file.
3 changes: 0 additions & 3 deletions bin/LNX-64/temp.txt

This file was deleted.

3 changes: 0 additions & 3 deletions bin/MAC-64/temp.txt

This file was deleted.

3 changes: 0 additions & 3 deletions bin/WIN-64/temp.txt

This file was deleted.

25 changes: 16 additions & 9 deletions example.jig
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
# To run this example navigate to the directory containing
# this file and run the following from the cmd line:
#
# On WIN-64 platforms:
# On WIN platforms:
#
# bin\WIN-64\jigsaw64r.exe example.jig
# bin\jigsaw.exe example.jig
#
# On LNX-64 platforms:
# On LNX platforms:
#
# bin/LNX-64/jigsaw64r example.jig
#
# On MAC-64 platforms:
#
# bin/MAC-64/jigsaw64r example.jig
# bin/jigsaw example.jig
#
# This command calls JIGSAW using the config. data contai-
# ned in "example.jig", which, in unmodified form, creates
# a tetrahedral mesh of the "stanford-bunny" geometry.
# a tetrahedral mesh of the "stanford-bunny" geometry.
#

# The subsequent sections detail the various configuration
Expand Down Expand Up @@ -62,6 +58,17 @@
# INIT_FILE = *.msh


# ---> INIT_NEAR - {default = 1.E-8} relative "zip" tol.
# applied when processing initial conditions. In cases
# where "sharp-feature" detection is active, nodes in
# the initial set are zipped to their nearest feature
# node if the separation length is less than NEAR*SCAL
# where SCAL is the max. bounding-box dimension.
#

# INIT_NEAR = 1.E-6


#
# OPTIONAL fields (GEOM):
# ----------------------
Expand Down
17 changes: 15 additions & 2 deletions inc/jigsaw_jig_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*
--------------------------------------------------------
*
* Last updated: 31 July, 2018
* Last updated: 10 April, 2019
*
* Copyright 2013-2018
* Copyright 2013-2019
* Darren Engwirda
* [email protected]
* https://github.com/dengwirda/
Expand Down Expand Up @@ -107,6 +107,19 @@

real_t _geom_eta2 ;

/*
--------------------------------------------------------
* INIT_NEAR - {default = 1.E-8} relative "zip" tol.
* applied when processing initial conditions. In cases
* where "sharp-feature" detection is active, nodes in
* the initial set are zipped to their nearest feature
* node if the separation length is less than NEAR*SCAL
* where SCAL is the max. bounding-box dimension.
--------------------------------------------------------
*/

real_t _init_near ;

/*
--------------------------------------------------------
* HFUN_SCAL - {default = 'relative'} scaling type for
Expand Down
Empty file added lib/.keep
Empty file.
3 changes: 0 additions & 3 deletions lib/LNX-64/temp.txt

This file was deleted.

3 changes: 0 additions & 3 deletions lib/MAC-64/temp.txt

This file was deleted.

3 changes: 0 additions & 3 deletions lib/WIN-64/temp.txt

This file was deleted.

Empty file added out/.keep
Empty file.
3 changes: 0 additions & 3 deletions out/temp.txt

This file was deleted.

37 changes: 37 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (INSTALL_LOCAL TRUE)
message ("installing locally")
else (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message ("installing to ${CMAKE_INSTALL_PREFIX}")
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

add_executable (jigsaw-cmd jigsaw.cpp)
target_compile_definitions (jigsaw-cmd PRIVATE __cmd_jigsaw)
set_target_properties (jigsaw-cmd PROPERTIES OUTPUT_NAME jigsaw)
if (DEFINED INSTALL_LOCAL)
install (TARGETS jigsaw-cmd DESTINATION "${PROJECT_SOURCE_DIR}/bin")
else ()
install (TARGETS jigsaw-cmd DESTINATION bin)
endif ()

add_executable (tripod-cmd jigsaw.cpp)
target_compile_definitions (tripod-cmd PRIVATE __cmd_tripod)
set_target_properties (tripod-cmd PROPERTIES OUTPUT_NAME tripod)
if (DEFINED INSTALL_LOCAL)
install (TARGETS tripod-cmd DESTINATION "${PROJECT_SOURCE_DIR}/bin")
else ()
install (TARGETS tripod-cmd DESTINATION bin)
endif ()

add_library (jigsaw-lib SHARED jigsaw.cpp)
target_compile_definitions (jigsaw-lib PRIVATE __lib_jigsaw)
set_target_properties (jigsaw-lib PROPERTIES OUTPUT_NAME jigsaw)
if (DEFINED INSTALL_LOCAL)
install (TARGETS jigsaw-lib DESTINATION "${PROJECT_SOURCE_DIR}/lib")
else ()
install (DIRECTORY inc/ DESTINATION include FILES_MATCHING PATTERN "*.h")
install (TARGETS jigsaw-lib DESTINATION lib)
endif ()
3 changes: 3 additions & 0 deletions src/geo_load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@
try
{

__unreferenced (_jlog) ;
__unreferenced (_jcfg) ;

if (_gmsh._flags ==
JIGSAW_EUCLIDEAN_MESH )
{
Expand Down
32 changes: 29 additions & 3 deletions src/hfn_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*
--------------------------------------------------------
*
* Last updated: 14 September, 2017
* Last updated: 18 April, 2019
*
* Copyright 2013-2017
* Copyright 2013-2019
* Darren Engwirda
* [email protected]
* https://github.com/dengwirda/
Expand Down Expand Up @@ -111,7 +111,7 @@
if (_geom._kind ==
jmsh_kind::ellipsoid_mesh)
{
/*--------------------------------- euclidean-mesh-3d */
/*--------------------------------- ellipsoid-mesh-3d */
_scal = (real_type) +0. ;
_scal +=
_geom._ellipsoid_mesh_3d._bmax[0] -
Expand Down Expand Up @@ -232,6 +232,32 @@
}

}
}
else
if (_hfun._kind ==
jmsh_kind::ellipsoid_mesh)
{
/*--------------------------------- ellipsoid-mesh-3d */
for (auto _node = _hfun.
_ellipsoid_mesh_3d._mesh._set1.head();
_node != _hfun.
_ellipsoid_mesh_3d._mesh._set1.tend();
++_node )
{
if (_node->mark() < 0) continue;

_node->hval() =
_scal * _node->hval();

_node->hval() =
std::min(_node->hval(),
_scal *_jcfg._hfun_hmax) ;

_node->hval() =
std::max(_node->hval(),
_scal *_jcfg._hfun_hmin) ;
}

}
else
if (_hfun._kind ==
Expand Down
Loading

0 comments on commit ed6f4da

Please sign in to comment.