diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml
index 2a1e522..5e05220 100644
--- a/.github/workflows/setup.yml
+++ b/.github/workflows/setup.yml
@@ -12,10 +12,10 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
- python-version: ["3.12"]
+ python-version: ["3.14"]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v7
- name: Print environment
run: |
@@ -23,7 +23,7 @@ jobs:
echo github.event_name: ${{ github.event_name }}
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
@@ -63,3 +63,11 @@ jobs:
- name: Eval. jigsaw-python
run: python example.py --IDnumber=-1
+
+ - name: Check installed package
+ working-directory: ${{ runner.temp }}
+ run: >-
+ python -I -c "
+ import jigsawpy;
+ import jigsawpy.libsaw;
+ print(jigsawpy.__file__)"
diff --git a/.gitignore b/.gitignore
index 8a5b349..3cb78b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-# jigsaw things
+# jigsaw things
*
!/**/
!*.*
@@ -10,7 +10,7 @@ cache/*.log
cache/*.jig
cache/*.msh
-# python things
+# python things
__pycache__/
*.py[cod]
diff --git a/MANIFEST.in b/MANIFEST.in
index b476b28..65e973a 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -2,8 +2,13 @@ include MANIFEST.in
include README.md
include LICENSE.md
include example.py
+include build.py
recursive-include cache *.*
recursive-include external *.*
recursive-include files *.*
recursive-include jigsawpy *.*
recursive-include tests *.*
+recursive-exclude external/jigsaw/bin *
+recursive-exclude external/jigsaw/lib *
+recursive-exclude jigsawpy/_bin *
+recursive-exclude jigsawpy/_lib *
diff --git a/README.md b/README.md
index 5ea3c00..29c9196 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,11 @@ This package provides a `Python` based scrip
python3 example.py --IDnumber=0
Note: installation of `JIGSAW` requires a `c++` compiler and the `cmake` utility.
+
+Note: Run `python3 build.py` before building a wheel or installing from source.
+Prebuilt wheels are platform- and Python-version-specific and may require the
+native libraries used when the backend was compiled (such as NetCDF or OpenMP)
+on the target system.
### `Function Listing`
@@ -35,8 +40,8 @@ See `jigsawpy` for a description of the various functions available.
jigsaw.py - cmd-line interface to JIGSAW's backend
libsaw.py - api-lib. interface to JIGSAW's backend
- loadmsh.py - load *.msh files.
- savemsh.py - save *.msh files.
+ loadmsh.py - load *.msh or NetCDF *.nc files.
+ savemsh.py - save *.msh or NetCDF *.nc files.
loadjig.py - load *.jig files.
savejig.py - save *.jig files.
@@ -87,4 +92,3 @@ There are a number of publications that describe the algorithms used in `JIGSAW`
`[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.
`[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.
-
diff --git a/cache/.keep b/cache/.keep
index e69de29..8d1c8b6 100644
--- a/cache/.keep
+++ b/cache/.keep
@@ -0,0 +1 @@
+
diff --git a/external/jigsaw/.github/workflows/cmake.yml b/external/jigsaw/.github/workflows/setup.yml
similarity index 53%
rename from external/jigsaw/.github/workflows/cmake.yml
rename to external/jigsaw/.github/workflows/setup.yml
index 3548fdc..0517797 100644
--- a/external/jigsaw/.github/workflows/cmake.yml
+++ b/external/jigsaw/.github/workflows/setup.yml
@@ -5,42 +5,46 @@ on:
pull_request:
push:
-env:
- BUILD_TYPE: Debug
-
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
+ timeout-minutes: 15
+
strategy:
fail-fast: false
matrix:
+ build_type: [Debug, Release]
config:
- - {
- name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz",
- os: windows-latest,
- cc: "cl", cxx: "cl"
- }
- - {
- name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz",
- os: ubuntu-latest,
- cc: "gcc", cxx: "g++"
- }
- - {
- name: "macOS Latest Clang", artifact: "macOS.tar.xz",
- os: macos-latest,
- cc: "clang", cxx: "clang++"
- }
+ - name: "Windows Latest MSVC"
+ artifact: "Windows-MSVC.tar.xz"
+ os: windows-latest
+ cc: "cl"
+ cxx: "cl"
+
+ - name: "Ubuntu Latest GCC"
+ artifact: "Linux.tar.xz"
+ os: ubuntu-latest
+ cc: "gcc"
+ cxx: "g++"
+
+ - name: "macOS Latest Clang"
+ artifact: "macOS.tar.xz"
+ os: macos-latest
+ cc: "clang"
+ cxx: "clang++"
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v7
- name: Print environment
+ timeout-minutes: 1
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Install dependencies on win
+ timeout-minutes: 5
if: startsWith(matrix.config.os, 'windows')
run: |
choco install ninja cmake
@@ -48,6 +52,7 @@ jobs:
cmake --version
- name: Install dependencies on unx
+ timeout-minutes: 5
if: startsWith(matrix.config.name, 'ubuntu')
run: |
sudo apt-get update
@@ -57,6 +62,7 @@ jobs:
g++ --version
- name: Install dependencies on osx
+ timeout-minutes: 5
if: startsWith(matrix.config.os, 'macos')
run: |
brew install ninja cmake llvm libomp
@@ -65,39 +71,46 @@ jobs:
clang++ --version
- name: Configure jigsaw
+ timeout-minutes: 1
run: |
- mkdir ${{github.workspace}}/build
- cd ${{github.workspace}}/build
- cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
+ mkdir ${{ github.workspace }}/build
+ cd ${{ github.workspace }}/build
+ cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build jigsaw
+ timeout-minutes: 10
run: |
- cd ${{github.workspace}}/build
- cmake --build . --config ${{env.BUILD_TYPE}} --target install
+ cd ${{ github.workspace }}/build
+ cmake --build . --config ${{ matrix.build_type }} --target install
- name: Clean jigsaw
- run: rm -r ${{github.workspace}}/build
+ timeout-minutes: 1
+ run: rm -r ${{ github.workspace }}/build
- name: Configure tests for jigsaw
+ timeout-minutes: 1
run: |
- mkdir ${{github.workspace}}/uni/build
- cd ${{github.workspace}}/uni/build
- cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
+ mkdir ${{ github.workspace }}/tests/build
+ cd ${{ github.workspace }}/tests/build
+ cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build tests for jigsaw
+ timeout-minutes: 5
run: |
- cd ${{github.workspace}}/uni/build
- cmake --build . --config ${{env.BUILD_TYPE}} --target install
-
+ cd ${{ github.workspace }}/tests/build
+ cmake --build . --config ${{ matrix.build_type }} --target install
+
- name: Prep. tests for jigsaw
+ timeout-minutes: 1
if: startsWith(matrix.config.os, 'windows')
run: |
- cd ${{github.workspace}}/uni
+ cd ${{ github.workspace }}/tests
cp ../lib/jigsaw.dll .
- name: Tests for cmd-jigsaw
+ timeout-minutes: 5
run: |
- cd ${{github.workspace}}
+ cd ${{ github.workspace }}
./bin/jigsaw example.jig
./bin/jigsaw geo/airfoil.jig
./bin/jigsaw geo/bunny.jig
@@ -106,9 +119,11 @@ jobs:
./bin/jigsaw geo/lakes.jig
- name: Tests for lib-jigsaw
+ timeout-minutes: 5
run: |
- cd ${{github.workspace}}/uni
+ cd ${{ github.workspace }}/tests
./test_all
- name: Clean tests for jigsaw
- run: rm -r ${{github.workspace}}/uni/build
+ timeout-minutes: 1
+ run: rm -r ${{ github.workspace }}/tests/build
diff --git a/external/jigsaw/.gitignore b/external/jigsaw/.gitignore
index 45f80cb..58cb7ea 100644
--- a/external/jigsaw/.gitignore
+++ b/external/jigsaw/.gitignore
@@ -6,4 +6,3 @@
*.dll
*.so
*.dylib
-
diff --git a/external/jigsaw/CMakeLists.txt b/external/jigsaw/CMakeLists.txt
index 63ebd7b..9a9f511 100644
--- a/external/jigsaw/CMakeLists.txt
+++ b/external/jigsaw/CMakeLists.txt
@@ -2,3 +2,4 @@ cmake_minimum_required (VERSION 3.9.4)
project (JIGSAW)
add_subdirectory ("${PROJECT_SOURCE_DIR}/src")
+
diff --git a/external/jigsaw/README.md b/external/jigsaw/README.md
index ab17904..9f4821f 100644
--- a/external/jigsaw/README.md
+++ b/external/jigsaw/README.md
@@ -26,7 +26,7 @@ This package provides the underlying `c++` source for `JIGSAW`; defining a basic
├── lib -- JIGSAW's lib binaries live here
├── geo -- geometry definitions and input data
├── out -- default folder for JIGSAW output
- └── uni -- unit tests and libjigsaw example programs
+ └── tests -- unit tests and libjigsaw example programs
### `Getting Started`
@@ -55,16 +55,16 @@ A repository of additional surface models generated using `JIGSAW` can be found
### `libJIGSAW Scripts`
-A set of unit-tests and `libjigsaw` example programs are contained in `../jigsaw/uni/`. The `JIGSAW-API` is documented via the header files in `../jigsaw/inc/`.
+A set of unit-tests and `libjigsaw` example programs are contained in `../jigsaw/tests/`. The `JIGSAW-API` is documented via the header files in `../jigsaw/inc/`.
The unit-tests can be built using the `cmake` utility:
- Navigate to the ../jigsaw/uni/ directory.
+ Navigate to the ../jigsaw/tests/ directory.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=BUILD_MODE
cmake --build . --config BUILD_MODE --target install EXTRAS
-This process will build the unit-tests as a set of executables in `../jigsaw/uni/`. `BUILD_MODE` is a compiler configuration flag (either `Release` or `Debug`). `EXTRAS` can be used to pass additional compile-time arguments.
+This process will build the unit-tests as a set of executables in `../jigsaw/tests/`. `BUILD_MODE` is a compiler configuration flag (either `Release` or `Debug`). `EXTRAS` can be used to pass additional compile-time arguments.
### `Contributors`
diff --git a/external/jigsaw/bin/.keep b/external/jigsaw/bin/.keep
index e69de29..8d1c8b6 100644
--- a/external/jigsaw/bin/.keep
+++ b/external/jigsaw/bin/.keep
@@ -0,0 +1 @@
+
diff --git a/external/jigsaw/example.jig b/external/jigsaw/example.jig
index ddcddd2..a6e4dc1 100644
--- a/external/jigsaw/example.jig
+++ b/external/jigsaw/example.jig
@@ -111,6 +111,20 @@
# GEOM_ETA2 = 60
+# ---> GEOM_PHI1 - {default=60deg} 1-dim. sharp-feature
+# angle, to be "protected" during mesh refinement.
+#
+
+# GEOM_PHI1 = 60
+
+
+# ---> GEOM_PHI2 - {default=60deg} 2-dim. sharp-feature
+# angle, to be "protected" during mesh refinement.
+#
+
+# GEOM_PHI2 = 60
+
+
#
# OPTIONAL fields (HFUN):
# ----------------------
diff --git a/external/jigsaw/inc/jigsaw_const.h b/external/jigsaw/inc/jigsaw_const.h
index 7a413ad..41103cf 100644
--- a/external/jigsaw/inc/jigsaw_const.h
+++ b/external/jigsaw/inc/jigsaw_const.h
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 29 May, 2022
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
@@ -106,4 +106,10 @@
# define JIGSAW_KERN_AREA_LEN +410
# define JIGSAW_KERN_SKEW_COS +411
+# define JIGSAW_MESH_RULE_SINK +3
+# define JIGSAW_MESH_RULE_OFFH +4
+# define JIGSAW_MESH_RULE_OFFC +5
+# define JIGSAW_MESH_RULE_OFFE +6
+# define JIGSAW_MESH_RULE_OFFT +7
+
diff --git a/external/jigsaw/inc/jigsaw_jig_t.h b/external/jigsaw/inc/jigsaw_jig_t.h
index 076e50b..b135d83 100644
--- a/external/jigsaw/inc/jigsaw_jig_t.h
+++ b/external/jigsaw/inc/jigsaw_jig_t.h
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
@@ -121,6 +121,24 @@
real_t _geom_eta2 ;
+ /*
+ --------------------------------------------------------
+ * GEOM_PHI1 - {default = 60deg} 1-dim. sharp-feature
+ * angle, to be "protected" during mesh refinement.
+ --------------------------------------------------------
+ */
+
+ real_t _mesh_phi1 ;
+
+ /*
+ --------------------------------------------------------
+ * GEOM_PHI2 - {default = 60deg} 2-dim. sharp-feature
+ * angle, to be "protected" during mesh refinement.
+ --------------------------------------------------------
+ */
+
+ real_t _mesh_phi2 ;
+
/*
--------------------------------------------------------
* INIT_NEAR - {default = 1.E-8} relative "zip" tol.
@@ -209,6 +227,17 @@
indx_t _mesh_iter ;
+ /*
+ --------------------------------------------------------
+ * MESH_RULE - bitmask selecting which refinement
+ * rules are utilised, with e.g. the status of the bit
+ * RULE[MESH_RULE_OFFH] selecting mesh-size adaptive
+ * off-centres, see jigsaw_const.h for options.
+ --------------------------------------------------------
+ */
+
+ indx_t _mesh_rule ;
+
/*
--------------------------------------------------------
* MESH_ORPH - {default=true} allow "orphaned" facets
diff --git a/external/jigsaw/inc/lib_jigsaw.h b/external/jigsaw/inc/lib_jigsaw.h
index e010e3b..d21cc2b 100644
--- a/external/jigsaw/inc/lib_jigsaw.h
+++ b/external/jigsaw/inc/lib_jigsaw.h
@@ -14,11 +14,11 @@
* JIGSAW: Interface to the JIGSAW meshing library.
--------------------------------------------------------
*
- * JIGSAW release 1.1.0.x
+ * JIGSAW release 1.1.1.x
*
- * Last updated: 20 Oct., 2024
+ * Last updated: 09 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
diff --git a/external/jigsaw/lib/.keep b/external/jigsaw/lib/.keep
index e69de29..8d1c8b6 100644
--- a/external/jigsaw/lib/.keep
+++ b/external/jigsaw/lib/.keep
@@ -0,0 +1 @@
+
diff --git a/external/jigsaw/out/.keep b/external/jigsaw/out/.keep
index e69de29..8d1c8b6 100644
--- a/external/jigsaw/out/.keep
+++ b/external/jigsaw/out/.keep
@@ -0,0 +1 @@
+
diff --git a/external/jigsaw/src/CMakeLists.txt b/external/jigsaw/src/CMakeLists.txt
index abfaf75..c385e26 100644
--- a/external/jigsaw/src/CMakeLists.txt
+++ b/external/jigsaw/src/CMakeLists.txt
@@ -37,7 +37,6 @@ if (DEFINED ICPC_LIKE)
cfg_compile_options (-fno-math-errno RELEASE) # no errno checks
cfg_compile_options (-fno-trapping-math RELEASE) # no fp exceptions
cfg_compile_options (-fno-signed-zeros RELEASE) # -0.0 == +0.0
- cfg_compile_options (-ffinite-math-only RELEASE) # no explicit nans, etc
endif ()
if (DEFINED MSVC_LIKE)
@@ -53,10 +52,14 @@ if (DEFINED GCXX_LIKE)
cfg_compile_options (-fno-math-errno RELEASE) # no errno checks
cfg_compile_options (-fno-trapping-math RELEASE) # no fp exceptions
cfg_compile_options (-fno-signed-zeros RELEASE) # -0.0 == +0.0
- cfg_compile_options (-ffinite-math-only RELEASE) # no explicit nans, etc
endif ()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}" CACHE PATH
+ "Install path prefix." FORCE)
+endif ()
+
+if (CMAKE_INSTALL_PREFIX STREQUAL PROJECT_SOURCE_DIR)
set (INSTALL_LOCAL TRUE)
message (STATUS "Installing locally")
else ()
@@ -193,6 +196,7 @@ 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 (DIRECTORY "${PROJECT_SOURCE_DIR}/inc/"
+ DESTINATION include FILES_MATCHING PATTERN "*.h")
install (TARGETS jigsaw-lib DESTINATION lib)
endif ()
diff --git a/external/jigsaw/src/geo_load.hpp b/external/jigsaw/src/geo_load.hpp
index 9e34aaa..4dd1366 100644
--- a/external/jigsaw/src/geo_load.hpp
+++ b/external/jigsaw/src/geo_load.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 10 Jul., 2021
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -47,28 +47,18 @@
# pragma once
-# include "msh_read.hpp"
+# include "parser/msh_read.hpp"
# ifndef __GEO_LOAD__
# define __GEO_LOAD__
/*
--------------------------------------------------------
- * GEOM-FROM-JMSH: read *.JMSH file into GEOM data.
+ * GEOM-READER: local reader for geom data.
--------------------------------------------------------
*/
- template <
- typename jlog_data
- >
- __normal_call iptr_type geom_from_jmsh (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- geom_data &_geom
- )
- {
- class geom_reader:
- public jmsh_reader_base
+ class geom_reader: public jmsh_reader_base
{
public :
geom_data *_geom ;
@@ -365,40 +355,46 @@
}
} ;
+ /*
+ --------------------------------------------------------
+ * READ-GEOM: read geometry input file.
+ --------------------------------------------------------
+ */
+
+ template <
+ typename jlog_data
+ >
+ __normal_call iptr_type read_geom (
+ jcfg_data &_jcfg ,
+ jlog_data &_jlog ,
+ geom_data &_geom
+ )
+ {
/*---------------------------------- parse GEOM. file */
iptr_type _errv = __no_error ;
try
{
- jmsh_reader _jmsh ;
- std::ifstream _file ;
- _file. open(
- _jcfg._geom_file, std::ifstream::in) ;
+ containers::array _errs ;
+ _errv = read_msh_file(
+ _jcfg._geom_file,
+ geom_reader(&_geom), _errs);
- if (_file.is_open() )
- {
- _jmsh.read_file (
- _file, geom_reader(&_geom));
- }
- else
+ if (_errv == __file_not_located)
{
_jlog.push(
"**parse error: file not found!\n" ) ;
-
- _errv = __file_not_located ;
}
- _file.close ();
- for (auto _iter =
- _jmsh._errs.head();
- _iter !=
- _jmsh._errs.tend();
+ for (auto _iter = _errs.head();
+ _iter != _errs.tend();
++_iter )
{
_jlog.push(
"**parse error: " + * _iter + "\n" ) ;
- _errv = __invalid_argument ;
+ if (_errv == __no_error)
+ _errv = __invalid_argument ;
}
}
catch (...)
@@ -411,313 +407,54 @@
/*
--------------------------------------------------------
- * GEOM-FROM-MSHT: read MSH_t data into GEOM data.
+ * COPY-GEOM: read geometry input data.
--------------------------------------------------------
*/
template <
typename jlog_data
>
- __normal_call iptr_type geom_from_msht (
+ __normal_call iptr_type copy_geom (
jcfg_data &_jcfg ,
jlog_data &_jlog ,
geom_data &_geom ,
jigsaw_msh_t const&_gmsh
)
{
+ /*---------------------------------- parse GEOM. data */
iptr_type _errv = __no_error ;
try
{
+ __unreferenced (_jlog) ;
+ __unreferenced (_jcfg) ;
- __unreferenced (_jlog) ;
- __unreferenced (_jcfg) ;
-
- if (_gmsh._flags ==
- JIGSAW_EUCLIDEAN_MESH )
- {
- if (_gmsh._vert2._size > 0)
+ msh_reader_api _read ;
+ if ( true )
{
- /*--------------------------------- euclidean-mesh-2d */
- _geom._kind
- = jmsh_kind::euclidean_mesh ;
- _geom._ndim = +2;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._vert2._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_2d
- ::node_type _ndat ;
- _ndat.pval(0) = _gmsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _gmsh.
- _vert2._data[_ipos]._ppos[1];
- _ndat.itag () = _gmsh.
- _vert2._data[_ipos]._itag ;
-
- _geom._euclidean_mesh_2d.
- _tria.push_node(_ndat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._seed2._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_2d
- ::seed_type _sdat ;
- _sdat.pval(0) = _gmsh.
- _seed2._data[_ipos]._ppos[0];
- _sdat.pval(1) = _gmsh.
- _seed2._data[_ipos]._ppos[1];
- _sdat.itag () = _gmsh.
- _seed2._data[_ipos]._itag ;
-
- _sdat.mark () = + 0 ;
- _sdat.self () = + 1 ;
-
- _geom._euclidean_mesh_2d.
- _seed.push_tail(_sdat);
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._edge2._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_2d
- ::edge_type _edat ;
- _edat.node(0) = _gmsh.
- _edge2._data[_ipos]._node[0];
- _edat.node(1) = _gmsh.
- _edge2._data[_ipos]._node[1];
- _edat.itag () = _gmsh.
- _edge2._data[_ipos]._itag ;
-
- _geom._euclidean_mesh_2d.
- _tria.push_edge(_edat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._bound._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_2d
- ::part_data _pdat ;
- _pdat.itag () = _gmsh.
- _bound._data[_ipos]._itag ;
- _pdat.indx () = _gmsh.
- _bound._data[_ipos]._indx ;
- _pdat.kind () = _gmsh.
- _bound._data[_ipos]._kind ;
-
- _geom._euclidean_mesh_2d.
- _part.push(_pdat) ;
- }
-
+ _read.read_data (
+ _gmsh, geom_reader(&_geom));
}
else
- if (_gmsh._vert3._size > 0)
{
- /*--------------------------------- euclidean-mesh-3d */
- _geom._kind
- = jmsh_kind::euclidean_mesh ;
- _geom._ndim = +3;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._vert3._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _gmsh.
- _vert3._data[_ipos]._ppos[0];
- _ndat.pval(1) = _gmsh.
- _vert3._data[_ipos]._ppos[1];
- _ndat.pval(2) = _gmsh.
- _vert3._data[_ipos]._ppos[2];
- _ndat.itag () = _gmsh.
- _vert3._data[_ipos]._itag ;
-
- _geom._euclidean_mesh_3d.
- _tria.push_node(_ndat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._seed3._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_3d
- ::seed_type _sdat ;
- _sdat.pval(0) = _gmsh.
- _seed3._data[_ipos]._ppos[0];
- _sdat.pval(1) = _gmsh.
- _seed3._data[_ipos]._ppos[1];
- _sdat.pval(2) = _gmsh.
- _seed3._data[_ipos]._ppos[2];
- _sdat.itag () = _gmsh.
- _seed3._data[_ipos]._itag ;
-
- _sdat.mark () = + 0 ;
- _sdat.self () = + 1 ;
-
- _geom._euclidean_mesh_3d.
- _seed.push_tail(_sdat);
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._edge2._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_3d
- ::edge_type _edat ;
- _edat.node(0) = _gmsh.
- _edge2._data[_ipos]._node[0];
- _edat.node(1) = _gmsh.
- _edge2._data[_ipos]._node[1];
- _edat.itag () = _gmsh.
- _edge2._data[_ipos]._itag ;
-
- _geom._euclidean_mesh_3d.
- _tria.push_edge(_edat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._tria3._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_3d
- ::tri3_type _tdat ;
- _tdat.node(0) = _gmsh.
- _tria3._data[_ipos]._node[0];
- _tdat.node(1) = _gmsh.
- _tria3._data[_ipos]._node[1];
- _tdat.node(2) = _gmsh.
- _tria3._data[_ipos]._node[2];
- _tdat.itag () = _gmsh.
- _tria3._data[_ipos]._itag ;
-
- _geom._euclidean_mesh_3d.
- _tria.push_tri3(_tdat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._bound._size ;
- ++_ipos )
- {
- typename
- geom_data::euclidean_mesh_3d
- ::part_data _pdat ;
- _pdat.itag () = _gmsh.
- _bound._data[_ipos]._itag ;
- _pdat.indx () = _gmsh.
- _bound._data[_ipos]._indx ;
- _pdat.kind () = _gmsh.
- _bound._data[_ipos]._kind ;
-
- _geom._euclidean_mesh_3d.
- _part.push(_pdat) ;
- }
-
- }
- }
- else
- if (_gmsh._flags ==
- JIGSAW_ELLIPSOID_MESH )
- {
- /*--------------------------------- ellipsoid-mesh-3d */
- _geom._kind
- = jmsh_kind::ellipsoid_mesh ;
- _geom._ndim = +2;
-
- if (_gmsh._radii._size==+3)
- {
- _geom._ellipsoid_mesh_3d.
- _radA = _gmsh._radii._data[0] ;
- _geom._ellipsoid_mesh_3d.
- _radB = _gmsh._radii._data[1] ;
- _geom._ellipsoid_mesh_3d.
- _radC = _gmsh._radii._data[2] ;
- }
- else
- if (_gmsh._radii._size==+1)
- {
- _geom._ellipsoid_mesh_3d.
- _radA = _gmsh._radii._data[0] ;
- _geom._ellipsoid_mesh_3d.
- _radB = _gmsh._radii._data[0] ;
- _geom._ellipsoid_mesh_3d.
- _radC = _gmsh._radii._data[0] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._vert2._size ;
- ++_ipos )
- {
- typename
- geom_data::ellipsoid_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _gmsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _gmsh.
- _vert2._data[_ipos]._ppos[1];
- _ndat.pval(2) = + 0.0 ;
- _ndat.itag () = _gmsh.
- _vert2._data[_ipos]._itag ;
-
- _geom._ellipsoid_mesh_3d.
- _mesh.push_node(_ndat , false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._seed2._size ;
- ++_ipos )
- {
- typename
- geom_data::ellipsoid_mesh_3d
- ::seed_type _sdat ;
- _sdat.pval(0) = _gmsh.
- _seed2._data[_ipos]._ppos[0];
- _sdat.pval(1) = _gmsh.
- _seed2._data[_ipos]._ppos[1];
- _sdat.pval(2) = + 0.0 ;
- _sdat.itag () = _gmsh.
- _seed2._data[_ipos]._itag ;
-
- _sdat.mark () = + 0 ;
- _sdat.self () = + 1 ;
+ _jlog.push(
+ "**parse error: struct is null!\n" ) ;
- _geom._ellipsoid_mesh_3d.
- _seed.push_tail(_sdat);
+ _errv = __invalid_argument ;
}
- for (auto _ipos = (size_t) +0 ;
- _ipos != _gmsh._edge2._size ;
- ++_ipos )
+ for (auto _iter =
+ _read._errs.head();
+ _iter !=
+ _read._errs.tend();
+ ++_iter )
{
- typename
- geom_data::ellipsoid_mesh_3d
- ::edge_type _edat ;
- _edat.node(0) = _gmsh.
- _edge2._data[_ipos]._node[0];
- _edat.node(1) = _gmsh.
- _edge2._data[_ipos]._node[1];
- _edat.itag () = _gmsh.
- _edge2._data[_ipos]._itag ;
+ _jlog.push(
+ "**parse error: " + * _iter + "\n" ) ;
- _geom._ellipsoid_mesh_3d.
- _mesh.push_edge(_edat , false) ;
+ _errv = __invalid_argument ;
}
}
-
- }
catch (...)
{
_errv = __unknown_error ;
@@ -726,45 +463,6 @@
return ( _errv ) ;
}
- /*
- --------------------------------------------------------
- * READ-GEOM: read geometry input file.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type read_geom (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- geom_data &_geom
- )
- {
- return geom_from_jmsh (
- _jcfg, _jlog, _geom ) ;
- }
-
- /*
- --------------------------------------------------------
- * COPY-GEOM: read geometry input data.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type copy_geom (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- geom_data &_geom ,
- jigsaw_msh_t const&_gmsh
- )
- {
- return geom_from_msht (
- _jcfg, _jlog, _geom, _gmsh);
- }
-
/*
--------------------------------------------------------
* TEST-GEOM: test GEOM data validity.
@@ -1400,5 +1098,3 @@
# endif //__GEO_LOAD__
-
-
diff --git a/external/jigsaw/src/hfn_init.hpp b/external/jigsaw/src/hfn_init.hpp
index c6cd93b..df6aa17 100644
--- a/external/jigsaw/src/hfn_init.hpp
+++ b/external/jigsaw/src/hfn_init.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 06 Jun., 2022
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -237,7 +237,7 @@
}
}
- else
+
if (_hfun._kind ==
jmsh_kind::ellipsoid_mesh)
{
diff --git a/external/jigsaw/src/hfn_load.hpp b/external/jigsaw/src/hfn_load.hpp
index 9bb4388..e4bdcf8 100644
--- a/external/jigsaw/src/hfn_load.hpp
+++ b/external/jigsaw/src/hfn_load.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Feb., 2025
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -47,28 +47,18 @@
# pragma once
-# include "msh_read.hpp"
+# include "parser/msh_read.hpp"
# ifndef __HFN_LOAD__
# define __HFN_LOAD__
/*
--------------------------------------------------------
- * HFUN-FROM-JMSH: read *.JMSH file into HFUN data.
+ * HFUN-READER: local reader for h(x) data.
--------------------------------------------------------
*/
- template <
- typename jlog_data
- >
- __normal_call iptr_type hfun_from_jmsh (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- hfun_data &_hfun
- )
- {
- class hfun_reader:
- public jmsh_reader_base
+ class hfun_reader: public jmsh_reader_base
{
public :
hfun_data *_hfun ;
@@ -540,40 +530,46 @@
}
} ;
+ /*
+ --------------------------------------------------------
+ * READ-HFUN: read HFUN input file.
+ --------------------------------------------------------
+ */
+
+ template <
+ typename jlog_data
+ >
+ __normal_call iptr_type read_hfun (
+ jcfg_data &_jcfg ,
+ jlog_data &_jlog ,
+ hfun_data &_hfun
+ )
+ {
/*---------------------------------- parse HFUN. file */
iptr_type _errv = __no_error ;
try
{
- jmsh_reader _jmsh ;
- std::ifstream _file ;
- _file. open(
- _jcfg._hfun_file, std::ifstream::in) ;
+ containers::array _errs ;
+ _errv = read_msh_file(
+ _jcfg._hfun_file,
+ hfun_reader(&_hfun), _errs);
- if (_file.is_open() )
- {
- _jmsh.read_file (
- _file, hfun_reader(&_hfun));
- }
- else
+ if (_errv == __file_not_located)
{
_jlog.push(
"**parse error: file not found!\n" ) ;
-
- _errv = __file_not_located ;
}
- _file.close ();
- for (auto _iter =
- _jmsh._errs.head();
- _iter !=
- _jmsh._errs.tend();
+ for (auto _iter = _errs.head();
+ _iter != _errs.tend();
++_iter )
{
_jlog.push(
"**parse error: " + * _iter + "\n" ) ;
- _errv = __invalid_argument ;
+ if (_errv == __no_error)
+ _errv = __invalid_argument ;
}
}
catch (...)
@@ -586,479 +582,54 @@
/*
--------------------------------------------------------
- * HFUN-FROM-MSHT: read MSH_t data into HFUN data.
+ * COPY-HFUN: copy HFUN input data.
--------------------------------------------------------
*/
template <
typename jlog_data
>
- __normal_call iptr_type hfun_from_msht (
+ __normal_call iptr_type copy_hfun (
jcfg_data &_jcfg ,
jlog_data &_jlog ,
hfun_data &_hfun ,
jigsaw_msh_t const&_hmsh
)
{
+ /*---------------------------------- parse HFUN. data */
iptr_type _errv = __no_error ;
try
{
+ __unreferenced (_jlog) ;
+ __unreferenced (_jcfg) ;
- __unreferenced (_jlog) ;
- __unreferenced (_jcfg) ;
-
- if (_hmsh._flags ==
- JIGSAW_EUCLIDEAN_MESH )
- {
- if (_hmsh._vert2._size > 0)
- {
- /*--------------------------------- euclidean-mesh-2d */
- _hfun._kind
- = jmsh_kind::euclidean_mesh ;
- _hfun._ndim = +2;
-
- if (_hmsh._vert2._size !=
- _hmsh._value._size )
- return __invalid_argument ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._vert2._size ;
- ++_ipos )
- {
- typename
- hfun_data::euclidean_mesh_2d
- ::node_type _ndat ;
- _ndat.pval(0) = _hmsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _hmsh.
- _vert2._data[_ipos]._ppos[1];
-
- _hfun._euclidean_mesh_2d.
- _mesh.push_node(_ndat, false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._tria3._size ;
- ++_ipos )
- {
- typename
- hfun_data::euclidean_mesh_2d
- ::tri3_type _tdat ;
- _tdat.node(0) = _hmsh.
- _tria3._data[_ipos]._node[0];
- _tdat.node(1) = _hmsh.
- _tria3._data[_ipos]._node[1];
- _tdat.node(2) = _hmsh.
- _tria3._data[_ipos]._node[2];
-
- _hfun._euclidean_mesh_2d.
- _mesh.push_tri3(_tdat, false) ;
- }
-
- _hfun._euclidean_mesh_2d._hval.
- set_count(_hmsh._value._size) ;
-
- _hfun._euclidean_mesh_2d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._euclidean_mesh_2d.
- _hval[_ipos] =
- _hmsh._value._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
- {
- _hfun._euclidean_mesh_2d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
-
- }
- else
- if (_hmsh._vert3._size > 0)
- {
- /*--------------------------------- euclidean-mesh-3d */
- _hfun._kind
- = jmsh_kind::euclidean_mesh ;
- _hfun._ndim = +3;
-
- if (_hmsh._vert3._size !=
- _hmsh._value._size )
- return __invalid_argument ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._vert3._size ;
- ++_ipos )
- {
- typename
- hfun_data::euclidean_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _hmsh.
- _vert3._data[_ipos]._ppos[0];
- _ndat.pval(1) = _hmsh.
- _vert3._data[_ipos]._ppos[1];
- _ndat.pval(2) = _hmsh.
- _vert3._data[_ipos]._ppos[2];
-
- _hfun._euclidean_mesh_3d.
- _mesh.push_node(_ndat, false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._tria4._size ;
- ++_ipos )
- {
- typename
- hfun_data::euclidean_mesh_3d
- ::tri4_type _tdat ;
- _tdat.node(0) = _hmsh.
- _tria4._data[_ipos]._node[0];
- _tdat.node(1) = _hmsh.
- _tria4._data[_ipos]._node[1];
- _tdat.node(2) = _hmsh.
- _tria4._data[_ipos]._node[2];
- _tdat.node(3) = _hmsh.
- _tria4._data[_ipos]._node[3];
-
- _hfun._euclidean_mesh_3d.
- _mesh.push_tri4(_tdat, false) ;
- }
-
- _hfun._euclidean_mesh_3d._hval.
- set_count(_hmsh._value._size) ;
-
- _hfun._euclidean_mesh_3d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._euclidean_mesh_3d.
- _hval[_ipos] =
- _hmsh._value._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
- {
- _hfun._euclidean_mesh_3d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
-
- }
- }
- else
- if (_hmsh._flags ==
- JIGSAW_ELLIPSOID_MESH )
- {
- /*--------------------------------- ellipsoid-mesh-3d */
- _hfun._kind
- = jmsh_kind::ellipsoid_mesh ;
- _hfun._ndim = +2;
-
- if (_hmsh._vert2._size !=
- _hmsh._value._size )
- return __invalid_argument ;
-
- if (_hmsh._radii._size==+3)
- {
- _hfun._ellipsoid_mesh_3d.
- _radA = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_mesh_3d.
- _radB = _hmsh._radii._data[1] ;
- _hfun._ellipsoid_mesh_3d.
- _radC = _hmsh._radii._data[2] ;
- }
- else
- if (_hmsh._radii._size==+1)
- {
- _hfun._ellipsoid_mesh_3d.
- _radA = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_mesh_3d.
- _radB = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_mesh_3d.
- _radC = _hmsh._radii._data[0] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._vert2._size ;
- ++_ipos )
- {
- typename
- hfun_data::ellipsoid_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _hmsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _hmsh.
- _vert2._data[_ipos]._ppos[1];
- _ndat.pval(2) = + 0.0 ;
-
- _hfun._ellipsoid_mesh_3d.
- _mesh.push_node(_ndat, false) ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._tria3._size ;
- ++_ipos )
- {
- typename
- hfun_data::ellipsoid_mesh_3d
- ::tri3_type _tdat ;
- _tdat.node(0) = _hmsh.
- _tria3._data[_ipos]._node[0];
- _tdat.node(1) = _hmsh.
- _tria3._data[_ipos]._node[1];
- _tdat.node(2) = _hmsh.
- _tria3._data[_ipos]._node[2];
-
- _hfun._ellipsoid_mesh_3d.
- _mesh.push_tri3(_tdat, false) ;
- }
-
- _hfun._ellipsoid_mesh_3d._hval.
- set_count(_hmsh._value._size) ;
-
- _hfun._ellipsoid_mesh_3d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._ellipsoid_mesh_3d.
- _hval[_ipos] =
- _hmsh._value._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
- {
- _hfun._ellipsoid_mesh_3d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
-
- }
- else
- if (_hmsh._flags ==
- JIGSAW_EUCLIDEAN_GRID )
- {
- if (_hmsh._zgrid._size== 0)
- {
- /*--------------------------------- euclidean-grid-2d */
- _hfun._kind
- = jmsh_kind::euclidean_grid ;
- _hfun._ndim = +2;
-
- _hfun._euclidean_grid_2d._xpos.
- set_count(_hmsh._xgrid._size) ;
- _hfun._euclidean_grid_2d._ypos.
- set_count(_hmsh._ygrid._size) ;
-
- _hfun._euclidean_grid_2d._hmat.
- set_count(_hmsh._value._size) ;
-
- _hfun._euclidean_grid_2d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._xgrid._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_2d.
- _xpos[_ipos] =
- _hmsh._xgrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._ygrid._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_2d.
- _ypos[_ipos] =
- _hmsh._ygrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_2d.
- _hmat[_ipos] =
- _hmsh._value._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_2d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
-
- }
- else
- if (_hmsh._zgrid._size!= 0)
- {
- /*--------------------------------- euclidean-grid-3d */
- _hfun._kind
- = jmsh_kind::euclidean_grid ;
- _hfun._ndim = +3;
-
- _hfun._euclidean_grid_3d._xpos.
- set_count(_hmsh._xgrid._size) ;
- _hfun._euclidean_grid_3d._ypos.
- set_count(_hmsh._ygrid._size) ;
- _hfun._euclidean_grid_3d._zpos.
- set_count(_hmsh._zgrid._size) ;
-
- _hfun._euclidean_grid_3d._hmat.
- set_count(_hmsh._value._size) ;
-
- _hfun._euclidean_grid_3d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._xgrid._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_3d.
- _xpos[_ipos] =
- _hmsh._xgrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._ygrid._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_3d.
- _ypos[_ipos] =
- _hmsh._ygrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._zgrid._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_3d.
- _zpos[_ipos] =
- _hmsh._zgrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_3d.
- _hmat[_ipos] =
- _hmsh._value._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
- {
- _hfun._euclidean_grid_3d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
-
- }
- }
- else
- if (_hmsh._flags ==
- JIGSAW_ELLIPSOID_GRID )
- {
- if (_hmsh._zgrid._size== 0)
- {
- /*--------------------------------- ellipsoid-grid-3d */
- _hfun._kind
- = jmsh_kind::ellipsoid_grid ;
- _hfun._ndim = +2;
-
- if (_hmsh._radii._size==+3)
+ msh_reader_api _read ;
+ if ( true )
{
- _hfun._ellipsoid_grid_3d.
- _radA = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_grid_3d.
- _radB = _hmsh._radii._data[1] ;
- _hfun._ellipsoid_grid_3d.
- _radC = _hmsh._radii._data[2] ;
+ _read.read_data (
+ _hmsh, hfun_reader(&_hfun));
}
else
- if (_hmsh._radii._size==+1)
{
- _hfun._ellipsoid_grid_3d.
- _radA = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_grid_3d.
- _radB = _hmsh._radii._data[0] ;
- _hfun._ellipsoid_grid_3d.
- _radC = _hmsh._radii._data[0] ;
- }
-
- _hfun._ellipsoid_grid_3d._xpos.
- set_count(_hmsh._xgrid._size) ;
- _hfun._ellipsoid_grid_3d._ypos.
- set_count(_hmsh._ygrid._size) ;
-
- _hfun._ellipsoid_grid_3d._hmat.
- set_count(_hmsh._value._size) ;
-
- _hfun._ellipsoid_grid_3d._dhdx.
- set_count(_hmsh._slope._size) ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._xgrid._size ;
- ++_ipos )
- {
- _hfun._ellipsoid_grid_3d.
- _xpos[_ipos] =
- _hmsh._xgrid._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._ygrid._size ;
- ++_ipos )
- {
- _hfun._ellipsoid_grid_3d.
- _ypos[_ipos] =
- _hmsh._ygrid._data[_ipos] ;
- }
+ _jlog.push(
+ "**parse error: struct is null!\n" ) ;
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._value._size ;
- ++_ipos )
- {
- _hfun._ellipsoid_grid_3d.
- _hmat[_ipos] =
- _hmsh._value._data[_ipos] ;
+ _errv = __invalid_argument ;
}
- for (auto _ipos = (size_t) +0 ;
- _ipos != _hmsh._slope._size ;
- ++_ipos )
+ for (auto _iter =
+ _read._errs.head();
+ _iter !=
+ _read._errs.tend();
+ ++_iter )
{
- _hfun._ellipsoid_grid_3d.
- _dhdx[_ipos] =
- _hmsh._slope._data[_ipos] ;
- }
+ _jlog.push(
+ "**parse error: " + * _iter + "\n" ) ;
+ _errv = __invalid_argument ;
}
}
-
- }
catch (...)
{
_errv = __unknown_error ;
@@ -1067,45 +638,6 @@
return ( _errv ) ;
}
- /*
- --------------------------------------------------------
- * READ-HFUN: read HFUN input file.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type read_hfun (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- hfun_data &_hfun
- )
- {
- return hfun_from_jmsh (
- _jcfg, _jlog, _hfun ) ;
- }
-
- /*
- --------------------------------------------------------
- * COPY-HFUN: copy HFUN input data.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type copy_hfun (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- hfun_data &_hfun ,
- jigsaw_msh_t const&_hmsh
- )
- {
- return hfun_from_msht (
- _jcfg, _jlog, _hfun, _hmsh);
- }
-
/*
--------------------------------------------------------
* TEST-HFUN: test HFUN data validity.
@@ -2513,5 +2045,3 @@
# endif //__HFN_LOAD__
-
-
diff --git a/external/jigsaw/src/hfn_save.inc b/external/jigsaw/src/hfn_save.inc
index 78d4cae..8cc7cf1 100644
--- a/external/jigsaw/src/hfn_save.inc
+++ b/external/jigsaw/src/hfn_save.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 05 Dec, 2024
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -66,6 +66,9 @@
)
{
auto constexpr VALUEBLOCK = VALUECHUNK / 4 ;
+ auto constexpr VALUEDIGIT = std::numeric_limits<
+ typename list_type::
+ data_type>::max_digits10 ;
/*--------------------- save msh_t REALS data to file */
auto _next = +0, _roll = +0 ;
@@ -81,11 +84,11 @@
/*--------------------- (apparently) faster to unroll */
PRINTCHARS(snprintf(&_fbuf[_next] ,
PRINTCHUNK-_next,
- "%.9g\n%.9g\n%.9g\n%.9g\n" ,
- *(_iter + 0) + _xoff,
- *(_iter + 1) + _xoff,
- *(_iter + 2) + _xoff,
- *(_iter + 3) + _xoff) , VALUEBLOCK)
+ "%.*g\n%.*g\n%.*g\n%.*g\n" ,
+ VALUEDIGIT, *(_iter + 0) + _xoff,
+ VALUEDIGIT, *(_iter + 1) + _xoff,
+ VALUEDIGIT, *(_iter + 2) + _xoff,
+ VALUEDIGIT, *(_iter + 3) + _xoff) , VALUEBLOCK)
}
for (auto _iter = _this,
@@ -95,8 +98,8 @@
{
/*--------------------- trailing non-mod(4) remainder */
PRINTCHARS(snprintf(&_fbuf[_next] ,
- PRINTCHUNK-_next, "%.9g\n",
- *(_iter + 0) + _xoff) , VALUECHUNK)
+ PRINTCHUNK-_next, "%.*g\n",
+ VALUEDIGIT, *(_iter + 0) + _xoff) , VALUECHUNK)
}
{
@@ -699,13 +702,21 @@
_jcfg._hfun_file, _path, _name, _fext) ;
int _retv, _ncid;
- if ((_retv = nc_create(
- _jcfg._hfun_file.c_str(),
- NC_CLOBBER|NC_NETCDF4, &_ncid)))
+ if((_retv = nc_open(
+ _jcfg._hfun_file.c_str(), NC_WRITE, &_ncid)))
{
- return __file_not_created;
+ return __file_not_located;
}
+ if ((_retv = nc_close(_ncid)))
+ {
+ return __unknown_error;
+ }
+
+ ncutil::put_str(
+ _jcfg._hfun_file, "title",
+ _name + "; created by " + __JGSWVSTR) ;
+
__unreferenced (_jcfg) ;
__unreferenced (_jlog) ;
@@ -713,10 +724,6 @@
_ffun._kind ==
jmsh_kind::euclidean_mesh)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._euclidean_mesh_2d.
_hval.count() > +0)
{
@@ -732,10 +739,6 @@
_ffun._kind ==
jmsh_kind::euclidean_mesh)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._euclidean_mesh_3d.
_hval.count() > +0)
{
@@ -751,10 +754,6 @@
_ffun._kind ==
jmsh_kind::ellipsoid_mesh)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._ellipsoid_mesh_3d.
_hval.count() > +0)
{
@@ -770,10 +769,6 @@
_ffun._kind ==
jmsh_kind::euclidean_grid)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._euclidean_grid_2d.
_hmat.count() > +0)
{
@@ -789,10 +784,6 @@
_ffun._kind ==
jmsh_kind::euclidean_grid)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._euclidean_grid_3d.
_hmat.count() > +0)
{
@@ -808,10 +799,6 @@
_ffun._kind ==
jmsh_kind::ellipsoid_grid)
{
- ncutil::put_str(_jcfg._hfun_file,
- "TITLE" ,
- _name + "; created by " + __JGSWVSTR);
-
if (_ffun._ellipsoid_grid_3d.
_hmat.count() > +0)
{
@@ -1059,6 +1046,3 @@
return ( _errv ) ;
}
-
-
-
diff --git a/external/jigsaw/src/ini_load.hpp b/external/jigsaw/src/ini_load.hpp
index 4145a8b..dc46a86 100644
--- a/external/jigsaw/src/ini_load.hpp
+++ b/external/jigsaw/src/ini_load.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 07 Jul., 2021
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -47,28 +47,18 @@
# pragma once
-# include "msh_read.hpp"
+# include "parser/msh_read.hpp"
# ifndef __INI_LOAD__
# define __INI_LOAD__
/*
--------------------------------------------------------
- * INIT-FROM-JMSH: read *.JMSH file into INIT data.
+ * INIT-READER: local reader for init data.
--------------------------------------------------------
*/
- template <
- typename jlog_data
- >
- __normal_call iptr_type init_from_jmsh (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- mesh_data &_init
- )
- {
- class init_reader:
- public jmsh_reader_base
+ class init_reader: public jmsh_reader_base
{
public :
mesh_data *_init ;
@@ -78,7 +68,7 @@
enum_data _kind ;
std:: size_t _ndim ;
- real_type _rrad[3] = {1.} ;
+ real_type _rrad[3] = {1., 1., 1.} ;
containers::
array _vpwr ;
@@ -469,46 +459,56 @@
{
save_point () ; // lon-lat to R^3
save_power () ; // match to point
+
+ if (this->
+ _kind== jmsh_kind::ellipsoid_mesh)
+ this->_init->_ndim = +3 ;
- this-> // pts now in R^3
- _init->_kind = jmsh_kind::euclidean_mesh ;
+ this->_init-> // pts now in R^3
+ _kind = jmsh_kind::euclidean_mesh ;
}
} ;
+ /*
+ --------------------------------------------------------
+ * READ-INIT: read init. distribution file.
+ --------------------------------------------------------
+ */
+
+ template <
+ typename jlog_data
+ >
+ __normal_call iptr_type read_init (
+ jcfg_data &_jcfg ,
+ jlog_data &_jlog ,
+ mesh_data &_init
+ )
+ {
/*---------------------------------- parse INIT. file */
iptr_type _errv = __no_error ;
try
{
- jmsh_reader _jmsh ;
- std::ifstream _file ;
- _file. open(
- _jcfg._init_file, std::ifstream::in) ;
+ containers::array _errs ;
+ _errv = read_msh_file(
+ _jcfg._init_file,
+ init_reader(&_init), _errs);
- if (_file.is_open() )
- {
- _jmsh.read_file (
- _file, init_reader(&_init));
- }
- else
+ if (_errv == __file_not_located)
{
_jlog.push(
"**parse error: file not found!\n" ) ;
-
- _errv = __file_not_located ;
}
- _file.close ();
- for (auto _iter =
- _jmsh._errs.head();
- _iter !=
- _jmsh._errs.tend();
+ for (auto _iter = _errs.head();
+ _iter != _errs.tend();
++_iter )
{
_jlog.push(
"**parse error: " + * _iter + "\n" ) ;
- _errv = __invalid_argument ;
+ if (_errv == __no_error)
+ _errv = __invalid_argument ;
}
}
catch (...)
@@ -521,358 +521,53 @@
/*
--------------------------------------------------------
- * INIT-FROM-MSHT: read MSH_t data into INIT data.
+ * COPY-INIT: copy INIT input data.
--------------------------------------------------------
*/
template <
typename jlog_data
>
- __normal_call iptr_type init_from_msht (
+ __normal_call iptr_type copy_init (
jcfg_data &_jcfg ,
jlog_data &_jlog ,
mesh_data &_init ,
jigsaw_msh_t const&_imsh
)
{
+ /*---------------------------------- parse INIT. data */
iptr_type _errv = __no_error ;
try
{
+ __unreferenced (_jlog) ;
+ __unreferenced (_jcfg) ;
- __unreferenced (_jlog) ;
- __unreferenced (_jcfg) ;
-
- if (_imsh._vert2._size > 0 &&
- _imsh._flags ==
- JIGSAW_EUCLIDEAN_MESH )
- {
- /*--------------------------------- euclidean-mesh-2d */
- _init._kind
- = jmsh_kind::euclidean_mesh ;
- _init._ndim = +2;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._vert2._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_2d
- ::node_type _ndat ;
- _ndat.pval(0) = _imsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _imsh.
- _vert2._data[_ipos]._ppos[1];
- _ndat.itag () = _imsh.
- _vert2._data[_ipos]._itag ;
-
- _ndat.pval(2) =
- (real_type) +0. ;
-
- _ndat.fdim () = +0 ;
-
- if (_ndat.itag () < +0)
- _ndat.feat () =
- mesh::user_feat ;
- else
- _ndat.feat () =
- mesh::null_feat ;
-
- _init._euclidean_mesh_2d.
- _mesh.push_node(_ndat,false);
- }
-
- if (_imsh._power._size != +0 &&
- _imsh._power._size !=
- _imsh._vert2._size )
- return __invalid_argument ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._power._size ;
- ++_ipos )
- {
- _init._euclidean_mesh_2d.
- _mesh.node(_ipos).pval(2) =
- _imsh._power._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._edge2._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_2d
- ::edge_type _edat ;
- _edat.node(0) = _imsh.
- _edge2._data[_ipos]._node[0];
- _edat.node(1) = _imsh.
- _edge2._data[_ipos]._node[1];
- _edat.itag () = _imsh.
- _edge2._data[_ipos]._itag ;
-
- _init._euclidean_mesh_2d.
- _mesh.push_edge(_edat,false);
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._tria3._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_2d
- ::tri3_type _tdat ;
- _tdat.node(0) = _imsh.
- _tria3._data[_ipos]._node[0];
- _tdat.node(1) = _imsh.
- _tria3._data[_ipos]._node[1];
- _tdat.node(2) = _imsh.
- _tria3._data[_ipos]._node[2];
- _tdat.itag () = _imsh.
- _tria3._data[_ipos]._itag ;
-
- _init._euclidean_mesh_2d.
- _mesh.push_tri3(_tdat,false);
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._quad4._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_2d
- ::quad_type _qdat ;
- _qdat.node(0) = _imsh.
- _quad4._data[_ipos]._node[0];
- _qdat.node(1) = _imsh.
- _quad4._data[_ipos]._node[1];
- _qdat.node(2) = _imsh.
- _quad4._data[_ipos]._node[2];
- _qdat.node(3) = _imsh.
- _quad4._data[_ipos]._node[3];
- _qdat.itag () = _imsh.
- _quad4._data[_ipos]._itag ;
-
- _init._euclidean_mesh_2d.
- _mesh.push_quad(_qdat,false);
- }
-
- }
- else
- if (_imsh._flags ==
- JIGSAW_ELLIPSOID_MESH ||
- (_imsh._vert3._size > 0 &&
- _imsh._flags ==
- JIGSAW_EUCLIDEAN_MESH ) )
- {
- /*--------------------------------- euclidean-mesh-3d */
- _init._kind
- = jmsh_kind::euclidean_mesh ;
- _init._ndim = + 3;
-
- real_type _rrad[3] = { 1. } ;
-
- if (_imsh._radii._size == 3 )
+ msh_reader_api _read ;
+ if ( true )
{
- _rrad[0] = _imsh._radii._data[0];
- _rrad[1] = _imsh._radii._data[1];
- _rrad[2] = _imsh._radii._data[2];
+ _read.read_data (
+ _imsh, init_reader(&_init));
}
else
- if (_imsh._radii._size == 1 )
{
- _rrad[0] = _imsh._radii._data[0];
- _rrad[1] = _imsh._radii._data[0];
- _rrad[2] = _imsh._radii._data[0];
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._vert3._size ;
- ++_ipos ) // from euclidean...
- {
- typename
- mesh_data::euclidean_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _imsh.
- _vert3._data[_ipos]._ppos[0];
- _ndat.pval(1) = _imsh.
- _vert3._data[_ipos]._ppos[1];
- _ndat.pval(2) = _imsh.
- _vert3._data[_ipos]._ppos[2];
- _ndat.itag () = _imsh.
- _vert3._data[_ipos]._itag ;
-
- _ndat.pval(3) =
- (real_type) +0. ;
-
- _ndat.fdim () = +0 ;
-
- if (_ndat.itag () < +0)
- _ndat.feat () =
- mesh::user_feat ;
- else
- _ndat.feat () =
- mesh::null_feat ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_node(_ndat,false);
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._vert2._size ;
- ++_ipos ) // from ellipsoid...
- {
- typename
- mesh_data::euclidean_mesh_3d
- ::node_type _ndat ;
- _ndat.pval(0) = _imsh.
- _vert2._data[_ipos]._ppos[0];
- _ndat.pval(1) = _imsh.
- _vert2._data[_ipos]._ppos[1];
- _ndat.itag () = _imsh.
- _vert2._data[_ipos]._itag ;
-
- _ndat.pval(3) =
- (real_type) +0. ;
-
- _ndat.fdim () = +0 ;
-
- real_type _apos[2];
- real_type _ppos[3];
-
- _apos[0] = _ndat. pval (0) ;
- _apos[1] = _ndat. pval (1) ;
-
- math::toR3(
- _rrad, _apos, _ppos) ;
-
- _ndat. pval(0) = _ppos [0] ;
- _ndat. pval(1) = _ppos [1] ;
- _ndat. pval(2) = _ppos [2] ;
-
- if (_ndat.itag () < +0)
- _ndat.feat () =
- mesh::user_feat ;
- else
- _ndat.feat () =
- mesh::null_feat ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_node(_ndat,false);
- }
-
- if (_imsh._power._size != +0 &&
- _imsh._power._size !=
- _imsh._vert3._size &&
- _imsh._power._size !=
- _imsh._vert2._size )
- return __invalid_argument ;
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._power._size ;
- ++_ipos )
- {
- _init._euclidean_mesh_3d.
- _mesh.node(_ipos).pval(3) =
- _imsh._power._data[_ipos] ;
- }
-
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._edge2._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_3d
- ::edge_type _edat ;
- _edat.node(0) = _imsh.
- _edge2._data[_ipos]._node[0];
- _edat.node(1) = _imsh.
- _edge2._data[_ipos]._node[1];
- _edat.itag () = _imsh.
- _edge2._data[_ipos]._itag ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_edge(_edat,false);
- }
+ _jlog.push(
+ "**parse error: struct is null!\n" ) ;
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._tria3._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_3d
- ::tri3_type _tdat ;
- _tdat.node(0) = _imsh.
- _tria3._data[_ipos]._node[0];
- _tdat.node(1) = _imsh.
- _tria3._data[_ipos]._node[1];
- _tdat.node(2) = _imsh.
- _tria3._data[_ipos]._node[2];
- _tdat.itag () = _imsh.
- _tria3._data[_ipos]._itag ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_tri3(_tdat,false);
+ _errv = __invalid_argument ;
}
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._quad4._size ;
- ++_ipos )
+ for (auto _iter =
+ _read._errs.head();
+ _iter !=
+ _read._errs.tend();
+ ++_iter )
{
- typename
- mesh_data::euclidean_mesh_3d
- ::quad_type _qdat ;
- _qdat.node(0) = _imsh.
- _quad4._data[_ipos]._node[0];
- _qdat.node(1) = _imsh.
- _quad4._data[_ipos]._node[1];
- _qdat.node(2) = _imsh.
- _quad4._data[_ipos]._node[2];
- _qdat.node(3) = _imsh.
- _quad4._data[_ipos]._node[3];
- _qdat.itag () = _imsh.
- _quad4._data[_ipos]._itag ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_quad(_qdat,false);
- }
+ _jlog.push(
+ "**parse error: " + * _iter + "\n" ) ;
- for (auto _ipos = (size_t) +0 ;
- _ipos != _imsh._tria4._size ;
- ++_ipos )
- {
- typename
- mesh_data::euclidean_mesh_3d
- ::tri4_type _tdat ;
- _tdat.node(0) = _imsh.
- _tria4._data[_ipos]._node[0];
- _tdat.node(1) = _imsh.
- _tria4._data[_ipos]._node[1];
- _tdat.node(2) = _imsh.
- _tria4._data[_ipos]._node[2];
- _tdat.node(3) = _imsh.
- _tria4._data[_ipos]._node[3];
- _tdat.itag () = _imsh.
- _tria4._data[_ipos]._itag ;
-
- _init._euclidean_mesh_3d.
- _mesh.push_tri4(_tdat,false);
+ _errv = __invalid_argument ;
}
- }
- else
- if (_imsh._flags ==
- JIGSAW_EUCLIDEAN_GRID)
- {
- _errv =
- __invalid_argument ;
- }
- else
- if (_imsh._flags ==
- JIGSAW_ELLIPSOID_GRID)
- {
- _errv =
- __invalid_argument ;
- }
-
}
catch (...)
{
@@ -882,45 +577,6 @@
return ( _errv ) ;
}
- /*
- --------------------------------------------------------
- * READ-INIT: read init. distribution file.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type read_init (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- mesh_data &_init
- )
- {
- return init_from_jmsh (
- _jcfg, _jlog, _init ) ;
- }
-
- /*
- --------------------------------------------------------
- * COPY-INIT: copy INIT input data.
- --------------------------------------------------------
- */
-
- template <
- typename jlog_data
- >
- __normal_call iptr_type copy_init (
- jcfg_data &_jcfg ,
- jlog_data &_jlog ,
- mesh_data &_init ,
- jigsaw_msh_t const&_imsh
- )
- {
- return init_from_msht (
- _jcfg, _jlog, _init, _imsh);
- }
-
/*
--------------------------------------------------------
* TEST-INIT: test INIT data validity.
@@ -1353,5 +1009,3 @@
# endif //__INI_LOAD__
-
-
diff --git a/external/jigsaw/src/jig_load.hpp b/external/jigsaw/src/jig_load.hpp
index 406e0f0..a513e31 100644
--- a/external/jigsaw/src/jig_load.hpp
+++ b/external/jigsaw/src/jig_load.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -47,7 +47,7 @@
# pragma once
-# include "jig_read.hpp"
+# include "parser/jig_read.hpp"
# ifndef __JIG_LOAD__
# define __JIG_LOAD__
@@ -538,13 +538,6 @@
__unreferenced(_jlog) ;
/*------------------------------------- MISC keywords */
- _jcfg._verbosity =
- _jjig._verbosity ;
- _jcfg._mesh_opts.
- verb() = _jjig._verbosity ;
- _jcfg._iter_opts.
- verb() = _jjig._verbosity ;
-
if (_jjig._numthread <= 0 )
# ifdef __use_openmp
_jjig._numthread =
@@ -553,12 +546,14 @@
_jjig._numthread = +1 ;
# endif//__use_openmp
+ _jcfg._verbosity = _jjig._verbosity ;
_jcfg._numthread =
_jjig._numthread ;
- _jcfg._mesh_opts.
- nprt() = _jjig._numthread ;
- _jcfg._iter_opts.
- nprt() = _jjig._numthread ;
+
+ static_cast(
+ _jcfg._mesh_opts) = _jjig ;
+ static_cast(
+ _jcfg._iter_opts) = _jjig ;
/*------------------------------------- BNDS keywords */
if (_jjig._bnds_kern ==
@@ -573,20 +568,6 @@
else
_errv = __invalid_useropts ;
- /*------------------------------------- GEOM keywords */
- _jcfg._mesh_opts.
- seed() = _jjig._geom_seed ;
- _jcfg._mesh_opts.
- feat() = _jjig._geom_feat ;
- _jcfg._mesh_opts.
- eta1() = _jjig._geom_eta1 ;
- _jcfg._mesh_opts.
- eta2() = _jjig._geom_eta2 ;
-
- /*------------------------------------- INIT keywords */
- _jcfg._mesh_opts.
- near() = _jjig._init_near ;
-
/*------------------------------------- HFUN keywords */
if (_jjig._hfun_scal ==
JIGSAW_HFUN_RELATIVE)
@@ -623,50 +604,6 @@
else
_errv = __invalid_useropts ;
- _jcfg._mesh_opts.
- dims() = _jjig._mesh_dims ;
- _jcfg._mesh_opts.
- iter() = _jjig._mesh_iter ;
-
- _jcfg._mesh_opts.
- siz1() = _jjig._mesh_siz1 ;
- _jcfg._mesh_opts.
- siz2() = _jjig._mesh_siz2 ;
- _jcfg._mesh_opts.
- siz3() = _jjig._mesh_siz3 ;
-
- _jcfg._mesh_opts.
- orph() = _jjig._mesh_orph ;
-
- _jcfg._mesh_opts.
- lock() = _jjig._mesh_lock ;
-
- _jcfg._mesh_opts.
- top1() = _jjig._mesh_top1 ;
- _jcfg._mesh_opts.
- top2() = _jjig._mesh_top2 ;
-
- _jcfg._mesh_opts.
- rad2() = _jjig._mesh_rad2 ;
- _jcfg._mesh_opts.
- rad3() = _jjig._mesh_rad3 ;
- _jcfg._mesh_opts.
- off2() = _jjig._mesh_off2 ;
- _jcfg._mesh_opts.
- off3() = _jjig._mesh_off3 ;
- _jcfg._mesh_opts.
- snk2() = _jjig._mesh_snk2 ;
- _jcfg._mesh_opts.
- snk3() = _jjig._mesh_snk3 ;
-
- _jcfg._mesh_opts.
- eps1() = _jjig._mesh_eps1 ;
- _jcfg._mesh_opts.
- eps2() = _jjig._mesh_eps2 ;
-
- _jcfg._mesh_opts.
- vol3() = _jjig._mesh_vol3 ;
-
/*------------------------------------- ITER keywords */
if (_jjig._optm_kern ==
JIGSAW_KERN_ODT_DQDX)
@@ -697,33 +634,6 @@
else
_errv = __invalid_useropts ;
- _jcfg._iter_opts.
- iter() = _jjig._optm_iter ;
-
- _jcfg._iter_opts.
- beta() = _jjig._optm_beta ;
- _jcfg._iter_opts.
- zeta() = _jjig._optm_zeta ;
-
- _jcfg._iter_opts.
- qtol() = _jjig._optm_qtol ;
- _jcfg._iter_opts.
- qlim() = _jjig._optm_qlim ;
-
- _jcfg._iter_opts.
- wmin() = _jjig._optm_wmin ;
- _jcfg._iter_opts.
- wmax() = _jjig._optm_wmax ;
-
- _jcfg._iter_opts.
- tria() = _jjig._optm_tria ;
- _jcfg._iter_opts.
- dual() = _jjig._optm_dual ;
- _jcfg._iter_opts.
- div_() = _jjig._optm_div_ ;
- _jcfg._iter_opts.
- zip_() = _jjig._optm_zip_ ;
-
}
catch (...)
{
@@ -1087,6 +997,8 @@
_jlog.push(" MESH-ITER = " +
__pushIVAL(_jcfg._mesh_opts.iter()));
+ _jlog.push(" MESH-RULE = " +
+ __pushIVAL(_jcfg._mesh_opts.rule()));
_jlog.push(" MESH-DIMS = " +
__pushIVAL(_jcfg._mesh_opts.dims()));
@@ -1094,7 +1006,7 @@
__pushRVAL(_jcfg._mesh_opts.siz1()));
_jlog.push(" MESH-SIZ2 = " +
__pushRVAL(_jcfg._mesh_opts.siz2()));
- _jlog.push(" MESH-SIZ2 = " +
+ _jlog.push(" MESH-SIZ3 = " +
__pushRVAL(_jcfg._mesh_opts.siz3()));
_jlog.push(" MESH-EPS1 = " +
diff --git a/external/jigsaw/src/jigsaw.cpp b/external/jigsaw/src/jigsaw.cpp
index 1e91b25..df04c4f 100644
--- a/external/jigsaw/src/jigsaw.cpp
+++ b/external/jigsaw/src/jigsaw.cpp
@@ -41,11 +41,11 @@
* JIGSAW: an unstructured mesh generation library.
--------------------------------------------------------
*
- * JIGSAW release 1.1.0.x
+ * JIGSAW release 1.1.1.x
*
- * Last updated: 20 Oct., 2024
+ * Last updated: 09 Nov., 2026
*
- * Copyright 2013 -- 2024
+ * Copyright 2013 -- 2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
@@ -193,7 +193,7 @@
--------------------------------------------------------
*/
-# define __JGSWVSTR "JIGSAW VERSION 1.1.0"
+# define __JGSWVSTR "JIGSAW VERSION 1.1.1"
# if defined( USE_NETCDF)
# define __use_netcdf
@@ -430,15 +430,11 @@
(real_type) +0.00E+00 ;
/*------------------------------- "low-level" config. */
- typedef mesh::mesh_params <
- real_type ,
- iptr_type > mesh_opts ;
+ typedef mesh::mesh_params mesh_opts ;
mesh_opts _mesh_opts ;
- typedef mesh::iter_params <
- real_type ,
- iptr_type > iter_opts ;
+ typedef mesh::iter_params iter_opts ;
iter_opts _iter_opts ;
@@ -930,4 +926,3 @@
# include "marche.hpp"
-
diff --git a/external/jigsaw/src/libcpp/aabb_tree/aabb_tree_k.hpp b/external/jigsaw/src/libcpp/aabb_tree/aabb_tree_k.hpp
index 1e4a352..3b83731 100644
--- a/external/jigsaw/src/libcpp/aabb_tree/aabb_tree_k.hpp
+++ b/external/jigsaw/src/libcpp/aabb_tree/aabb_tree_k.hpp
@@ -35,9 +35,9 @@
*
------------------------------------------------------------
*
- * Last updated: 20 Apr., 2023
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2023
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -985,18 +985,18 @@
{
real_type _dloc =
_bmin[_idim] - _ppos[_idim];
- _dist += _dloc ;
+ _dist += _dloc * _dloc ;
}
else
if (_ppos[_idim] > _bmax[_idim])
{
real_type _dloc =
_ppos[_idim] - _bmax[_idim];
- _dist += _dloc ;
+ _dist += _dloc * _dloc ;
}
}
- return ( _dist * _dist ) ;
+ return ( _dist ) ;
}
/*-------- search collection via recursive aabb traversal */
@@ -1158,6 +1158,10 @@
_nnpq.push(_ndat) ;
}
+ else
+ {
+ break ; // heap ensures none less
+ }
}
}
diff --git a/external/jigsaw/src/libcpp/algorithms/sort.hpp b/external/jigsaw/src/libcpp/algorithms/sort.hpp
index 5663c97..ebb8aac 100644
--- a/external/jigsaw/src/libcpp/algorithms/sort.hpp
+++ b/external/jigsaw/src/libcpp/algorithms/sort.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 24 Jul., 2019
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2019
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -70,6 +70,8 @@
pred_type _less // comparison predicate
)
{
+ if (_head == _tail) return ( true ) ;
+
for ( ; _head+1 != _tail; ++_head )
{ /* check pair ordering */
if (_less(*(_head+1), *_head))
@@ -249,7 +251,7 @@
>
__normal_call void_type ssort (
iter_type _head, // head of sequence to sort
- iter_type _tend, // head of sequence to sort
+ iter_type _tend, // last of sequence to sort
pred_type _less // comparison predicate
)
{
@@ -354,14 +356,15 @@
pred_type const&_less
)
{
- //typename containers::
- // iterator_traits::
- //diff_type static constexpr _LONG = 256;
+ typename containers::
+ iterator_traits::
+ diff_type static constexpr _LONG = 512;
+ bool_type static constexpr _FIVE = false;
iter_type _imid =
_head + (_tail - _head) / 2 ;
- if (false) //(_tail - _head >= _LONG)
+ if (_FIVE && _tail - _head + 1 >= _LONG)
{
/*-------------- median-of-5 choice for pivot element */
typename containers::
@@ -374,9 +377,14 @@
iter_type _pos3 =
_head + _step * 3 ;
- sort_3(_head, _pos1, _imid, _less);
- sort_3(_imid, _pos3, _tail, _less);
- sort_3(_pos1, _imid, _pos3, _less);
+ sort_2(_head, _pos1, _less);
+ sort_2(_pos3, _tail, _less);
+ sort_2(_imid, _tail, _less);
+ sort_2(_imid, _pos3, _less);
+ sort_2(_pos1, _tail, _less);
+ sort_2(_head, _pos3, _less);
+ sort_2(_pos1, _pos3, _less);
+ sort_2(_pos1, _imid, _less);
}
else
{
@@ -392,7 +400,7 @@
typename pred_type
>
__normal_call void_type qsort ( // unrolled quick sort
- iter_type _head,
+ iter_type _head, // head of sequence to sort
iter_type _tend, // last of sequence to sort
pred_type _less // comparison predicate
)
@@ -400,6 +408,8 @@
typedef containers::
iterator_traits iter_base ;
+ if (_head == _tend) return;
+
/*------- tiny-list threshold, push to insertion sort */
typename iter_base::
diff_type static constexpr _LONG = 16;
@@ -503,35 +513,25 @@
typename pred_type
>
__normal_call void_type qsift ( // quick select
- iter_type _head,
+ iter_type _head, // head of sequence to parition
iter_type _kk, // pos. in sequence to find
iter_type _tend, // last of sequence to parition
pred_type _less // comparison predicate
)
{
+ if (_head == _tend) return;
+
iter_type _hh, _tt, _mm;
_hh = _head + 0;
_tt = _tend - 1;
do {
- /* deal with "spec.-case" tiny partition */
- if (_tt - _hh + 1 <= 1)
- break ;
-
- if (_tt - _hh + 1 == 2)
- {
- if (_less(*_tt, *_hh))
- std::swap(*_hh, *_tt);
- break ;
- }
-
- /*
+ /* use explicit small sorts for tiny partitions */
if (_tt - _hh + 1 <= 4)
{
- isort ( _hh, _tt, _less);
+ isort ( _hh, _tt + 1, _less);
break ;
}
- */
/* find pivot item for current partition */
_mm = pivot(_hh, _tt, _less);
@@ -539,7 +539,7 @@
/* reduce partition around pivot element */
iter_type _ll = _hh + 1;
iter_type _rr = _tt - 1;
- for ( ; _ll < _rr; )
+ for ( ; _ll <= _rr; )
{
for(;_less(*_ll, *_mm);) ++_ll;
for(;_less(*_mm, *_rr);) --_rr;
@@ -561,11 +561,9 @@
}
}
- //if (_mm == _kk) break ;
-
- if (_kk < _rr) _tt = _rr;
+ if (_kk <= _rr) _tt = _rr;
else
- if (_kk > _ll) _hh = _ll;
+ if (_kk >= _ll) _hh = _ll;
else
{
_hh = _rr+1; _tt = _ll-1;
diff --git a/external/jigsaw/src/libcpp/allocators/alloc_item.hpp b/external/jigsaw/src/libcpp/allocators/alloc_item.hpp
index 6371849..250c5fc 100644
--- a/external/jigsaw/src/libcpp/allocators/alloc_item.hpp
+++ b/external/jigsaw/src/libcpp/allocators/alloc_item.hpp
@@ -42,9 +42,9 @@
*
--------------------------------------------------------
*
- * Last updated: 06 Sept., 2018
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2018
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -252,9 +252,10 @@
__static_call
__inline_call void_type construct (
data_type * _xptr,
- data_part const&... _part
+ data_part &&... _part
)
- { new(_xptr)data_type(_part...) ;
+ { new(_xptr)data_type(
+ std::forward(_part)...) ;
}
} ;
@@ -399,9 +400,10 @@
__static_call
__inline_call void_type construct (
data_type * _xptr,
- data_part const&... _part
+ data_part &&... _part
)
- { new(_xptr)data_type(_part...) ;
+ { new(_xptr)data_type(
+ std::forward(_part)...) ;
}
} ;
diff --git a/external/jigsaw/src/libcpp/allocators/alloc_pool.hpp b/external/jigsaw/src/libcpp/allocators/alloc_pool.hpp
index 0f03078..f8a48dd 100644
--- a/external/jigsaw/src/libcpp/allocators/alloc_pool.hpp
+++ b/external/jigsaw/src/libcpp/allocators/alloc_pool.hpp
@@ -45,9 +45,9 @@
*
--------------------------------------------------------
*
- * Last updated: 02 May, 2017
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2017
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -181,6 +181,11 @@
/*--------------- construct to force alloc on request */
this->_item_size =
std::max(_size, (size_type)sizeof(char*)) ;
+
+ size_type const _algn = alignof(char*) ;
+ this->_item_size =
+ (this->_item_size + _algn - 1) / _algn * _algn ;
+
this->_slab_size =
(size_type)pool_size / this->_item_size;
this->_slab_size =
@@ -194,6 +199,22 @@
clear() ;
}
+ __inline_call _pool_alloc (
+ self_type const&_src
+ ) = delete ;
+ __inline_call _pool_alloc (
+ self_type && _src
+ ) = delete ;
+
+ __inline_call
+ self_type & operator= (
+ self_type const&_src
+ ) = delete ;
+ __inline_call
+ self_type & operator= (
+ self_type && _src
+ ) = delete ;
+
/*
--------------------------------------------------------
* CLEAR: de-alloc. and free the allocator.
@@ -321,7 +342,14 @@
if (_addr == nullptr)
return self_type::allocate(_new_count);
- /*------------------ deal with genuine reallocations */
+ /*------------------ deal with genuine de-allocations */
+ if (_new_count == +0)
+ {
+ self_type::deallocate(_addr, _old_count);
+ return nullptr;
+ }
+
+ /*------------------ deal with genuine re-allocations */
char_type *_nptr;
if (_old_count <= this->_item_size)
{
diff --git a/external/jigsaw/src/libcpp/containers/array_iter.hpp b/external/jigsaw/src/libcpp/containers/array_iter.hpp
index 67f1185..2c7f061 100644
--- a/external/jigsaw/src/libcpp/containers/array_iter.hpp
+++ b/external/jigsaw/src/libcpp/containers/array_iter.hpp
@@ -9,7 +9,7 @@
* to consist of a single block, as returned by malloc,
* etc. Provides O(1) random access, amortarised
* O(log(n)) incremental insertion, etc. This is a
- * striped-down implementation -- offering only
+ * stripped-down implementation -- offering only
* "efficient" operations (no insert, delete, etc).
*
------------------------------------------------------------
@@ -45,9 +45,9 @@
*
------------------------------------------------------------
*
- * Last updated: 03 May, 2017
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2017
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -174,16 +174,16 @@
__inline_call iter_type operator + (
size_type _off
- )
+ ) const
{ /*-------------------- add offset */
- iter_type _tmp(*(iter_type*)this);
+ iter_type _tmp(*(iter_type const*)this);
return _tmp += _off;
}
__inline_call iter_type operator - (
size_type _off
- )
+ ) const
{ /*-------------------- sub offset */
- iter_type _tmp(*(iter_type*)this);
+ iter_type _tmp(*(iter_type const*)this);
return _tmp -= _off;
}
@@ -271,9 +271,10 @@
public :
__inline_call const_array_iterator (
- data_type *_psrc = nullptr,
+ data_type const*_psrc = nullptr,
container *_osrc = nullptr
- ) : base_type(_psrc, _osrc) {}
+ ) : base_type(
+ const_cast(_psrc), _osrc) {}
__inline_call~const_array_iterator()= default ;
diff --git a/external/jigsaw/src/libcpp/containers/arraylist.hpp b/external/jigsaw/src/libcpp/containers/arraylist.hpp
index 84e7cfb..20dc3be 100644
--- a/external/jigsaw/src/libcpp/containers/arraylist.hpp
+++ b/external/jigsaw/src/libcpp/containers/arraylist.hpp
@@ -41,9 +41,9 @@
*
------------------------------------------------------------
*
- * Last updated: 11 Apr., 2018
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2018
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -359,6 +359,7 @@
item_type*_item =*_iter ;
item_type*_next ;
+ *_iter = nullptr ;
/*----------------------------- free current list */
for(;_item != nullptr;
_item = _next)
diff --git a/external/jigsaw/src/libcpp/containers/basic_stack.hpp b/external/jigsaw/src/libcpp/containers/basic_stack.hpp
index 4d60e89..4ea670f 100644
--- a/external/jigsaw/src/libcpp/containers/basic_stack.hpp
+++ b/external/jigsaw/src/libcpp/containers/basic_stack.hpp
@@ -43,9 +43,9 @@
*
------------------------------------------------------------
*
- * Last updated: 21 Dec., 2018
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2018
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -114,8 +114,10 @@
__cont::base_iterator_kind
)
{ /* push the sequence onto list */
+ _write_it _prev = tend() ;
for ( ; _head != _tend; ++_head)
- push_tail(*_head) ;
+ _prev = insert_next(
+ _prev, *_head) ;
}
__inline_call void_type copy_list (
@@ -397,6 +399,7 @@
}
else
{ /* insert in middle of list */
+ _next_item = _prev_item->next();
item_type *_this_item =
self_type::allocate(1);
self_type::construct(
@@ -424,6 +427,7 @@
}
else
{ /* insert in middle of list */
+ _next_item = _prev_item->next();
item_type *_this_item =
self_type::allocate(1);
self_type::construct(_this_item,
@@ -452,6 +456,7 @@
}
else
{ /* insert in middle of list */
+ _next_item = _prev_item->next();
item_type *_this_item =
self_type::allocate(1);
self_type::construct(_this_item,
@@ -478,7 +483,6 @@
item_type
*_this_item = _this_iter. item() ,
*_prev_item = _prev_iter. item() ,
- *_prev_next = _prev_item->next() ,
*_next_item = _this_item->next() ;
if (_prev_item == nullptr)
@@ -491,7 +495,7 @@
else
{/* re-link item neighbours in list mid */
__assert (
- _prev_next == _this_item &&
+ _prev_item->next() == _this_item &&
"list.erase: _bad iterator!" ) ;
_prev_item->next()
= _next_item ;
diff --git a/external/jigsaw/src/libcpp/containers/block_array.hpp b/external/jigsaw/src/libcpp/containers/block_array.hpp
index 7bff094..cc48e83 100644
--- a/external/jigsaw/src/libcpp/containers/block_array.hpp
+++ b/external/jigsaw/src/libcpp/containers/block_array.hpp
@@ -47,9 +47,9 @@
*
------------------------------------------------------------
*
- * Last updated: 27 Apr., 2020
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2020
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -610,7 +610,7 @@
__inline_call allocator get_alloc ( // return alloc obj.
) const
- { return static_cast( *this ) ;
+ { return this->_block.get_alloc() ;
}
__inline_call size_type count (// return container count
@@ -751,11 +751,20 @@
size_type result = count();
size_type offset = count()>>_pwr2;
- if (result == alloc())
- inc_alloc(result + 1);
+ if (result != alloc())
+ {
+ this-> _block[offset].
+ push_tail(__copy(data_type,_data)) ;
+ }
+ else
+ {
+ data_type _temp(
+ __copy(data_type,_data)) ;
- this-> _block[offset].
- push_tail(__copy(data_type,_data)) ;
+ inc_alloc(result + 1);
+ this-> _block[offset].
+ push_tail(__move(data_type,_temp)) ;
+ }
this-> _count += + 1 ;
return result ;
@@ -768,11 +777,20 @@
size_type result = count();
size_type offset = count()>>_pwr2;
- if (result == alloc())
- inc_alloc(result + 1);
+ if (result != alloc())
+ {
+ this-> _block[offset].
+ push_tail(__move(data_type,_data)) ;
+ }
+ else
+ {
+ data_type _temp(
+ __move(data_type,_data)) ;
- this-> _block[offset].
- push_tail(__move(data_type,_data)) ;
+ inc_alloc(result + 1);
+ this-> _block[offset].
+ push_tail(__move(data_type,_temp)) ;
+ }
this-> _count += + 1 ;
return result ;
diff --git a/external/jigsaw/src/libcpp/containers/block_iter.hpp b/external/jigsaw/src/libcpp/containers/block_iter.hpp
index 4c4eacf..480061f 100644
--- a/external/jigsaw/src/libcpp/containers/block_iter.hpp
+++ b/external/jigsaw/src/libcpp/containers/block_iter.hpp
@@ -47,9 +47,9 @@
*
------------------------------------------------------------
*
- * Last updated: 03 Jul., 2019
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2019
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -185,16 +185,16 @@
__inline_call iter_type operator + (
size_type _val
- )
+ ) const
{ /*-------------------- add offset */
- iter_type _tmp(*(iter_type*)this);
+ iter_type _tmp(*(iter_type const*)this);
return _tmp += _val;
}
__inline_call iter_type operator - (
size_type _val
- )
+ ) const
{ /*-------------------- sub offset */
- iter_type _tmp(*(iter_type*)this);
+ iter_type _tmp(*(iter_type const*)this);
return _tmp -= _val;
}
diff --git a/external/jigsaw/src/libcpp/containers/double_list.hpp b/external/jigsaw/src/libcpp/containers/double_list.hpp
index 676537c..a741524 100644
--- a/external/jigsaw/src/libcpp/containers/double_list.hpp
+++ b/external/jigsaw/src/libcpp/containers/double_list.hpp
@@ -43,9 +43,9 @@
*
------------------------------------------------------------
*
- * Last updated: 03 May, 2017
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2017
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -754,7 +754,7 @@
_data = __move (
data_type, this->_tptr->_data);
/*-- delegate to _pop impl.*/
- self_type::_pop_head () ;
+ self_type::_pop_tail () ;
}
/*-------------------------- insert data (_def construct) */
diff --git a/external/jigsaw/src/libcpp/containers/fixed_array.hpp b/external/jigsaw/src/libcpp/containers/fixed_array.hpp
index 2db557d..991f0a5 100644
--- a/external/jigsaw/src/libcpp/containers/fixed_array.hpp
+++ b/external/jigsaw/src/libcpp/containers/fixed_array.hpp
@@ -41,9 +41,9 @@
*
------------------------------------------------------------
*
- * Last updated: 03 May, 2017
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2017
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -238,9 +238,9 @@
__inline_call _write_it hend (
)
{ /* return iterator at head - 1 */
- size_type _off = 1;
+ size_type _off = 1;
self_type *_obj = (self_type *)this ;
- return _write_it(this->_data + _off, _obj);
+ return _write_it(this->_data - _off, _obj);
}
__inline_call _write_it tend (
diff --git a/external/jigsaw/src/libcpp/containers/hashtable.hpp b/external/jigsaw/src/libcpp/containers/hashtable.hpp
index 0efa690..b530aa8 100644
--- a/external/jigsaw/src/libcpp/containers/hashtable.hpp
+++ b/external/jigsaw/src/libcpp/containers/hashtable.hpp
@@ -41,9 +41,9 @@
*
------------------------------------------------------------
*
- * Last updated: 28 Apr., 2020
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2020
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -156,11 +156,30 @@
)
{
/*------------------------------- round to next 2^pwr */
- _slots = next_pwr2 (_slots * 1) ;
+ _slots = std::max(next_pwr2(_slots*1),
+ this->_mini_count );
+
+ /*------------------------------- don't delete if dec */
+ for (auto _ipos = _slots;
+ _ipos < this->_lptr.count();
+ ++_ipos )
+ {
+ item_type *_root, *_head, *_next ;
+ _root = this->_lptr[ +0 ];
+ _head = this->_lptr[_ipos];
+ this->_lptr[_ipos] = nullptr;
+ while(_head != nullptr)
+ {
+ _next = _head->_next ;
+ base_type::
+ push_item( _root , _head ) ;
+ _head = _next ;
+ }
+ this->_lptr[ 0 ] = _root ;
+ }
/*------------------------------- inc/dec. table size */
- this->_lptr.set_count(std::max(
- _slots, this->_mini_count), _alloc, nullptr) ;
+ this->_lptr.set_count(_slots, _alloc, nullptr) ;
/*------------------------------- re-hash all objects */
redo_hash() ;
diff --git a/external/jigsaw/src/libcpp/containers/hashtwice.hpp b/external/jigsaw/src/libcpp/containers/hashtwice.hpp
index 56d6d8c..914798d 100644
--- a/external/jigsaw/src/libcpp/containers/hashtwice.hpp
+++ b/external/jigsaw/src/libcpp/containers/hashtwice.hpp
@@ -165,17 +165,30 @@
)
{
/*------------------------------- round to next 2^pwr */
- _slots = next_pwr2 (_slots);
+ _slots = std::max(next_pwr2(_slots*1),
+ this->_mini_count );
+
+ /*------------------------------- don't delete if dec */
+ for (auto _ipos = _slots;
+ _ipos < this->_lptr.count();
+ ++_ipos )
+ {
+ item_type *_root, *_head, *_next ;
+ _root = this->_lptr[ +0 ];
+ _head = this->_lptr[_ipos];
+ this->_lptr[_ipos] = nullptr;
+ while(_head != nullptr)
+ {
+ _next = _head->_next ;
+ base_type::
+ push_item( _root , _head ) ;
+ _head = _next ;
+ }
+ this->_lptr[ 0 ] = _root ;
+ }
/*------------------------------- inc/dec. table size */
- if (_slots <
- this->_mini_count )
- this->_lptr.set_count (
- this->_mini_count ,
- _alloc , nullptr) ;
- else
- this->_lptr.set_count (
- _slots, _alloc , nullptr) ;
+ this->_lptr.set_count(_slots, _alloc, nullptr) ;
/*------------------------------- re-hash all objects */
redo_hash() ;
@@ -185,8 +198,7 @@
)
{
/*------------------------------- increase table size */
- if (this->_lptr.count() <
- this->_mini_count )
+ if (this->_lptr.count() < this->_mini_count)
this->_lptr.set_count (
this->_mini_count ,
containers::tight_alloc, nullptr) ;
@@ -416,6 +428,10 @@
}
}
+ /*------------------------------- don't scan it twice */
+ if (_hash[0] == _hash[1])
+ return false ;
+
/*------------------------------- scan list from head */
_same = this->_lptr[_hash[1]];
/*------------------------------- check exact matches */
@@ -462,6 +478,10 @@
}
}
+ /*------------------------------- don't scan it twice */
+ if (_hash[0] == _hash[1])
+ return false ;
+
/*------------------------------- scan list from head */
_spos = this->_lptr[_hash[1]];
/*------------------------------- check exact matches */
@@ -512,6 +532,10 @@
}
}
+ /*------------------------------- don't scan it twice */
+ if (_hash[0] == _hash[1])
+ return ( !_list.empty() );
+
/*------------------------------- scan list from head */
_same = this->_lptr[_hash[1]] ;
/*------------------------------- check exact matches */
diff --git a/external/jigsaw/src/libcpp/containers/priorityidx.hpp b/external/jigsaw/src/libcpp/containers/priorityidx.hpp
index 1948807..5a26ace 100644
--- a/external/jigsaw/src/libcpp/containers/priorityidx.hpp
+++ b/external/jigsaw/src/libcpp/containers/priorityidx.hpp
@@ -43,9 +43,9 @@
*
------------------------------------------------------------
*
- * Last updated: 15 Jun., 2022
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -380,10 +380,14 @@
}
/*-------------------------------------------- _set alloc */
- __inline_call size_type set_alloc (
+ __inline_call void_type set_alloc (
size_type _asiz
)
- { this->_heap.set_alloc( _asiz) ;
+ {
+ while (this->_heap.count() > _asiz)
+ _pop(this->_heap.tail()->_kidx);
+
+ this->_heap.set_alloc( _asiz) ;
}
/*------------------------------------- (const) iterators */
@@ -493,7 +497,8 @@
{
/*---------------------------- _pop root, cache temp. */
data_type _temp ;
- _pop( +0, _temp);
+ iptr_type _kpos ;
+ _pop_root (_kpos , _temp) ;
}
__inline_call void_type _pop_root (
iptr_type &_kpos ,
@@ -608,8 +613,8 @@
/*------------------------ copy position into mapping */
this->_keys[_kpos] =
- (iptr_type)
- _ipos - this->_heap.head() ;
+ (iptr_type)(
+ _ipos - this->_heap.head()) ;
}
__inline_call void_type update ( // move
diff --git a/external/jigsaw/src/libcpp/containers/prioritymap.hpp b/external/jigsaw/src/libcpp/containers/prioritymap.hpp
index 1ce5e74..4b57064 100644
--- a/external/jigsaw/src/libcpp/containers/prioritymap.hpp
+++ b/external/jigsaw/src/libcpp/containers/prioritymap.hpp
@@ -43,9 +43,9 @@
*
------------------------------------------------------------
*
- * Last updated: 30 Mar., 2022
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -371,10 +371,14 @@
}
/*-------------------------------------------- _set alloc */
- __inline_call size_type set_alloc (
+ __inline_call void_type set_alloc (
size_type _asiz
)
- { this->_heap.set_alloc( _asiz) ;
+ {
+ while (this->_heap.count() > _asiz)
+ _pop(this->_heap.tail()->_kptr) ;
+
+ this->_heap.set_alloc( _asiz) ;
}
/*------------------------------------- (const) iterators */
@@ -474,7 +478,7 @@
{
/*---------------------------- _pop root, cache temp. */
data_type _temp ;
- _pop( +0, _temp);
+ _pop_root (_temp);
}
__inline_call void_type _pop_root (
data_type &_data
diff --git a/external/jigsaw/src/libcpp/containers/priorityset.hpp b/external/jigsaw/src/libcpp/containers/priorityset.hpp
index af5911a..7b0f699 100644
--- a/external/jigsaw/src/libcpp/containers/priorityset.hpp
+++ b/external/jigsaw/src/libcpp/containers/priorityset.hpp
@@ -43,9 +43,9 @@
*
------------------------------------------------------------
*
- * Last updated: 03 May, 2017
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2017
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -405,7 +405,8 @@
_data = std::move (
*(this->_heap.head() + _hpos));
/*--------- push "hole" at HPOS into updated position */
- if (this->_heap.count() > 1)
+ if (this->_heap.head() + _hpos !=
+ this->_heap.tail() )
{
/*---------- find new position for "hole" at HPOS */
_write_it _ipos = push_lower (
diff --git a/external/jigsaw/src/libcpp/containers/single_list.hpp b/external/jigsaw/src/libcpp/containers/single_list.hpp
index 3fc278e..2898469 100644
--- a/external/jigsaw/src/libcpp/containers/single_list.hpp
+++ b/external/jigsaw/src/libcpp/containers/single_list.hpp
@@ -769,7 +769,6 @@
item_type
*_this_item = _this_iter. item() ,
*_prev_item = _prev_iter. item() ,
- *_prev_next = _prev_item->next() ,
*_next_item = _this_item->next() ;
if (_prev_item == nullptr)
@@ -784,7 +783,7 @@
else
{/* re-link item neighbours in list mid */
__assert (
- _prev_next == _this_item &&
+ _prev_item->next() == _this_item &&
"list.erase: _bad iterator!" ) ;
_prev_item->next()
= _next_item ;
diff --git a/external/jigsaw/src/libcpp/expansion/ia_float.hpp b/external/jigsaw/src/libcpp/expansion/ia_float.hpp
index 1d2cc80..dca47eb 100644
--- a/external/jigsaw/src/libcpp/expansion/ia_float.hpp
+++ b/external/jigsaw/src/libcpp/expansion/ia_float.hpp
@@ -35,7 +35,7 @@
*
--------------------------------------------------------
*
- * Last updated: 10 Apr., 2020
+ * Last updated: 07 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -275,7 +275,7 @@
__inline_call ia_flt operator - (
) const
- { return ia_flt(-lo(), -up());
+ { return ia_flt(-up(), -lo());
}
__inline_call ia_flt& operator+= ( // via double
@@ -350,20 +350,29 @@
__inline_call real_type mid (
) const
{
- real_type _mm = lo() + up() ;
+ real_type constexpr _hh =
+ ((real_type)+0.5) *
+ std::numeric_limits::max() ;
+ real_type constexpr _ll =
+ ((real_type)+0.5) *
+ std::numeric_limits::min() ;
- if (!std::isfinite(_mm))
- {
- _mm =
- (lo() / (real_type)+2.)+
- (up() / (real_type)+2.);
- }
- else
- {
- _mm /= (real_type)+2. ;
- }
+ real_type _al = std::abs(lo());
+ real_type _au = std::abs(up());
+
+ real_type two = (real_type)2.0;
+
+ if (_al <= _hh && _au <= _hh)
+ return (lo() + up()) / two;
+
+ if (_al < _ll)
+ return lo() + (up() / two) ;
- return _mm ;
+ if (_au < _ll)
+ return up() + (lo() / two) ;
+
+ return ( lo() / two +
+ up() / two ) ;
}
__inline_call real_type rad (
@@ -530,7 +539,7 @@
REAL_TYPE _u1, _u2;
_u1 = mul_up(_aa.lo(), _bb.lo());
_u2 = mul_up(_aa.up(), _bb.up());
- _up = std::min(_u1, _u2);
+ _up = std::max(_u1, _u2);
}
else // mix * -ve
{
diff --git a/external/jigsaw/src/libcpp/expansion/mp_basic.hpp b/external/jigsaw/src/libcpp/expansion/mp_basic.hpp
index 66262e5..443d000 100644
--- a/external/jigsaw/src/libcpp/expansion/mp_basic.hpp
+++ b/external/jigsaw/src/libcpp/expansion/mp_basic.hpp
@@ -63,7 +63,7 @@
*
--------------------------------------------------------
*
- * Last updated: 16 Apr., 2020
+ * Last updated: 07 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -90,7 +90,7 @@
std::is_same::value;
# elif defined(FP_FAST_FMAF)
bool constexpr _has_fma =
- std::is_same::value;
+ std::is_same::value;
# else
bool constexpr _has_fma = false;
# endif
@@ -566,7 +566,7 @@
_ss = _a0 * _b0 ;
_ss = fma(_a1, _b0, _ss);
- _ss = fma(_a0, _b0, _ss);
+ _ss = fma(_a0, _b1, _ss);
_t0 = _t0 + _ss ;
diff --git a/external/jigsaw/src/libcpp/expansion/mp_float.hpp b/external/jigsaw/src/libcpp/expansion/mp_float.hpp
index a38b452..b1afd1a 100644
--- a/external/jigsaw/src/libcpp/expansion/mp_float.hpp
+++ b/external/jigsaw/src/libcpp/expansion/mp_float.hpp
@@ -59,7 +59,7 @@
*
--------------------------------------------------------
*
- * Last updated: 05 Jun., 2022
+ * Last updated: 07 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -117,7 +117,12 @@
__inline_call void push (
real_type _xx
)
- { this->_xdat[this->_xlen++] = _xx ;
+ {
+ assert ( this->_xlen >= 0 &&
+ this->_xlen < this->_size &&
+ "expansion: insufficient alloc.") ;
+
+ this->_xdat[this->_xlen++] = _xx ;
}
/*------------------------------ query the expansion size */
@@ -139,7 +144,8 @@
indx_type _ii
)
{
- assert ( _ii < this->_size &&
+ assert ( _ii >= 0 &&
+ _ii < this->_size &&
"expansion: index out of bounds") ;
return ( this->_xdat[_ii] ) ;
@@ -149,7 +155,8 @@
indx_type _ii
) const
{
- assert ( _ii<= this->_size &&
+ assert ( _ii >= 0 &&
+ _ii < this->_size &&
"expansion: index out of bounds") ;
return ( this->_xdat[_ii] ) ;
@@ -312,12 +319,12 @@
if((_fx > _ex) == (_fx > -_ex))
{
_qq = _ex;
- _ex = _ee[++_ei];
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
_qq = _fx;
- _fx = _ff[++_fi];
+ if (++_fi < _ff._xlen) _fx = _ff[_fi];
}
if((_ei < _ee._xlen) && (_fi < _ff._xlen))
@@ -327,14 +334,14 @@
one_one_add_fast(
_ex, _qq, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei];
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
one_one_add_fast(
_fx, _qq, _qn, _hx);
_qq = _qn;
- _fx = _ff[++_fi];
+ if (++_fi < _ff._xlen) _fx = _ff[_fi];
}
if (_hx != +0.0) _hh.push (_hx) ;
@@ -346,14 +353,14 @@
one_one_add_full(
_qq, _ex, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei] ;
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
one_one_add_full(
_qq, _fx, _qn, _hx);
_qq = _qn;
- _fx = _ff[++_fi] ;
+ if (++_fi < _ff._xlen) _fx = _ff[_fi];
}
if (_hx != +0.0) _hh.push (_hx) ;
}
@@ -363,7 +370,8 @@
{
one_one_add_full(_qq, _ex, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei];
+ _ei+= 1;
+ if (_ei < _ee._xlen) _ex = _ee[_ei];
if (_hx != +0.0) _hh.push (_hx) ;
}
@@ -371,7 +379,8 @@
{
one_one_add_full(_qq, _fx, _qn, _hx);
_qq = _qn;
- _fx = _ff[++_fi];
+ _fi+= 1;
+ if (_fi < _ff._xlen) _fx = _ff[_fi];
if (_hx != +0.0) _hh.push (_hx) ;
}
@@ -488,12 +497,12 @@
if((_fx > _ex) == (_fx > -_ex))
{
_qq = _ex;
- _ex = _ee[++_ei];
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
_qq = _fx;
- _fx =-_ff[++_fi];
+ if (++_fi < _ff._xlen) _fx =-_ff[_fi];
}
if((_ei < _ee._xlen) && (_fi < _ff._xlen))
@@ -503,14 +512,14 @@
one_one_add_fast(
_ex, _qq, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei];
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
one_one_add_fast(
_fx, _qq, _qn, _hx);
_qq = _qn;
- _fx =-_ff[++_fi];
+ if (++_fi < _ff._xlen) _fx =-_ff[_fi];
}
if (_hx != +0.0) _hh.push (_hx) ;
@@ -522,14 +531,14 @@
one_one_add_full(
_qq, _ex, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei] ;
+ if (++_ei < _ee._xlen) _ex = _ee[_ei];
}
else
{
one_one_add_full(
_qq, _fx, _qn, _hx);
_qq = _qn;
- _fx =-_ff[++_fi] ;
+ if (++_fi < _ff._xlen) _fx =-_ff[_fi];
}
if (_hx != +0.0) _hh.push (_hx) ;
}
@@ -539,7 +548,8 @@
{
one_one_add_full(_qq, _ex, _qn, _hx);
_qq = _qn;
- _ex = _ee[++_ei];
+ _ei+= 1;
+ if (_ei < _ee._xlen) _ex = _ee[_ei];
if (_hx != +0.0) _hh.push (_hx) ;
}
@@ -547,7 +557,8 @@
{
one_one_add_full(_qq, _fx, _qn, _hx);
_qq = _qn;
- _fx =-_ff[++_fi];
+ _fi+= 1;
+ if (_fi < _ff._xlen) _fx =-_ff[_fi];
if (_hx != +0.0) _hh.push (_hx) ;
}
diff --git a/external/jigsaw/src/libcpp/geom_base/cell_base_k.hpp b/external/jigsaw/src/libcpp/geom_base/cell_base_k.hpp
index 0c77b7d..8654582 100644
--- a/external/jigsaw/src/libcpp/geom_base/cell_base_k.hpp
+++ b/external/jigsaw/src/libcpp/geom_base/cell_base_k.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 24 Jul., 2025
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -124,14 +124,14 @@
) // see VERDICT ref. manual
{
_x1[0] = (_p2[0] - _p1[0])
- + (_p4[0] - _p3[0]);
+ + (_p3[0] - _p4[0]) ;
_x1[1] = (_p2[1] - _p1[1])
- + (_p4[1] - _p3[1]);
+ + (_p3[1] - _p4[1]) ;
_x2[0] = (_p3[0] - _p2[0])
- + (_p4[0] - _p1[0]);
+ + (_p4[0] - _p1[0]) ;
_x2[1] = (_p3[1] - _p2[1])
- + (_p4[1] - _p1[1]);
+ + (_p4[1] - _p1[1]) ;
}
template <
@@ -147,18 +147,18 @@
) // see VERDICT ref. manual
{
_x1[0] = (_p2[0] - _p1[0])
- + (_p4[0] - _p3[0]);
+ + (_p3[0] - _p4[0]) ;
_x1[1] = (_p2[1] - _p1[1])
- + (_p4[1] - _p3[1]);
+ + (_p3[1] - _p4[1]) ;
_x1[2] = (_p2[2] - _p1[2])
- + (_p4[2] - _p3[2]);
+ + (_p3[2] - _p4[2]) ;
_x2[0] = (_p3[0] - _p2[0])
- + (_p4[0] - _p1[0]);
+ + (_p4[0] - _p1[0]) ;
_x2[1] = (_p3[1] - _p2[1])
- + (_p4[1] - _p1[1]);
+ + (_p4[1] - _p1[1]) ;
_x2[2] = (_p3[2] - _p2[2])
- + (_p4[2] - _p1[2]);
+ + (_p4[2] - _p1[2]) ;
}
template <
@@ -606,6 +606,9 @@
std::pow(_dd22, 2) +
std::pow(_dd33, 2) ) ;
+ _skew = std::min(
+ _skew, (real_type) +1.) ;
+
return std::pow(
(real_type) +1. - _skew, +4./3.) ;
}
@@ -657,6 +660,9 @@
std::pow(_dd22, 2) +
std::pow(_dd33, 2) ) ;
+ _skew = std::min(
+ _skew, (real_type) +1.) ;
+
return std::pow(
(real_type) +1. - _skew, +4./3.) ;
}
diff --git a/external/jigsaw/src/libcpp/geom_base/intersect_k.hpp b/external/jigsaw/src/libcpp/geom_base/intersect_k.hpp
index 071fe03..1272a34 100644
--- a/external/jigsaw/src/libcpp/geom_base/intersect_k.hpp
+++ b/external/jigsaw/src/libcpp/geom_base/intersect_k.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 10 Feb., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -61,6 +61,36 @@
hits_type face_hits = +3 ;
hits_type tria_hits = +4 ;
+ /*
+ --------------------------------------------------------
+ * pairwise sign helpers.
+ * Review refactor: reuse these strict comparisons below.
+ * Both helpers return false when either operand is zero.
+ --------------------------------------------------------
+ */
+
+ template <
+ typename data_type
+ >
+ __inline_call bool is_same_sign (
+ data_type _s1,
+ data_type _s2
+ )
+ { return ( _s1 > 0.0 && _s2 > 0.0 ) ||
+ ( _s1 < 0.0 && _s2 < 0.0 ) ;
+ }
+
+ template <
+ typename data_type
+ >
+ __inline_call bool is_diff_sign (
+ data_type _s1,
+ data_type _s2
+ )
+ { return ( _s1 > 0.0 && _s2 < 0.0 ) ||
+ ( _s1 < 0.0 && _s2 > 0.0 ) ;
+ }
+
/*
--------------------------------------------------------
* COPY-NODE-KD: node-node copy helpers.
@@ -517,23 +547,34 @@
__write_ptr (real_type) _qb
)
{
- size_t _ni = +0;
-
- if (line_flat_3d (
- _pp, _nv,
- _pa, _pb,
- (_ni == +0) ? _qa : _qb))
- _ni += +1 ;
- if (line_flat_3d (
- _pp, _nv,
- _pb, _pc,
- (_ni == +0) ? _qa : _qb))
- _ni += +1 ;
- if (line_flat_3d (
- _pp, _nv,
- _pc, _pa,
- (_ni == +0) ? _qa : _qb))
- _ni += +1 ;
+ size_t _ni = 0;
+ real_type _qt[3];
+ auto assessor = [&]()
+ {
+ if (_ni == 0)
+ {
+ copy_node_3d(_qa, _qt);
+ _ni = 1;
+ }
+ else
+ if (_qt[0] != _qa[0] ||
+ _qt[1] != _qa[1] ||
+ _qt[2] != _qa[2] )
+ {
+ copy_node_3d(_qb, _qt);
+ _ni = 2;
+ }
+ };
+
+ if (line_flat_3d(_pp, _nv, _pa, _pb, _qt))
+ assessor() ;
+ if (line_flat_3d(_pp, _nv, _pb, _pc, _qt))
+ assessor() ;
+ if (line_flat_3d(_pp, _nv, _pc, _pa, _qt))
+ assessor() ;
+
+ // single-point cut collapses
+ if (_ni == 1) copy_node_3d(_qb, _qa);
return ( _ni ) ;
}
@@ -579,6 +620,14 @@
hits_type &_ht
)
{
+ if (_pa[0] == _pb[0] &&
+ _pa[1] == _pb[1])
+ {
+ copy_node_2d(_qq, _pa);
+ _ht = node_hits;
+ return true;
+ }
+
real_type _vv[2], _tt;
_vv[0] = _pb[0] - _pa[0] ;
_vv[1] = _pb[1] - _pa[1] ;
@@ -663,6 +712,15 @@
hits_type &_ht
)
{
+ if (_pa[0] == _pb[0] &&
+ _pa[1] == _pb[1] &&
+ _pa[2] == _pb[2])
+ {
+ copy_node_3d(_qq, _pa);
+ _ht = node_hits;
+ return true;
+ }
+
real_type _vv[3], _tt;
_vv[0] = _pb[0] - _pa[0] ;
_vv[1] = _pb[1] - _pa[1] ;
@@ -772,8 +830,10 @@
/*----------------------- projector for low-dim. face */
# define __projface2d(_pi, _pj) \
+ do { \
+ hits_type _kh = null_hits; \
if (proj_line_2d ( \
- _pp , _pi, _pj, _qt, _ht) ) \
+ _pp , _pi, _pj, _qt, _kh) ) \
{ \
real_type _dd = \
geometry::lensqr_2d(_pp, _qt) ; \
@@ -783,9 +843,11 @@
_qq[0] = _qt[0] ; \
_qq[1] = _qt[1] ; \
\
+ _ht = _kh ; \
_dm = _dd ; \
} \
- }
+ } \
+ } while (false)
{
/*----------------------- test node-tria intersection */
@@ -819,9 +881,12 @@
(double*)_PA ,
(double*)_PP ) ;
- if (_s1 * _s2 < +0.0 ||
- _s2 * _s3 < +0.0 ||
- _s3 * _s1 < +0.0 )
+ if ( (_s1 == 0. &&
+ _s2 == 0. &&
+ _s3 == 0. ) ||
+ is_diff_sign(_s1, _s2) ||
+ is_diff_sign(_s2, _s3) ||
+ is_diff_sign(_s3, _s1) )
{
real_type _dm = +std::
@@ -877,8 +942,10 @@
/*----------------------- projector for low-dim. face */
# define __projface3d(_pi, _pj) \
+ do { \
+ hits_type _kh = null_hits; \
if (proj_line_3d ( \
- _pp , _pi, _pj, _qt, _ht) ) \
+ _pp , _pi, _pj, _qt, _kh) ) \
{ \
real_type _dd = \
geometry::lensqr_3d(_pp, _qt) ; \
@@ -889,9 +956,11 @@
_qq[1] = _qt[1] ; \
_qq[2] = _qt[2] ; \
\
+ _ht = _kh ; \
_dm = _dd ; \
} \
- }
+ } \
+ } while (false)
/*----------------------- test node-tria intersection */
double _s1[3], _s2[3], _s3[3];
@@ -899,6 +968,23 @@
real_type _nv[3];
tria_norm_3d(_pa, _pb, _pc, _nv);
+ // collapsed triangle: no normal
+ if (_nv[0] == 0. && _nv[1] == 0. &&
+ _nv[2] == 0. )
+ {
+ real_type _dm =
+ std::numeric_limits
+ ::infinity();
+
+ real_type _qt[3];
+ _ht = null_hits;
+ __projface3d(_pa, _pb);
+ __projface3d(_pb, _pc);
+ __projface3d(_pc, _pa);
+
+ return ( true ) ;
+ }
+
real_type _pt[3];
proj_flat_3d(_pp, _pa, _nv, _pt);
@@ -1003,16 +1089,20 @@
{
/*----------------------- test node-tria intersection */
+ int _ax = 0;
+ if (std::abs(_nv[1]) >
+ std::abs(_nv[_ax]) )
+ _ax = 1;
+ if (std::abs(_nv[2]) >
+ std::abs(_nv[_ax]) )
+ _ax = 2;
+
+ // best-conditioned projector
+ int _pr = 2 - _ax; // yz, xz, xy
if (
- _s1[0] * _s2[0] < +0.0 ||
- _s2[0] * _s3[0] < +0.0 ||
- _s3[0] * _s1[0] < +0.0 ||
- _s1[1] * _s2[1] < +0.0 ||
- _s2[1] * _s3[1] < +0.0 ||
- _s3[1] * _s1[1] < +0.0 ||
- _s1[2] * _s2[2] < +0.0 ||
- _s2[2] * _s3[2] < +0.0 ||
- _s3[2] * _s1[2] < +0.0 )
+ is_diff_sign(_s1[_pr], _s2[_pr]) ||
+ is_diff_sign(_s2[_pr], _s3[_pr]) ||
+ is_diff_sign(_s3[_pr], _s1[_pr]) )
{
real_type _dm = +std::
@@ -1059,8 +1149,10 @@
/*----------------------- projector for low-dim. face */
# define __projface3d(_pi, _pj, _pk) \
+ do { \
+ hits_type _kh = null_hits; \
if (proj_tria_3d ( \
- _pp , _pi, _pj, _pk, _qt, _ht)) \
+ _pp , _pi, _pj, _pk, _qt, _kh)) \
{ \
real_type _dd = \
geometry::lensqr_3d(_pp, _qt) ; \
@@ -1071,9 +1163,11 @@
_qq[1] = _qt[1] ; \
_qq[2] = _qt[2] ; \
\
+ _ht = _kh ; \
_dm = _dd ; \
} \
- }
+ } \
+ } while (false)
{
/*----------------------- test node-tria intersection */
@@ -1120,12 +1214,16 @@
(double*)_PC ,
(double*)_PP ) ;
- if (_s1 * _s2 < +0.0 ||
- _s2 * _s3 < +0.0 ||
- _s3 * _s1 < +0.0 ||
- _s1 * _s4 < +0.0 ||
- _s2 * _s4 < +0.0 ||
- _s3 * _s4 < +0.0 )
+ if ( (_s1 == 0. &&
+ _s2 == 0. &&
+ _s3 == 0. &&
+ _s4 == 0. ) ||
+ is_diff_sign(_s1, _s2) ||
+ is_diff_sign(_s2, _s3) ||
+ is_diff_sign(_s3, _s1) ||
+ is_diff_sign(_s1, _s4) ||
+ is_diff_sign(_s2, _s4) ||
+ is_diff_sign(_s3, _s4) )
{
real_type _dm = +std::
@@ -1314,7 +1412,7 @@
(double*)_PA ,
(double*)_PP ) ;
- if (_sa*_sb > +0.0)
+ if (is_same_sign(_sa, _sb))
{
/*----------------------- have node-line intersection */
copy_node_2d(_qq, _pp) ;
@@ -1455,7 +1553,7 @@
(double*)_PA ,
(double*)_PP ) ;
- if (_sa*_sb > +0.0)
+ if (is_same_sign(_sa, _sb))
{
/*----------------------- have node-line intersection */
copy_node_3d(_qq, _pp) ;
@@ -1566,7 +1664,7 @@
if (_bind)
{
/*----------------------- no intersections: null hits */
- if (_sa * _sb < +0.0 )
+ if (is_diff_sign(_sa, _sb))
return null_hits;
}
@@ -1585,7 +1683,7 @@
if (_bind)
{
/*----------------------- no intersections: null hits */
- if (_sc * _sd < +0.0 )
+ if (is_diff_sign(_sc, _sd))
return null_hits;
}
@@ -1865,9 +1963,9 @@
(double*)_PP ) ;
/*----------------------- test intersection hierarchy */
- if (_s1*_s2<0.0 ||
- _s1*_s3<0.0 ||
- _s2*_s3<0.0 )
+ if (is_diff_sign(_s1, _s2) ||
+ is_diff_sign(_s1, _s3) ||
+ is_diff_sign(_s2, _s3) )
{
/*----------------------- no intersections: null hits */
return null_hits ;
@@ -2035,9 +2133,9 @@
(double*)_T1 ,
(double*)_TP ) ;
- if (_s1[0]*_s2[0] < +0.0 ||
- _s2[0]*_s3[0] < +0.0 ||
- _s3[0]*_s1[0] < +0.0 )
+ if (is_diff_sign(_s1[0], _s2[0]) ||
+ is_diff_sign(_s2[0], _s3[0]) ||
+ is_diff_sign(_s3[0], _s1[0]) )
{
/*----------------------- no intersections: null hits */
return null_hits ;
@@ -2067,9 +2165,9 @@
(double*)_T1 ,
(double*)_TP ) ;
- if (_s1[1]*_s2[1] < +0.0 ||
- _s2[1]*_s3[1] < +0.0 ||
- _s3[1]*_s1[1] < +0.0 )
+ if (is_diff_sign(_s1[1], _s2[1]) ||
+ is_diff_sign(_s2[1], _s3[1]) ||
+ is_diff_sign(_s3[1], _s1[1]) )
{
/*----------------------- no intersections: null hits */
return null_hits ;
@@ -2099,9 +2197,9 @@
(double*)_T1 ,
(double*)_TP ) ;
- if (_s1[2]*_s2[2] < +0.0 ||
- _s2[2]*_s3[2] < +0.0 ||
- _s3[2]*_s1[2] < +0.0 )
+ if (is_diff_sign(_s1[2], _s2[2]) ||
+ is_diff_sign(_s2[2], _s3[2]) ||
+ is_diff_sign(_s3[2], _s1[2]) )
{
/*----------------------- no intersections: null hits */
return null_hits ;
@@ -2134,7 +2232,7 @@
/*----------------------- have node-node intersection */
copy_node_3d(_qq, _pp) ;
- return edge_hits ;
+ return node_hits ;
}
else
if (_z2 && _z3 )
@@ -2286,7 +2384,7 @@
if (_bind)
{
/*----------------------- no intersections: null hits */
- if (_sa*_sb < 0.0)
+ if (is_diff_sign(_sa, _sb))
return null_hits ;
}
@@ -2315,13 +2413,13 @@
if (_bind)
{
/*----------------------- no intersections: null hits */
- if (_s1*_s2 < 0.0)
+ if (is_diff_sign(_s1, _s2))
return null_hits ;
- if (_s2*_s3 < 0.0)
+ if (is_diff_sign(_s2, _s3))
return null_hits ;
- if (_s3*_s1 < 0.0)
+ if (is_diff_sign(_s3, _s1))
return null_hits ;
}
@@ -2364,6 +2462,7 @@
{
/*----------------------- have line-edge intersection */
double _WS = _s2 + _s3 ;
+ if (_WS == +0.) return null_hits ;
double _W1 = _s2 / _WS ;
double _W2 = _s3 / _WS ;
@@ -2390,6 +2489,7 @@
{
/*----------------------- have line-edge intersection */
double _WS = _s1 + _s3 ;
+ if (_WS == +0.) return null_hits ;
double _W2 = _s3 / _WS ;
double _W3 = _s1 / _WS ;
@@ -2416,6 +2516,7 @@
{
/*----------------------- have line-edge intersection */
double _WS = _s1 + _s2 ;
+ if (_WS == +0.) return null_hits ;
double _W3 = _s1 / _WS ;
double _W1 = _s2 / _WS ;
@@ -2441,6 +2542,7 @@
{
/*----------------------- have line-face intersection */
double _WS = _s1 + _s2 + _s3 ;
+ if (_WS == +0.) return null_hits ;
double _W1 = _s2 / _WS ;
double _W2 = _s3 / _WS ;
double _W3 = _s1 / _WS ;
diff --git a/external/jigsaw/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp b/external/jigsaw/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp
index 2cc7d4f..ab3add8 100644
--- a/external/jigsaw/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp
+++ b/external/jigsaw/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 26 Feb., 2025
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -1228,8 +1228,24 @@
_rmax[2] = std::max(
(float)_apos[2], (float)_bpos[2]) ;
+ /*- bound the arc on the unit sphere, then scale axes */
+ real_type _anrm[3] = {
+ _apos[0] / this->_radA,
+ _apos[1] / this->_radB,
+ _apos[2] / this->_radC } ;
+
+ real_type _bnrm[3] = {
+ _bpos[0] / this->_radA,
+ _bpos[1] / this->_radB,
+ _bpos[2] / this->_radC } ;
+
real_type _rlen =
- geometry::length_3d(_apos, _bpos) ;
+ geometry::length_3d(_anrm, _bnrm) ;
+
+ real_type _rwid[3] = {
+ _rlen * this->_radA,
+ _rlen * this->_radB,
+ _rlen * this->_radC } ;
real_type _rmid[3] = {
_apos[0] * (real_type)+.5 +
@@ -1241,18 +1257,18 @@
} ;
_rmin[0] = std::min(
- _rmin[0], (float)(_rmid[0]-_rlen));
+ _rmin[0], (float)(_rmid[0]-_rwid[0]));
_rmin[1] = std::min(
- _rmin[1], (float)(_rmid[1]-_rlen));
+ _rmin[1], (float)(_rmid[1]-_rwid[1]));
_rmin[2] = std::min(
- _rmin[2], (float)(_rmid[2]-_rlen));
+ _rmin[2], (float)(_rmid[2]-_rwid[2]));
_rmax[0] = std::max(
- _rmax[0], (float)(_rmid[0]+_rlen));
+ _rmax[0], (float)(_rmid[0]+_rwid[0]));
_rmax[1] = std::max(
- _rmax[1], (float)(_rmid[1]+_rlen));
+ _rmax[1], (float)(_rmid[1]+_rwid[1]));
_rmax[2] = std::max(
- _rmax[2], (float)(_rmid[2]+_rlen));
+ _rmax[2], (float)(_rmid[2]+_rwid[2]));
_rmin[0] = _rmin[0]-(float)_rTOL;
_rmin[1] = _rmin[1]-(float)_rTOL;
@@ -1366,55 +1382,29 @@
)
{
/*--------------------------- great-ellipse projector */
- real_type _zero[3] ;
- _zero[0] = (real_type) +.0 ;
- _zero[1] = (real_type) +.0 ;
- _zero[2] = (real_type) +.0 ;
-
- _pprj[0] =_psrc[0] ;
- _pprj[1] =_psrc[1] ;
- _pprj[2] =_psrc[2] ;
-
- real_type _ttaa, _ttbb ;
- if (line_surf(
- _zero, _psrc, _ttaa, _ttbb) )
+ real_type _xx =
+ _psrc[0] / this->_radA ;
+ real_type _yy =
+ _psrc[1] / this->_radB ;
+ real_type _zz =
+ _psrc[2] / this->_radC ;
+
+ real_type _sc = _xx * _xx
+ + _yy * _yy
+ + _zz * _zz ;
+
+ _pprj[0] = _psrc[0] ;
+ _pprj[1] = _psrc[1] ;
+ _pprj[2] = _psrc[2] ;
+
+ if (_sc > (real_type) +0.)
{
- real_type _pmid[3] = {
- _psrc[0] * (real_type) +.5 +
- _zero[0] * (real_type) +.5 ,
- _psrc[1] * (real_type) +.5 +
- _zero[1] * (real_type) +.5 ,
- _psrc[2] * (real_type) +.5 +
- _zero[2] * (real_type) +.5
- } ;
- real_type _pdel[3] = {
- _psrc[0] * (real_type) +.5 -
- _zero[0] * (real_type) +.5 ,
- _psrc[1] * (real_type) +.5 -
- _zero[1] * (real_type) +.5 ,
- _psrc[2] * (real_type) +.5 -
- _zero[2] * (real_type) +.5
- } ;
+ _sc = (real_type) +1.
+ / std::sqrt (_sc) ;
- if (_ttaa > (real_type) -1.)
- {
- _pprj[0] =
- _pmid[0] + _ttaa*_pdel[0] ;
- _pprj[1] =
- _pmid[1] + _ttaa*_pdel[1] ;
- _pprj[2] =
- _pmid[2] + _ttaa*_pdel[2] ;
- }
- else
- if (_ttbb > (real_type) -1.)
- {
- _pprj[0] =
- _pmid[0] + _ttbb*_pdel[0] ;
- _pprj[1] =
- _pmid[1] + _ttbb*_pdel[1] ;
- _pprj[2] =
- _pmid[2] + _ttbb*_pdel[2] ;
- }
+ _pprj[0] *= _sc ;
+ _pprj[1] *= _sc ;
+ _pprj[2] *= _sc ;
}
}
@@ -2192,7 +2182,7 @@
hits_func &_hfun
)
{
- bool_type _find = true ;
+ bool_type _find = false ;
/*------------------ calc. initial dir. to surf.-ball */
real_type _proj[3], _vdir[3] ;
@@ -2232,6 +2222,7 @@
iptr_type _itag = +0;
char_type _topo[2] = {2};
+ _find = true ;
_hfun( _proj ,
_hits, _feat , _topo, _itag) ;
}
@@ -2246,7 +2237,7 @@
--------------------------------------------------------
*/
- __normal_call bool_type is_inside (
+ __normal_call iptr_type is_inside (
real_type *_ppos
)
{
@@ -2261,7 +2252,9 @@
return ( _xx * _xx
+ _yy * _yy
+ _zz * _zz
- <= (real_type) +1. ) ;
+ <= (real_type) +1. ) ?
+ (iptr_type) +0 :
+ (iptr_type) -1 ;
}
/*
diff --git a/external/jigsaw/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp b/external/jigsaw/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp
index 1ffa69f..eaaed05 100644
--- a/external/jigsaw/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp
+++ b/external/jigsaw/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 26 Feb., 2025
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -73,7 +73,7 @@
iptr_type ,
allocator > geom_type ;
- typedef geom_base_3d <
+ typedef geom_base_2d <
real_type ,
iptr_type > base_type ;
diff --git a/external/jigsaw/src/libcpp/interpolate/hfun_clip_k.hpp b/external/jigsaw/src/libcpp/interpolate/hfun_clip_k.hpp
index 884155b..7070647 100644
--- a/external/jigsaw/src/libcpp/interpolate/hfun_clip_k.hpp
+++ b/external/jigsaw/src/libcpp/interpolate/hfun_clip_k.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 20 Oct., 2024
+ * Last updated: 06 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
@@ -161,13 +161,15 @@
polyroots(_at, _bt, _ct, _tt) )
{
/*-------------------------- test flow along boundary */
- return EIKONAL_edge_2d (
+ bool_type _o1 = EIKONAL_edge_2d (
_p1, _h1, _g1,
- _p3, _h3, _g3)
+ _p3, _h3, _g3) ;
- || EIKONAL_edge_2d (
+ bool_type _o2 = EIKONAL_edge_2d (
_p2, _h2, _g2,
_p3, _h3, _g3) ;
+
+ return ( _o1 || _o2 ) ;
}
else
{
@@ -267,13 +269,15 @@
polyroots(_at, _bt, _ct, _tt) )
{
/*-------------------------- test flow along boundary */
- return EIKONAL_edge_3d (
+ bool_type _o1 = EIKONAL_edge_3d (
_p1, _h1, _g1,
- _p3, _h3, _g3)
+ _p3, _h3, _g3) ;
- || EIKONAL_edge_3d (
+ bool_type _o2 = EIKONAL_edge_3d (
_p2, _h2, _g2,
_p3, _h3, _g3) ;
+
+ return ( _o1 || _o2 ) ;
}
else
{
@@ -395,7 +399,7 @@
_p2, _h2, _g2,
_p4, _hn, _g4) )
{
- _uu = (real_type)0.;
+ _uu = (real_type).5;
_vv = (real_type).5;
}
@@ -403,8 +407,8 @@
_p3, _h3, _g3,
_p4, _hn, _g4) )
{
- _uu = (real_type).5;
- _vv = (real_type)0.;
+ _uu = (real_type)0.;
+ _vv = (real_type).5;
}
if (EIKONAL_tria_3d(_p3, _h3, _g3,
@@ -412,7 +416,7 @@
_p4, _hn, _g4) )
{
_uu = (real_type).5;
- _vv = (real_type).5;
+ _vv = (real_type)0.;
}
for (auto _iter = 8; _iter-- != +0; )
@@ -437,7 +441,7 @@
/*---------------------- local line-search relaxation */
bool _up = false;
- for (auto _line = 4; _line-- != +0; )
+ for (auto _line = 8; _line-- != +0; )
{
real_type _tt = +1. ;
real_type _un = _uu - _ss * _du ;
@@ -480,12 +484,14 @@
_ha * _um + _hb * _vm + _h3
+ _gg * std::sqrt(_dm)) ;
- if (_hm < _hn || _ss <= 0.)
+ if (_hm < _hn)
{
/*---------------------- move on to new better optima */
_uu = _um; _vv = _vm; _hn = _hm;
_up = true; break ;
}
+ else
+ if (_ss <= 0.) break ; // retain candidate at stall
else { _ss *= (real_type).5; }
}
/*---------------------- done if stuck or on boundary */
diff --git a/external/jigsaw/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp b/external/jigsaw/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp
index ac6f90f..31ac084 100644
--- a/external/jigsaw/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp
+++ b/external/jigsaw/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 20 Oct., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -184,8 +184,10 @@
real_type _zrat =
_ppos[2] / this->_radC ;
- _zrat = std::min(+1.,_zrat);
- _zrat = std::max(-1.,_zrat);
+ _zrat = std::min(
+ (real_type) +1., _zrat);
+ _zrat = std::max(
+ (real_type) -1., _zrat);
_apos[0]= std::atan2(_ymul,
_xmul);
@@ -201,10 +203,13 @@
__inline_call void_type init (
)
{
- real_type static const _FTOL =
+ real_type static const FT =
std::pow (
std::numeric_limits
- ::epsilon(), (real_type) +.75) ;
+ ::epsilon(), (real_type)+0.5);
+
+ real_type static const PI =
+ (real_type)std::atan(+1.0) * +4.0 ;
this->_xvar = false ;
this->_yvar = false ;
@@ -220,8 +225,8 @@
_xbar /=(this->_xpos.count () - 1) ;
- _xmin = _xbar - _FTOL * _xbar ;
- _xmax = _xbar + _FTOL * _xbar ;
+ _xmin = _xbar - FT * _xbar ;
+ _xmax = _xbar + FT * _xbar ;
real_type _ybar, _ymin, _ymax ;
_ybar = *this->_ypos.tail() -
@@ -229,8 +234,8 @@
_ybar /=(this->_ypos.count () - 1) ;
- _ymin = _ybar - _FTOL * _ybar ;
- _ymax = _ybar + _FTOL * _ybar ;
+ _ymin = _ybar - FT * _ybar ;
+ _ymax = _ybar + FT * _ybar ;
for (auto _iter = _xpos.head() ;
_iter != _xpos.tail() ;
@@ -264,19 +269,23 @@
this->_ivdy = +1. / _ybar ;
/*-------------------------- test for "x" periodicity */
- real_type _xdel =
- std::cos(*_xpos.tail()) -
- std::cos(*_xpos.head()) ;
-
+ real_type _xdel = *_xpos.tail() -
+ *_xpos.head() ;
+
this->_wrap =
- std::abs(_xdel) < _FTOL ;
+ _xdel > (real_type)1. * PI &&
+ _xdel < (real_type)3. * PI &&
+ std::abs((real_type)1. - std::cos(_xdel)) < FT ;
/*-------------------------- sum for extrap. at poles */
- double _xtop = 0., _xbot = 0. ;
+ double _xtop = 0.0, _xbot = 0.0 ;
+
+ auto _xend = this->_wrap ?
+ _xpos.tail() : _xpos.tend() ;
iptr_type _indx, _jpos = +0 ;
for (auto _iter = _xpos.head() ;
- _iter != _xpos.tail() ;
+ _iter != _xend;
++_iter, ++_jpos)
{
iptr_type _n = -1 +
@@ -285,18 +294,18 @@
indx_from_subs(
+0, _jpos, _indx) ;
- _xtop += this->_hmat[_indx] ;
+ _xbot += this->_hmat[_indx] ;
indx_from_subs(
_n, _jpos, _indx) ;
- _xbot += this->_hmat[_indx] ;
+ _xtop += this->_hmat[_indx] ;
}
- this->_htop = (vals_type)(
- _xtop / this->_xpos.count() ) ;
- this->_hbot = (vals_type)(
- _xbot / this->_xpos.count() ) ;
+ this->_htop =
+ (vals_type) (_xtop / _jpos) ;
+ this->_hbot =
+ (vals_type) (_xbot / _jpos) ;
}
/*
@@ -616,11 +625,11 @@
REQUEUE (_inew, _iold, _pair)
}
- if (_jpjj==JEND)
+ if (_jpjj==JBEG)
{
iptr_type _pair;
indx_from_subs(
- _jpii, JBEG, _pair) ;
+ _jpii, JEND, _pair) ;
REQUEUE (_jnew, _jold, _pair)
}
@@ -632,11 +641,11 @@
REQUEUE (_knew, _kold, _pair)
}
- if (_lpjj==JBEG)
+ if (_lpjj==JEND)
{
iptr_type _pair;
indx_from_subs(
- _lpii, JEND, _pair) ;
+ _lpii, JBEG, _pair) ;
REQUEUE (_lnew, _lold, _pair)
}
}
@@ -677,11 +686,11 @@
REQUEUE (_inew, _iold, _pair)
}
- if (_jpjj==JEND)
+ if (_jpjj==JBEG)
{
iptr_type _pair;
indx_from_subs(
- _jpii, JBEG, _pair) ;
+ _jpii, JEND, _pair) ;
REQUEUE (_jnew, _jold, _pair)
}
@@ -693,11 +702,11 @@
REQUEUE (_knew, _kold, _pair)
}
- if (_lpjj==JBEG)
+ if (_lpjj==JEND)
{
iptr_type _pair;
indx_from_subs(
- _lpii, JEND, _pair) ;
+ _lpii, JBEG, _pair) ;
REQUEUE (_lnew, _lold, _pair)
}
}
diff --git a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp
index 0e11686..5980393 100644
--- a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp
+++ b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 23 Oct., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -174,8 +174,10 @@
real_type _zrat =
_ppos[2] / this->_radC ;
- _zrat = std::min(+1.,_zrat);
- _zrat = std::max(-1.,_zrat);
+ _zrat = std::min(
+ (real_type) +1., _zrat);
+ _zrat = std::max(
+ (real_type) -1., _zrat);
_apos[0]= std::atan2(_ymul,
_xmul);
@@ -749,8 +751,8 @@
(float) _ppos[1] ,
(float) _ppos[2] } ;
- real_type _hOUT =
- +std::numeric_limits::infinity() ;
+ real_type _hOUT = std::
+ numeric_limits::infinity() ;
if (hint_okay(_hint))
{
@@ -761,6 +763,11 @@
{
_hint = this->null_hint();
}
+ else
+ {
+ geometry::
+ copy_node_3d(_QPOS, _QTMP);
+ }
}
else
{
diff --git a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp
index f59c93e..f1f13b8 100644
--- a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp
+++ b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 23 Oct., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -671,8 +671,8 @@
(float) _ppos[0] ,
(float) _ppos[1] } ;
- real_type _hOUT =
- +std::numeric_limits::infinity() ;
+ real_type _hOUT = std::
+ numeric_limits::infinity() ;
if (hint_okay(_hint))
{
@@ -683,6 +683,11 @@
{
_hint = this->null_hint();
}
+ else
+ {
+ geometry::
+ copy_node_2d(_QPOS, _QTMP);
+ }
}
else
{
diff --git a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp
index 49bc69e..e9fbf2c 100644
--- a/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp
+++ b/external/jigsaw/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 23 Oct., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -727,6 +727,11 @@
{
_hint = this->null_hint();
}
+ else
+ {
+ geometry::
+ copy_node_3d(_QPOS, _QTMP);
+ }
}
else
{
diff --git a/external/jigsaw/src/libcpp/iter_mesh/_zip_mesh_2.inc b/external/jigsaw/src/libcpp/iter_mesh/_zip_mesh_2.inc
index b8f6551..d34bc4a 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/_zip_mesh_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/_zip_mesh_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 21 Jan., 2025
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -152,8 +152,6 @@
conn_list _iset , _jset, _kset ;
fp32_list _qold , _qnew, _qtmp ;
- _nzip = +0 ; _ndiv = +0 ;
-
// assemble list of faces attached to "recent" nodes
# ifdef __use_timers
@@ -418,8 +416,6 @@
conn_list _conn , _iset, _jset ;
fp32_list _qold , _qnew, _qtmp ;
- _nzip = +0 ; _ndiv = +0 ;
-
// assemble list of edges attached to "recent" nodes
# ifdef __use_timers
@@ -616,6 +612,8 @@
# endif//__use_timers
/*--------------------- zip//div topo. cell hierarchy */
+ _nzip = 0; _ndiv = 0;
+
_zip_fcel( _geom, _mesh, _hfun,
_kern, _hval, _nset, _mark,
_imrk, _opts,
diff --git a/external/jigsaw/src/libcpp/iter_mesh/iter_flip_2.inc b/external/jigsaw/src/libcpp/iter_mesh/iter_flip_2.inc
index 4d2fad3..ac3e383 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/iter_flip_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/iter_flip_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 01 Sept., 2021
+ * Last updated: 06 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -204,12 +204,12 @@
real_type _jpwr =
_mesh.node(_jnod[2]).pval (_last) ;
- _ilen -= _ipwr ;
- _jlen -= _jpwr ;
-
real_type _btol =
(real_type)+.5 * _LTOL * (_ilen + _jlen) ;
+ _ilen -= _ipwr ;
+ _jlen -= _jpwr ;
+
real_type _idel =
_ilen - _jbal [_last] ;
real_type _jdel =
diff --git a/external/jigsaw/src/libcpp/iter_mesh/iter_mesh_2.hpp b/external/jigsaw/src/libcpp/iter_mesh/iter_mesh_2.hpp
index 0b3e68e..41b01b4 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/iter_mesh_2.hpp
+++ b/external/jigsaw/src/libcpp/iter_mesh/iter_mesh_2.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 04 Dec., 2024
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda,
* Marc Tunnell
* d.engwirda@gmail.com
@@ -111,9 +111,7 @@
class cell_kind{} ; // dummies for overload
class dual_kind{} ;
- typedef mesh::iter_params <
- real_type ,
- iptr_type > iter_opts ;
+ typedef mesh::iter_params iter_opts ;
typedef mesh::iter_timers iter_stat ;
@@ -421,6 +419,8 @@
_QMIN = std::min (_QMIN, _qmin) ;
}
}
+ # else
+ _QMIN = _qmin ;
# endif//__use_openmp
}
@@ -875,4 +875,3 @@
# endif //__ITER_MESH_2__
-
diff --git a/external/jigsaw/src/libcpp/iter_mesh/iter_node_2.inc b/external/jigsaw/src/libcpp/iter_mesh/iter_node_2.inc
index 2f6ffd3..add8c70 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/iter_node_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/iter_node_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 08 Aug., 2025
+ * Last updated: 08 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -325,8 +325,7 @@
_ladj = (real_type) +0.0 ;
- real_type _wsum =
- +std::numeric_limits::epsilon();
+ real_type _wsum = (real_type)+0.0 ;
iptr_type _cnum = +0 ;
@@ -355,6 +354,7 @@
if (_cnum > +0)
{
+ if (_wsum > (real_type)+0.0)
for (auto _idim =
pred_type::geom_dims ; _idim-- != 0; )
{
@@ -744,8 +744,7 @@
_ladj = (real_type) +0.0 ;
- real_type _wsum =
- +std::numeric_limits::epsilon();
+ real_type _wsum = (real_type)+0.0 ;
iptr_type _cnum = +0 ;
@@ -774,6 +773,7 @@
if (_cnum > +0)
{
+ if (_wsum > (real_type)+0.0)
for (auto _idim =
pred_type::geom_dims ; _idim-- != 0; )
{
@@ -867,7 +867,7 @@
{
real_type static const _HINC =
std::pow(std::numeric_limits
- ::epsilon(), +0.75) ;
+ ::epsilon(), +0.50) ;
/*------------------------------------- cell indexing */
auto _ppos = &_node->pval(0);
@@ -883,6 +883,7 @@
_bmin[_idim] ;
real_type _hdel = _HINC*_binc;
+ if (_hdel == (real_type)+0.) continue;
real_type _dsup , _dsdn ;
{
/*------------------ centred finite-diff. for dQ / dx */
@@ -1016,7 +1017,7 @@
{
real_type static const _HINC =
std::pow(std::numeric_limits
- ::epsilon(), +0.75) ;
+ ::epsilon(), +0.50) ;
/*------------------------------------- cell indexing */
auto _ppos = &_node->pval(0);
@@ -1032,6 +1033,7 @@
_bmin[_idim] ;
real_type _hdel = _HINC*_binc;
+ if (_hdel == (real_type)+0.) continue;
real_type _dsup , _dsdn ;
{
/*------------------ centred finite-diff. for dQ / dx */
@@ -1120,12 +1122,15 @@
float _qmin =
+std::numeric_limits::infinity();
- real_type _bmin[_last] = {
- +std::numeric_limits::infinity()
- } ;
- real_type _bmax[_last] = {
- -std::numeric_limits::infinity()
- } ;
+ real_type _bmin[_last], _bmax[_last] ;
+ for (auto _idim =
+ pred_type::geom_dims; _idim-- != +0; )
+ {
+ _bmin[_idim] =
+ +std::numeric_limits::infinity();
+ _bmax[_idim] =
+ -std::numeric_limits::infinity();
+ }
iptr_type _cnum = + 0 ;
for (auto _next = _conn.head() ,
diff --git a/external/jigsaw/src/libcpp/iter_mesh/move_mesh_2.inc b/external/jigsaw/src/libcpp/iter_mesh/move_mesh_2.inc
index cfc6f41..141977d 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/move_mesh_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/move_mesh_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda,
* Marc Tunnell
* d.engwirda@gmail.com
@@ -232,10 +232,10 @@
{
/*---------------- push update along search direction */
real_type _scal = _SCAL;
- real_type _zeta = _opts._zeta *
+ real_type _zeta = _opts.zeta() *
std::min ((real_type)1.,_scal) ;
- real_type _beta = _opts._beta ;
+ real_type _beta = _opts.beta() ;
for (auto _idim =
pred_type::geom_dims; _idim-- != +0; )
@@ -334,7 +334,7 @@
real_list &_hval , // cached node spacing array
iter_opts &_opts , // user options
node_iter _node , // iterator to node to iter.
- real_type _last , // lagged line direction
+ real_type &_last , // lagged line direction
iptr_type &_move , // > 0 if move successful
conn_list &_conn , // list of adj. cells
fp32_list &_dold , // list of old adj. costs
@@ -412,11 +412,11 @@
{
real_type _wmov;
real_type _scal = _SCAL;
- real_type _zeta = _opts._zeta *
+ real_type _zeta = _opts.zeta() *
(real_type)3./4. *
std::min((real_type)1.,_scal) ;
- real_type _beta = _opts._beta ;
+ real_type _beta = _opts.beta() ;
/*---------------- momentum-type bias for search dir. */
_step =
diff --git a/external/jigsaw/src/libcpp/iter_mesh/part_mesh_2.inc b/external/jigsaw/src/libcpp/iter_mesh/part_mesh_2.inc
index 7a6ca27..f94b16f 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/part_mesh_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/part_mesh_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 23 Dec., 2022
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Marc Tunnell,
* Darren Engwirda
* d.engwirda@gmail.com
@@ -54,7 +54,7 @@
mesh_type &_mesh, // full mesh obj.
part_sets &_part, // partition data-structure
iptr_type _nprt, // number of partitions to make
- iptr_list _aset, // list of active nodes
+ iptr_list &_aset, // list of active nodes
iptr_type _isub, // inner iteration marker
real_type _arot,
iter_stat &_tcpu // CPU timers/info
diff --git a/external/jigsaw/src/libcpp/iter_mesh/sort_mesh_2.inc b/external/jigsaw/src/libcpp/iter_mesh/sort_mesh_2.inc
index 7286b29..50f6e94 100644
--- a/external/jigsaw/src/libcpp/iter_mesh/sort_mesh_2.inc
+++ b/external/jigsaw/src/libcpp/iter_mesh/sort_mesh_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 18 Dec., 2022
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2022
+ * Copyright 2013-2026
* Darren Engwirda,
* Marc Tunnell
* d.engwirda@gmail.com
@@ -334,7 +334,10 @@
float _cval =
(float)_qbar[_ipos]/_nadj -
- (float)_qmin[_ipos] ;
+ (float)_qmin[_ipos] +
+ 0.25f * std::max(+0.0f ,
+ (float)_QLIM -
+ (float)_qmin[_ipos]) ;
_sset.push_tail (
cost_pair(_ipos , _cval)) ;
diff --git a/external/jigsaw/src/libcpp/mathutil.hpp b/external/jigsaw/src/libcpp/mathutil.hpp
index f46c5e2..a6253b1 100644
--- a/external/jigsaw/src/libcpp/mathutil.hpp
+++ b/external/jigsaw/src/libcpp/mathutil.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 30 Mar., 2021
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -94,10 +94,30 @@
{
_real = true ;
- _aa *=(real_type)+2. ;
-
- _xx[0] /= _aa ;
- _xx[1] /= _aa ;
+ if (_xm <= std::
+ numeric_limits::min())
+ {
+ _xx[0] = (real_type)+0.;
+ _xx[1] = (real_type)+0.;
+ }
+ else // use Vieta's product
+ if (std::abs(_xx[0]) >=
+ std::abs(_xx[1]) )
+ {
+ real_type _qq =
+ _xx[0] / (real_type)+2. ;
+
+ _xx[0] = +_qq / _aa ;
+ _xx[1] = +_cc / _qq ;
+ }
+ else
+ {
+ real_type _qq =
+ _xx[1] / (real_type)+2. ;
+
+ _xx[0] = +_cc / _qq ;
+ _xx[1] = +_qq / _aa ;
+ }
}
else
if (std::abs(_bb) >
@@ -158,8 +178,10 @@
real_type _zrat =
_ppos[2] / _rrad [2] ;
- _zrat = std::min(+1.,_zrat);
- _zrat = std::max(-1.,_zrat);
+ _zrat = std::min(
+ (real_type) +1., _zrat);
+ _zrat = std::max(
+ (real_type) -1., _zrat);
_apos[0]= std::atan2(_ymul,
_xmul);
diff --git a/external/jigsaw/src/libcpp/mesh_reps/base_complex_k.hpp b/external/jigsaw/src/libcpp/mesh_reps/base_complex_k.hpp
index 189bfef..a59404b 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/base_complex_k.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/base_complex_k.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 11 Dec., 2022
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2020--2022
+ * Copyright 2020--2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -710,6 +710,14 @@
if (_itop == -1)
{
/*----- if it's a "top"-level face, copy data */
+ if (_mesh._llE2[*_same].
+ self() >= 1)
+ for (auto _n = 2; _n-- != 0; )
+ {
+ _mesh.node(_edat.node(_n)).
+ ndeg(EDGE2_tag)-= 1 ;
+ }
+
_mesh._llE2[*_same] =
_mesh._llE2[ _ipos] ;
}
@@ -722,6 +730,7 @@
}
_put_edge(_mesh, _ipos) ;
+ _ipos = *_same ;
}
else
{
@@ -838,6 +847,14 @@
if (_itop == -1)
{
/*----- if it's a "top"-level face, copy data */
+ if (_mesh._llT3[*_same].
+ self() >= 1)
+ for (auto _n = 3; _n-- != 0; )
+ {
+ _mesh.node(_tdat.node(_n)).
+ ndeg(TRIA3_tag)-= 1 ;
+ }
+
_mesh._llT3[*_same] =
_mesh._llT3[ _ipos] ;
}
@@ -850,6 +867,7 @@
}
_put_tri3(_mesh, _ipos) ;
+ _ipos = *_same ;
}
else
{
@@ -974,6 +992,14 @@
if (_itop == -1)
{
/*----- if it's a "top"-level face, copy data */
+ if (_mesh._llQ4[*_same].
+ self() >= 1)
+ for (auto _n = 4; _n-- != 0; )
+ {
+ _mesh.node(_qdat.node(_n)).
+ ndeg(QUAD4_tag)-= 1 ;
+ }
+
_mesh._llQ4[*_same] =
_mesh._llQ4[ _ipos] ;
}
@@ -986,6 +1012,7 @@
}
_put_quad(_mesh, _ipos) ;
+ _ipos = *_same ;
}
else
{
@@ -1110,6 +1137,14 @@
if (_itop == -1)
{
/*----- if it's a "top"-level face, copy data */
+ if (_mesh._llT4[*_same].
+ self() >= 1)
+ for (auto _n = 4; _n-- != 0; )
+ {
+ _mesh.node(_tdat.node(_n)).
+ ndeg(TRIA4_tag)-= 1 ;
+ }
+
_mesh._llT4[*_same] =
_mesh._llT4[ _ipos] ;
}
@@ -1122,6 +1157,7 @@
}
_put_tri4(_mesh, _ipos) ;
+ _ipos = *_same ;
}
else
{
diff --git a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_1.hpp b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_1.hpp
index c769db6..439928b 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_1.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_1.hpp
@@ -269,6 +269,8 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1
) ;
diff --git a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_2.hpp b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_2.hpp
index c6e50fc..b2509b6 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_2.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_2.hpp
@@ -382,6 +382,10 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+ this->_mmT3.empty () ;
+ this->_mmQ4.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1 +
(this->_llT3.count()*3) / 2 + 1 +
diff --git a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_3.hpp b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_3.hpp
index 0e41833..e7cc4e9 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_3.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/mesh_complex_3.hpp
@@ -601,6 +601,11 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+ this->_mmT3.empty () ;
+ this->_mmQ4.empty () ;
+ this->_mmT4.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1 +
(this->_llT3.count()*3) / 2 + 1 +
diff --git a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_1.hpp b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_1.hpp
index c05ee19..fb054fa 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_1.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_1.hpp
@@ -269,6 +269,8 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1
) ;
diff --git a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_2.hpp b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_2.hpp
index 64edff3..d6d3424 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_2.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_2.hpp
@@ -331,6 +331,9 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+ this->_mmT3.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1 +
(this->_llT3.count()*3) / 2 + 1
diff --git a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_3.hpp b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_3.hpp
index bb98415..2b1b602 100644
--- a/external/jigsaw/src/libcpp/mesh_reps/tria_complex_3.hpp
+++ b/external/jigsaw/src/libcpp/mesh_reps/tria_complex_3.hpp
@@ -390,6 +390,10 @@
__normal_call void_type make_link (
)
{
+ this->_mmE2.empty () ;
+ this->_mmT3.empty () ;
+ this->_mmT4.empty () ;
+
this->_mmE2.set_slots(
(this->_llE2.count()*5) / 4 + 1 +
(this->_llT3.count()*3) / 2 + 1 +
diff --git a/external/jigsaw/src/libcpp/parameters/iter_params.hpp b/external/jigsaw/src/libcpp/parameters/iter_params.hpp
index b8320dd..1268ffa 100644
--- a/external/jigsaw/src/libcpp/parameters/iter_params.hpp
+++ b/external/jigsaw/src/libcpp/parameters/iter_params.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -60,37 +60,12 @@
--------------------------------------------------------
*/
- template <
- typename R ,
- typename I
- >
- class iter_params
+ class iter_params : public jigsaw_jig_t
{
public :
- typedef R real_type ;
- typedef I iptr_type ;
-
- typedef iter_params self_type ;
-
- iptr_type _verb ; // logfile output verbosity
- iptr_type _nprt ; // no. threads
-
- iptr_type _iter ; // no. iterations
-
- real_type _beta ; // QHM momentum coeff.
- real_type _zeta ; // QHM momentum coeff.
-
- real_type _qtol ; // convergence tolerance
- real_type _qlim ; // fallback score threshold
-
- real_type _wmin ; // up/lo limits on weights
- real_type _wmax ;
-
- bool_type _zip_ ; // do cell merge operations
- bool_type _div_ ; // do cell split operations
- bool_type _tria ; // mesh cell optimisation
- bool_type _dual ; // dual cell optimisation
+ typedef real_t real_type ;
+ typedef indx_t iptr_type ;
public :
@@ -98,158 +73,125 @@
__inline_call iter_params (
)
{ // load default values
- jigsaw_jig_t _jjig ;
- jigsaw_null_jig_t( &_jjig ) ;
-
- this->_verb =
- iptr_type(_jjig._verbosity) ;
- this->_nprt =
- iptr_type(_jjig._numthread) ;
-
- this->_iter =
- iptr_type(_jjig._optm_iter) ;
-
- this->_beta =
- real_type(_jjig._optm_beta) ;
- this->_zeta =
- real_type(_jjig._optm_zeta) ;
-
- this->_qtol =
- real_type(_jjig._optm_qtol) ;
- this->_qlim =
- real_type(_jjig._optm_qlim) ;
-
- this->_wmin =
- real_type(_jjig._optm_wmin) ;
- this->_wmax =
- real_type(_jjig._optm_wmax) ;
-
- this->_zip_ =
- bool_type(_jjig._optm_zip_) ;
- this->_div_ =
- bool_type(_jjig._optm_div_) ;
- this->_tria =
- bool_type(_jjig._optm_tria) ;
- this->_dual =
- bool_type(_jjig._optm_dual) ;
+ jigsaw_null_jig_t(this) ;
}
/*------------------------------------ "write" access */
__inline_call iptr_type & verb (
)
- { return this->_verb ;
+ { return this->_verbosity ;
}
__inline_call iptr_type & nprt (
)
- { return this->_nprt ;
+ { return this->_numthread ;
}
__inline_call iptr_type & iter (
)
- { return this->_iter ;
+ { return this->_optm_iter ;
}
__inline_call real_type & beta (
)
- { return this->_beta ;
+ { return this->_optm_beta ;
}
__inline_call real_type & zeta (
)
- { return this->_zeta ;
+ { return this->_optm_zeta ;
}
__inline_call real_type & qtol (
)
- { return this->_qtol ;
+ { return this->_optm_qtol ;
}
__inline_call real_type & qlim (
)
- { return this->_qlim ;
+ { return this->_optm_qlim ;
}
__inline_call real_type & wmin (
)
- { return this->_wmin ;
+ { return this->_optm_wmin ;
}
__inline_call real_type & wmax (
)
- { return this->_wmax ;
+ { return this->_optm_wmax ;
}
- __inline_call bool_type & zip_ (
+ __inline_call iptr_type & zip_ (
)
- { return this->_zip_ ;
+ { return this->_optm_zip_ ;
}
- __inline_call bool_type & div_ (
+ __inline_call iptr_type & div_ (
)
- { return this->_div_ ;
+ { return this->_optm_div_ ;
}
- __inline_call bool_type & tria (
+ __inline_call iptr_type & tria (
)
- { return this->_tria ;
+ { return this->_optm_tria ;
}
- __inline_call bool_type & dual (
+ __inline_call iptr_type & dual (
)
- { return this->_dual ;
+ { return this->_optm_dual ;
}
/*------------------------------------ "const" access */
__inline_call iptr_type const& verb (
) const
- { return this->_verb ;
+ { return this->_verbosity ;
}
__inline_call iptr_type const& nprt (
) const
- { return this->_nprt ;
+ { return this->_numthread ;
}
__inline_call iptr_type const& iter (
) const
- { return this->_iter ;
+ { return this->_optm_iter ;
}
__inline_call real_type const& beta (
) const
- { return this->_beta ;
+ { return this->_optm_beta ;
}
__inline_call real_type const& zeta (
) const
- { return this->_zeta ;
+ { return this->_optm_zeta ;
}
__inline_call real_type const& qtol (
) const
- { return this->_qtol ;
+ { return this->_optm_qtol ;
}
__inline_call real_type const& qlim (
) const
- { return this->_qlim ;
+ { return this->_optm_qlim ;
}
__inline_call real_type const& wmin (
) const
- { return this->_wmin ;
+ { return this->_optm_wmin ;
}
__inline_call real_type const& wmax (
) const
- { return this->_wmax ;
+ { return this->_optm_wmax ;
}
- __inline_call bool_type const& zip_ (
+ __inline_call iptr_type const& zip_ (
) const
- { return this->_zip_ ;
+ { return this->_optm_zip_ ;
}
- __inline_call bool_type const& div_ (
+ __inline_call iptr_type const& div_ (
) const
- { return this->_div_ ;
+ { return this->_optm_div_ ;
}
- __inline_call bool_type const& tria (
+ __inline_call iptr_type const& tria (
) const
- { return this->_tria ;
+ { return this->_optm_tria ;
}
- __inline_call bool_type const& dual (
+ __inline_call iptr_type const& dual (
) const
- { return this->_dual ;
+ { return this->_optm_dual ;
}
} ;
@@ -257,6 +199,3 @@
}
# endif //__ITER_PARAMS__
-
-
-
diff --git a/external/jigsaw/src/libcpp/parameters/mesh_params.hpp b/external/jigsaw/src/libcpp/parameters/mesh_params.hpp
index 6bbca47..82fa72f 100644
--- a/external/jigsaw/src/libcpp/parameters/mesh_params.hpp
+++ b/external/jigsaw/src/libcpp/parameters/mesh_params.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 21 Apr., 2024
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -60,432 +60,298 @@
--------------------------------------------------------
*/
- template <
- typename R ,
- typename I
- >
- class mesh_params
+ class mesh_params : public jigsaw_jig_t
{
public :
- typedef R real_type ;
- typedef I iptr_type ;
-
- typedef mesh::mesh_params self_type ;
+ typedef real_t real_type ;
+ typedef indx_t iptr_type ;
enum node_kind { // "off-centre" descriptors
null_kind = +0 ,
- fail_kind ,
- circ_kind , // "circ"-type refinement
- sink_kind , // "sink"-type off-centre
- offH_kind , // "size"-type off-centre
- offC_kind , // "circ"-type off-centre
- offE_kind , // "err."-type off-centre
- offT_kind , // "topo"-type off-centre
+ fail_kind = +1 ,
+ circ_kind = +2 , // "circ"-type refinement
+ sink_kind = JIGSAW_MESH_RULE_SINK ,
+ // "sink"-type off-centre
+ offH_kind = JIGSAW_MESH_RULE_OFFH ,
+ // "size"-type off-centre
+ offC_kind = JIGSAW_MESH_RULE_OFFC ,
+ // "circ"-type off-centre
+ offE_kind = JIGSAW_MESH_RULE_OFFE ,
+ // "err."-type off-centre
+ offT_kind = JIGSAW_MESH_RULE_OFFT ,
+ // "topo"-type off-centre
last_kind } ;
- iptr_type _verb ; // logfile output verbosity
- iptr_type _nprt ; // no. threads
-
- iptr_type _seed ; // no. init. "seed" nodes
-
- real_type _phi1 ; // 1-"hard" angle tolerance
- real_type _phi2 ; // 2-"hard" angle tolerance
-
- real_type _eta1 ; // 1-"soft" angle tolerance
- real_type _eta2 ; // 2-"soft" angle tolerance
-
- bool_type _feat ; // true for feature calc.
-
- real_type _near ; // "zip" tolerance for IC's
-
- iptr_type _dims ; // topo. dimensions to mesh
-
- iptr_type _iter ; // max. num. refine iter.
-
- iptr_type _rule ; // rule for cell refinement
-
- real_type _siz1 ; // 1-dim. element size mul.
- real_type _siz2 ; // 2-dim. element size mul.
- real_type _siz3 ; // 3-dim. element size mul.
-
- real_type _eps1 ; // 1-dim. 1-hausdorff error
- real_type _eps2 ; // 2-dim. 2-hausdorff error
-
- real_type _rad2 ; // 2-dim. radius-edge ratio
- real_type _rad3 ; // 3-dim. radius-edge ratio
-
- real_type _off2 ; // 2-off. radius-edge ratio
- real_type _off3 ; // 3-off. radius-edge ratio
-
- real_type _snk2 ; // 2-dim. sink "safe" ratio
- real_type _snk3 ; // 3-dim. sink "safe" ratio
-
- real_type _vol3 ; // volume-length ratio
-
- bool_type _orph ; // allow "orphaned" facets
-
- bool_type _lock ; // stop subface refinement
-
- bool_type _top1 ; // impose 1-"manifold-ness"
- bool_type _top2 ; // impose 2-"manifold-ness"
-
- public :
-
- __static_call
- __inline_call iptr_type init_rule (
- )
- {
- iptr_type _rule = +0 ;
- __setbit( _rule, offH_kind) ;
- __setbit( _rule, offC_kind) ;
- __setbit( _rule, offT_kind) ;
- __setbit( _rule, sink_kind) ;
-
- return _rule ;
- }
-
public :
/*-------------------------- construct default param. */
__inline_call mesh_params (
)
{ // load default values
- jigsaw_jig_t _jjig ;
- jigsaw_null_jig_t( &_jjig ) ;
-
- this->_verb =
- iptr_type(_jjig._verbosity) ;
- this->_nprt =
- iptr_type(_jjig._numthread) ;
-
- this->_seed =
- iptr_type(_jjig._geom_seed) ;
-
- this->_phi1 = real_type(60) ;
- this->_phi2 = real_type(60) ;
-
- this->_eta1 =
- real_type(_jjig._geom_eta1) ;
- this->_eta2 =
- real_type(_jjig._geom_eta2) ;
-
- this->_feat =
- bool_type(_jjig._geom_feat) ;
-
- this->_near =
- real_type(_jjig._init_near) ;
-
- this->_dims =
- iptr_type(_jjig._mesh_dims) ;
- this->_iter =
- iptr_type(_jjig._mesh_iter) ;
-
- this->_rule =
- iptr_type(init_rule()) ;
-
- this->_siz1 =
- real_type(_jjig._mesh_siz1) ;
- this->_siz2 =
- real_type(_jjig._mesh_siz2) ;
- this->_siz3 =
- real_type(_jjig._mesh_siz3) ;
-
- this->_eps1 =
- real_type(_jjig._mesh_eps1) ;
- this->_eps2 =
- real_type(_jjig._mesh_eps2) ;
-
- this->_rad2 =
- real_type(_jjig._mesh_rad2) ;
- this->_rad3 =
- real_type(_jjig._mesh_rad3) ;
-
- this->_off2 =
- real_type(_jjig._mesh_off2) ;
- this->_off3 =
- real_type(_jjig._mesh_off3) ;
-
- this->_snk2 =
- real_type(_jjig._mesh_snk2) ;
- this->_snk3 =
- real_type(_jjig._mesh_snk3) ;
-
- this->_vol3 =
- real_type(_jjig._mesh_vol3) ;
-
- this->_orph =
- bool_type(_jjig._mesh_orph) ;
-
- this->_lock =
- bool_type(_jjig._mesh_lock) ;
-
- this->_top1 =
- bool_type(_jjig._mesh_top1) ;
- this->_top2 =
- bool_type(_jjig._mesh_top2) ;
+ jigsaw_null_jig_t(this) ;
}
/*------------------------------------ "write" access */
__inline_call iptr_type & verb (
)
- { return this->_verb ;
+ { return this->_verbosity ;
}
__inline_call iptr_type & nprt (
)
- { return this->_nprt ;
+ { return this->_numthread ;
}
__inline_call iptr_type & rule (
)
- { return this->_rule ;
+ { return this->_mesh_rule ;
}
__inline_call iptr_type & iter (
)
- { return this->_iter ;
+ { return this->_mesh_iter ;
}
__inline_call iptr_type & seed (
)
- { return this->_seed ;
+ { return this->_geom_seed ;
}
__inline_call real_type & phi1 (
)
- { return this->_phi1 ;
+ { return this->_mesh_phi1 ;
}
__inline_call real_type & phi2 (
)
- { return this->_phi2 ;
+ { return this->_mesh_phi2 ;
}
__inline_call real_type & eta1 (
)
- { return this->_eta1 ;
+ { return this->_geom_eta1 ;
}
__inline_call real_type & eta2 (
)
- { return this->_eta2 ;
+ { return this->_geom_eta2 ;
}
- __inline_call bool_type & feat (
+ __inline_call iptr_type & feat (
)
- { return this->_feat ;
+ { return this->_geom_feat ;
}
__inline_call real_type & near (
)
- { return this->_near ;
+ { return this->_init_near ;
}
__inline_call iptr_type & dims (
)
- { return this->_dims ;
+ { return this->_mesh_dims ;
}
__inline_call real_type & siz1 (
)
- { return this->_siz1 ;
+ { return this->_mesh_siz1 ;
}
__inline_call real_type & siz2 (
)
- { return this->_siz2 ;
+ { return this->_mesh_siz2 ;
}
__inline_call real_type & siz3 (
)
- { return this->_siz3 ;
+ { return this->_mesh_siz3 ;
}
__inline_call real_type & eps1 (
)
- { return this->_eps1 ;
+ { return this->_mesh_eps1 ;
}
__inline_call real_type & eps2 (
)
- { return this->_eps2 ;
+ { return this->_mesh_eps2 ;
}
__inline_call real_type & rad2 (
)
- { return this->_rad2 ;
+ { return this->_mesh_rad2 ;
}
__inline_call real_type & rad3 (
)
- { return this->_rad3 ;
+ { return this->_mesh_rad3 ;
}
__inline_call real_type & off2 (
)
- { return this->_off2 ;
+ { return this->_mesh_off2 ;
}
__inline_call real_type & off3 (
)
- { return this->_off3 ;
+ { return this->_mesh_off3 ;
}
__inline_call real_type & snk2 (
)
- { return this->_snk2 ;
+ { return this->_mesh_snk2 ;
}
__inline_call real_type & snk3 (
)
- { return this->_snk3 ;
+ { return this->_mesh_snk3 ;
}
__inline_call real_type & vol3 (
)
- { return this->_vol3 ;
+ { return this->_mesh_vol3 ;
}
- __inline_call bool_type & orph (
+ __inline_call iptr_type & orph (
)
- { return this->_orph ;
+ { return this->_mesh_orph ;
}
- __inline_call bool_type & lock (
+ __inline_call iptr_type & lock (
)
- { return this->_lock ;
+ { return this->_mesh_lock ;
}
- __inline_call bool_type & top1 (
+ __inline_call iptr_type & top1 (
)
- { return this->_top1 ;
+ { return this->_mesh_top1 ;
}
- __inline_call bool_type & top2 (
+ __inline_call iptr_type & top2 (
)
- { return this->_top2 ;
+ { return this->_mesh_top2 ;
}
/*------------------------------------ "const" access */
__inline_call iptr_type const& verb (
) const
- { return this->_verb ;
+ { return this->_verbosity ;
}
__inline_call iptr_type const& nprt (
) const
- { return this->_nprt ;
+ { return this->_numthread ;
}
__inline_call iptr_type const& rule (
) const
- { return this->_rule ;
+ { return this->_mesh_rule ;
}
__inline_call iptr_type const& iter (
) const
- { return this->_iter ;
+ { return this->_mesh_iter ;
}
__inline_call iptr_type const& seed (
) const
- { return this->_seed ;
+ { return this->_geom_seed ;
}
__inline_call real_type const& phi1 (
) const
- { return this->_phi1 ;
+ { return this->_mesh_phi1 ;
}
__inline_call real_type const& phi2 (
) const
- { return this->_phi2 ;
+ { return this->_mesh_phi2 ;
}
__inline_call real_type const& eta1 (
) const
- { return this->_eta1 ;
+ { return this->_geom_eta1 ;
}
__inline_call real_type const& eta2 (
) const
- { return this->_eta2 ;
+ { return this->_geom_eta2 ;
}
- __inline_call bool_type const& feat (
+ __inline_call iptr_type const& feat (
) const
- { return this->_feat ;
+ { return this->_geom_feat ;
}
__inline_call real_type const& near (
) const
- { return this->_near ;
+ { return this->_init_near ;
}
__inline_call iptr_type const& dims (
) const
- { return this->_dims ;
+ { return this->_mesh_dims ;
}
__inline_call real_type const& siz1 (
) const
- { return this->_siz1 ;
+ { return this->_mesh_siz1 ;
}
__inline_call real_type const& siz2 (
) const
- { return this->_siz2 ;
+ { return this->_mesh_siz2 ;
}
__inline_call real_type const& siz3 (
) const
- { return this->_siz3 ;
+ { return this->_mesh_siz3 ;
}
__inline_call real_type const& eps1 (
) const
- { return this->_eps1 ;
+ { return this->_mesh_eps1 ;
}
__inline_call real_type const& eps2 (
) const
- { return this->_eps2 ;
+ { return this->_mesh_eps2 ;
}
__inline_call real_type const& rad2 (
) const
- { return this->_rad2 ;
+ { return this->_mesh_rad2 ;
}
__inline_call real_type const& rad3 (
) const
- { return this->_rad3 ;
+ { return this->_mesh_rad3 ;
}
__inline_call real_type const& off2 (
) const
- { return this->_off2 ;
+ { return this->_mesh_off2 ;
}
__inline_call real_type const& off3 (
) const
- { return this->_off3 ;
+ { return this->_mesh_off3 ;
}
__inline_call real_type const& snk2 (
) const
- { return this->_snk2 ;
+ { return this->_mesh_snk2 ;
}
__inline_call real_type const& snk3 (
) const
- { return this->_snk3 ;
+ { return this->_mesh_snk3 ;
}
__inline_call real_type const& vol3 (
) const
- { return this->_vol3 ;
+ { return this->_mesh_vol3 ;
}
- __inline_call bool_type const& orph (
+ __inline_call iptr_type const& orph (
) const
- { return this->_orph ;
+ { return this->_mesh_orph ;
}
- __inline_call bool_type const& lock (
+ __inline_call iptr_type const& lock (
) const
- { return this->_lock ;
+ { return this->_mesh_lock ;
}
- __inline_call bool_type const& top1 (
+ __inline_call iptr_type const& top1 (
) const
- { return this->_top1 ;
+ { return this->_mesh_top1 ;
}
- __inline_call bool_type const& top2 (
+ __inline_call iptr_type const& top2 (
) const
- { return this->_top2 ;
+ { return this->_mesh_top2 ;
}
} ;
@@ -494,5 +360,3 @@
# endif // __MESH_PARAMS__
-
-
diff --git a/external/jigsaw/src/libcpp/predicate/bisect_k.hpp b/external/jigsaw/src/libcpp/predicate/bisect_k.hpp
index bb3a730..f3be5fa 100644
--- a/external/jigsaw/src/libcpp/predicate/bisect_k.hpp
+++ b/external/jigsaw/src/libcpp/predicate/bisect_k.hpp
@@ -35,7 +35,7 @@
*
--------------------------------------------------------
*
- * Last updated: 30 Apr., 2020
+ * Last updated: 09 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -127,8 +127,9 @@
+ (_aby * (_acy + _bcy)) ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
@@ -264,8 +265,9 @@
_sgn-= _abw ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
@@ -413,8 +415,9 @@
+ (_abz * (_acz + _bcz)) ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
@@ -569,8 +572,9 @@
_sgn-= _abw ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
@@ -732,8 +736,9 @@
+ (_abq * (_acq + _bcq)) ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
@@ -903,8 +908,9 @@
_sgn-= _abw ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid () ) ;
}
diff --git a/external/jigsaw/src/libcpp/predicate/inball_k.hpp b/external/jigsaw/src/libcpp/predicate/inball_k.hpp
index 3878afb..ba48031 100644
--- a/external/jigsaw/src/libcpp/predicate/inball_k.hpp
+++ b/external/jigsaw/src/libcpp/predicate/inball_k.hpp
@@ -35,7 +35,7 @@
*
--------------------------------------------------------
*
- * Last updated: 11 May., 2024
+ * Last updated: 09 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -168,9 +168,9 @@
)
{
/*--------------- inball2d predicate, "bound" version */
- ia_flt _adx, _ady, _adw ,
- _bdx, _bdy, _bdw ,
- _cdx, _cdy, _cdw ;
+ ia_flt _adx, _ady,
+ _bdx, _bdy,
+ _cdx, _cdy;
ia_flt _ali, _bli, _cli ;
ia_flt _bdxcdy, _cdxbdy ,
_cdxady, _adxcdy ,
@@ -182,15 +182,12 @@
_adx.from_sub(_pa[0], _pd[0]) ; // coord. diff.
_ady.from_sub(_pa[1], _pd[1]) ;
- _adw.from_sub(_pa[2], _pd[2]) ;
_bdx.from_sub(_pb[0], _pd[0]) ;
_bdy.from_sub(_pb[1], _pd[1]) ;
- _bdw.from_sub(_pb[2], _pd[2]) ;
_cdx.from_sub(_pc[0], _pd[0]) ;
_cdy.from_sub(_pc[1], _pd[1]) ;
- _cdw.from_sub(_pc[2], _pd[2]) ;
_ali = sqr (_adx) + sqr (_ady) ; // lifted terms
@@ -211,8 +208,9 @@
+ _cli * (_adxbdy - _bdxady) ;
_OK =
- _d33.lo() >= (REAL_TYPE)0.
- ||_d33.up() <= (REAL_TYPE)0. ;
+ _d33.lo() > (REAL_TYPE)0.
+ ||_d33.up() < (REAL_TYPE)0.
+ ||_d33.lo() == _d33.up() ;
return ( _d33.mid() ) ;
}
@@ -464,8 +462,9 @@
+ _cli * (_adxbdy - _bdxady) ;
_OK =
- _d33.lo() >= (REAL_TYPE)0.
- ||_d33.up() <= (REAL_TYPE)0. ;
+ _d33.lo() > (REAL_TYPE)0.
+ ||_d33.up() < (REAL_TYPE)0.
+ ||_d33.lo() == _d33.up() ;
return ( _d33.mid() ) ;
}
@@ -509,20 +508,17 @@
_cdy = _pc [1] - _pd [1] ;
_cdw = _pc [2] - _pd [2] ;
- _ali = _adx * _adx + _ady * _ady // lifted terms
- - _adw ;
-
- _ALI = std::abs (_ali) ;
-
- _bli = _bdx * _bdx + _bdy * _bdy
- - _bdw ;
+ _ali = _adx * _adx + _ady * _ady ; // lifted terms
+ _ALI = _ali + std::abs (_adw) ;
+ _ali-= _adw ;
- _BLI = std::abs (_bli) ;
+ _bli = _bdx * _bdx + _bdy * _bdy ;
+ _BLI = _bli + std::abs (_bdw) ;
+ _bli-= _bdw ;
- _cli = _cdx * _cdx + _cdy * _cdy
- - _cdw ;
-
- _CLI = std::abs (_cli) ;
+ _cli = _cdx * _cdx + _cdy * _cdy ;
+ _CLI = _cli + std::abs (_cdw) ;
+ _cli-= _cdw ;
_bdxcdy = _bdx * _cdy ; // 2 x 2 minors
_cdxbdy = _cdx * _bdy ;
@@ -871,8 +867,9 @@
+ _bli * _cda - _ali * _bcd ;
_OK =
- _d44.lo() >= (REAL_TYPE)0.
- ||_d44.up() <= (REAL_TYPE)0.;
+ _d44.lo() > (REAL_TYPE)0.
+ ||_d44.up() < (REAL_TYPE)0.
+ ||_d44.lo() == _d44.up();
return ( _d44.mid() ) ;
}
@@ -1379,8 +1376,9 @@
+ _bli * _cda - _ali * _bcd ;
_OK =
- _d44.lo() >= (REAL_TYPE)0.
- ||_d44.up() <= (REAL_TYPE)0.;
+ _d44.lo() > (REAL_TYPE)0.
+ ||_d44.up() < (REAL_TYPE)0.
+ ||_d44.lo() == _d44.up();
return ( _d44.mid() ) ;
}
@@ -1459,24 +1457,24 @@
_DEZ = std::abs (_dez) ;
_ali = _aex * _aex + _aey * _aey // lifted terms
- + _aez * _aez - _aew ;
-
- _ALI = std::abs (_ali) ;
+ + _aez * _aez ;
+ _ALI = _ali + std::abs (_aew) ;
+ _ali-= _aew ;
_bli = _bex * _bex + _bey * _bey
- + _bez * _bez - _bew ;
-
- _BLI = std::abs (_bli) ;
+ + _bez * _bez ;
+ _BLI = _bli + std::abs (_bew) ;
+ _bli-= _bew ;
_cli = _cex * _cex + _cey * _cey
- + _cez * _cez - _cew ;
-
- _CLI = std::abs (_cli) ;
+ + _cez * _cez ;
+ _CLI = _cli + std::abs (_cew) ;
+ _cli-= _cew ;
_dli = _dex * _dex + _dey * _dey
- + _dez * _dez - _dew ;
-
- _DLI = std::abs (_dli) ;
+ + _dez * _dez ;
+ _DLI = _dli + std::abs (_dew) ;
+ _dli-= _dew ;
_aexbey = _aex * _bey ; // 2 x 2 minors
_bexaey = _bex * _aey ;
@@ -2007,30 +2005,34 @@
)
{
/*--------------- inball4d predicate, "bound" version */
- ia_flt _afx, _afy, _afz ,
+ ia_flt _afx, _afy, _afz,
_afq, _ali,
- _bfx, _bfy, _bfz ,
+ _bfx, _bfy, _bfz,
_bfq, _bli,
- _cfx, _cfy, _cfz ,
+ _cfx, _cfy, _cfz,
_cfq, _cli,
- _dfx, _dfy, _dfz ,
+ _dfx, _dfy, _dfz,
_dfq, _dli,
- _efx, _efy, _efz ,
+ _efx, _efy, _efz,
_efq, _eli;
-
- ia_flt _afxbfy, _bfxafy ,
- _afxcfy, _cfxafy ,
- _bfxcfy, _cfxbfy ,
- _cfxdfy, _dfxcfy ,
- _dfxafy, _afxdfy ,
- _bfxdfy, _dfxbfy ;
-
- ia_flt _ab_, _bc_, _cd_, _da_,
- _ac_, _bd_;
-
-
- ia_flt _abc, _bcd, _cda, _dab;
-
+ ia_flt _afxbfy, _bfxafy,
+ _afxcfy, _cfxafy,
+ _afxdfy, _dfxafy,
+ _afxefy, _efxafy,
+ _bfxcfy, _cfxbfy,
+ _bfxdfy, _dfxbfy,
+ _bfxefy, _efxbfy,
+ _cfxdfy, _dfxcfy,
+ _cfxefy, _efxcfy,
+ _dfxefy, _efxdfy;
+ ia_flt _ab_, _ac_, _ad_, _ae_,
+ _bc_, _bd_, _be_, _cd_,
+ _ce_, _de_;
+ ia_flt _abc, _abd, _abe, _acd,
+ _ace, _ade, _bcd, _bce,
+ _bde, _cde;
+ ia_flt _abcd, _abce, _abde, _acde,
+ _bcde;
ia_flt _d55;
@@ -2076,71 +2078,445 @@
_eli = sqr (_efx) + sqr (_efy)
+ sqr (_efz) + sqr (_efq) ;
+ _afxbfy = _afx * _bfy ; // 2 x 2 minors
+ _bfxafy = _bfx * _afy ;
+ _ab_ = _afxbfy - _bfxafy ;
- /*
- _aexbey = _aex * _bey ; // 2 x 2 minors
- _bexaey = _bex * _aey ;
- _ab_ = _aexbey - _bexaey ;
+ _afxcfy = _afx * _cfy ;
+ _cfxafy = _cfx * _afy ;
+ _ac_ = _afxcfy - _cfxafy ;
- _bexcey = _bex * _cey;
- _cexbey = _cex * _bey;
- _bc_ = _bexcey - _cexbey ;
+ _afxdfy = _afx * _dfy ;
+ _dfxafy = _dfx * _afy ;
+ _ad_ = _afxdfy - _dfxafy ;
- _cexdey = _cex * _dey;
- _dexcey = _dex * _cey;
- _cd_ = _cexdey - _dexcey ;
+ _afxefy = _afx * _efy ;
+ _efxafy = _efx * _afy ;
+ _ae_ = _afxefy - _efxafy ;
- _dexaey = _dex * _aey;
- _aexdey = _aex * _dey;
- _da_ = _dexaey - _aexdey ;
+ _bfxcfy = _bfx * _cfy ;
+ _cfxbfy = _cfx * _bfy ;
+ _bc_ = _bfxcfy - _cfxbfy ;
- _aexcey = _aex * _cey;
- _cexaey = _cex * _aey;
- _ac_ = _aexcey - _cexaey ;
+ _bfxdfy = _bfx * _dfy ;
+ _dfxbfy = _dfx * _bfy ;
+ _bd_ = _bfxdfy - _dfxbfy ;
- _bexdey = _bex * _dey;
- _dexbey = _dex * _bey;
- _bd_ = _bexdey - _dexbey ;
+ _bfxefy = _bfx * _efy ;
+ _efxbfy = _efx * _bfy ;
+ _be_ = _bfxefy - _efxbfy ;
+
+ _cfxdfy = _cfx * _dfy ;
+ _dfxcfy = _dfx * _cfy ;
+ _cd_ = _cfxdfy - _dfxcfy ;
+ _cfxefy = _cfx * _efy ;
+ _efxcfy = _efx * _cfy ;
+ _ce_ = _cfxefy - _efxcfy ;
+ _dfxefy = _dfx * _efy ;
+ _efxdfy = _efx * _dfy ;
+ _de_ = _dfxefy - _efxdfy ;
_abc = // 3 x 3 minors
- _aez * _bc_ - _bez * _ac_
- + _cez * _ab_ ;
+ _afz * _bc_ - _bfz * _ac_
+ + _cfz * _ab_ ;
+
+ _abd =
+ _afz * _bd_ - _bfz * _ad_
+ + _dfz * _ab_ ;
+
+ _abe =
+ _afz * _be_ - _bfz * _ae_
+ + _efz * _ab_ ;
+
+ _acd =
+ _afz * _cd_ - _cfz * _ad_
+ + _dfz * _ac_ ;
+
+ _ace =
+ _afz * _ce_ - _cfz * _ae_
+ + _efz * _ac_ ;
+
+ _ade =
+ _afz * _de_ - _dfz * _ae_
+ + _efz * _ad_ ;
_bcd =
- _bez * _cd_ - _cez * _bd_
- + _dez * _bc_ ;
+ _bfz * _cd_ - _cfz * _bd_
+ + _dfz * _bc_ ;
- _cda =
- _cez * _da_ + _dez * _ac_
- + _aez * _cd_ ;
+ _bce =
+ _bfz * _ce_ - _cfz * _be_
+ + _efz * _bc_ ;
- _dab =
- _dez * _ab_ + _aez * _bd_
- + _bez * _da_ ;
+ _bde =
+ _bfz * _de_ - _dfz * _be_
+ + _efz * _bd_ ;
+
+ _cde =
+ _cfz * _de_ - _dfz * _ce_
+ + _efz * _cd_ ;
+
+ _abcd = // 4 x 4 minors
+ _dfq * _abc - _cfq * _abd
+ + _bfq * _acd - _afq * _bcd ;
+ _abce =
+ _efq * _abc - _cfq * _abe
+ + _bfq * _ace - _afq * _bce ;
+ _abde =
+ _efq * _abd - _dfq * _abe
+ + _bfq * _ade - _afq * _bde ;
- _d44 = // 5 x 5 result
- _eli * _abcd
- + _dli * _abce
- - _cli * _deab
- + _bli * _cdea
- - _ali * _bcde ;
- */
+ _acde =
+ _efq * _acd - _dfq * _ace
+ + _cfq * _ade - _afq * _cde ;
+ _bcde =
+ _efq * _bcd - _dfq * _bce
+ + _cfq * _bde - _bfq * _cde ;
+
+ _d55 = // 5 x 5 result
+ _eli * _abcd - _dli * _abce
+ + _cli * _abde - _bli * _acde
+ + _ali * _bcde ;
+
+ /*-------------------- strict sign, or point interval */
_OK =
- _d55.lo() >= (REAL_TYPE)0.
- ||_d55.up() <= (REAL_TYPE)0.;
+ _d55.lo() > (REAL_TYPE)0.
+ ||_d55.up() < (REAL_TYPE)0.
+ ||_d55.lo() == _d55.up() ;
return ( _d55.mid() ) ;
}
+ __normal_call REAL_TYPE inball4d_f (
+ __const_ptr(REAL_TYPE) _pa ,
+ __const_ptr(REAL_TYPE) _pb ,
+ __const_ptr(REAL_TYPE) _pc ,
+ __const_ptr(REAL_TYPE) _pd ,
+ __const_ptr(REAL_TYPE) _pe ,
+ __const_ptr(REAL_TYPE) _pf ,
+ bool_type &_OK
+ )
+ {
+ /*--------------- inball4d predicate, "float" version */
+ REAL_TYPE static const _ER =
+ + 25. * std::pow(mp::_epsilon, 1) ;
+ REAL_TYPE _afx, _afy, _afz,
+ _afq, _ali,
+ _bfx, _bfy, _bfz,
+ _bfq, _bli,
+ _cfx, _cfy, _cfz,
+ _cfq, _cli,
+ _dfx, _dfy, _dfz,
+ _dfq, _dli,
+ _efx, _efy, _efz,
+ _efq, _eli;
+ REAL_TYPE _afxbfy, _bfxafy,
+ _afxcfy, _cfxafy,
+ _afxdfy, _dfxafy,
+ _afxefy, _efxafy,
+ _bfxcfy, _cfxbfy,
+ _bfxdfy, _dfxbfy,
+ _bfxefy, _efxbfy,
+ _cfxdfy, _dfxcfy,
+ _cfxefy, _efxcfy,
+ _dfxefy, _efxdfy;
+ REAL_TYPE _ab_, _ac_, _ad_, _ae_,
+ _bc_, _bd_, _be_, _cd_,
+ _ce_, _de_;
+ REAL_TYPE _abc, _abd, _abe, _acd,
+ _ace, _ade, _bcd, _bce,
+ _bde, _cde;
+ REAL_TYPE _abcd, _abce, _abde, _acde,
+ _bcde;
+
+ REAL_TYPE _AFZ, _BFZ, _CFZ, _DFZ,
+ _EFZ;
+ REAL_TYPE _AFQ, _BFQ, _CFQ, _DFQ,
+ _EFQ;
+ REAL_TYPE _AFXBFY, _BFXAFY,
+ _AFXCFY, _CFXAFY,
+ _AFXDFY, _DFXAFY,
+ _AFXEFY, _EFXAFY,
+ _BFXCFY, _CFXBFY,
+ _BFXDFY, _DFXBFY,
+ _BFXEFY, _EFXBFY,
+ _CFXDFY, _DFXCFY,
+ _CFXEFY, _EFXCFY,
+ _DFXEFY, _EFXDFY;
+ REAL_TYPE _AB_, _AC_, _AD_, _AE_,
+ _BC_, _BD_, _BE_, _CD_,
+ _CE_, _DE_;
+ REAL_TYPE _ABC, _ABD, _ABE, _ACD,
+ _ACE, _ADE, _BCD, _BCE,
+ _BDE, _CDE;
+ REAL_TYPE _ABCD, _ABCE, _ABDE, _ACDE,
+ _BCDE;
+
+ REAL_TYPE _d55, _FT;
+
+ _afx = _pa [0] - _pf [0] ; // coord. diff.
+ _afy = _pa [1] - _pf [1] ;
+ _afz = _pa [2] - _pf [2] ;
+ _afq = _pa [3] - _pf [3] ;
+
+ _AFZ = std::abs (_afz) ;
+ _AFQ = std::abs (_afq) ;
+
+ _bfx = _pb [0] - _pf [0] ;
+ _bfy = _pb [1] - _pf [1] ;
+ _bfz = _pb [2] - _pf [2] ;
+ _bfq = _pb [3] - _pf [3] ;
+
+ _BFZ = std::abs (_bfz) ;
+ _BFQ = std::abs (_bfq) ;
+
+ _cfx = _pc [0] - _pf [0] ;
+ _cfy = _pc [1] - _pf [1] ;
+ _cfz = _pc [2] - _pf [2] ;
+ _cfq = _pc [3] - _pf [3] ;
+
+ _CFZ = std::abs (_cfz) ;
+ _CFQ = std::abs (_cfq) ;
+
+ _dfx = _pd [0] - _pf [0] ;
+ _dfy = _pd [1] - _pf [1] ;
+ _dfz = _pd [2] - _pf [2] ;
+ _dfq = _pd [3] - _pf [3] ;
+
+ _DFZ = std::abs (_dfz) ;
+ _DFQ = std::abs (_dfq) ;
+
+ _efx = _pe [0] - _pf [0] ;
+ _efy = _pe [1] - _pf [1] ;
+ _efz = _pe [2] - _pf [2] ;
+ _efq = _pe [3] - _pf [3] ;
+
+ _EFZ = std::abs (_efz) ;
+ _EFQ = std::abs (_efq) ;
+
+ _ali = _afx * _afx + _afy * _afy // lifted terms
+ + _afz * _afz + _afq * _afq ;
+
+ _bli = _bfx * _bfx + _bfy * _bfy
+ + _bfz * _bfz + _bfq * _bfq ;
+
+ _cli = _cfx * _cfx + _cfy * _cfy
+ + _cfz * _cfz + _cfq * _cfq ;
+
+ _dli = _dfx * _dfx + _dfy * _dfy
+ + _dfz * _dfz + _dfq * _dfq ;
+
+ _eli = _efx * _efx + _efy * _efy
+ + _efz * _efz + _efq * _efq ;
+
+ _afxbfy = _afx * _bfy ; // 2 x 2 minors
+ _bfxafy = _bfx * _afy ;
+ _ab_ = _afxbfy - _bfxafy ;
+
+ _AFXBFY = std::abs (_afxbfy) ;
+ _BFXAFY = std::abs (_bfxafy) ;
+ _AB_ = _AFXBFY + _BFXAFY ;
+
+ _afxcfy = _afx * _cfy ;
+ _cfxafy = _cfx * _afy ;
+ _ac_ = _afxcfy - _cfxafy ;
+
+ _AFXCFY = std::abs (_afxcfy) ;
+ _CFXAFY = std::abs (_cfxafy) ;
+ _AC_ = _AFXCFY + _CFXAFY ;
+
+ _afxdfy = _afx * _dfy ;
+ _dfxafy = _dfx * _afy ;
+ _ad_ = _afxdfy - _dfxafy ;
+
+ _AFXDFY = std::abs (_afxdfy) ;
+ _DFXAFY = std::abs (_dfxafy) ;
+ _AD_ = _AFXDFY + _DFXAFY ;
+
+ _afxefy = _afx * _efy ;
+ _efxafy = _efx * _afy ;
+ _ae_ = _afxefy - _efxafy ;
+
+ _AFXEFY = std::abs (_afxefy) ;
+ _EFXAFY = std::abs (_efxafy) ;
+ _AE_ = _AFXEFY + _EFXAFY ;
+
+ _bfxcfy = _bfx * _cfy ;
+ _cfxbfy = _cfx * _bfy ;
+ _bc_ = _bfxcfy - _cfxbfy ;
+
+ _BFXCFY = std::abs (_bfxcfy) ;
+ _CFXBFY = std::abs (_cfxbfy) ;
+ _BC_ = _BFXCFY + _CFXBFY ;
+
+ _bfxdfy = _bfx * _dfy ;
+ _dfxbfy = _dfx * _bfy ;
+ _bd_ = _bfxdfy - _dfxbfy ;
+
+ _BFXDFY = std::abs (_bfxdfy) ;
+ _DFXBFY = std::abs (_dfxbfy) ;
+ _BD_ = _BFXDFY + _DFXBFY ;
+
+ _bfxefy = _bfx * _efy ;
+ _efxbfy = _efx * _bfy ;
+ _be_ = _bfxefy - _efxbfy ;
+
+ _BFXEFY = std::abs (_bfxefy) ;
+ _EFXBFY = std::abs (_efxbfy) ;
+ _BE_ = _BFXEFY + _EFXBFY ;
+
+ _cfxdfy = _cfx * _dfy ;
+ _dfxcfy = _dfx * _cfy ;
+ _cd_ = _cfxdfy - _dfxcfy ;
+
+ _CFXDFY = std::abs (_cfxdfy) ;
+ _DFXCFY = std::abs (_dfxcfy) ;
+ _CD_ = _CFXDFY + _DFXCFY ;
+
+ _cfxefy = _cfx * _efy ;
+ _efxcfy = _efx * _cfy ;
+ _ce_ = _cfxefy - _efxcfy ;
+
+ _CFXEFY = std::abs (_cfxefy) ;
+ _EFXCFY = std::abs (_efxcfy) ;
+ _CE_ = _CFXEFY + _EFXCFY ;
+
+ _dfxefy = _dfx * _efy ;
+ _efxdfy = _efx * _dfy ;
+ _de_ = _dfxefy - _efxdfy ;
+
+ _DFXEFY = std::abs (_dfxefy) ;
+ _EFXDFY = std::abs (_efxdfy) ;
+ _DE_ = _DFXEFY + _EFXDFY ;
+ _abc = // 3 x 3 minors
+ _afz * _bc_ - _bfz * _ac_
+ + _cfz * _ab_ ;
+ _ABC =
+ _AFZ * _BC_ + _BFZ * _AC_
+ + _CFZ * _AB_ ;
+
+ _abd =
+ _afz * _bd_ - _bfz * _ad_
+ + _dfz * _ab_ ;
+ _ABD =
+ _AFZ * _BD_ + _BFZ * _AD_
+ + _DFZ * _AB_ ;
+
+ _abe =
+ _afz * _be_ - _bfz * _ae_
+ + _efz * _ab_ ;
+ _ABE =
+ _AFZ * _BE_ + _BFZ * _AE_
+ + _EFZ * _AB_ ;
+
+ _acd =
+ _afz * _cd_ - _cfz * _ad_
+ + _dfz * _ac_ ;
+ _ACD =
+ _AFZ * _CD_ + _CFZ * _AD_
+ + _DFZ * _AC_ ;
+
+ _ace =
+ _afz * _ce_ - _cfz * _ae_
+ + _efz * _ac_ ;
+ _ACE =
+ _AFZ * _CE_ + _CFZ * _AE_
+ + _EFZ * _AC_ ;
+
+ _ade =
+ _afz * _de_ - _dfz * _ae_
+ + _efz * _ad_ ;
+ _ADE =
+ _AFZ * _DE_ + _DFZ * _AE_
+ + _EFZ * _AD_ ;
+ _bcd =
+ _bfz * _cd_ - _cfz * _bd_
+ + _dfz * _bc_ ;
+ _BCD =
+ _BFZ * _CD_ + _CFZ * _BD_
+ + _DFZ * _BC_ ;
+
+ _bce =
+ _bfz * _ce_ - _cfz * _be_
+ + _efz * _bc_ ;
+ _BCE =
+ _BFZ * _CE_ + _CFZ * _BE_
+ + _EFZ * _BC_ ;
+
+ _bde =
+ _bfz * _de_ - _dfz * _be_
+ + _efz * _bd_ ;
+ _BDE =
+ _BFZ * _DE_ + _DFZ * _BE_
+ + _EFZ * _BD_ ;
+
+ _cde =
+ _cfz * _de_ - _dfz * _ce_
+ + _efz * _cd_ ;
+ _CDE =
+ _CFZ * _DE_ + _DFZ * _CE_
+ + _EFZ * _CD_ ;
+
+ _abcd = // 4 x 4 minors
+ _dfq * _abc - _cfq * _abd
+ + _bfq * _acd - _afq * _bcd ;
+ _ABCD =
+ _DFQ * _ABC + _CFQ * _ABD
+ + _BFQ * _ACD + _AFQ * _BCD ;
+
+ _abce =
+ _efq * _abc - _cfq * _abe
+ + _bfq * _ace - _afq * _bce ;
+ _ABCE =
+ _EFQ * _ABC + _CFQ * _ABE
+ + _BFQ * _ACE + _AFQ * _BCE ;
+
+ _abde =
+ _efq * _abd - _dfq * _abe
+ + _bfq * _ade - _afq * _bde ;
+ _ABDE =
+ _EFQ * _ABD + _DFQ * _ABE
+ + _BFQ * _ADE + _AFQ * _BDE ;
+
+ _acde =
+ _efq * _acd - _dfq * _ace
+ + _cfq * _ade - _afq * _cde ;
+ _ACDE =
+ _EFQ * _ACD + _DFQ * _ACE
+ + _CFQ * _ADE + _AFQ * _CDE ;
+
+ _bcde =
+ _efq * _bcd - _dfq * _bce
+ + _cfq * _bde - _bfq * _cde ;
+ _BCDE =
+ _EFQ * _BCD + _DFQ * _BCE
+ + _CFQ * _BDE + _BFQ * _CDE ;
+ _FT = // roundoff tol
+ _eli * _ABCD + _dli * _ABCE
+ + _cli * _ABDE + _bli * _ACDE
+ + _ali * _BCDE ;
+
+ _FT *= _ER ;
+
+ _d55 = // 5 x 5 result
+ _eli * _abcd - _dli * _abce
+ + _cli * _abde - _bli * _acde
+ + _ali * _bcde ;
+
+ _OK =
+ _d55 > _FT || _d55 < -_FT ;
+
+ return ( _d55 ) ;
+ }
/*
--------------------------------------------------------
@@ -2581,5 +2957,549 @@
delete _d6full ; return _d66 ;
}
+ __normal_call REAL_TYPE inball4w_i (
+ __const_ptr(REAL_TYPE) _pa ,
+ __const_ptr(REAL_TYPE) _pb ,
+ __const_ptr(REAL_TYPE) _pc ,
+ __const_ptr(REAL_TYPE) _pd ,
+ __const_ptr(REAL_TYPE) _pe ,
+ __const_ptr(REAL_TYPE) _pf ,
+ bool_type &_OK
+ )
+ {
+ /*--------------- inball4w predicate, "bound" version */
+ ia_flt _afx, _afy, _afz,
+ _afq, _afw, _ali,
+ _bfx, _bfy, _bfz,
+ _bfq, _bfw, _bli,
+ _cfx, _cfy, _cfz,
+ _cfq, _cfw, _cli,
+ _dfx, _dfy, _dfz,
+ _dfq, _dfw, _dli,
+ _efx, _efy, _efz,
+ _efq, _efw, _eli;
+ ia_flt _afxbfy, _bfxafy,
+ _afxcfy, _cfxafy,
+ _afxdfy, _dfxafy,
+ _afxefy, _efxafy,
+ _bfxcfy, _cfxbfy,
+ _bfxdfy, _dfxbfy,
+ _bfxefy, _efxbfy,
+ _cfxdfy, _dfxcfy,
+ _cfxefy, _efxcfy,
+ _dfxefy, _efxdfy;
+ ia_flt _ab_, _ac_, _ad_, _ae_,
+ _bc_, _bd_, _be_, _cd_,
+ _ce_, _de_;
+ ia_flt _abc, _abd, _abe, _acd,
+ _ace, _ade, _bcd, _bce,
+ _bde, _cde;
+ ia_flt _abcd, _abce, _abde, _acde,
+ _bcde;
+
+ ia_flt _d55;
+
+ ia_rnd _rnd; // up rounding!
+
+ _afx.from_sub(_pa[0], _pf[0]) ; // coord. diff.
+ _afy.from_sub(_pa[1], _pf[1]) ;
+ _afz.from_sub(_pa[2], _pf[2]) ;
+ _afq.from_sub(_pa[3], _pf[3]) ;
+ _afw.from_sub(_pa[4], _pf[4]) ;
+
+ _bfx.from_sub(_pb[0], _pf[0]) ;
+ _bfy.from_sub(_pb[1], _pf[1]) ;
+ _bfz.from_sub(_pb[2], _pf[2]) ;
+ _bfq.from_sub(_pb[3], _pf[3]) ;
+ _bfw.from_sub(_pb[4], _pf[4]) ;
+
+ _cfx.from_sub(_pc[0], _pf[0]) ;
+ _cfy.from_sub(_pc[1], _pf[1]) ;
+ _cfz.from_sub(_pc[2], _pf[2]) ;
+ _cfq.from_sub(_pc[3], _pf[3]) ;
+ _cfw.from_sub(_pc[4], _pf[4]) ;
+
+ _dfx.from_sub(_pd[0], _pf[0]) ;
+ _dfy.from_sub(_pd[1], _pf[1]) ;
+ _dfz.from_sub(_pd[2], _pf[2]) ;
+ _dfq.from_sub(_pd[3], _pf[3]) ;
+ _dfw.from_sub(_pd[4], _pf[4]) ;
+
+ _efx.from_sub(_pe[0], _pf[0]) ;
+ _efy.from_sub(_pe[1], _pf[1]) ;
+ _efz.from_sub(_pe[2], _pf[2]) ;
+ _efq.from_sub(_pe[3], _pf[3]) ;
+ _efw.from_sub(_pe[4], _pf[4]) ;
+
+ _ali = sqr (_afx) + sqr (_afy) // lifted terms
+ + sqr (_afz) + sqr (_afq) - _afw ;
+
+ _bli = sqr (_bfx) + sqr (_bfy)
+ + sqr (_bfz) + sqr (_bfq) - _bfw ;
+
+ _cli = sqr (_cfx) + sqr (_cfy)
+ + sqr (_cfz) + sqr (_cfq) - _cfw ;
+
+ _dli = sqr (_dfx) + sqr (_dfy)
+ + sqr (_dfz) + sqr (_dfq) - _dfw ;
+
+ _eli = sqr (_efx) + sqr (_efy)
+ + sqr (_efz) + sqr (_efq) - _efw ;
+
+ _afxbfy = _afx * _bfy ; // 2 x 2 minors
+ _bfxafy = _bfx * _afy ;
+ _ab_ = _afxbfy - _bfxafy ;
+
+ _afxcfy = _afx * _cfy ;
+ _cfxafy = _cfx * _afy ;
+ _ac_ = _afxcfy - _cfxafy ;
+
+ _afxdfy = _afx * _dfy ;
+ _dfxafy = _dfx * _afy ;
+ _ad_ = _afxdfy - _dfxafy ;
+
+ _afxefy = _afx * _efy ;
+ _efxafy = _efx * _afy ;
+ _ae_ = _afxefy - _efxafy ;
+
+ _bfxcfy = _bfx * _cfy ;
+ _cfxbfy = _cfx * _bfy ;
+ _bc_ = _bfxcfy - _cfxbfy ;
+
+ _bfxdfy = _bfx * _dfy ;
+ _dfxbfy = _dfx * _bfy ;
+ _bd_ = _bfxdfy - _dfxbfy ;
+
+ _bfxefy = _bfx * _efy ;
+ _efxbfy = _efx * _bfy ;
+ _be_ = _bfxefy - _efxbfy ;
+
+ _cfxdfy = _cfx * _dfy ;
+ _dfxcfy = _dfx * _cfy ;
+ _cd_ = _cfxdfy - _dfxcfy ;
+
+ _cfxefy = _cfx * _efy ;
+ _efxcfy = _efx * _cfy ;
+ _ce_ = _cfxefy - _efxcfy ;
+
+ _dfxefy = _dfx * _efy ;
+ _efxdfy = _efx * _dfy ;
+ _de_ = _dfxefy - _efxdfy ;
+
+ _abc = // 3 x 3 minors
+ _afz * _bc_ - _bfz * _ac_
+ + _cfz * _ab_ ;
+
+ _abd =
+ _afz * _bd_ - _bfz * _ad_
+ + _dfz * _ab_ ;
+
+ _abe =
+ _afz * _be_ - _bfz * _ae_
+ + _efz * _ab_ ;
+
+ _acd =
+ _afz * _cd_ - _cfz * _ad_
+ + _dfz * _ac_ ;
+
+ _ace =
+ _afz * _ce_ - _cfz * _ae_
+ + _efz * _ac_ ;
+
+ _ade =
+ _afz * _de_ - _dfz * _ae_
+ + _efz * _ad_ ;
+
+ _bcd =
+ _bfz * _cd_ - _cfz * _bd_
+ + _dfz * _bc_ ;
+
+ _bce =
+ _bfz * _ce_ - _cfz * _be_
+ + _efz * _bc_ ;
+
+ _bde =
+ _bfz * _de_ - _dfz * _be_
+ + _efz * _bd_ ;
+
+ _cde =
+ _cfz * _de_ - _dfz * _ce_
+ + _efz * _cd_ ;
+
+ _abcd = // 4 x 4 minors
+ _dfq * _abc - _cfq * _abd
+ + _bfq * _acd - _afq * _bcd ;
+
+ _abce =
+ _efq * _abc - _cfq * _abe
+ + _bfq * _ace - _afq * _bce ;
+
+ _abde =
+ _efq * _abd - _dfq * _abe
+ + _bfq * _ade - _afq * _bde ;
+
+ _acde =
+ _efq * _acd - _dfq * _ace
+ + _cfq * _ade - _afq * _cde ;
+
+ _bcde =
+ _efq * _bcd - _dfq * _bce
+ + _cfq * _bde - _bfq * _cde ;
+
+ _d55 = // 5 x 5 result
+ _eli * _abcd - _dli * _abce
+ + _cli * _abde - _bli * _acde
+ + _ali * _bcde ;
+
+ /*-------------------- strict sign, or point interval */
+ _OK =
+ _d55.lo() > (REAL_TYPE)0.
+ ||_d55.up() < (REAL_TYPE)0.
+ ||_d55.lo() == _d55.up() ;
+
+ return ( _d55.mid() ) ;
+ }
+
+ __normal_call REAL_TYPE inball4w_f (
+ __const_ptr(REAL_TYPE) _pa ,
+ __const_ptr(REAL_TYPE) _pb ,
+ __const_ptr(REAL_TYPE) _pc ,
+ __const_ptr(REAL_TYPE) _pd ,
+ __const_ptr(REAL_TYPE) _pe ,
+ __const_ptr(REAL_TYPE) _pf ,
+ bool_type &_OK
+ )
+ {
+ /*--------------- inball4w predicate, "float" version */
+ REAL_TYPE static const _ER =
+ + 26. * std::pow(mp::_epsilon, 1) ;
+
+ REAL_TYPE _afx, _afy, _afz,
+ _afq, _afw, _ali,
+ _bfx, _bfy, _bfz,
+ _bfq, _bfw, _bli,
+ _cfx, _cfy, _cfz,
+ _cfq, _cfw, _cli,
+ _dfx, _dfy, _dfz,
+ _dfq, _dfw, _dli,
+ _efx, _efy, _efz,
+ _efq, _efw, _eli;
+ REAL_TYPE _afxbfy, _bfxafy,
+ _afxcfy, _cfxafy,
+ _afxdfy, _dfxafy,
+ _afxefy, _efxafy,
+ _bfxcfy, _cfxbfy,
+ _bfxdfy, _dfxbfy,
+ _bfxefy, _efxbfy,
+ _cfxdfy, _dfxcfy,
+ _cfxefy, _efxcfy,
+ _dfxefy, _efxdfy;
+ REAL_TYPE _ab_, _ac_, _ad_, _ae_,
+ _bc_, _bd_, _be_, _cd_,
+ _ce_, _de_;
+ REAL_TYPE _abc, _abd, _abe, _acd,
+ _ace, _ade, _bcd, _bce,
+ _bde, _cde;
+ REAL_TYPE _abcd, _abce, _abde, _acde,
+ _bcde;
+
+ REAL_TYPE _AFZ, _BFZ, _CFZ, _DFZ,
+ _EFZ;
+ REAL_TYPE _AFQ, _BFQ, _CFQ, _DFQ,
+ _EFQ;
+ REAL_TYPE _ALI, _BLI, _CLI, _DLI,
+ _ELI;
+ REAL_TYPE _AFXBFY, _BFXAFY,
+ _AFXCFY, _CFXAFY,
+ _AFXDFY, _DFXAFY,
+ _AFXEFY, _EFXAFY,
+ _BFXCFY, _CFXBFY,
+ _BFXDFY, _DFXBFY,
+ _BFXEFY, _EFXBFY,
+ _CFXDFY, _DFXCFY,
+ _CFXEFY, _EFXCFY,
+ _DFXEFY, _EFXDFY;
+ REAL_TYPE _AB_, _AC_, _AD_, _AE_,
+ _BC_, _BD_, _BE_, _CD_,
+ _CE_, _DE_;
+ REAL_TYPE _ABC, _ABD, _ABE, _ACD,
+ _ACE, _ADE, _BCD, _BCE,
+ _BDE, _CDE;
+ REAL_TYPE _ABCD, _ABCE, _ABDE, _ACDE,
+ _BCDE;
+
+ REAL_TYPE _d55, _FT;
+
+ _afx = _pa [0] - _pf [0] ; // coord. diff.
+ _afy = _pa [1] - _pf [1] ;
+ _afz = _pa [2] - _pf [2] ;
+ _afq = _pa [3] - _pf [3] ;
+ _afw = _pa [4] - _pf [4] ;
+
+ _AFZ = std::abs (_afz) ;
+ _AFQ = std::abs (_afq) ;
+
+ _bfx = _pb [0] - _pf [0] ;
+ _bfy = _pb [1] - _pf [1] ;
+ _bfz = _pb [2] - _pf [2] ;
+ _bfq = _pb [3] - _pf [3] ;
+ _bfw = _pb [4] - _pf [4] ;
+
+ _BFZ = std::abs (_bfz) ;
+ _BFQ = std::abs (_bfq) ;
+
+ _cfx = _pc [0] - _pf [0] ;
+ _cfy = _pc [1] - _pf [1] ;
+ _cfz = _pc [2] - _pf [2] ;
+ _cfq = _pc [3] - _pf [3] ;
+ _cfw = _pc [4] - _pf [4] ;
+
+ _CFZ = std::abs (_cfz) ;
+ _CFQ = std::abs (_cfq) ;
+
+ _dfx = _pd [0] - _pf [0] ;
+ _dfy = _pd [1] - _pf [1] ;
+ _dfz = _pd [2] - _pf [2] ;
+ _dfq = _pd [3] - _pf [3] ;
+ _dfw = _pd [4] - _pf [4] ;
+
+ _DFZ = std::abs (_dfz) ;
+ _DFQ = std::abs (_dfq) ;
+
+ _efx = _pe [0] - _pf [0] ;
+ _efy = _pe [1] - _pf [1] ;
+ _efz = _pe [2] - _pf [2] ;
+ _efq = _pe [3] - _pf [3] ;
+ _efw = _pe [4] - _pf [4] ;
+
+ _EFZ = std::abs (_efz) ;
+ _EFQ = std::abs (_efq) ;
+
+ _ali = _afx * _afx + _afy * _afy // lifted terms
+ + _afz * _afz + _afq * _afq ;
+ _ALI = _ali + std::abs (_afw) ;
+ _ali-= _afw ;
+
+ _bli = _bfx * _bfx + _bfy * _bfy
+ + _bfz * _bfz + _bfq * _bfq ;
+ _BLI = _bli + std::abs (_bfw) ;
+ _bli-= _bfw ;
+
+ _cli = _cfx * _cfx + _cfy * _cfy
+ + _cfz * _cfz + _cfq * _cfq ;
+ _CLI = _cli + std::abs (_cfw) ;
+ _cli-= _cfw ;
+
+ _dli = _dfx * _dfx + _dfy * _dfy
+ + _dfz * _dfz + _dfq * _dfq ;
+ _DLI = _dli + std::abs (_dfw) ;
+ _dli-= _dfw ;
+
+ _eli = _efx * _efx + _efy * _efy
+ + _efz * _efz + _efq * _efq ;
+ _ELI = _eli + std::abs (_efw) ;
+ _eli-= _efw ;
+
+ _afxbfy = _afx * _bfy ; // 2 x 2 minors
+ _bfxafy = _bfx * _afy ;
+ _ab_ = _afxbfy - _bfxafy ;
+
+ _AFXBFY = std::abs (_afxbfy) ;
+ _BFXAFY = std::abs (_bfxafy) ;
+ _AB_ = _AFXBFY + _BFXAFY ;
+
+ _afxcfy = _afx * _cfy ;
+ _cfxafy = _cfx * _afy ;
+ _ac_ = _afxcfy - _cfxafy ;
+
+ _AFXCFY = std::abs (_afxcfy) ;
+ _CFXAFY = std::abs (_cfxafy) ;
+ _AC_ = _AFXCFY + _CFXAFY ;
+
+ _afxdfy = _afx * _dfy ;
+ _dfxafy = _dfx * _afy ;
+ _ad_ = _afxdfy - _dfxafy ;
+
+ _AFXDFY = std::abs (_afxdfy) ;
+ _DFXAFY = std::abs (_dfxafy) ;
+ _AD_ = _AFXDFY + _DFXAFY ;
+
+ _afxefy = _afx * _efy ;
+ _efxafy = _efx * _afy ;
+ _ae_ = _afxefy - _efxafy ;
+
+ _AFXEFY = std::abs (_afxefy) ;
+ _EFXAFY = std::abs (_efxafy) ;
+ _AE_ = _AFXEFY + _EFXAFY ;
+
+ _bfxcfy = _bfx * _cfy ;
+ _cfxbfy = _cfx * _bfy ;
+ _bc_ = _bfxcfy - _cfxbfy ;
+
+ _BFXCFY = std::abs (_bfxcfy) ;
+ _CFXBFY = std::abs (_cfxbfy) ;
+ _BC_ = _BFXCFY + _CFXBFY ;
+
+ _bfxdfy = _bfx * _dfy ;
+ _dfxbfy = _dfx * _bfy ;
+ _bd_ = _bfxdfy - _dfxbfy ;
+
+ _BFXDFY = std::abs (_bfxdfy) ;
+ _DFXBFY = std::abs (_dfxbfy) ;
+ _BD_ = _BFXDFY + _DFXBFY ;
+
+ _bfxefy = _bfx * _efy ;
+ _efxbfy = _efx * _bfy ;
+ _be_ = _bfxefy - _efxbfy ;
+
+ _BFXEFY = std::abs (_bfxefy) ;
+ _EFXBFY = std::abs (_efxbfy) ;
+ _BE_ = _BFXEFY + _EFXBFY ;
+
+ _cfxdfy = _cfx * _dfy ;
+ _dfxcfy = _dfx * _cfy ;
+ _cd_ = _cfxdfy - _dfxcfy ;
+
+ _CFXDFY = std::abs (_cfxdfy) ;
+ _DFXCFY = std::abs (_dfxcfy) ;
+ _CD_ = _CFXDFY + _DFXCFY ;
+
+ _cfxefy = _cfx * _efy ;
+ _efxcfy = _efx * _cfy ;
+ _ce_ = _cfxefy - _efxcfy ;
+
+ _CFXEFY = std::abs (_cfxefy) ;
+ _EFXCFY = std::abs (_efxcfy) ;
+ _CE_ = _CFXEFY + _EFXCFY ;
+
+ _dfxefy = _dfx * _efy ;
+ _efxdfy = _efx * _dfy ;
+ _de_ = _dfxefy - _efxdfy ;
+
+ _DFXEFY = std::abs (_dfxefy) ;
+ _EFXDFY = std::abs (_efxdfy) ;
+ _DE_ = _DFXEFY + _EFXDFY ;
+
+ _abc = // 3 x 3 minors
+ _afz * _bc_ - _bfz * _ac_
+ + _cfz * _ab_ ;
+ _ABC =
+ _AFZ * _BC_ + _BFZ * _AC_
+ + _CFZ * _AB_ ;
+
+ _abd =
+ _afz * _bd_ - _bfz * _ad_
+ + _dfz * _ab_ ;
+ _ABD =
+ _AFZ * _BD_ + _BFZ * _AD_
+ + _DFZ * _AB_ ;
+
+ _abe =
+ _afz * _be_ - _bfz * _ae_
+ + _efz * _ab_ ;
+ _ABE =
+ _AFZ * _BE_ + _BFZ * _AE_
+ + _EFZ * _AB_ ;
+
+ _acd =
+ _afz * _cd_ - _cfz * _ad_
+ + _dfz * _ac_ ;
+ _ACD =
+ _AFZ * _CD_ + _CFZ * _AD_
+ + _DFZ * _AC_ ;
+
+ _ace =
+ _afz * _ce_ - _cfz * _ae_
+ + _efz * _ac_ ;
+ _ACE =
+ _AFZ * _CE_ + _CFZ * _AE_
+ + _EFZ * _AC_ ;
+
+ _ade =
+ _afz * _de_ - _dfz * _ae_
+ + _efz * _ad_ ;
+ _ADE =
+ _AFZ * _DE_ + _DFZ * _AE_
+ + _EFZ * _AD_ ;
+
+ _bcd =
+ _bfz * _cd_ - _cfz * _bd_
+ + _dfz * _bc_ ;
+ _BCD =
+ _BFZ * _CD_ + _CFZ * _BD_
+ + _DFZ * _BC_ ;
+
+ _bce =
+ _bfz * _ce_ - _cfz * _be_
+ + _efz * _bc_ ;
+ _BCE =
+ _BFZ * _CE_ + _CFZ * _BE_
+ + _EFZ * _BC_ ;
+
+ _bde =
+ _bfz * _de_ - _dfz * _be_
+ + _efz * _bd_ ;
+ _BDE =
+ _BFZ * _DE_ + _DFZ * _BE_
+ + _EFZ * _BD_ ;
+
+ _cde =
+ _cfz * _de_ - _dfz * _ce_
+ + _efz * _cd_ ;
+ _CDE =
+ _CFZ * _DE_ + _DFZ * _CE_
+ + _EFZ * _CD_ ;
+
+ _abcd = // 4 x 4 minors
+ _dfq * _abc - _cfq * _abd
+ + _bfq * _acd - _afq * _bcd ;
+ _ABCD =
+ _DFQ * _ABC + _CFQ * _ABD
+ + _BFQ * _ACD + _AFQ * _BCD ;
+
+ _abce =
+ _efq * _abc - _cfq * _abe
+ + _bfq * _ace - _afq * _bce ;
+ _ABCE =
+ _EFQ * _ABC + _CFQ * _ABE
+ + _BFQ * _ACE + _AFQ * _BCE ;
+
+ _abde =
+ _efq * _abd - _dfq * _abe
+ + _bfq * _ade - _afq * _bde ;
+ _ABDE =
+ _EFQ * _ABD + _DFQ * _ABE
+ + _BFQ * _ADE + _AFQ * _BDE ;
+
+ _acde =
+ _efq * _acd - _dfq * _ace
+ + _cfq * _ade - _afq * _cde ;
+ _ACDE =
+ _EFQ * _ACD + _DFQ * _ACE
+ + _CFQ * _ADE + _AFQ * _CDE ;
+
+ _bcde =
+ _efq * _bcd - _dfq * _bce
+ + _cfq * _bde - _bfq * _cde ;
+ _BCDE =
+ _EFQ * _BCD + _DFQ * _BCE
+ + _CFQ * _BDE + _BFQ * _CDE ;
+
+ _FT = // roundoff tol
+ _ELI * _ABCD + _DLI * _ABCE
+ + _CLI * _ABDE + _BLI * _ACDE
+ + _ALI * _BCDE ;
+ _FT *= _ER ;
+
+ _d55 = // 5 x 5 result
+ _eli * _abcd - _dli * _abce
+ + _cli * _abde - _bli * _acde
+ + _ali * _bcde ;
+
+ _OK =
+ _d55 > _FT || _d55 < -_FT ;
+
+ return ( _d55 ) ;
+ }
diff --git a/external/jigsaw/src/libcpp/predicate/orient_k.hpp b/external/jigsaw/src/libcpp/predicate/orient_k.hpp
index fe6505d..018cbbc 100644
--- a/external/jigsaw/src/libcpp/predicate/orient_k.hpp
+++ b/external/jigsaw/src/libcpp/predicate/orient_k.hpp
@@ -35,7 +35,7 @@
*
--------------------------------------------------------
*
- * Last updated: 30 Apr., 2020
+ * Last updated: 09 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -127,8 +127,9 @@
_sgn = _acxbcy - _acybcx ; // 2 x 2 result
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- || _sgn.up() <= (REAL_TYPE)0. ;
+ _sgn.lo() > (REAL_TYPE)0.
+ || _sgn.up() < (REAL_TYPE)0.
+ || _sgn.lo() == _sgn.up() ;
return ( _sgn.mid() ) ;
}
@@ -313,8 +314,9 @@
+ _cdz * (_adxbdy - _bdxady);
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- ||_sgn.up() <= (REAL_TYPE)0.;
+ _sgn.lo() > (REAL_TYPE)0.
+ ||_sgn.up() < (REAL_TYPE)0.
+ ||_sgn.lo() == _sgn.up();
return ( _sgn.mid() ) ;
}
@@ -674,8 +676,9 @@
+ _beq * _cda - _aeq * _bcd ;
_OK =
- _sgn.lo() >= (REAL_TYPE)0.
- ||_sgn.up() <= (REAL_TYPE)0.;
+ _sgn.lo() > (REAL_TYPE)0.
+ ||_sgn.up() < (REAL_TYPE)0.
+ ||_sgn.lo() == _sgn.up();
return ( _sgn.mid() ) ;
}
diff --git a/external/jigsaw/src/libcpp/predicate/predicate_k.hpp b/external/jigsaw/src/libcpp/predicate/predicate_k.hpp
index 70fc15c..1a2a47e 100644
--- a/external/jigsaw/src/libcpp/predicate/predicate_k.hpp
+++ b/external/jigsaw/src/libcpp/predicate/predicate_k.hpp
@@ -60,7 +60,7 @@
*
--------------------------------------------------------
*
- * Last updated: 11 May., 2024
+ * Last updated: 14 Nov., 2026
*
* Copyright 2020--
* Darren Engwirda
@@ -75,8 +75,10 @@
# ifndef __PREDICATE_K__
# define __PREDICATE_K__
+# include
+
# define USE_KERNEL_FLTPOINT
-# define USE_KERNEL_INTERVAL
+// define USE_KERNEL_INTERVAL
namespace geompred {
@@ -103,7 +105,7 @@
INBALL4W_f, INBALL4W_i, INBALL4W_e ,
LASTKERNEL } ;
- size_t _nn_calls[LASTKERNEL] = {0} ;
+ std::atomic _nn_calls[LASTKERNEL] = {} ;
# include "orient_k.hpp"
# include "bisect_k.hpp"
@@ -688,7 +690,7 @@
# endif
# ifdef USE_KERNEL_INTERVAL
- _nn_calls[INBALL3D_i] += +1;
+ _nn_calls[INBALL3W_i] += +1;
_rr = inball3w_i( // "bound" kernel
_pa, _pb, _pc, _pd, _pe, _OK
@@ -722,7 +724,6 @@
REAL_TYPE _rr;
bool_type _OK;
- /*
# ifdef USE_KERNEL_FLTPOINT
_nn_calls[INBALL4D_f] += +1;
@@ -743,7 +744,6 @@
if (_OK) return _rr ;
# endif
- */
_nn_calls[INBALL4D_e] += +1;
@@ -765,7 +765,7 @@
__const_ptr(REAL_TYPE) _pf
)
{
- /*------------ inball3w predicate, "filtered" version */
+ /*------------ inball4w predicate, "filtered" version */
if (_pa [ 4] == _pb [ 4] &&
_pb [ 4] == _pc [ 4] &&
_pc [ 4] == _pd [ 4] &&
@@ -781,11 +781,10 @@
REAL_TYPE _rr; // given weights, full kernel
bool_type _OK;
- /*
# ifdef USE_KERNEL_FLTPOINT
_nn_calls[INBALL4W_f] += +1;
- _rr = inball4w_f( // "float" kernal
+ _rr = inball4w_f( // "float" kernel
_pa, _pb, _pc, _pd, _pe, _pf, _OK
) ;
@@ -794,7 +793,7 @@
# endif
# ifdef USE_KERNEL_INTERVAL
- _nn_calls[INBALL4D_i] += +1;
+ _nn_calls[INBALL4W_i] += +1;
_rr = inball4w_i( // "bound" kernel
_pa, _pb, _pc, _pd, _pe, _pf, _OK
@@ -802,7 +801,6 @@
if (_OK) return _rr ;
# endif
- */
_nn_calls[INBALL4W_e] += +1;
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_2.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_2.hpp
index f93a07b..aecd68f 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_2.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_2.hpp
@@ -450,6 +450,9 @@
this->_eset.clear(_alloc) ;
this->_epol.clear() ;
+ this->_etwo.clear(_alloc) ;
+ this->_e2nd.clear() ;
+
this->_tset.clear(_alloc) ;
this->_tpol.clear() ;
}
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_3.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_3.hpp
index 0f5b8d7..c280b13 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_3.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_complex_3.hpp
@@ -519,9 +519,15 @@
this->_eset.clear(_alloc) ;
this->_epol.clear() ;
+ this->_etwo.clear(_alloc) ;
+ this->_e2nd.clear() ;
+
this->_fset.clear(_alloc) ;
this->_fpol.clear() ;
+ this->_ftwo.clear(_alloc) ;
+ this->_f2nd.clear() ;
+
this->_tset.clear(_alloc) ;
this->_tpol.clear() ;
}
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_2.inc b/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_2.inc
index 4695294..b9a9de1 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_2.inc
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 15 Jul., 2021
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -255,7 +255,7 @@
::infinity();
_imap.set_count (
- _iset.count(),
+ _init._mesh.node().count (),
containers::tight_alloc, _null);
real_type _pmid[2] ;
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_3.inc b/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_3.inc
index 367f1f4..ed108aa 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_3.inc
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_create_init_3.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 15 Jul., 2021
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -393,7 +393,7 @@
::infinity();
_imap.set_count (
- _iset.count(),
+ _init._mesh.node().count (),
containers::tight_alloc, _null);
real_type _pmid[3] ;
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_2.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_2.hpp
index e69489b..a1da8fc 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_2.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_2.hpp
@@ -128,9 +128,7 @@
geom_type,
mesh_type > rdel_pred ;
- typedef mesh::mesh_params <
- real_type,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
/*
--------------------------------------------------------
@@ -973,4 +971,3 @@
# endif //__RDEL_MAKE_2__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_3.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_3.hpp
index a45481f..adbd1a2 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_3.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_make_3.hpp
@@ -137,9 +137,7 @@
geom_type,
mesh_type > rdel_pred ;
- typedef mesh::mesh_params <
- real_type,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
/*
--------------------------------------------------------
@@ -1185,4 +1183,3 @@
# endif //__RDEL_MAKE_3__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_2.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_2.hpp
index 9bdfecb..a9ee4b1 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_2.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_2.hpp
@@ -182,9 +182,7 @@
typedef typename
mesh_type::tria_list tria_hash ;
- typedef mesh::mesh_params <
- real_type,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef containers::array <
iptr_type > iptr_list ;
@@ -809,7 +807,8 @@
iptr_type constexpr _jlog_freq = +250 ;
# else
iptr_type _jlog_tens =
- (iptr_type) std::log10(_pass) ;
+ (iptr_type) std::log10(
+ std::max(_pass, iptr_type(+1))) ;
iptr_type _jlog_freq = // logarithmic updates
(+1 * std::max(10000,
@@ -1206,6 +1205,7 @@
}
# ifdef __use_timers
+ _ttoc = _time.now() ;
_tcpu._list_push +=
_tcpu.nano_span(_ttic,_ttoc) ;
# endif//__use_timers
@@ -1470,4 +1470,3 @@
# endif //__RDEL_MESH_2__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_3.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_3.hpp
index c6a9032..fa280c8 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_3.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_mesh_3.hpp
@@ -188,9 +188,7 @@
typedef typename
mesh_type::tria_data tria_data ;
- typedef mesh::mesh_params <
- real_type,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef containers::array <
real_type > real_list ;
@@ -1076,7 +1074,8 @@
iptr_type constexpr _jlog_freq = +250 ;
# else
iptr_type _jlog_tens =
- (iptr_type) std::log10(_pass) ;
+ (iptr_type) std::log10(
+ std::max(_pass, iptr_type(+1))) ;
iptr_type _jlog_freq = // logarithmic updates
(+1 * std::max(10000,
@@ -1921,4 +1920,3 @@
# endif //__RDEL_MESH_3__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp
index c5c4bd6..236fbfe 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp
@@ -118,9 +118,7 @@
typedef typename
mesh_type::iptr_type iptr_type ;
- typedef mesh::mesh_params <
- real_type ,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef mesh::rdel_pred_base_2 <
geom_type ,
@@ -270,4 +268,3 @@
# endif //__RDEL_PRED_DELAUNAY_2__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp
index 392251e..be6122a 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp
@@ -118,9 +118,7 @@
typedef typename
mesh_type::iptr_type iptr_type ;
- typedef mesh::mesh_params <
- real_type ,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef mesh::rdel_pred_base_3 <
geom_type ,
@@ -340,4 +338,3 @@
# endif //__RDEL_PRED_DELAUNAY_3__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp
index 03f4697..e56ca98 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp
@@ -97,7 +97,7 @@
* pp. 125-138
* https://doi.org/10.1006/jcph.1993.1097
*
- * H. Erten, A. Üngör, (2009): "Quality Triangulations
+ * H. Erten, A. �ng�r, (2009): "Quality Triangulations
* with Locally Optimal Steiner Points", SIAM J. Sci.
* Comp., 31, pp. 2103-2130,
* https://doi.org/10.1137/080716748
@@ -135,9 +135,7 @@
typedef typename
mesh_type::iptr_type iptr_type ;
- typedef mesh::mesh_params <
- real_type ,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef mesh::rdel_pred_base_2 <
geom_type ,
@@ -647,4 +645,3 @@
# endif //__RDEL_PRED_DELFRONT_2__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp
index 269400e..1aaee58 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp
@@ -97,7 +97,7 @@
* pp. 125-138
* https://doi.org/10.1006/jcph.1993.1097
*
- * H. Erten, A. Üngör, (2009): "Quality Triangulations
+ * H. Erten, A. �ng�r, (2009): "Quality Triangulations
* with Locally Optimal Steiner Points", SIAM J. Sci.
* Comp., 31, pp. 2103-2130,
* https://doi.org/10.1137/080716748
@@ -135,9 +135,7 @@
typedef typename
mesh_type::iptr_type iptr_type ;
- typedef mesh::mesh_params <
- real_type,
- iptr_type > rdel_opts ;
+ typedef mesh::mesh_params rdel_opts ;
typedef mesh::rdel_pred_base_3 <
geom_type ,
@@ -1108,4 +1106,3 @@
# endif //__RDEL_PRED_DELFRONT_3__
-
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc
index 7bd61d0..022abe0 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 18 Aug., 2021
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -227,7 +227,7 @@
++_tpos )
{
iptr_type _npos;
- for (_npos = +3; _npos-- != +0; )
+ for (_npos = +4; _npos-- != +0; )
{
iptr_type _node =
_mesh._tria.
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc
index b593554..962ba78 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 15 Jul., 2021
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -260,6 +260,9 @@
if(__chkbit(
_opts.rule(),rdel_opts::offT_kind) )
{
+ if ( _kind == rdel_opts::null_kind )
+ return _kind ;
+
/*--------------------- calc. "skinny" off-centre */
_vnrm[2] =
geometry::normalise_2d (_vnrm) ;
diff --git a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc
index 4c0fadc..d668eaa 100644
--- a/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc
+++ b/external/jigsaw/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 21 Apr., 2024
+ * Last updated: 07 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -556,6 +556,9 @@
if(__chkbit(
_opts.rule(),rdel_opts::offT_kind) )
{
+ if ( _kind == rdel_opts::null_kind )
+ return _kind ;
+
/*--------------------- calc. "skinny" off-centre */
_vdir[3] =
geometry::normalise_3d (_vdir) ;
@@ -781,6 +784,9 @@
if(__chkbit(
_opts.rule(),rdel_opts::offT_kind) )
{
+ if ( _kind == rdel_opts::null_kind )
+ return _kind ;
+
/*--------------------- calc. "skinny" off-centre */
_vnrm[3] =
geometry::normalise_3d (_vnrm) ;
diff --git a/external/jigsaw/src/libcpp/tessellate/delaunay_tri_k.hpp b/external/jigsaw/src/libcpp/tessellate/delaunay_tri_k.hpp
index 5079718..a25007e 100644
--- a/external/jigsaw/src/libcpp/tessellate/delaunay_tri_k.hpp
+++ b/external/jigsaw/src/libcpp/tessellate/delaunay_tri_k.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 17 Apr., 2021
+ * Last updated: 06 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -298,13 +298,23 @@
_ipos = _get_node () ;
}
else
- if (( (iptr_type)
- this->_nset.count()) > _iask)
+ if (( (iptr_type)this->_nset.count() ) > _iask)
{
if (node(_iask)->mark() < 0 )
- /*---------------------------- have within old alloc. */
- _ipos = _iask ;
+ {
+ /*---------------------------- remove hint if in free */
+ for (size_t _i = 0;
+ _i < this->_npop.count(); ++_i)
+ if (this->_npop[_i] == _iask)
+ {
+ this->_npop[_i] =
+ this->_npop[this->_npop.count()-1] ;
+ this->_npop._pop_tail();
+ break;
+ }
+ _ipos = _iask;
+ }
else
/*---------------------------- fallback to new alloc. */
_ipos = _get_node () ;
@@ -313,16 +323,12 @@
else
{
/*---------------------------- have within new alloc. */
- _ipos = _iask ;
-
node_type _null ;
_null.mark() =-1;
-
- auto _kind =
- containers::loose_alloc ;
-
_nset.set_count (
- _iask + 1, _kind, _null);
+ _iask + 1, containers::loose_alloc, _null) ;
+
+ _ipos = _iask;
}
this->node(_ipos)->mark() = 0 ;
@@ -371,13 +377,23 @@
_ipos = _get_tria () ;
}
else
- if (( (iptr_type)
- this->_tset.count()) > _iask)
+ if (( (iptr_type)this->_tset.count() ) > _iask)
{
if (tria(_iask)->mark() < 0 )
- /*---------------------------- have within old alloc. */
- _ipos = _iask ;
+ {
+ /*---------------------------- remove hint if in free */
+ for (size_t _i = 0;
+ _i < this->_tpop.count(); ++_i)
+ if (this->_tpop[_i] == _iask)
+ {
+ this->_tpop[_i] =
+ this->_tpop[this->_tpop.count()-1] ;
+ this->_tpop._pop_tail();
+ break;
+ }
+ _ipos = _iask;
+ }
else
/*---------------------------- fallback to new alloc. */
_ipos = _get_tria () ;
@@ -386,16 +402,12 @@
else
{
/*---------------------------- have within new alloc. */
- _ipos = _iask ;
-
tria_type _null ;
_null.mark() =-1;
-
- auto _kind =
- containers::loose_alloc ;
-
_tset.set_count (
- _iask + 1, _kind, _null);
+ _iask + 1, containers::loose_alloc, _null) ;
+
+ _ipos = _iask;
}
this->tria(_ipos)->mark() = 0 ;
@@ -562,14 +574,13 @@
)
{
/*-------------------------------- de-alloc. existing */
- this->_nset.clear() ;
- this->_tset.clear() ;
+ this->clear() ;
/*-------------------------------- scale initial tria */
real_type static constexpr _scal =
(real_type)tria_pred::geom_dims ;
- real_type _pmid[real_dims] = {.0};
+ real_type _pmid[real_dims] ;
real_type _pdel = (real_type)+.0 ;
for (auto _idim = tria_pred::geom_dims + 0 ;
_idim-- != + 0 ; )
@@ -671,7 +682,7 @@
{
this->_work.clear();
/*------------------------------- find enclosing tria */
- if (walk_mesh_node(_ppos, _elem, _hint))
+ if (walk_tria_near(_ppos, _elem, _hint))
{
/*---------------------------------- bfs about cavity */
typename tria_pred::
@@ -789,8 +800,11 @@
return ( false ) ;
}
-
-
+ /*
+ --------------------------------------------------------
+ * UPDATE: re-evaluate criteria about a point.
+ --------------------------------------------------------
+ */
__inline_call bool_type update (
__const_ptr(real_type) _ppos,
diff --git a/external/jigsaw/src/libcpp/textutil.hpp b/external/jigsaw/src/libcpp/textutil.hpp
index eb1e1c2..2d73916 100644
--- a/external/jigsaw/src/libcpp/textutil.hpp
+++ b/external/jigsaw/src/libcpp/textutil.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 07 Jul., 2021
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -47,6 +47,8 @@
# pragma once
+# include
+
# ifndef __TEXTUTIL__
# define __TEXTUTIL__
@@ -83,22 +85,20 @@
std::string const&_line
)
{
- typename std::string::size_type _pos1 =
- _line.find_first_not_of(" \n\r\t") ;
+ std::string::size_type _head = +0 ;
+ std::string::size_type _tail = _line.size() ;
- typename std::string::size_type _pos2 =
- _line. find_last_not_of(" \n\r\t") ;
+ while (_head < _tail &&
+ std::isspace(
+ (unsigned char)_line[_head + 0]))
+ ++ _head ;
- if (_pos1 != std::string::npos &&
- _pos2 != std::string::npos )
- {
- return _line.substr(
- _pos1, _pos2-_pos1 + 1 );
- }
- else
- {
- return ( std::string() ) ;
- }
+ while (_tail > _head &&
+ std::isspace(
+ (unsigned char)_line[_tail - 1]))
+ -- _tail ;
+
+ return _line.substr(_head, _tail - _head) ;
}
/*
@@ -249,5 +249,3 @@
# endif //__TEXTUTIL__
-
-
diff --git a/external/jigsaw/src/liblib/init_jig_t.hpp b/external/jigsaw/src/liblib/init_jig_t.hpp
index fc9e2ae..b6053fa 100644
--- a/external/jigsaw/src/liblib/init_jig_t.hpp
+++ b/external/jigsaw/src/liblib/init_jig_t.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 26 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -85,6 +85,9 @@
_jcfg->_geom_eta1 = (real_t) +45.0 ;
_jcfg->_geom_eta2 = (real_t) +45.0 ;
+ _jcfg->_mesh_phi1 = (real_t) +60.0 ;
+ _jcfg->_mesh_phi2 = (real_t) +60.0 ;
+
/*------------------------------------- INIT keywords */
_jcfg->_init_near = (real_t) +1.E-8;
@@ -99,6 +102,12 @@
_jcfg->_mesh_iter = (indx_t)
std::numeric_limits< indx_t >::max() ;
+ _jcfg->_mesh_rule = (indx_t)(
+ (1 << JIGSAW_MESH_RULE_OFFH) |
+ (1 << JIGSAW_MESH_RULE_OFFC) |
+ (1 << JIGSAW_MESH_RULE_OFFT) |
+ (1 << JIGSAW_MESH_RULE_SINK)) ;
+
_jcfg->_mesh_orph = (indx_t) +1 ;
_jcfg->_mesh_lock = (indx_t) +0 ;
diff --git a/external/jigsaw/src/liblib/init_msh_t.hpp b/external/jigsaw/src/liblib/init_msh_t.hpp
index acbda4c..c6fd234 100644
--- a/external/jigsaw/src/liblib/init_msh_t.hpp
+++ b/external/jigsaw/src/liblib/init_msh_t.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 08 Feb., 2021
+ * Last updated: 06 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -149,6 +149,9 @@
jigsaw_free_vert3(&_mesh->_vert3);
jigsaw_free_reals(&_mesh->_power);
+ jigsaw_free_vert2(&_mesh->_seed2);
+ jigsaw_free_vert3(&_mesh->_seed3);
+
jigsaw_free_reals(&_mesh->_radii);
jigsaw_free_edge2(&_mesh->_edge2);
diff --git a/external/jigsaw/src/liblib/load_jig_t.hpp b/external/jigsaw/src/liblib/load_jig_t.hpp
index de7d300..105e547 100644
--- a/external/jigsaw/src/liblib/load_jig_t.hpp
+++ b/external/jigsaw/src/liblib/load_jig_t.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 26 Jul., 2025
+ * Last updated: 11 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -58,7 +58,7 @@
# ifdef __lib_jigsaw
-# include "../jig_read.hpp"
+# include "../parser/jig_read.hpp"
indx_t jigsaw_load_jig_t ( // load jig_t
char *_fchr,
@@ -108,6 +108,20 @@
this->
_jjig->_geom_feat = _feat;
}
+ __normal_call void_type push_geom_phi1 (
+ double _phi1
+ )
+ {
+ this->
+ _jjig->_mesh_phi1 = _phi1;
+ }
+ __normal_call void_type push_geom_phi2 (
+ double _phi2
+ )
+ {
+ this->
+ _jjig->_mesh_phi2 = _phi2;
+ }
__normal_call void_type push_geom_eta1 (
double _eta1
)
@@ -187,6 +201,13 @@
this->
_jjig->_mesh_iter = _iter;
}
+ __normal_call void_type push_mesh_rule (
+ std::int32_t _rule
+ )
+ {
+ this->
+ _jjig->_mesh_rule = _rule;
+ }
__normal_call void_type push_mesh_siz1 (
double _siz1
)
diff --git a/external/jigsaw/src/liblib/load_msh_t.hpp b/external/jigsaw/src/liblib/load_msh_t.hpp
index 027d7f8..aa41fbf 100644
--- a/external/jigsaw/src/liblib/load_msh_t.hpp
+++ b/external/jigsaw/src/liblib/load_msh_t.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 08 Feb., 2021
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -58,15 +58,14 @@
# ifdef __lib_jigsaw
-# include "../msh_read.hpp"
+# include "../parser/msh_read.hpp"
indx_t jigsaw_load_msh_t ( // load msh_t
char *_fchr,
jigsaw_msh_t *_jmsh
)
{
- class msht_reader:
- public jmsh_reader_base
+ class msht_reader: public jmsh_reader_base
{
public :
jigsaw_msh_t *_jmsh ;
@@ -351,8 +350,8 @@
}
/*-------------------------------- open COORD section */
__normal_call void_type open_coord (
- std:: size_t _idim,
- std:: size_t _nrow
+ std:: size_t _nrow,
+ std:: size_t _idim
)
{
if (_idim == +1)
@@ -625,35 +624,13 @@
try
{
- jmsh_reader _read ;
- std::ifstream _file ;
-
- std::string _fstr(_fchr) ;
- std::string _path ;
- std::string _name ;
- std::string _fext ;
- file_part(_fstr,
- _path, _name, _fext) ;
-
- _file.open(
- _fstr, std::ifstream:: in) ;
-
- if (_file.is_open() )
- {
- _read.read_file (
- _file, msht_reader(_jmsh)) ;
- }
- else
- {
- _errv = __file_not_located ;
- }
+ containers::array _errs ;
+ _errv = read_msh_file(
+ std::string(_fchr),
+ msht_reader(_jmsh), _errs) ;
- _file.close ();
-
- if(!_read._errs.empty())
- {
+ if (!_errs.empty() && _errv == __no_error)
_errv = __invalid_argument ;
- }
}
catch (...)
{
@@ -668,5 +645,3 @@
# endif
-
-
diff --git a/external/jigsaw/src/liblib/save_jig_t.hpp b/external/jigsaw/src/liblib/save_jig_t.hpp
index 5e40fd5..739e1ee 100644
--- a/external/jigsaw/src/liblib/save_jig_t.hpp
+++ b/external/jigsaw/src/liblib/save_jig_t.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 26 Jul., 2025
+ * Last updated: 13 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -81,6 +81,9 @@
if (_file.is_open())
{
+ _file << std::setprecision(std::
+ numeric_limits::max_digits10) ;
+
_file << "# " << _name << ".jig"
<< "; created by " ;
_file << __JGSWVSTR "\n" ;
@@ -97,7 +100,13 @@
_jcfg->_geom_seed << "\n" ;
_file << "GEOM_FEAT = " <<
- _jcfg->_geom_feat << "\n" ;
+ (_jcfg->_geom_feat ? "TRUE" : "FALSE")
+ << "\n" ;
+
+ _file << "GEOM_PHI1 = " <<
+ _jcfg->_mesh_phi1 << "\n" ;
+ _file << "GEOM_PHI2 = " <<
+ _jcfg->_mesh_phi2 << "\n" ;
_file << "GEOM_ETA1 = " <<
_jcfg->_geom_eta1 << "\n" ;
@@ -119,9 +128,9 @@
<< "ABSOLUTE\n" ;
_file << "HFUN_HMIN = " <<
- _jcfg->_hfun_hmax << "\n" ;
- _file << "HFUN_HMAX = " <<
_jcfg->_hfun_hmin << "\n" ;
+ _file << "HFUN_HMAX = " <<
+ _jcfg->_hfun_hmax << "\n" ;
/*--------------------------------- BNDS keywords */
if (_jcfg->_bnds_kern ==
@@ -152,6 +161,9 @@
_file << "MESH_ITER = " <<
_jcfg->_mesh_iter << "\n" ;
+ _file << "MESH_RULE = " <<
+ _jcfg->_mesh_rule << "\n" ;
+
_file << "MESH_SIZ1 = " <<
_jcfg->_mesh_siz1 << "\n" ;
_file << "MESH_SIZ2 = " <<
@@ -160,15 +172,19 @@
_jcfg->_mesh_siz3 << "\n" ;
_file << "MESH_ORPH = " <<
- _jcfg->_mesh_orph << "\n" ;
+ (_jcfg->_mesh_orph ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "MESH_LOCK = " <<
- _jcfg->_mesh_lock << "\n" ;
+ (_jcfg->_mesh_lock ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "MESH_TOP1 = " <<
- _jcfg->_mesh_top1 << "\n" ;
+ (_jcfg->_mesh_top1 ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "MESH_TOP2 = " <<
- _jcfg->_mesh_top2 << "\n" ;
+ (_jcfg->_mesh_top2 ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "MESH_RAD2 = " <<
_jcfg->_mesh_rad2 << "\n" ;
@@ -239,13 +255,17 @@
_jcfg->_optm_wmax << "\n" ;
_file << "OPTM_TRIA = " <<
- _jcfg->_optm_tria << "\n" ;
+ (_jcfg->_optm_tria ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "OPTM_DUAL = " <<
- _jcfg->_optm_dual << "\n" ;
+ (_jcfg->_optm_dual ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "OPTM_DIV_ = " <<
- _jcfg->_optm_div_ << "\n" ;
+ (_jcfg->_optm_div_ ? "TRUE" : "FALSE")
+ << "\n" ;
_file << "OPTM_ZIP_ = " <<
- _jcfg->_optm_zip_ << "\n" ;
+ (_jcfg->_optm_zip_ ? "TRUE" : "FALSE")
+ << "\n" ;
}
else
{
diff --git a/external/jigsaw/src/msh_save.inc b/external/jigsaw/src/msh_save.inc
index 3d840c2..7fc067f 100644
--- a/external/jigsaw/src/msh_save.inc
+++ b/external/jigsaw/src/msh_save.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 05 Dec, 2024
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -844,6 +844,15 @@
return __file_not_created;
}
+ if ((_retv = nc_close(_ncid)))
+ {
+ return __unknown_error;
+ }
+
+ int _ndim = (int)_mesh._ndim ;
+ ncutil::put_att(
+ _jcfg._mesh_file, "NDIMS", NC_INT, _ndim);
+
if (_mesh._ndim == +2 &&
_mesh._kind ==
jmsh_kind::euclidean_mesh)
@@ -1263,7 +1272,7 @@
_mmsh._quad4._data[_fout]. \
_node[2] = _nmap[_iter->node(2)] ; \
_mmsh._quad4._data[_fout]. \
- _node[2] = _nmap[_iter->node(2)] ; \
+ _node[3] = _nmap[_iter->node(3)] ; \
\
_mmsh._quad4. \
_data[_fout]._itag = _iter->itag() ; \
@@ -1618,5 +1627,3 @@
return ( _errv ) ;
}
-
-
diff --git a/external/jigsaw/src/netcdf/ncutil.h b/external/jigsaw/src/netcdf/ncutil.h
index 2749f96..0e5333e 100644
--- a/external/jigsaw/src/netcdf/ncutil.h
+++ b/external/jigsaw/src/netcdf/ncutil.h
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 20 May, 2022
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2022--
+ * Copyright 2022-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -48,6 +48,7 @@
# include
# include
# include
+# include
# include "netcdf.h"
@@ -134,7 +135,7 @@
*/
template <
- typename data_type
+ typename data_type
>
__inline_call void get_att (
std::string const&_file, // name of file
@@ -150,8 +151,35 @@
"Can't open " + _file +
" for read.: " + std::to_string(_retv));
- if ((_retv = nc_get_att(_ncid,
- _vtag, _name.c_str (), (void *) _vals)))
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_att_double(
+ _ncid, _vtag, _name.c_str(), _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_att_float(
+ _ncid, _vtag, _name.c_str(), _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_att_long(
+ _ncid, _vtag, _name.c_str(), _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_att_int(
+ _ncid, _vtag, _name.c_str(), _vals);
+ }
+ else
+ {
+ static_assert(std::is_same_v,
+ "ncutil::get_att: type not supported");
+ }
+ if (_retv != 0)
{
nc_close(_ncid) ;
throw std::invalid_argument(
@@ -206,7 +234,7 @@
}
template <
- typename data_type
+ typename data_type
>
__inline_call void put_att (
std::string const&_file, // name of file
@@ -269,7 +297,7 @@
}
template <
- typename data_type
+ typename data_type
>
__inline_call void put_att (
std::string const&_file, // name of file
@@ -368,7 +396,7 @@
}
template <
- typename data_type
+ typename data_type
>
__inline_call void get_var (
std::string const&_file, // name of file
@@ -391,7 +419,31 @@
_name + " : " + std::to_string(_retv));
}
- if ((_retv = nc_get_var(_ncid, _vtag, (void *) _vals)))
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_var_double(_ncid, _vtag, _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_var_float(_ncid, _vtag, _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_var_long(_ncid, _vtag, _vals);
+ }
+ else
+ if constexpr (std::is_same_v)
+ {
+ _retv = nc_get_var_int(_ncid, _vtag, _vals);
+ }
+ else
+ {
+ static_assert(std::is_same_v,
+ "ncutil::get_var: type not supported");
+ }
+ if (_retv != 0)
{
nc_close(_ncid) ;
throw std::invalid_argument(
@@ -405,8 +457,163 @@
_file + " close: " + std::to_string(_retv));
}
+ __inline_call bool has_var (
+ std::string const&_file, // name of file
+ std::string const&_name // name of variable
+ )
+ {
+ int _retv, _ncid, _vtag;
+
+ if ((_retv = nc_open(_file.c_str(), NC_NOWRITE, &_ncid)))
+ throw std::invalid_argument(
+ "Can't open " + _file +
+ " for read.: " + std::to_string(_retv));
+
+ _retv = nc_inq_varid(_ncid, _name.c_str(), &_vtag);
+
+ int _cerr = nc_close(_ncid);
+ if (_cerr)
+ throw std::invalid_argument(
+ "Error handling " +
+ _file + " close: " + std::to_string(_cerr));
+ if (_retv == NC_ENOTVAR)
+ return false;
+ if (_retv)
+ throw std::invalid_argument(
+ "Error checking variable " +
+ _name + ": " + std::to_string(_retv));
+
+ return true;
+ }
+
+ __inline_call bool has_att (
+ std::string const&_file, // name of file
+ std::string const&_name, // name of variable
+ int _vtag = NC_GLOBAL
+ )
+ {
+ int _retv, _ncid, _atag;
+
+ if ((_retv = nc_open(_file.c_str(), NC_NOWRITE, &_ncid)))
+ throw std::invalid_argument(
+ "Can't open " + _file +
+ " for read.: " + std::to_string(_retv));
+
+ _retv = nc_inq_attid(
+ _ncid, _vtag, _name.c_str(), &_atag);
+
+ int _cerr = nc_close(_ncid);
+ if (_cerr)
+ throw std::invalid_argument(
+ "Error handling " +
+ _file + " close: " + std::to_string(_cerr));
+ if (_retv == NC_ENOTATT)
+ return false;
+ if (_retv)
+ throw std::invalid_argument(
+ "Error checking attribute " +
+ _name + ": " + std::to_string(_retv));
+
+ return true;
+ }
+
+ __inline_call void get_att_len (
+ std::string const&_file, // name of file
+ std::string const&_name, // name of variable
+ size_t &_alen, // length assigned to att
+ int _vtag = NC_GLOBAL
+ )
+ {
+ int _retv, _ncid;
+
+ if ((_retv = nc_open(_file.c_str(), NC_NOWRITE, &_ncid)))
+ throw std::invalid_argument(
+ "Can't open " + _file +
+ " for read.: " + std::to_string(_retv));
+
+ if ((_retv = nc_inq_attlen(
+ _ncid, _vtag, _name.c_str(), &_alen)))
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Error getting attribute " +
+ _name + ": " + std::to_string(_retv));
+ }
+
+ if ((_retv = nc_close(_ncid)))
+ throw std::invalid_argument(
+ "Error handling " +
+ _file + " close: " + std::to_string(_retv));
+ }
+
+ __inline_call void get_var_len (
+ std::string const&_file, // name of file
+ std::string const&_name, // name of variable
+ int &_ndim, // number of dims in variable
+ size_t *_vlen, // array of lengths
+ size_t _vmax // max size of vlen
+ )
+ {
+ int _retv, _ncid, _vtag;
+
+ if ((_retv = nc_open(_file.c_str(), NC_NOWRITE, &_ncid)))
+ throw std::invalid_argument(
+ "Can't open " + _file +
+ " for read.: " + std::to_string(_retv));
+
+ if ((_retv = nc_inq_varid(
+ _ncid, _name.c_str(), &_vtag)))
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Error getting variable " +
+ _name + ": " + std::to_string(_retv));
+ }
+
+ if ((_retv = nc_inq_varndims(_ncid, _vtag, &_ndim)))
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Error getting variable dimensions " +
+ _name + ": " + std::to_string(_retv));
+ }
+
+ if (_ndim < 0 || (size_t)_ndim > _vmax)
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Too many dimensions for variable " + _name);
+ }
+
+ int _dtag[NC_MAX_VAR_DIMS];
+ if ((_retv = nc_inq_vardimid(_ncid, _vtag, _dtag)))
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Error getting variable dimensions " +
+ _name + ": " + std::to_string(_retv));
+ }
+
+ for (int _idim = 0; _idim < _ndim; ++_idim)
+ {
+ if ((_retv = nc_inq_dimlen(
+ _ncid, _dtag[_idim], &_vlen[_idim])))
+ {
+ nc_close(_ncid);
+ throw std::invalid_argument(
+ "Error getting variable dimensions " +
+ _name + ": " + std::to_string(_retv));
+ }
+ }
+
+ if ((_retv = nc_close(_ncid)))
+ throw std::invalid_argument(
+ "Error handling " +
+ _file + " close: " + std::to_string(_retv));
+ }
+
template <
- typename data_type
+ typename data_type
>
__inline_call void put_var (
std::string const&_file, // name of file
@@ -514,4 +721,3 @@
# endif //__NCUTIL__
-
diff --git a/external/jigsaw/src/jig_read.hpp b/external/jigsaw/src/parser/jig_read.hpp
similarity index 99%
rename from external/jigsaw/src/jig_read.hpp
rename to external/jigsaw/src/parser/jig_read.hpp
index a14ccd6..da260f6 100644
--- a/external/jigsaw/src/jig_read.hpp
+++ b/external/jigsaw/src/parser/jig_read.hpp
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 27 Jul., 2025
+ * Last updated: 13 Nov., 2026
*
- * Copyright 2013-2025
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -495,7 +495,7 @@
__putFILE(push_init_file, _stok) ;
}
else
- if (_stok[0] == "INIT-NEAR")
+ if (_stok[0] == "INIT_NEAR")
{
__putREAL(push_init_near, _stok) ;
}
diff --git a/external/jigsaw/src/parser/msh_read.hpp b/external/jigsaw/src/parser/msh_read.hpp
new file mode 100644
index 0000000..9a15f77
--- /dev/null
+++ b/external/jigsaw/src/parser/msh_read.hpp
@@ -0,0 +1,255 @@
+
+ /*
+ --------------------------------------------------------
+ * MSH-READ: parse *.MSH file into mesh data.
+ --------------------------------------------------------
+ *
+ * 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 THE CONTRIBUTORS warrant
+ * this code in any way whatsoever. This code is
+ * provided "as-is" to be used at your own risk.
+ *
+ * THE CONTRIBUTORS include:
+ * (a) The University of Sydney
+ * (b) The Massachusetts Institute of Technology
+ * (c) Columbia University
+ * (d) The National Aeronautics & Space Administration
+ * (e) Los Alamos National Laboratory
+ *
+ --------------------------------------------------------
+ *
+ * Last updated: 12 Nov., 2026
+ *
+ * Copyright 2013-2026
+ * Darren Engwirda
+ * d.engwirda@gmail.com
+ * https://github.com/dengwirda/
+ *
+ --------------------------------------------------------
+ */
+
+# pragma once
+
+# ifndef __MSH_READ__
+# define __MSH_READ__
+
+ class jmsh_reader_base
+ {
+/*------------------------ inherit from base to read file */
+ public :
+ __normal_call void_type initialise() {}
+ __normal_call void_type postscript() {}
+ __normal_call void_type push_mshid (
+ std::int32_t /*_ftag*/,
+ jmsh_kind::enum_data /*_kind*/
+ ) { }
+ __normal_call void_type push_ndims (
+ std:: size_t /*_ndim*/
+ ) { }
+ __normal_call void_type push_radii (
+ double * /*_erad*/
+ ) { }
+ __normal_call void_type open_point (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_point (
+ std:: size_t /*_irow*/,
+ double * /*_pval*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_seeds (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_seeds (
+ std:: size_t /*_irow*/,
+ double * /*_pval*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_power (
+ std:: size_t /*_nrow*/,
+ std:: size_t /*_npwr*/
+ ) { }
+ __normal_call void_type push_power (
+ std:: size_t /*_irow*/,
+ double * /*_xpwr*/
+ ) { }
+ __normal_call void_type open_edge2 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_edge2 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_tria3 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_tria3 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_quad4 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_quad4 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_tria4 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_tria4 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_hexa8 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_hexa8 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_wedg6 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_wedg6 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_pyra5 (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_pyra5 (
+ std:: size_t /*_irow*/,
+ std::int32_t* /*_node*/,
+ std::int32_t /*_itag*/
+ ) { }
+ __normal_call void_type open_value (
+ std:: size_t /*_nrow*/,
+ std:: size_t /*_nval*/
+ ) { }
+ __normal_call void_type push_value (
+ std:: size_t /*_irow*/,
+ float * /*_vdat*/
+ ) { }
+ __normal_call void_type open_slope (
+ std:: size_t /*_nrow*/,
+ std:: size_t /*_nval*/
+ ) { }
+ __normal_call void_type push_slope (
+ std:: size_t /*_irow*/,
+ float * /*_vdat*/
+ ) { }
+ __normal_call void_type open_bound (
+ std:: size_t /*_nrow*/
+ ) { }
+ __normal_call void_type push_bound (
+ std:: size_t /*_irow*/,
+ std::int32_t /*_itag*/,
+ std::int32_t /*_inum*/,
+ std::int32_t /*_kind*/
+ ) { }
+ __normal_call void_type open_coord (
+ std:: size_t /*_ndim*/,
+ std:: size_t /*_idim*/
+ ) { }
+ __normal_call void_type push_coord (
+ std:: size_t /*_idim*/,
+ std:: size_t /*_irow*/,
+ double /*_ppos*/
+ ) { }
+ } ;
+
+# include "msh_read_txt.hpp"
+# include "msh_read_api.hpp"
+# include "msh_read_nc_.hpp"
+
+ template <
+ typename dest_type
+ >
+ __normal_call iptr_type read_msh_file (
+ std::string const&_file,
+ dest_type &&_dest,
+ containers::array &_errs
+ )
+ {
+ std::string _path, _name, _fext ;
+ file_part(_file, _path, _name, _fext) ;
+ std::transform(_fext.begin() ,
+ _fext. end() ,
+ _fext.begin() ,
+ [](unsigned char c){ return
+ (unsigned char)::tolower(c); } ) ;
+
+ if (_fext == "msh")
+ {
+ auto _kind = std::ifstream::in;
+ std::ifstream _input(_file, _kind) ;
+ if (!_input.is_open())
+ return __file_not_located ;
+
+ msh_reader_txt _read ;
+ _read.read_file(_input, _dest);
+ for (auto _iter = _read._errs.head() ;
+ _iter!= _read._errs.tend() ;
+ ++_iter )
+ _errs.push_tail(*_iter) ;
+ }
+ else
+ if (_fext == "nc")
+ {
+ auto _kind = std::ifstream::in |
+ std::ifstream::binary ;
+ std::ifstream _input(_file, _kind) ;
+ if (!_input.is_open())
+ return __file_not_located ;
+
+# ifdef __use_netcdf
+ msh_reader_nc_ _read ;
+ _read.read_file( _file, _dest);
+ for (auto _iter = _read._errs.head() ;
+ _iter!= _read._errs.tend() ;
+ ++_iter )
+ _errs.push_tail(*_iter) ;
+# else
+ _errs.push_tail(
+ "NetCDF support is not available") ;
+ return __netcdf_not_available ;
+# endif
+ }
+ else
+ {
+ _errs.push_tail(
+ "Unsupported file type: " + _fext) ;
+ }
+
+ return _errs.empty() ? __no_error
+ : __invalid_argument;
+ }
+
+# endif //__MSH_READ__
+
+
+
diff --git a/external/jigsaw/src/parser/msh_read_api.hpp b/external/jigsaw/src/parser/msh_read_api.hpp
new file mode 100644
index 0000000..3cc8715
--- /dev/null
+++ b/external/jigsaw/src/parser/msh_read_api.hpp
@@ -0,0 +1,422 @@
+
+ /*
+ --------------------------------------------------------
+ * MSH-READ-API: parse MSH_t data into mesh data.
+ --------------------------------------------------------
+ *
+ * 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 THE CONTRIBUTORS warrant
+ * this code in any way whatsoever. This code is
+ * provided "as-is" to be used at your own risk.
+ *
+ * THE CONTRIBUTORS include:
+ * (a) The University of Sydney
+ * (b) The Massachusetts Institute of Technology
+ * (c) Columbia University
+ * (d) The National Aeronautics & Space Administration
+ * (e) Los Alamos National Laboratory
+ *
+ --------------------------------------------------------
+ *
+ * Last updated: 09 Nov., 2026
+ *
+ * Copyright 2013-2026
+ * Darren Engwirda
+ * d.engwirda@gmail.com
+ * https://github.com/dengwirda/
+ *
+ --------------------------------------------------------
+ */
+
+ // from msh_read.hpp
+
+
+ /*
+ --------------------------------------------------------
+ * MSH-READER-API: read MSH_t mesh data
+ --------------------------------------------------------
+ */
+
+ class msh_reader_api
+ {
+ public :
+
+ typedef containers::array <
+ std::string > string_tokens;
+
+ string_tokens _errs ;
+
+ std::int32_t _ftag = -1 ;
+ std:: size_t _ndim = +0 ;
+
+ jmsh_kind::enum_data _kind =
+ jmsh_kind::euclidean_mesh ;
+
+ public :
+
+ template <
+ typename dest_type
+ >
+ __normal_call void_type read_data (
+ jigsaw_msh_t const&_msht,
+ dest_type &&_dest
+ )
+ {
+ switch (_msht._flags)
+ {
+ case JIGSAW_EUCLIDEAN_MESH:
+ this->_kind = jmsh_kind::euclidean_mesh;
+ break;
+
+ case JIGSAW_ELLIPSOID_MESH:
+ this->_kind = jmsh_kind::ellipsoid_mesh;
+ break;
+
+ case JIGSAW_EUCLIDEAN_GRID:
+ this->_kind = jmsh_kind::euclidean_grid;
+ break;
+
+ case JIGSAW_ELLIPSOID_GRID:
+ this->_kind = jmsh_kind::ellipsoid_grid;
+ break;
+
+ default:
+ this->_errs.push_tail(
+ "Unsupported msh kind") ;
+ return;
+ }
+
+ if (std::max({_msht._vert2._size,
+ _msht._vert3._size}) > 0 &&
+ std::max({_msht._xgrid._size,
+ _msht._ygrid._size,
+ _msht._zgrid._size}) > 0 )
+ {
+ _errs.push_tail(
+ "POINT/COORD mismatch") ;
+ }
+
+ if (_msht._xgrid._size > 0) this->_ndim = +1;
+ if (_msht._ygrid._size > 0) this->_ndim = +2;
+ if (_msht._zgrid._size > 0) this->_ndim = +3;
+
+ if (_msht._seed2._size > 0) this->_ndim = +2;
+ if (_msht._vert2._size > 0) this->_ndim = +2;
+ if (_msht._seed3._size > 0) this->_ndim = +3;
+ if (_msht._vert3._size > 0) this->_ndim = +3;
+
+ _dest.initialise() ;
+
+ _dest.push_mshid(this->_ftag,
+ this->_kind) ;
+ _dest.push_ndims(this->_ndim) ;
+
+ if (this->_kind == jmsh_kind::ellipsoid_mesh ||
+ this->_kind == jmsh_kind::ellipsoid_grid )
+ {
+ double _rrad[3] = {1., 1., 1.} ;
+ if (_msht._radii._size == 3)
+ {
+ _rrad[0] = _msht._radii._data[0];
+ _rrad[1] = _msht._radii._data[1];
+ _rrad[2] = _msht._radii._data[2];
+ }
+ else
+ if (_msht._radii._size == 1)
+ {
+ _rrad[0] = _msht._radii._data[0];
+ _rrad[1] = _msht._radii._data[0];
+ _rrad[2] = _msht._radii._data[0];
+ }
+ _dest.push_radii(_rrad);
+ }
+
+ if (this->_ndim != 2 && _msht._vert2._size > 0)
+ {
+ _errs.push_tail(
+ "NDIMS/POINT mismatch") ;
+ }
+ else
+ {
+ _dest.open_point( _msht._vert2._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._vert2._size ;
+ ++_ipos )
+ {
+ _dest.push_point( _ipos,
+ _msht._vert2._data[_ipos]._ppos,
+ _msht._vert2._data[_ipos]._itag
+ ) ;
+ }
+ }
+
+ if (this->_ndim != 2 && _msht._seed2._size > 0)
+ {
+ _errs.push_tail(
+ "NDIMS/SEEDS mismatch") ;
+ }
+ else
+ {
+ _dest.open_seeds( _msht._seed2._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._seed2._size ;
+ ++_ipos )
+ {
+ _dest.push_seeds( _ipos,
+ _msht._seed2._data[_ipos]._ppos,
+ _msht._seed2._data[_ipos]._itag
+ ) ;
+ }
+ }
+
+ if (this->_ndim != 3 && _msht._vert3._size > 0)
+ {
+ _errs.push_tail(
+ "NDIMS/POINT mismatch") ;
+ }
+ else
+ {
+ _dest.open_point( _msht._vert3._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._vert3._size ;
+ ++_ipos )
+ {
+ _dest.push_point( _ipos,
+ _msht._vert3._data[_ipos]._ppos,
+ _msht._vert3._data[_ipos]._itag
+ ) ;
+ }
+ }
+
+ if (this->_ndim != 3 && _msht._seed3._size > 0)
+ {
+ _errs.push_tail(
+ "NDIMS/SEEDS mismatch") ;
+ }
+ else
+ {
+ _dest.open_seeds( _msht._seed3._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._seed3._size ;
+ ++_ipos )
+ {
+ _dest.push_seeds( _ipos,
+ _msht._seed3._data[_ipos]._ppos,
+ _msht._seed3._data[_ipos]._itag
+ ) ;
+ }
+ }
+
+ _dest.open_edge2( _msht._edge2._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._edge2._size ;
+ ++_ipos )
+ {
+ _dest.push_edge2( _ipos,
+ _msht._edge2._data[_ipos]._node,
+ _msht._edge2._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_tria3( _msht._tria3._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._tria3._size ;
+ ++_ipos )
+ {
+ _dest.push_tria3( _ipos,
+ _msht._tria3._data[_ipos]._node,
+ _msht._tria3._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_quad4( _msht._quad4._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._quad4._size ;
+ ++_ipos )
+ {
+ _dest.push_quad4( _ipos,
+ _msht._quad4._data[_ipos]._node,
+ _msht._quad4._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_tria4( _msht._tria4._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._tria4._size ;
+ ++_ipos )
+ {
+ _dest.push_tria4( _ipos,
+ _msht._tria4._data[_ipos]._node,
+ _msht._tria4._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_hexa8( _msht._hexa8._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._hexa8._size ;
+ ++_ipos )
+ {
+ _dest.push_hexa8( _ipos,
+ _msht._hexa8._data[_ipos]._node,
+ _msht._hexa8._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_wedg6( _msht._wedg6._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._wedg6._size ;
+ ++_ipos )
+ {
+ _dest.push_wedg6( _ipos,
+ _msht._wedg6._data[_ipos]._node,
+ _msht._wedg6._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_pyra5( _msht._pyra5._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._pyra5._size ;
+ ++_ipos )
+ {
+ _dest.push_pyra5( _ipos,
+ _msht._pyra5._data[_ipos]._node,
+ _msht._pyra5._data[_ipos]._itag
+ ) ;
+ }
+
+ _dest.open_coord( _msht._xgrid._size, 1);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._xgrid._size ;
+ ++_ipos )
+ {
+ _dest.push_coord( 1, _ipos,
+ _msht._xgrid._data[_ipos]
+ ) ;
+ }
+
+ _dest.open_coord( _msht._ygrid._size, 2);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._ygrid._size ;
+ ++_ipos )
+ {
+ _dest.push_coord( 2, _ipos,
+ _msht._ygrid._data[_ipos]
+ ) ;
+ }
+
+ _dest.open_coord( _msht._zgrid._size, 3);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._zgrid._size ;
+ ++_ipos )
+ {
+ _dest.push_coord( 3, _ipos,
+ _msht._zgrid._data[_ipos]
+ ) ;
+ }
+
+ _dest.open_power( _msht._power._size, 1);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._power._size ;
+ ++_ipos )
+ {
+ _dest.push_power( _ipos,
+ &_msht._power._data[_ipos]
+ ) ;
+ }
+
+ if (_msht._power._size > +0 &&
+ _msht._power._size !=
+ _msht._vert2._size &&
+ _msht._power._size !=
+ _msht._vert3._size )
+ {
+ _errs.push_tail(
+ "POWER/POINT mismatch") ;
+ }
+
+ _dest.open_value( _msht._value._size, 1);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._value._size ;
+ ++_ipos )
+ {
+ _dest.push_value( _ipos,
+ &_msht._value._data[_ipos]
+ ) ;
+ }
+
+ if (_msht._value._size > +1 &&
+ _msht._value._size !=
+ _msht._vert2._size &&
+ _msht._value._size !=
+ _msht._vert3._size &&
+ _msht._value._size !=
+ std::max(+1u, _msht._xgrid._size) *
+ std::max(+1u, _msht._ygrid._size) *
+ std::max(+1u, _msht._zgrid._size) )
+ {
+ _errs.push_tail(
+ "VALUE/POINT mismatch") ;
+ }
+
+ _dest.open_slope( _msht._slope._size, 1);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._slope._size ;
+ ++_ipos )
+ {
+ _dest.push_slope( _ipos,
+ &_msht._slope._data[_ipos]
+ ) ;
+ }
+
+ if (_msht._slope._size > +1 &&
+ _msht._slope._size !=
+ _msht._vert2._size &&
+ _msht._slope._size !=
+ _msht._vert3._size &&
+ _msht._slope._size !=
+ std::max(+1u, _msht._xgrid._size) *
+ std::max(+1u, _msht._ygrid._size) *
+ std::max(+1u, _msht._zgrid._size) )
+ {
+ _errs.push_tail(
+ "SLOPE/POINT mismatch") ;
+ }
+
+ _dest.open_bound( _msht._bound._size);
+ for (auto _ipos = (size_t) +0 ;
+ _ipos!= _msht._bound._size ;
+ ++_ipos )
+ {
+ _dest.push_bound( _ipos,
+ _msht._bound._data[_ipos]._itag,
+ _msht._bound._data[_ipos]._indx,
+ _msht._bound._data[_ipos]._kind
+ ) ;
+ }
+
+ {
+ _dest.postscript();
+ }
+ }
+
+ } ;
+
+
+
diff --git a/external/jigsaw/src/parser/msh_read_nc_.hpp b/external/jigsaw/src/parser/msh_read_nc_.hpp
new file mode 100644
index 0000000..8e09490
--- /dev/null
+++ b/external/jigsaw/src/parser/msh_read_nc_.hpp
@@ -0,0 +1,605 @@
+ /*
+ --------------------------------------------------------
+ * MSH-READ-NC: parse NetCDF into mesh data.
+ --------------------------------------------------------
+ *
+ * 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 THE CONTRIBUTORS warrant
+ * this code in any way whatsoever. This code is
+ * provided "as-is" to be used at your own risk.
+ *
+ * THE CONTRIBUTORS include:
+ * (a) The University of Sydney
+ * (b) The Massachusetts Institute of Technology
+ * (c) Columbia University
+ * (d) The National Aeronautics & Space Administration
+ * (e) Los Alamos National Laboratory
+ *
+ --------------------------------------------------------
+ *
+ * Last updated: 12 Nov., 2026
+ *
+ * Copyright 2013-2026
+ * Darren Engwirda
+ * d.engwirda@gmail.com
+ * https://github.com/dengwirda/
+ *
+ --------------------------------------------------------
+ */
+
+ // from msh_read.hpp
+
+
+ /*
+ --------------------------------------------------------
+ * MSH-READER-NC: read *.nc mesh files
+ --------------------------------------------------------
+ */
+
+ class msh_reader_nc_
+ {
+ public :
+
+ typedef containers::array <
+ std::string > string_tokens;
+
+ string_tokens _errs ;
+
+ std::int32_t _ftag = +3 ;
+ std:: size_t _ndim = +0 ;
+
+ jmsh_kind::enum_data _kind =
+ jmsh_kind::euclidean_mesh ;
+
+ private :
+
+# ifdef __use_netcdf
+
+ std::string _file ;
+
+ __normal_call size_t checked_size (
+ size_t const*_lens,
+ int _rank
+ ) const
+ {
+ size_t constexpr _imax =
+ std::numeric_limits::max();
+
+ size_t _size = 1;
+ for (int _idim = 0; _idim < _rank; ++_idim)
+ {
+ if (_lens[_idim] != 0 &&
+ _size > _imax / _lens[_idim])
+ throw std::invalid_argument(
+ "NetCDF variable shape overflow") ;
+
+ _size *= _lens [_idim] ;
+ }
+ return _size ;
+ }
+
+ __normal_call bool has_var (
+ std::string const&_name
+ ) const
+ {
+ return ncutil::has_var(this->_file, _name) ;
+ }
+
+ __normal_call void get_var_len (
+ std::string const&_name,
+ int &_rank,
+ size_t *_lens
+ ) const
+ {
+ ncutil::get_var_len(this->_file,
+ _name, _rank , _lens, NC_MAX_VAR_DIMS) ;
+ }
+
+ template <
+ typename data_type
+ >
+ __normal_call void read_var (
+ std::string const&_name,
+ size_t _size,
+ containers::array &_data
+ ) const
+ {
+ _data.set_count(_size, containers::tight_alloc) ;
+ if (_size == 0) return ;
+
+ ncutil::get_var( this->_file, _name, &_data[0]) ;
+ }
+
+ __normal_call void read_header (
+ )
+ {
+ if (!ncutil::has_att(this->_file, "MSHID"))
+ throw std::invalid_argument(
+ "Missing NetCDF MSHID attribute");
+
+ std::string _kind_name ;
+ ncutil::get_str(this->_file, "MSHID", _kind_name) ;
+ while (!_kind_name.empty() &&
+ _kind_name.back() == '\0')
+ _kind_name.pop_back() ;
+
+ _kind_name = trim(_kind_name) ;
+
+ std::transform(_kind_name.begin(),
+ _kind_name. end(),
+ _kind_name.begin(),
+ [](unsigned char c){ return
+ (unsigned char)::toupper(c); } ) ;
+
+ if (_kind_name == "EUCLIDEAN-MESH")
+ this->_kind = jmsh_kind::euclidean_mesh ;
+ else
+ if (_kind_name == "EUCLIDEAN-GRID")
+ this->_kind = jmsh_kind::euclidean_grid ;
+ else
+ if (_kind_name == "EUCLIDEAN-DUAL")
+ this->_kind = jmsh_kind::euclidean_dual ;
+ else
+ if (_kind_name == "ELLIPSOID-MESH")
+ this->_kind = jmsh_kind::ellipsoid_mesh ;
+ else
+ if (_kind_name == "ELLIPSOID-GRID")
+ this->_kind = jmsh_kind::ellipsoid_grid ;
+ else
+ if (_kind_name == "ELLIPSOID-DUAL")
+ this->_kind = jmsh_kind::ellipsoid_dual ;
+ else
+ throw std::invalid_argument(
+ "Invalid NetCDF MSHID attribute");
+
+ if (ncutil::has_att(this->_file, "NDIMS"))
+ {
+ int _ndim_val = +0 ;
+ ncutil::get_att(
+ this->_file, "NDIMS", &_ndim_val) ;
+ if (_ndim_val < +1 || _ndim_val > +3)
+ throw std::invalid_argument(
+ "Invalid NetCDF NDIMS attribute") ;
+
+ this->_ndim = (size_t)_ndim_val ;
+ }
+ else
+ {
+ if (has_var("xgrid_val")) this->_ndim = 1 ;
+ if (has_var("ygrid_val")) this->_ndim = 2 ;
+ if (has_var("zgrid_val")) this->_ndim = 3 ;
+
+ if (has_var("vert2_pos")) this->_ndim = 2 ;
+ if (has_var("seed2_pos")) this->_ndim = 2 ;
+ if (has_var("vert3_pos")) this->_ndim = 3 ;
+ if (has_var("seed3_pos")) this->_ndim = 3 ;
+
+ if (this->_ndim <= 0)
+ throw std::invalid_argument(
+ "Missing NetCDF NDIMS attribute") ;
+ }
+ }
+
+ template <
+ typename dest_type
+ >
+ __normal_call void read_radii (
+ dest_type &_dest
+ )
+ {
+ if(!ncutil::has_att(this->_file, "RADII"))
+ return ;
+
+ size_t _nrad = +0 ;
+ ncutil::get_att_len(this->_file, "RADII",
+ _nrad) ;
+ if (_nrad != +3)
+ throw std::invalid_argument(
+ "Invalid NetCDF RADII attribute");
+
+ double _radii[3] = {1., 1., 1.} ;
+ ncutil::get_att(this->_file, "RADII", _radii) ;
+ _dest.push_radii (_radii) ;
+ }
+
+ template <
+ typename dest_type,
+ typename open_type,
+ typename push_type
+ >
+ __normal_call void read_point (
+ std::string const&_pos_name,
+ std::string const&_tag_name,
+ dest_type &_dest,
+ open_type _open,
+ push_type _push
+ )
+ {
+ bool _has_pos = has_var(_pos_name) ;
+ bool _has_tag = has_var(_tag_name) ;
+ if (!_has_pos && !_has_tag)
+ return ;
+ if (!_has_pos || !_has_tag)
+ throw std::invalid_argument(
+ "Missing NetCDF " + _tag_name + " variable") ;
+
+ int _rank = +0 ;
+ size_t _lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_pos_name, _rank, _lens) ;
+ if (_rank != +2 || _lens[1] != this->_ndim)
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _pos_name + " dimensions") ;
+
+ size_t _nrow = _lens[0] ;
+ int _tag_rank = +0 ;
+ size_t _tag_lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_tag_name, _tag_rank, _tag_lens) ;
+ if ((_tag_rank != +1 && _tag_rank != +2) ||
+ _tag_lens[0] != _nrow ||
+ (_tag_rank == +2 && _tag_lens[1] != +1))
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _tag_name + " dimensions") ;
+
+ size_t _size = checked_size(_lens, _rank) ;
+
+ containers::array _pos ;
+ containers::array _tag ;
+ read_var(_pos_name, _size, _pos) ;
+ read_var(_tag_name, _nrow, _tag) ;
+
+ _open(_dest, _nrow) ;
+ for (size_t _irow = +0; _irow < _nrow; ++_irow)
+ _push(_dest, _irow,
+ &_pos[_irow * this->_ndim], _tag[_irow]
+ ) ;
+ }
+
+ template <
+ typename dest_type,
+ typename open_type,
+ typename push_type
+ >
+ __normal_call void read_coord (
+ size_t _idim,
+ dest_type &_dest,
+ open_type _open,
+ push_type _push
+ )
+ {
+ static char const*_names[3] = {
+ "xgrid_val", "ygrid_val", "zgrid_val"
+ } ;
+
+ std::string _name = _names[_idim - 1] ;
+ if (!has_var(_name))
+ return ;
+ if (_idim > this->_ndim)
+ throw std::invalid_argument(
+ "NetCDF coord dimension exceeds NDIMS");
+
+ int _rank = +0 ;
+ size_t _lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_name, _rank, _lens) ;
+ if (_rank != +1 && _rank != +2)
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _name + " dimensions");
+ if (_rank == +2 && _lens[1] != +1)
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _name + " dimensions");
+
+ size_t _nrow = _lens[0] ;
+ containers::array _data ;
+ read_var(_name, _nrow, _data) ;
+
+ _open(_dest, _nrow, _idim) ;
+ for (size_t _irow = +0; _irow < _nrow; ++_irow)
+ _push(_dest,
+ _idim, _irow, _data[_irow]) ;
+ }
+
+ template <
+ typename data_type,
+ typename dest_type,
+ typename open_type,
+ typename push_type
+ >
+ __normal_call void read_value (
+ std::string const&_name,
+ bool _flatten,
+ dest_type &_dest,
+ open_type _open,
+ push_type _push
+ )
+ {
+ if (!has_var(_name)) return ;
+
+ int _rank = +0 ;
+ size_t _lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_name, _rank, _lens) ;
+ if (_rank < +1 || (_rank > +2 && !_flatten) ||
+ (_rank == +2 && _lens[1] == +0))
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _name + " dimensions") ;
+
+ size_t _size = checked_size(_lens, _rank) ;
+ size_t _nrow = _lens[0] ;
+ size_t _nval = _rank == +1 ? +1 : _lens[1] ;
+ if (_flatten &&
+ (this->_kind == jmsh_kind::euclidean_grid ||
+ this->_kind == jmsh_kind::ellipsoid_grid ||
+ _rank > +2))
+ {
+ _nrow = _size ;
+ _nval = +1 ;
+ }
+ containers::array _data ;
+ read_var(_name, _size, _data) ;
+
+ _open(_dest, _nrow, _nval) ;
+ for (size_t _irow = +0; _irow < _nrow; ++_irow)
+ _push(_dest, _irow,
+ &_data[ _irow * _nval]) ;
+ }
+
+ template <
+ typename dest_type,
+ typename open_type,
+ typename push_type
+ >
+ __normal_call void read_elements (
+ std::string const&_name,
+ size_t _nnod,
+ dest_type &_dest,
+ open_type _open,
+ push_type _push
+ )
+ {
+ std::string _idx_name = _name + "_idx" ;
+ std::string _tag_name = _name + "_tag" ;
+ bool _has_idx = has_var(_idx_name) ;
+ bool _has_tag = has_var(_tag_name) ;
+ if (!_has_idx && !_has_tag)
+ return ;
+ if (!_has_idx || !_has_tag)
+ throw std::invalid_argument(
+ "Missing NetCDF " + _tag_name + " variable") ;
+
+ int _rank = +0 ;
+ size_t _lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_idx_name, _rank, _lens) ;
+ if (_rank != +2 || _lens[1] != _nnod)
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _idx_name + " dimensions") ;
+
+ size_t _nrow = _lens[0] ;
+ int _tag_rank = +0 ;
+ size_t _tag_lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_tag_name, _tag_rank, _tag_lens) ;
+ if ((_tag_rank != +1 && _tag_rank != +2) ||
+ _tag_lens[0] != _nrow ||
+ (_tag_rank == +2 && _tag_lens[1] != +1))
+ throw std::invalid_argument(
+ "Invalid NetCDF " + _tag_name + " dimensions") ;
+
+ size_t _size = checked_size(_lens, _rank) ;
+
+ containers::array _idx ;
+ containers::array _tag ;
+ read_var(_idx_name, _size, _idx) ;
+ read_var(_tag_name, _nrow, _tag) ;
+
+ _open(_dest, _nrow) ;
+ std::int32_t _node[8] = {} ;
+ for (size_t _irow = +0; _irow < _nrow; ++_irow)
+ {
+ for (size_t _inod = +0; _inod < _nnod ;
+ ++_inod )
+ _node[_inod] = _idx[_irow * _nnod + _inod] ;
+
+ _push(_dest, _irow, _node, _tag[_irow]) ;
+ }
+ }
+
+ template <
+ typename dest_type
+ >
+ __normal_call void read_bound (
+ std::string const&_name,
+ dest_type &_dest
+ )
+ {
+ if (!has_var(_name)) return ;
+
+ int _rank = +0 ;
+ size_t _lens[NC_MAX_VAR_DIMS] = {} ;
+ get_var_len(_name, _rank, _lens) ;
+ if (_rank != +2 || _lens[1] != +3)
+ throw std::invalid_argument(
+ "Invalid NetCDF bound dimensions") ;
+
+ size_t _nrow = _lens[0] ;
+ containers::array _data ;
+ read_var(_name,
+ checked_size(_lens, _rank), _data) ;
+ _dest.open_bound(_nrow) ;
+ for (size_t _irow = +0; _irow < _nrow; ++_irow)
+ _dest.push_bound(_irow,
+ _data[_irow * 3 + 0],
+ _data[_irow * 3 + 1],
+ _data[_irow * 3 + 2]) ;
+ }
+
+ template <
+ typename dest_type
+ >
+ __normal_call void read_all (
+ dest_type &_dest
+ )
+ {
+ if (this->_ndim >= +2)
+ {
+ read_point (
+ this->_ndim == +2 ? "vert2_pos" :
+ "vert3_pos" ,
+ this->_ndim == +2 ? "vert2_tag" :
+ "vert3_tag" , _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_point(_n); },
+ [](dest_type &_d, size_t _i, double *_p,
+ std::int32_t _t)
+ { _d.push_point(_i, _p, _t); }) ;
+
+ read_point (
+ this->_ndim == +2 ? "seed2_pos" :
+ "seed3_pos" ,
+ this->_ndim == +2 ? "seed2_tag" :
+ "seed3_tag" , _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_seeds(_n); },
+ [](dest_type &_d, size_t _i, double *_p,
+ std::int32_t _t)
+ { _d.push_seeds(_i, _p, _t); }) ;
+ }
+
+ read_radii(_dest) ;
+
+ read_coord(+1, _dest,
+ [](dest_type &_d, size_t _n, size_t _i)
+ { _d.open_coord(_n, _i); },
+ [](dest_type &_d, size_t _i, size_t _r,
+ double _v)
+ { _d.push_coord(_i, _r, _v); }) ;
+ read_coord(+2, _dest,
+ [](dest_type &_d, size_t _n, size_t _i)
+ { _d.open_coord(_n, _i); },
+ [](dest_type &_d, size_t _i, size_t _r,
+ double _v)
+ { _d.push_coord(_i, _r, _v); }) ;
+ read_coord(+3, _dest,
+ [](dest_type &_d, size_t _n, size_t _i)
+ { _d.open_coord(_n, _i); },
+ [](dest_type &_d, size_t _i, size_t _r,
+ double _v)
+ { _d.push_coord(_i, _r, _v); }) ;
+
+ read_value("power_val", false, _dest,
+ [](dest_type &_d, size_t _n, size_t _v)
+ { _d.open_power(_n, _v); },
+ [](dest_type &_d, size_t _i, double *_v)
+ { _d.push_power(_i, _v); }) ;
+ read_value("value_mat", true, _dest,
+ [](dest_type &_d, size_t _n, size_t _v)
+ { _d.open_value(_n, _v); },
+ [](dest_type &_d, size_t _i, fp32_t*_v)
+ { _d.push_value(_i, _v); }) ;
+ read_value("slope_mat", true, _dest,
+ [](dest_type &_d, size_t _n, size_t _v)
+ { _d.open_slope(_n, _v); },
+ [](dest_type &_d, size_t _i, fp32_t*_v)
+ { _d.push_slope(_i, _v); }) ;
+
+ read_elements("edge2", +2, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_edge2(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_edge2(_i, _n, _t); }) ;
+ read_elements("tria3", +3, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_tria3(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_tria3(_i, _n, _t); }) ;
+ read_elements("quad4", +4, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_quad4(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_quad4(_i, _n, _t); }) ;
+ read_elements("tria4", +4, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_tria4(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_tria4(_i, _n, _t); }) ;
+ read_elements("hexa8", +8, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_hexa8(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_hexa8(_i, _n, _t); }) ;
+ read_elements("wedg6", +6, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_wedg6(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_wedg6(_i, _n, _t); }) ;
+ read_elements("pyra5", +5, _dest,
+ [](dest_type &_d, size_t _n)
+ { _d.open_pyra5(_n); },
+ [](dest_type &_d, size_t _i, std::int32_t *_n,
+ std::int32_t _t)
+ { _d.push_pyra5(_i, _n, _t); }) ;
+
+ read_bound("bound_idx", _dest) ;
+ }
+
+# endif
+
+ public :
+
+ template <
+ typename dest_type
+ >
+ __normal_call void_type read_file (
+ std::string const&_path,
+ dest_type &_dest
+ )
+ {
+ this->_errs.clear() ;
+ this->_ftag = +3 ;
+ this->_ndim = +0 ;
+# ifdef __use_netcdf
+ this->_file = _path ;
+ try
+ {
+ _dest.initialise() ;
+ read_header() ;
+ _dest.push_mshid(this->_ftag, this->_kind) ;
+ _dest.push_ndims(this->_ndim) ;
+ read_all(_dest) ;
+ _dest.postscript() ;
+ }
+ catch (std::exception const&_error)
+ {
+ this->_errs.push_tail(_error.what()) ;
+ }
+# else
+ __unreferenced(_path) ;
+ __unreferenced(_dest) ;
+ this->_errs.push_tail(
+ "NetCDF support is not available") ;
+# endif
+ }
+
+ } ;
+
+
+
diff --git a/external/jigsaw/src/msh_read.hpp b/external/jigsaw/src/parser/msh_read_txt.hpp
similarity index 88%
rename from external/jigsaw/src/msh_read.hpp
rename to external/jigsaw/src/parser/msh_read_txt.hpp
index b475efb..c81760d 100644
--- a/external/jigsaw/src/msh_read.hpp
+++ b/external/jigsaw/src/parser/msh_read_txt.hpp
@@ -1,7 +1,7 @@
/*
--------------------------------------------------------
- * MSH-READ: parse *.MSH file into mesh data.
+ * MSH-READ-TXT: parse *.MSH file into mesh data.
--------------------------------------------------------
*
* This program may be freely redistributed under the
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 08 Feb., 2021
+ * Last updated: 09 Nov., 2026
*
- * Copyright 2013-2021
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -45,150 +45,16 @@
--------------------------------------------------------
*/
-# pragma once
+ // from msh_read.hpp
-# ifndef __MSH_READ__
-# define __MSH_READ__
-
- class jmsh_reader_base
- {
-/*------------------------ inherit from base to read file */
- public :
- __normal_call void_type initialise() {}
- __normal_call void_type postscript() {}
- __normal_call void_type push_mshid (
- std::int32_t /*_ftag*/,
- jmsh_kind::enum_data /*_kind*/
- ) { }
- __normal_call void_type push_ndims (
- std:: size_t /*_ndim*/
- ) { }
- __normal_call void_type push_radii (
- double * /*_erad*/
- ) { }
- __normal_call void_type open_point (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_point (
- std:: size_t /*_irow*/,
- double * /*_pval*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_seeds (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_seeds (
- std:: size_t /*_irow*/,
- double * /*_pval*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_power (
- std:: size_t /*_nrow*/,
- std:: size_t /*_npwr*/
- ) { }
- __normal_call void_type push_power (
- std:: size_t /*_irow*/,
- double * /*_xpwr*/
- ) { }
- __normal_call void_type open_edge2 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_edge2 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_tria3 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_tria3 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_quad4 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_quad4 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_tria4 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_tria4 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_hexa8 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_hexa8 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_wedg6 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_wedg6 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_pyra5 (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_pyra5 (
- std:: size_t /*_irow*/,
- std::int32_t* /*_node*/,
- std::int32_t /*_itag*/
- ) { }
- __normal_call void_type open_value (
- std:: size_t /*_nrow*/,
- std:: size_t /*_nval*/
- ) { }
- __normal_call void_type push_value (
- std:: size_t /*_irow*/,
- float * /*_vdat*/
- ) { }
- __normal_call void_type open_slope (
- std:: size_t /*_nrow*/,
- std:: size_t /*_nval*/
- ) { }
- __normal_call void_type push_slope (
- std:: size_t /*_irow*/,
- float * /*_vdat*/
- ) { }
- __normal_call void_type open_bound (
- std:: size_t /*_nrow*/
- ) { }
- __normal_call void_type push_bound (
- std:: size_t /*_irow*/,
- std::int32_t /*_itag*/,
- std::int32_t /*_inum*/,
- std::int32_t /*_kind*/
- ) { }
- __normal_call void_type open_coord (
- std:: size_t /*_idim*/,
- std:: size_t /*_ndim*/
- ) { }
- __normal_call void_type push_coord (
- std:: size_t /*_idim*/,
- std:: size_t /*_irow*/,
- double /*_ppos*/
- ) { }
- } ;
/*
--------------------------------------------------------
- * JMSH-READER: read *.MSH mesh files
+ * MSH-READER-TXT: read *.MSH mesh files
--------------------------------------------------------
*/
- class jmsh_reader
+ class msh_reader_txt
{
public :
@@ -385,6 +251,8 @@
_dest.open_point(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -454,6 +322,8 @@
_dest.open_seeds(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -523,7 +393,9 @@
push_tail("Invalid COORD!");
}
- _dest.open_coord(_idim, _nrow) ;
+ _dest.open_coord(_nrow , _idim);
+
+ if (_nrow == 0) return ;
/*----------------------------------------- read data */
std::string _line ;
@@ -577,6 +449,8 @@
_dest.open_power(_nrow , _npwr);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -642,7 +516,9 @@
push_tail("Invalid VALUE!");
}
- _dest.open_value (_nrow, _nval);
+ _dest.open_value(_nrow , _nval);
+
+ if (_nrow == 0) return ;
/*----------------------------------------- read data */
std::string _line ;
@@ -709,7 +585,9 @@
push_tail("Invalid SLOPE!");
}
- _dest.open_slope (_nrow, _nval);
+ _dest.open_slope(_nrow , _nval);
+
+ if (_nrow == 0) return ;
/*----------------------------------------- read data */
std::string _line ;
@@ -776,6 +654,8 @@
_dest.open_edge2(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -840,6 +720,8 @@
_dest.open_tria3(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -907,6 +789,8 @@
_dest.open_quad4(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -977,6 +861,8 @@
_dest.open_tria4(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -1047,6 +933,8 @@
_dest.open_hexa8(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -1129,6 +1017,8 @@
_dest.open_wedg6(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -1205,6 +1095,8 @@
_dest.open_pyra5(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -1278,6 +1170,8 @@
_dest.open_bound(_nrow);
+ if (_nrow == 0) return ;
+
/*----------------------------------------- read data */
std::string _line ;
while (std::getline(_ffid, _line))
@@ -1457,7 +1351,5 @@
} ;
-# endif //__MSH_READ__
-
diff --git a/external/jigsaw/src/rdt_save.inc b/external/jigsaw/src/rdt_save.inc
index e6f5965..11924e1 100644
--- a/external/jigsaw/src/rdt_save.inc
+++ b/external/jigsaw/src/rdt_save.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 05 Dec, 2024
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -740,22 +740,31 @@
int _retv, _ncid;
if ((_retv = nc_create(
- _jcfg._tria_file.c_str(),
+ _jcfg._mesh_file.c_str(),
NC_CLOBBER|NC_NETCDF4, &_ncid)))
{
return __file_not_created;
}
+ if ((_retv = nc_close(_ncid)))
+ {
+ return __unknown_error;
+ }
+
+ int _ndim = (int)_rdel._ndim ;
+ ncutil::put_att(
+ _jcfg._mesh_file, "NDIMS", NC_INT, _ndim);
+
if (_rdel._ndim == +2 &&
_rdel._kind ==
jmsh_kind::euclidean_mesh)
{
/*-------------------------- save 2-dim. mesh */
- ncutil::put_str(_jcfg._tria_file,
+ ncutil::put_str(_jcfg._mesh_file,
"title",
_name + "; created by " + __JGSWVSTR);
- ncutil::put_str(_jcfg._tria_file,
+ ncutil::put_str(_jcfg._mesh_file,
"MSHID", "EUCLIDEAN-MESH" ) ;
/*------------ index mapping for active nodes */
@@ -842,11 +851,11 @@
jmsh_kind::euclidean_mesh)
{
/*-------------------------- save 3-dim. mesh */
- ncutil::put_str(_jcfg._tria_file,
+ ncutil::put_str(_jcfg._mesh_file,
"title",
_name + "; created by " + __JGSWVSTR);
- ncutil::put_str(_jcfg._tria_file,
+ ncutil::put_str(_jcfg._mesh_file,
"MSHID", "EUCLIDEAN-MESH" ) ;
/*------------ index mapping for active nodes */
@@ -1413,6 +1422,3 @@
return ( _errv ) ;
}
-
-
-
diff --git a/external/jigsaw/src/tri_save.inc b/external/jigsaw/src/tri_save.inc
index 54c994a..171b1ac 100644
--- a/external/jigsaw/src/tri_save.inc
+++ b/external/jigsaw/src/tri_save.inc
@@ -35,9 +35,9 @@
*
--------------------------------------------------------
*
- * Last updated: 05 Dec, 2024
+ * Last updated: 12 Nov., 2026
*
- * Copyright 2013-2024
+ * Copyright 2013-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda/
@@ -574,6 +574,15 @@
return __file_not_created;
}
+ if ((_retv = nc_close(_ncid)))
+ {
+ return __unknown_error;
+ }
+
+ int _ndim = (int)_rdel._ndim ;
+ ncutil::put_att(
+ _jcfg._tria_file, "NDIMS", NC_INT, _ndim);
+
if (_rdel._ndim == +2 &&
_rdel._kind ==
jmsh_kind::euclidean_mesh)
@@ -1028,5 +1037,3 @@
return ( _errv ) ;
}
-
-
diff --git a/external/jigsaw/uni/CMakeLists.txt b/external/jigsaw/tests/CMakeLists.txt
similarity index 97%
rename from external/jigsaw/uni/CMakeLists.txt
rename to external/jigsaw/tests/CMakeLists.txt
index d29307e..94ca183 100644
--- a/external/jigsaw/uni/CMakeLists.txt
+++ b/external/jigsaw/tests/CMakeLists.txt
@@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 3.9.4)
project (JIGSAW_UNIT_TEST)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}" CACHE PATH
+ "Install path prefix." FORCE)
+endif ()
+
+if (CMAKE_INSTALL_PREFIX STREQUAL PROJECT_SOURCE_DIR)
set (INSTALL_LOCAL TRUE)
message ( ">> INSTALLING LOCALLY" )
else ()
diff --git a/external/jigsaw/uni/README.md b/external/jigsaw/tests/README.md
similarity index 100%
rename from external/jigsaw/uni/README.md
rename to external/jigsaw/tests/README.md
diff --git a/external/jigsaw/uni/print.h b/external/jigsaw/tests/print.h
similarity index 100%
rename from external/jigsaw/uni/print.h
rename to external/jigsaw/tests/print.h
diff --git a/external/jigsaw/uni/test2d_a.c b/external/jigsaw/tests/test2d_a.c
similarity index 100%
rename from external/jigsaw/uni/test2d_a.c
rename to external/jigsaw/tests/test2d_a.c
diff --git a/external/jigsaw/uni/test2d_b.c b/external/jigsaw/tests/test2d_b.c
similarity index 100%
rename from external/jigsaw/uni/test2d_b.c
rename to external/jigsaw/tests/test2d_b.c
diff --git a/external/jigsaw/uni/test2d_c.c b/external/jigsaw/tests/test2d_c.c
similarity index 100%
rename from external/jigsaw/uni/test2d_c.c
rename to external/jigsaw/tests/test2d_c.c
diff --git a/external/jigsaw/uni/test2d_d.c b/external/jigsaw/tests/test2d_d.c
similarity index 100%
rename from external/jigsaw/uni/test2d_d.c
rename to external/jigsaw/tests/test2d_d.c
diff --git a/external/jigsaw/uni/test2d_e.c b/external/jigsaw/tests/test2d_e.c
similarity index 100%
rename from external/jigsaw/uni/test2d_e.c
rename to external/jigsaw/tests/test2d_e.c
diff --git a/external/jigsaw/uni/test2d_f.c b/external/jigsaw/tests/test2d_f.c
similarity index 100%
rename from external/jigsaw/uni/test2d_f.c
rename to external/jigsaw/tests/test2d_f.c
diff --git a/external/jigsaw/uni/test2d_g.c b/external/jigsaw/tests/test2d_g.c
similarity index 100%
rename from external/jigsaw/uni/test2d_g.c
rename to external/jigsaw/tests/test2d_g.c
diff --git a/external/jigsaw/uni/test2d_h.c b/external/jigsaw/tests/test2d_h.c
similarity index 100%
rename from external/jigsaw/uni/test2d_h.c
rename to external/jigsaw/tests/test2d_h.c
diff --git a/external/jigsaw/uni/test2d_i.c b/external/jigsaw/tests/test2d_i.c
similarity index 100%
rename from external/jigsaw/uni/test2d_i.c
rename to external/jigsaw/tests/test2d_i.c
diff --git a/external/jigsaw/uni/test2s_a.c b/external/jigsaw/tests/test2s_a.c
similarity index 100%
rename from external/jigsaw/uni/test2s_a.c
rename to external/jigsaw/tests/test2s_a.c
diff --git a/external/jigsaw/uni/test2s_b.c b/external/jigsaw/tests/test2s_b.c
similarity index 100%
rename from external/jigsaw/uni/test2s_b.c
rename to external/jigsaw/tests/test2s_b.c
diff --git a/external/jigsaw/uni/test2s_c.c b/external/jigsaw/tests/test2s_c.c
similarity index 100%
rename from external/jigsaw/uni/test2s_c.c
rename to external/jigsaw/tests/test2s_c.c
diff --git a/external/jigsaw/uni/test2s_e.c b/external/jigsaw/tests/test2s_e.c
similarity index 100%
rename from external/jigsaw/uni/test2s_e.c
rename to external/jigsaw/tests/test2s_e.c
diff --git a/external/jigsaw/uni/test2s_f.c b/external/jigsaw/tests/test2s_f.c
similarity index 100%
rename from external/jigsaw/uni/test2s_f.c
rename to external/jigsaw/tests/test2s_f.c
diff --git a/external/jigsaw/uni/test2s_g.c b/external/jigsaw/tests/test2s_g.c
similarity index 100%
rename from external/jigsaw/uni/test2s_g.c
rename to external/jigsaw/tests/test2s_g.c
diff --git a/external/jigsaw/uni/test2s_h.c b/external/jigsaw/tests/test2s_h.c
similarity index 100%
rename from external/jigsaw/uni/test2s_h.c
rename to external/jigsaw/tests/test2s_h.c
diff --git a/external/jigsaw/uni/test2s_i.c b/external/jigsaw/tests/test2s_i.c
similarity index 100%
rename from external/jigsaw/uni/test2s_i.c
rename to external/jigsaw/tests/test2s_i.c
diff --git a/external/jigsaw/uni/test3d_a.c b/external/jigsaw/tests/test3d_a.c
similarity index 100%
rename from external/jigsaw/uni/test3d_a.c
rename to external/jigsaw/tests/test3d_a.c
diff --git a/external/jigsaw/uni/test3d_b.c b/external/jigsaw/tests/test3d_b.c
similarity index 100%
rename from external/jigsaw/uni/test3d_b.c
rename to external/jigsaw/tests/test3d_b.c
diff --git a/external/jigsaw/uni/test3d_c.c b/external/jigsaw/tests/test3d_c.c
similarity index 100%
rename from external/jigsaw/uni/test3d_c.c
rename to external/jigsaw/tests/test3d_c.c
diff --git a/external/jigsaw/uni/test3d_d.c b/external/jigsaw/tests/test3d_d.c
similarity index 100%
rename from external/jigsaw/uni/test3d_d.c
rename to external/jigsaw/tests/test3d_d.c
diff --git a/external/jigsaw/uni/test3d_e.c b/external/jigsaw/tests/test3d_e.c
similarity index 100%
rename from external/jigsaw/uni/test3d_e.c
rename to external/jigsaw/tests/test3d_e.c
diff --git a/external/jigsaw/uni/test3d_f.c b/external/jigsaw/tests/test3d_f.c
similarity index 100%
rename from external/jigsaw/uni/test3d_f.c
rename to external/jigsaw/tests/test3d_f.c
diff --git a/external/jigsaw/uni/test3d_g.c b/external/jigsaw/tests/test3d_g.c
similarity index 100%
rename from external/jigsaw/uni/test3d_g.c
rename to external/jigsaw/tests/test3d_g.c
diff --git a/external/jigsaw/uni/test3d_h.c b/external/jigsaw/tests/test3d_h.c
similarity index 100%
rename from external/jigsaw/uni/test3d_h.c
rename to external/jigsaw/tests/test3d_h.c
diff --git a/external/jigsaw/uni/test3d_i.c b/external/jigsaw/tests/test3d_i.c
similarity index 100%
rename from external/jigsaw/uni/test3d_i.c
rename to external/jigsaw/tests/test3d_i.c
diff --git a/external/jigsaw/uni/test_all.c b/external/jigsaw/tests/test_all.c
similarity index 100%
rename from external/jigsaw/uni/test_all.c
rename to external/jigsaw/tests/test_all.c
diff --git a/files/airfoil.msh b/files/airfoil.msh
index da9b78d..eab043f 100644
--- a/files/airfoil.msh
+++ b/files/airfoil.msh
@@ -1,4 +1,4 @@
-# airfoil.msh geometry file
+# airfoil.msh geometry file
mshid=1
ndims=2
point=476
diff --git a/files/bunny.msh b/files/bunny.msh
index 488e0df..fd64823 100644
--- a/files/bunny.msh
+++ b/files/bunny.msh
@@ -1,4 +1,4 @@
-# bunny.msh geometry file
+# bunny.msh geometry file
mshid=1
ndims=3
point=10680
diff --git a/files/eight.msh b/files/eight.msh
index 49ed237..8d46c3c 100644
--- a/files/eight.msh
+++ b/files/eight.msh
@@ -1,4 +1,4 @@
-# eight.msh geometry file
+# eight.msh geometry file
mshid=1
ndims=3
point=12866
diff --git a/files/lakes.msh b/files/lakes.msh
index 7a697e6..e41327e 100644
--- a/files/lakes.msh
+++ b/files/lakes.msh
@@ -1,4 +1,4 @@
-# lake.msh geometry file
+# lake.msh geometry file
mshid=1
ndims=2
point=303
diff --git a/files/piece.msh b/files/piece.msh
index be58301..bfc653d 100644
--- a/files/piece.msh
+++ b/files/piece.msh
@@ -1,4 +1,4 @@
-# piece.msh geometry file
+# piece.msh geometry file
mshid=1
ndims=3
point=337
diff --git a/files/wheel.msh b/files/wheel.msh
index 608744a..9a12ca3 100644
--- a/files/wheel.msh
+++ b/files/wheel.msh
@@ -1,4 +1,4 @@
-# wheel.msh geometry file
+# wheel.msh geometry file
mshid=1
ndims=3
point=6115
diff --git a/jigsawpy/__init__.py b/jigsawpy/__init__.py
index 574034a..9a280e0 100644
--- a/jigsawpy/__init__.py
+++ b/jigsawpy/__init__.py
@@ -13,9 +13,9 @@
* JIGSAW: Interface to the JIGSAW meshing library.
------------------------------------------------------------
*
- * Last updated: 13 Aug., 2025
+ * Last updated: 14 Nov., 2026
*
- * Copyright 2019-2025
+ * Copyright 2019-2026
* Darren Engwirda
* d.engwirda@gmail.com
* https://github.com/dengwirda
diff --git a/jigsawpy/bisect.py b/jigsawpy/bisect.py
index c7ea674..d4d887a 100644
--- a/jigsawpy/bisect.py
+++ b/jigsawpy/bisect.py
@@ -6,6 +6,23 @@
from jigsawpy.certify import certify
+def _clear_data(mesh):
+ cleared = []
+ for name in ("value", "slope", "power", "bound"):
+ data = getattr(mesh, name)
+ if data is not None and data.size:
+ cleared.append(name)
+
+ if cleared:
+ message = "BISECT clears MESH." \
+ + ", MESH.".join(
+ name.upper() for name in cleared)
+ warnings.warn(message, Warning)
+ empty = jigsaw_msh_t()
+ for name in cleared:
+ setattr(mesh, name, getattr(empty, name))
+
+
class struct(object): pass
class mapper(object):
#------------------------------ obj. to store index mappings
@@ -235,6 +252,8 @@ def bisect(mesh):
hexa = hexa[hfwd, :]
+ if (edge.size != 0): _clear_data(mesh)
+
#------------------------------ map unique joins to elements
if (mesh.edge2 is not None and
mesh.edge2.size != +0):
@@ -253,7 +272,7 @@ def bisect(mesh):
if (mesh.quad4 is not None and
mesh.quad4.size != +0):
qmap.quad4.index[:, 0] = \
- qrev[emap.quad4.index[:, 0]]
+ qrev[qmap.quad4.index[:, 0]]
emap.quad4.index[:, 0] = \
erev[emap.quad4.index[:, 0]]
diff --git a/jigsawpy/certify.py b/jigsawpy/certify.py
index 311aa7c..5ff9431 100644
--- a/jigsawpy/certify.py
+++ b/jigsawpy/certify.py
@@ -207,12 +207,8 @@ def certifycoord(data, stag):
def certifyNDmat(data, stag, dims):
- if (data.size > 1 and
- data.ndim != len(dims)):
- raise ValueError("Invalid " + stag + " size.")
-
- if (data.size > 1 and
- data.size != np.prod(dims)):
+ if (data.size > 1 and
+ data.shape != tuple(dims)):
raise ValueError("Invalid " + stag + " size.")
if (data.dtype != jigsaw_msh_t.REALS_t and
@@ -241,7 +237,7 @@ def certifygridt(mesh):
if (certifyarray(mesh.ygrid, "MESH.YGRID")):
- dims = dims + [mesh.ygrid.size]
+ dims = [mesh.ygrid.size] + dims
certifycoord(mesh.ygrid, "MESH.YGRID")
diff --git a/jigsawpy/def_t.py b/jigsawpy/def_t.py
index aaa313f..f3dd983 100644
--- a/jigsawpy/def_t.py
+++ b/jigsawpy/def_t.py
@@ -49,6 +49,7 @@ class jigsaw_def_t:
JIGSAW_KERN_DELFRONT = +400
JIGSAW_KERN_DELAUNAY = +401
+ JIGSAW_KERN_BISECTOR = +402
JIGSAW_BNDS_TRIACELL = +402
JIGSAW_BNDS_DUALCELL = +403
@@ -59,3 +60,9 @@ class jigsaw_def_t:
JIGSAW_KERN_AREA_LEN = +410
JIGSAW_KERN_SKEW_COS = +411
+
+ JIGSAW_MESH_RULE_SINK = +3
+ JIGSAW_MESH_RULE_OFFH = +4
+ JIGSAW_MESH_RULE_OFFC = +5
+ JIGSAW_MESH_RULE_OFFE = +6
+ JIGSAW_MESH_RULE_OFFT = +7
diff --git a/jigsawpy/jig_l.py b/jigsawpy/jig_l.py
index 519ef66..362fc9b 100644
--- a/jigsawpy/jig_l.py
+++ b/jigsawpy/jig_l.py
@@ -51,6 +51,16 @@ class libsaw_jig_t(ct.Structure):
("geom_eta2", real_t),
+ # GEOM_PHI1 - {default = 60deg} 1-dim. sharp-feature
+ # angle, to be "protected" during mesh refinement.
+
+ ("geom_phi1", real_t),
+
+ # GEOM_PHI2 - {default = 60deg} 2-dim. sharp-feature
+ # angle, to be "protected" during mesh refinement.
+
+ ("geom_phi2", real_t),
+
# INIT_NEAR - {default = 1.E-8} relative "zip" tol.
# applied when processing initial conditions. In cases
# where "sharp-feature" detection is active, nodes in
@@ -107,6 +117,13 @@ class libsaw_jig_t(ct.Structure):
("mesh_iter", indx_t),
+ # MESH_RULE - bitmask selecting which refinement
+ # rules are utilised, with e.g. the status of the bit
+ # RULE[MESH_RULE_OFFH] selecting mesh-size adaptive
+ # off-centres, see jigsaw_const.h for options.
+
+ ("mesh_rule", indx_t),
+
# MESH_ORPH - {default=true} allow "orphaned" facets
# to remain in the mesh. A K-1 dimensional subcell is
# orphaned if it does not appear in any K-dimensional
diff --git a/jigsawpy/jig_t.py b/jigsawpy/jig_t.py
index e0f6b47..3012329 100644
--- a/jigsawpy/jig_t.py
+++ b/jigsawpy/jig_t.py
@@ -55,6 +55,12 @@
features are located between any neighbouring
"faces" that subtend angles less than ETA2 deg.
+ OPTS.GEOM_PHI1 - {default = 60deg} 1-dim. sharp-feature
+ angle, to be "protected" during mesh refinement.
+
+ OPTS.GEOM_PHI2 - {default = 60deg} 2-dim. sharp-feature
+ angle, to be "protected" during mesh refinement.
+
OPTIONAL fields (HFUN):
----------------------
@@ -89,13 +95,19 @@
OPTS.MESH_KERN - {default='delfront'} meshing kernal,
choice of the standard Delaunay-refinement algorithm
- (KERN='delaunay') or the Frontal-Delaunay method
- (KERN='delfront').
+ (KERN='delaunay'), the Frontal-Delaunay method
+ (KERN='delfront'), or the Bisection method
+ (KERN='bisector').
OPTS.MESH_ITER - {default=+INF} max. number of mesh ref-
inement iterations. Set ITER=N to see progress after
N iterations.
+ OPTS.MESH_RULE - bitmask selecting which refinement
+ rules are utilised, with e.g. the status of the bit
+ RULE[MESH_RULE_OFFH] selecting mesh-size adaptive
+ off-centres, see jigsaw_const.h for options.
+
OPTS.MESH_ORPH - {default=true} allow "orphaned" facets
to remain in the mesh. A K-1 dimensional subcell is
orphaned if it does not appear in any K-dimensional
@@ -286,6 +298,9 @@ def __init__(self):
self.geom_eta1 = None
self.geom_eta2 = None
+ self.geom_phi1 = None
+ self.geom_phi2 = None
+
#------------------------------------------ HFUN options
self.hfun_file = None
self.hfun_tags = None
@@ -304,6 +319,8 @@ def __init__(self):
self.mesh_iter = None
+ self.mesh_rule = None
+
self.mesh_orph = None
self.mesh_lock = None
diff --git a/jigsawpy/jigsaw.py b/jigsawpy/jigsaw.py
index d44acfa..51e4243 100644
--- a/jigsawpy/jigsaw.py
+++ b/jigsawpy/jigsaw.py
@@ -25,6 +25,22 @@
from jigsawpy.savejig import savejig
+def _run_and_load(executable, config, filename, mesh):
+ if mesh is not None:
+ jigsaw_msh_t.__init__(mesh)
+
+ success = False
+ try:
+ subprocess.run(
+ [str(executable), config], check=True)
+ if mesh is not None:
+ loadmsh(filename, mesh)
+ success = True
+ finally:
+ if mesh is not None and not success:
+ jigsaw_msh_t.__init__(mesh)
+
+
def jigsaw(opts, mesh=None):
"""
JIGSAW cmd-line interface to JIGSAW.
@@ -37,6 +53,9 @@ def jigsaw(opts, mesh=None):
OPTS is a user-defined set of meshing options. See JIG_t
for details.
+ MESH is reset before execution, and remains empty if the
+ command or output loading fails.
+
"""
jexename = Path()
@@ -79,11 +98,9 @@ def jigsaw(opts, mesh=None):
if (jexename != Path()):
#---------------------------- call JIGSAW and capture output
- subprocess.run([
- str(jexename), opts.jcfg_file], check=True)
-
- if (mesh is not None):
- loadmsh(opts.mesh_file, mesh)
+ _run_and_load(
+ jexename, opts.jcfg_file,
+ opts.mesh_file, mesh)
else:
@@ -104,6 +121,9 @@ def tripod(opts, tria=None):
OPTS is a user-defined set of meshing options. See JIG_t
for details.
+ TRIA is reset before execution, and remains empty if the
+ command or output loading fails.
+
"""
jexename = Path()
@@ -146,11 +166,9 @@ def tripod(opts, tria=None):
if (jexename != Path()):
#---------------------------- call JIGSAW and capture output
- subprocess.run([
- str(jexename), opts.jcfg_file], check=True)
-
- if (tria is not None):
- loadmsh(opts.mesh_file, tria)
+ _run_and_load(
+ jexename, opts.jcfg_file,
+ opts.mesh_file, tria)
else:
@@ -178,6 +196,9 @@ def marche(opts, ffun=None):
OPTS is a user-defined set of meshing options. See JIG_t
for details.
+ FFUN is reset before execution, and remains empty if the
+ command or output loading fails.
+
"""
jexename = Path()
@@ -220,11 +241,9 @@ def marche(opts, ffun=None):
if (jexename != Path()):
#---------------------------- call JIGSAW and capture output
- subprocess.run([
- str(jexename), opts.jcfg_file], check=True)
-
- if (ffun is not None):
- loadmsh(opts.hfun_file, ffun)
+ _run_and_load(
+ jexename, opts.jcfg_file,
+ opts.hfun_file, ffun)
else:
@@ -258,7 +277,8 @@ def jitter(opts, imax, ibad, mesh=None):
if (mesh.power is not None): npwr = mesh.power.size
if (opts.optm_dual is not None):
- OPTS.optm_dual = iter == imax-1 or npts == npwr
+ OPTS.optm_dual = opts.optm_dual and \
+ (iter == imax-1 or npts == npwr)
if (mesh.point is not None and
mesh.point.size != +0):
@@ -363,7 +383,7 @@ def tetris(opts, nlev, mesh=None):
if (opts.optm_dual is not None):
#------------------------ create/write current DUAL data
- OPTS.optm_dual = nlev == 0
+ OPTS.optm_dual = opts.optm_dual and nlev == 0
if (opts.hfun_hmax is not None):
#------------------------ create/write current HMAX data
@@ -395,6 +415,9 @@ def tetris(opts, nlev, mesh=None):
savemsh(OPTS.hfun_file, HFUN)
+ elif (opts.hfun_file is not None):
+ OPTS.hfun_file = opts.hfun_file
+
#------------------------ call JIGSAW kernel at this lev
jitter(OPTS, 4 + (nlev > 0) *12, 3, mesh)
@@ -462,12 +485,13 @@ def refine(opts, nlev, mesh=None):
for ilev in reversed(range(nlev + 1)):
+ OPTS = copy.copy(opts)
if (opts.optm_dual is not None):
#------------------------ create/write current DUAL data
- opts.optm_dual = ilev == 0
+ OPTS.optm_dual = opts.optm_dual and ilev == 0
#------------------------ call JIGSAW kernel at this lev
- jigsaw(opts, mesh)
+ jigsaw(OPTS, mesh)
if (ilev <= +0): break
@@ -509,6 +533,7 @@ def icosahedron(opts, nlev, mesh=None):
loadmsh(opts.geom_file, geom)
if (mesh is None): mesh = jigsaw_msh_t()
+ else: jigsaw_msh_t.__init__(mesh)
#-------------------------------- setup icosahedron geometry
la = math.atan(0.5)
@@ -590,6 +615,7 @@ def cubedsphere(opts, nlev, mesh=None):
loadmsh(opts.geom_file, geom)
if (mesh is None): mesh = jigsaw_msh_t()
+ else: jigsaw_msh_t.__init__(mesh)
#-------------------------------- setup cubedsphere geometry
aval = math.atan(
diff --git a/jigsawpy/libsaw.py b/jigsawpy/libsaw.py
index 34c9f2d..ccc5622 100644
--- a/jigsawpy/libsaw.py
+++ b/jigsawpy/libsaw.py
@@ -24,681 +24,261 @@
from jigsawpy.jig_t import jigsaw_jig_t
from jigsawpy.msh_t import jigsaw_msh_t
-#---------------------------- Try to find/load JIGSAW's API.
-JLIBNAME = Path()
-
-if (JLIBNAME == Path()):
-#---------------------------- set-up path for "local" binary
-
- WIN = "Windows"
- LNX = "Linux"
- MAC = "Darwin"
-
-# stackoverflow.com/questions/2632199/
-# how-do-i-get-the-
-# path-of-the-current-executed-file-in-python
- FILENAME = \
- inspect.getsourcefile(lambda: +0)
-
- FILEPATH = \
- (Path(FILENAME).resolve()).parent
-
- if (platform.system() == WIN):
- JLIBNAME = \
- FILEPATH / "_lib" / "jigsaw.dll"
-
- elif (platform.system() == LNX):
- JLIBNAME = \
- FILEPATH / "_lib" / "libjigsaw.so"
-
- elif (platform.system() == MAC):
- JLIBNAME = \
- FILEPATH / "_lib" / "libjigsaw.dylib"
-
- if (not JLIBNAME.is_file()):
- JLIBNAME = Path()
-
-if (JLIBNAME == Path()):
-#---------------------------- search machine path for binary
- if (platform.system() == WIN):
- JLIBNAME = Path(
- ctypes.util.find_library("jigsaw.dll"))
-
- elif (platform.system() == LNX):
- JLIBNAME = Path("libjigsaw.so")
-
- elif (platform.system() == MAC):
- JLIBNAME = Path("libjigsaw.dylib")
-
-if (JLIBNAME != Path()):
-#---------------------------- load jigsaw library via ctypes
- JLIB = ct.cdll.LoadLibrary(str(JLIBNAME))
-
-else:
- raise ValueError("JIGSAW lib. not found")
+_LIB_NAMES = {
+ "Windows": "jigsaw.dll",
+ "Linux" : "libjigsaw.so",
+ "Darwin" : "libjigsaw.dylib",
+}
+
+_LIBRARY = _LIB_NAMES.get(platform.system())
+if _LIBRARY is None:
+ raise ValueError(
+ "Unsupported platform: " + platform.system())
+
+JLIBNAME = Path(
+ inspect.getsourcefile(lambda: 0)).resolve().parent
+JLIBNAME = JLIBNAME / "_lib" / _LIBRARY
+if not JLIBNAME.is_file():
+ JLIBNAME = Path(
+ ctypes.util.find_library(_LIBRARY) or _LIBRARY)
+JLIB = ct.cdll.LoadLibrary(str(JLIBNAME))
+
+
+_KERNELS = {
+ "hfun_scal": {
+ "absolute": defs.JIGSAW_HFUN_ABSOLUTE,
+ "relative": defs.JIGSAW_HFUN_RELATIVE,
+ },
+ "bnds_kern": {
+ "triacell": defs.JIGSAW_BNDS_TRIACELL,
+ "dualcell": defs.JIGSAW_BNDS_DUALCELL,
+ },
+ "mesh_kern": {
+ "delfront": defs.JIGSAW_KERN_DELFRONT,
+ "delaunay": defs.JIGSAW_KERN_DELAUNAY,
+ "bisector": defs.JIGSAW_KERN_BISECTOR,
+ },
+ "optm_kern": {
+ "odt+dqdx": defs.JIGSAW_KERN_ODT_DQDX,
+ "cvt+dqdx": defs.JIGSAW_KERN_CVT_DQDX,
+ "h95+dqdx": defs.JIGSAW_KERN_H95_DQDX,
+ },
+ "optm_cost": {
+ "area-len": defs.JIGSAW_KERN_AREA_LEN,
+ "skew-cos": defs.JIGSAW_KERN_SKEW_COS,
+ },
+}
+
+_INTEGER_OPTS = frozenset(
+ "verbosity numthread geom_seed mesh_dims mesh_iter "
+ "mesh_rule optm_iter".split())
+_BOOLEAN_OPTS = frozenset(
+ "geom_feat mesh_orph mesh_lock mesh_top1 mesh_top2 "
+ "optm_tria optm_dual optm_zip_ optm_div_".split())
+
+_MESH_FLAGS = {
+ "euclidean-mesh": defs.JIGSAW_EUCLIDEAN_MESH,
+ "euclidean-grid": defs.JIGSAW_EUCLIDEAN_GRID,
+ "ellipsoid-mesh": defs.JIGSAW_ELLIPSOID_MESH,
+ "ellipsoid-grid": defs.JIGSAW_ELLIPSOID_GRID,
+}
+
+# field, dtype, ctypes pointer target, and native deallocator
+_MESH_ARRAYS = (
+ ("vert2", jigsaw_msh_t.VERT2_t, libsaw_VERT2_t, "vert2"),
+ ("vert3", jigsaw_msh_t.VERT3_t, libsaw_VERT3_t, "vert3"),
+ ("power", real_t, real_t, "reals"),
+ ("edge2", jigsaw_msh_t.EDGE2_t, libsaw_EDGE2_t, "edge2"),
+ ("tria3", jigsaw_msh_t.TRIA3_t, libsaw_TRIA3_t, "tria3"),
+ ("quad4", jigsaw_msh_t.QUAD4_t, libsaw_QUAD4_t, "quad4"),
+ ("tria4", jigsaw_msh_t.TRIA4_t, libsaw_TRIA4_t, "tria4"),
+ ("hexa8", jigsaw_msh_t.HEXA8_t, libsaw_HEXA8_t, "hexa8"),
+ ("wedg6", jigsaw_msh_t.WEDG6_t, libsaw_WEDG6_t, "wedg6"),
+ ("pyra5", jigsaw_msh_t.PYRA5_t, libsaw_PYRA5_t, "pyra5"),
+ ("bound", jigsaw_msh_t.BOUND_t, libsaw_BOUND_t, "bound"),
+ ("seed2", jigsaw_msh_t.VERT2_t, libsaw_VERT2_t, "vert2"),
+ ("seed3", jigsaw_msh_t.VERT3_t, libsaw_VERT3_t, "vert3"),
+ ("radii", real_t, real_t, "reals"),
+ ("xgrid", real_t, real_t, "reals"),
+ ("ygrid", real_t, real_t, "reals"),
+ ("zgrid", real_t, real_t, "reals"),
+ ("value", fp32_t, fp32_t, "flt32"),
+ ("slope", fp32_t, fp32_t, "flt32"),
+)
def is_type_t(data, kind):
-
- base = getattr(data, "tolist", lambda: data)()
-
- return isinstance(base, kind)
+ return isinstance(
+ getattr(data, "tolist", lambda: data)(), kind)
def put_jig_t(jigt, jigl):
- """
- PUT-JIG_t: Assign data from python-to-ctypes objects.
-
- """
- if (jigt is None): return
-
- if (not isinstance(jigt, jigsaw_jig_t)):
+ if jigt is None:
+ return
+ if not isinstance(jigt, jigsaw_jig_t):
raise TypeError("OPTS not JIG_t")
- #--------------------------------- assign "kernels" opt.
- if (isinstance(jigt.hfun_scal, str)):
- if (jigt.hfun_scal.lower() == "absolute"):
- jigl.hfun_scal = \
- defs.JIGSAW_HFUN_ABSOLUTE
-
- if (jigt.hfun_scal.lower() == "relative"):
- jigl.hfun_scal = \
- defs.JIGSAW_HFUN_RELATIVE
-
- elif (jigt.hfun_scal is not None):
- raise TypeError("HFUN-SCAL type")
-
- if (isinstance(jigt.bnds_kern, str)):
- if (jigt.bnds_kern.lower() == "triacell"):
- jigl.bnds_kern = \
- defs.JIGSAW_BNDS_TRIACELL
-
- if (jigt.bnds_kern.lower() == "dualcell"):
- jigl.bnds_kern = \
- defs.JIGSAW_BNDS_DUALCELL
-
- elif (jigt.bnds_kern is not None):
- raise TypeError("BNDS-KERN type")
-
- if (isinstance(jigt.mesh_kern, str)):
- if (jigt.mesh_kern.lower() == "delfront"):
- jigl.mesh_kern = \
- defs.JIGSAW_KERN_DELFRONT
-
- if (jigt.mesh_kern.lower() == "delaunay"):
- jigl.mesh_kern = \
- defs.JIGSAW_KERN_DELAUNAY
-
- elif (jigt.mesh_kern is not None):
- raise TypeError("MESH-KERN type")
-
- if (isinstance(jigt.optm_kern, str)):
- if (jigt.optm_kern.lower() == "odt+dqdx"):
- jigl.optm_kern = \
- defs.JIGSAW_KERN_ODT_DQDX
-
- if (jigt.optm_kern.lower() == "cvt+dqdx"):
- jigl.optm_kern = \
- defs.JIGSAW_KERN_CVT_DQDX
-
- if (jigt.optm_kern.lower() == "h95+dqdx"):
- jigl.optm_kern = \
- defs.JIGSAW_KERN_H95_DQDX
-
- elif (jigt.optm_kern is not None):
- raise TypeError("OPTM-KERN type")
-
- if (isinstance(jigt.optm_cost, str)):
- if (jigt.optm_cost.lower() == "area-len"):
- jigl.optm_cost = \
- defs.JIGSAW_KERN_AREA_LEN
-
- if (jigt.optm_cost.lower() == "skew-cos"):
- jigl.optm_cost = \
- defs.JIGSAW_KERN_SKEW_COS
-
- elif (jigt.optm_cost is not None):
- raise TypeError("OPTM-COST type")
-
- #--------------------------------- assign MISC user-opt.
- if (is_type_t(jigt.verbosity, int)):
- jigl.verbosity = indx_t(jigt.verbosity)
- elif (jigt.verbosity is not None):
- raise TypeError("VERBOSITY type")
-
- if (is_type_t(jigt.numthread, int)):
- jigl.numthread = indx_t(jigt.numthread)
- elif (jigt.numthread is not None):
- raise TypeError("NUMTHREAD type")
-
- #--------------------------------- assign GEOM user-opt.
- if (is_type_t(jigt.geom_seed, int)):
- jigl.geom_seed = indx_t(jigt.geom_seed)
- elif (jigt.geom_seed is not None):
- raise TypeError("GEOM-SEED type")
-
- if (is_type_t(jigt.geom_feat, bool)):
- jigl.geom_feat = indx_t(jigt.geom_feat)
- elif (jigt.geom_feat is not None):
- raise TypeError("GEOM-FEAT type")
-
- if (is_type_t(jigt.geom_eta1, float)):
- jigl.geom_eta1 = real_t(jigt.geom_eta1)
- elif (jigt.geom_eta1 is not None):
- raise TypeError("GEOM-ETA1 type")
-
- if (is_type_t(jigt.geom_eta2, float)):
- jigl.geom_eta2 = real_t(jigt.geom_eta2)
- elif (jigt.geom_eta2 is not None):
- raise TypeError("GEOM-ETA2 type")
-
- #--------------------------------- assign INIT user-opt.
- if (is_type_t(jigt.init_near, float)):
- jigl.init_near = real_t(jigt.init_near)
- elif (jigt.init_near is not None):
- raise TypeError("INIT-NEAR type")
-
- #--------------------------------- assign HFUN user-opt.
- if (is_type_t(jigt.hfun_hmax, float)):
- jigl.hfun_hmax = real_t(jigt.hfun_hmax)
- elif (jigt.hfun_hmax is not None):
- raise TypeError("HFUN-HMAX type")
-
- if (is_type_t(jigt.hfun_hmin, float)):
- jigl.hfun_hmin = real_t(jigt.hfun_hmin)
- elif (jigt.hfun_hmin is not None):
- raise TypeError("HFUN-HMIN type")
-
- #--------------------------------- assign MESH user-opt.
- if (is_type_t(jigt.mesh_dims, int)):
- jigl.mesh_dims = indx_t(jigt.mesh_dims)
- elif (jigt.mesh_dims is not None):
- raise TypeError("MESH-DIMS type")
-
- if (is_type_t(jigt.mesh_iter, int)):
- jigl.mesh_iter = indx_t(jigt.mesh_iter)
- elif (jigt.mesh_iter is not None):
- raise TypeError("MESH-ITER type")
-
- if (is_type_t(jigt.mesh_orph, bool)):
- jigl.mesh_orph = indx_t(jigt.mesh_orph)
- elif (jigt.mesh_orph is not None):
- raise TypeError("MESH-ORPH type")
-
- if (is_type_t(jigt.mesh_lock, bool)):
- jigl.mesh_lock = indx_t(jigt.mesh_lock)
- elif (jigt.mesh_lock is not None):
- raise TypeError("MESH-LOCK type")
-
- if (is_type_t(jigt.mesh_top1, bool)):
- jigl.mesh_top1 = indx_t(jigt.mesh_top1)
- elif (jigt.mesh_top1 is not None):
- raise TypeError("MESH-TOP1 type")
-
- if (is_type_t(jigt.mesh_top2, bool)):
- jigl.mesh_top2 = indx_t(jigt.mesh_top2)
- elif (jigt.mesh_top2 is not None):
- raise TypeError("MESH-TOP2 type")
-
- if (is_type_t(jigt.mesh_rad2, float)):
- jigl.mesh_rad2 = real_t(jigt.mesh_rad2)
- elif (jigt.mesh_rad2 is not None):
- raise TypeError("MESH-RAD2 type")
-
- if (is_type_t(jigt.mesh_rad3, float)):
- jigl.mesh_rad3 = real_t(jigt.mesh_rad3)
- elif (jigt.mesh_rad3 is not None):
- raise TypeError("MESH-RAD3 type")
-
- if (is_type_t(jigt.mesh_siz1, float)):
- jigl.mesh_siz1 = real_t(jigt.mesh_siz1)
- elif (jigt.mesh_siz1 is not None):
- raise TypeError("MESH-SIZ1 type")
-
- if (is_type_t(jigt.mesh_siz2, float)):
- jigl.mesh_siz2 = real_t(jigt.mesh_siz2)
- elif (jigt.mesh_siz2 is not None):
- raise TypeError("MESH-SIZ2 type")
-
- if (is_type_t(jigt.mesh_siz3, float)):
- jigl.mesh_siz3 = real_t(jigt.mesh_siz3)
- elif (jigt.mesh_siz3 is not None):
- raise TypeError("MESH-SIZ3 type")
-
- if (is_type_t(jigt.mesh_off2, float)):
- jigl.mesh_off2 = real_t(jigt.mesh_off2)
- elif (jigt.mesh_off2 is not None):
- raise TypeError("MESH-OFF2 type")
-
- if (is_type_t(jigt.mesh_off3, float)):
- jigl.mesh_off3 = real_t(jigt.mesh_off3)
- elif (jigt.mesh_off3 is not None):
- raise TypeError("MESH-OFF3 type")
-
- if (is_type_t(jigt.mesh_snk2, float)):
- jigl.mesh_snk2 = real_t(jigt.mesh_snk2)
- elif (jigt.mesh_snk2 is not None):
- raise TypeError("MESH-SNK2 type")
-
- if (is_type_t(jigt.mesh_snk3, float)):
- jigl.mesh_snk3 = real_t(jigt.mesh_snk3)
- elif (jigt.mesh_snk3 is not None):
- raise TypeError("MESH-SNK3 type")
-
- if (is_type_t(jigt.mesh_eps1, float)):
- jigl.mesh_eps1 = real_t(jigt.mesh_eps1)
- elif (jigt.mesh_eps1 is not None):
- raise TypeError("MESH-EPS1 type")
-
- if (is_type_t(jigt.mesh_eps2, float)):
- jigl.mesh_eps2 = real_t(jigt.mesh_eps2)
- elif (jigt.mesh_eps2 is not None):
- raise TypeError("MESH-EPS2 type")
-
- if (is_type_t(jigt.mesh_vol3, float)):
- jigl.mesh_vol3 = real_t(jigt.mesh_vol3)
- elif (jigt.mesh_vol3 is not None):
- raise TypeError("MESH-VOL3 type")
-
- #--------------------------------- assign OPTM user-opt.
- if (is_type_t(jigt.optm_iter, int)):
- jigl.optm_iter = indx_t(jigt.optm_iter)
- elif (jigt.optm_iter is not None):
- raise TypeError("OPTM-ITER type")
-
- if (is_type_t(jigt.optm_beta, float)):
- jigl.optm_beta = real_t(jigt.optm_beta)
- elif (jigt.optm_beta is not None):
- raise TypeError("OPTM-BETA type")
-
- if (is_type_t(jigt.optm_zeta, float)):
- jigl.optm_zeta = real_t(jigt.optm_zeta)
- elif (jigt.optm_zeta is not None):
- raise TypeError("OPTM-ZETA type")
-
- if (is_type_t(jigt.optm_qtol, float)):
- jigl.optm_qtol = real_t(jigt.optm_qtol)
- elif (jigt.optm_qtol is not None):
- raise TypeError("OPTM-QTOL type")
-
- if (is_type_t(jigt.optm_qlim, float)):
- jigl.optm_qlim = real_t(jigt.optm_qlim)
- elif (jigt.optm_qlim is not None):
- raise TypeError("OPTM-QLIM type")
-
- if (is_type_t(jigt.optm_wmin, float)):
- jigl.optm_wmin = real_t(jigt.optm_wmin)
- elif (jigt.optm_wmin is not None):
- raise TypeError("OPTM-WMIN type")
-
- if (is_type_t(jigt.optm_wmax, float)):
- jigl.optm_wmax = real_t(jigt.optm_wmax)
- elif (jigt.optm_wmax is not None):
- raise TypeError("OPTM-WMAX type")
-
- if (is_type_t(jigt.optm_tria, bool)):
- jigl.optm_tria = indx_t(jigt.optm_tria)
- elif (jigt.optm_tria is not None):
- raise TypeError("OPTM-TRIA type")
-
- if (is_type_t(jigt.optm_dual, bool)):
- jigl.optm_dual = indx_t(jigt.optm_dual)
- elif (jigt.optm_dual is not None):
- raise TypeError("OPTM-DUAL type")
-
- if (is_type_t(jigt.optm_zip_, bool)):
- jigl.optm_zip_ = indx_t(jigt.optm_zip_)
- elif (jigt.optm_zip_ is not None):
- raise TypeError("OPTM-ZIP_ type")
-
- if (is_type_t(jigt.optm_div_, bool)):
- jigl.optm_div_ = indx_t(jigt.optm_div_)
- elif (jigt.optm_div_ is not None):
- raise TypeError("OPTM-DIV_ type")
-
- return
+ for name, options in _KERNELS.items():
+ value = getattr(jigt, name)
+ if value is None:
+ continue
+ if isinstance(value, str):
+ code = options.get(value.lower())
+ if code is None:
+ raise ValueError(
+ "Invalid " +
+ name.upper().replace("_", "-") + " value")
+ setattr(jigl, name, indx_t(code))
+ else:
+ raise TypeError(
+ name.upper().replace("_", "-") + " type")
+
+ for name, ctype in libsaw_jig_t._fields_:
+ if name in _KERNELS:
+ continue
+ value = getattr(jigt, name)
+ if value is None:
+ continue
+
+ kind = (int if name in _INTEGER_OPTS else
+ bool if name in _BOOLEAN_OPTS else float)
+ if not is_type_t(value, kind):
+ raise TypeError(
+ name.upper().replace("_", "-") + " type")
+ setattr(jigl, name, ctype(value))
def put_ptr_t(data, kind):
-
- #--------------------------------- helper to assign ptrs
return data.ctypes.data_as(ct.POINTER(kind))
def put_msh_t(msht, mshl):
- """
- PUT-MSH_t: Assign ptrs from python-to-ctypes objects.
-
- """
- if (msht is None): return
+ if msht is None: return
certify(msht)
- if (msht.mshID is not None):
- #--------------------------------- assign mshID variable
- istr = msht.mshID.lower()
-
- if (istr == "euclidean-mesh"):
- mshl.flags = \
- defs.JIGSAW_EUCLIDEAN_MESH
-
- if (istr == "euclidean-grid"):
- mshl.flags = \
- defs.JIGSAW_EUCLIDEAN_GRID
-
- if (istr == "ellipsoid-mesh"):
- mshl.flags = \
- defs.JIGSAW_ELLIPSOID_MESH
-
- if (istr == "ellipsoid-grid"):
- mshl.flags = \
- defs.JIGSAW_ELLIPSOID_GRID
-
- if (msht.radii is not None and
- msht.radii.size != +0):
- #--------------------------------- assign ptrs for RADII
- mshl.radii.size = msht.radii.size
- mshl.radii.data = \
- put_ptr_t(msht.radii, real_t)
-
- if (msht.vert2 is not None and
- msht.vert2.size != +0):
- #--------------------------------- assign ptrs for VERT2
- mshl.vert2.size = msht.vert2.size
- mshl.vert2.data = put_ptr_t(
- msht.vert2, libsaw_VERT2_t)
-
- if (msht.vert3 is not None and
- msht.vert3.size != +0):
- #--------------------------------- assign ptrs for VERT3
- mshl.vert3.size = msht.vert3.size
- mshl.vert3.data = put_ptr_t(
- msht.vert3, libsaw_VERT3_t)
-
- if (msht.seed2 is not None and
- msht.seed2.size != +0):
- #--------------------------------- assign ptrs for SEED2
- mshl.seed2.size = msht.seed2.size
- mshl.seed2.data = put_ptr_t(
- msht.seed2, libsaw_VERT2_t)
-
- if (msht.seed3 is not None and
- msht.seed3.size != +0):
- #--------------------------------- assign ptrs for SEED3
- mshl.seed3.size = msht.seed3.size
- mshl.seed3.data = put_ptr_t(
- msht.seed3, libsaw_VERT3_t)
-
- if (msht.power is not None and
- msht.power.size != +0):
- #--------------------------------- assign ptrs for POWER
- msht.power = \
- np.asfortranarray(msht.power)
-
- mshl.power.size = msht.power.size
- mshl.power.data = \
- put_ptr_t(msht.power, real_t)
-
- if (msht.edge2 is not None and
- msht.edge2.size != +0):
- #--------------------------------- assign ptrs for EDGE2
- mshl.edge2.size = msht.edge2.size
- mshl.edge2.data = put_ptr_t(
- msht.edge2, libsaw_EDGE2_t)
-
- if (msht.tria3 is not None and
- msht.tria3.size != +0):
- #--------------------------------- assign ptrs for TRIA3
- mshl.tria3.size = msht.tria3.size
- mshl.tria3.data = put_ptr_t(
- msht.tria3, libsaw_TRIA3_t)
-
- if (msht.quad4 is not None and
- msht.quad4.size != +0):
- #--------------------------------- assign ptrs for QUAD4
- mshl.quad4.size = msht.quad4.size
- mshl.quad4.data = put_ptr_t(
- msht.quad4, libsaw_QUAD4_t)
-
- if (msht.tria4 is not None and
- msht.tria4.size != +0):
- #--------------------------------- assign ptrs for TRIA4
- mshl.tria4.size = msht.tria4.size
- mshl.tria4.data = put_ptr_t(
- msht.tria4, libsaw_TRIA4_t)
-
- if (msht.hexa8 is not None and
- msht.hexa8.size != +0):
- #--------------------------------- assign ptrs for HEXA8
- mshl.hexa8.size = msht.hexa8.size
- mshl.hexa8.data = put_ptr_t(
- msht.hexa8, libsaw_HEXA8_t)
-
- if (msht.wedg6 is not None and
- msht.wedg6.size != +0):
- #--------------------------------- assign ptrs for WEDG6
- mshl.wedg6.size = msht.wedg6.size
- mshl.wedg6.data = put_ptr_t(
- msht.wedg6, libsaw_WEDG6_t)
-
- if (msht.pyra5 is not None and
- msht.pyra5.size != +0):
- #--------------------------------- assign ptrs for PYRA5
- mshl.pyra5.size = msht.pyra5.size
- mshl.pyra5.data = put_ptr_t(
- msht.pyra5, libsaw_PYRA5_t)
-
- if (msht.bound is not None and
- msht.bound.size != +0):
- #--------------------------------- assign ptrs for BOUND
- mshl.bound.size = msht.bound.size
- mshl.bound.data = put_ptr_t(
- msht.bound, libsaw_BOUND_t)
-
- if (msht.xgrid is not None and
- msht.xgrid.size != +0):
- #--------------------------------- assign ptrs for XGRID
- mshl.xgrid.size = msht.xgrid.size
- mshl.xgrid.data = \
- put_ptr_t(msht.xgrid, real_t)
-
- if (msht.ygrid is not None and
- msht.ygrid.size != +0):
- #--------------------------------- assign ptrs for YGRID
- mshl.ygrid.size = msht.ygrid.size
- mshl.ygrid.data = \
- put_ptr_t(msht.ygrid, real_t)
-
- if (msht.zgrid is not None and
- msht.zgrid.size != +0):
- #--------------------------------- assign ptrs for ZGRID
- mshl.zgrid.size = msht.zgrid.size
- mshl.zgrid.data = \
- put_ptr_t(msht.zgrid, real_t)
-
- if (msht.value is not None and
- msht.value.size != +0):
- #--------------------------------- assign ptrs for VALUE
- msht.value = np.asfortranarray(
- msht.value, dtype=np.float32)
-
- mshl.value.size = msht.value.size
- mshl.value.data = \
- put_ptr_t(msht.value, fp32_t)
-
- if (msht.slope is not None and
- msht.slope.size != +0):
- #--------------------------------- assign ptrs for SLOPE
- msht.slope = np.asfortranarray(
- msht.slope, dtype=np.float32)
-
- mshl.slope.size = msht.slope.size
- mshl.slope.data = \
- put_ptr_t(msht.slope, fp32_t)
-
- return
-
-
-def get_ptr_t(ptrl, kind):
-
- #--------------------------------- helper to copy buffer
- data = np.empty(ptrl.size, dtype=kind)
-
- byte = np.dtype(kind).itemsize
-
- ct.memmove(data.ctypes.data,
- ptrl.data,
- ptrl.size * byte)
-
+ try:
+ mshl.flags = _MESH_FLAGS[msht.mshID.lower()]
+ except KeyError as error:
+ raise ValueError(
+ "Invalid MESH.MSHID tag.") from error
+
+ owners = []
+ for name, dtype, pointer_type, _ in _MESH_ARRAYS:
+ data = getattr(msht, name)
+ if data is None or data.size == 0:
+ continue
+
+ if name in ("power", "radii",
+ "xgrid", "ygrid", "zgrid",
+ "value", "slope"):
+ data = np.asfortranarray(data, dtype=dtype)
+ else:
+ data = np.ascontiguousarray(data)
+
+ owners.append(data)
+ c_array = getattr(mshl, name)
+ c_array.size = data.size
+ c_array.data = put_ptr_t(data, pointer_type)
+
+ if name in ("power", "value", "slope"):
+ setattr(msht, name, data)
+
+ mshl._keepalive = owners
+
+
+def _copy_and_free(c_array, dtype, free_type):
+ try:
+ view = np.ctypeslib.as_array(
+ c_array.data, shape=(c_array.size,))
+ return view.view(dtype).copy()
+ finally:
+ getattr(JLIB, "jigsaw_free_" + free_type)(
+ ct.byref(c_array))
+
+
+def get_msh_values(data, mesh, stag):
+ if data.size == 1:
+ return data.reshape((1, 1))
+
+ if mesh.mshID.lower() in ("euclidean-grid", "ellipsoid-grid"):
+ x, y, z = mesh.xgrid.size, mesh.ygrid.size, mesh.zgrid.size
+ axes = [size for size in (x, y, z) if size]
+ if not axes:
+ return data
+
+ npos = int(np.prod(axes))
+ if data.size % npos:
+ raise ValueError("Invalid MESH." + stag + " size")
+ nval = data.size // npos
+
+ if len(axes) == 1:
+ shape = (axes[0], nval)
+ elif x and y and z:
+ shape = (y, x, z, nval)
+ elif x and y:
+ shape = (y, x, nval)
+ else:
+ shape = tuple(axes) + (nval,)
+
+ data = data.reshape(shape, order="F")
+ return data.squeeze(axis=-1) if nval == 1 else data
+
+ point = mesh.point
+ if point is not None and point.size:
+ if data.size % point.size:
+ raise ValueError("Invalid MESH." + stag + " size")
+ return data.reshape((point.size, data.size // point.size),
+ order="F")
return data
def get_msh_t(msht, mshl):
- """
- GET-MSH_t: Copy buffer from ctypes-to-python objects.
-
- """
-
- #--------------------------------- assign mshID variable
- if (mshl.flags ==
- defs.JIGSAW_EUCLIDEAN_MESH):
-
- msht.mshID = "euclidean-mesh"
-
- if (mshl.flags ==
- defs.JIGSAW_EUCLIDEAN_GRID):
-
- msht.mshID = "euclidean-grid"
-
- if (mshl.flags ==
- defs.JIGSAW_ELLIPSOID_MESH):
-
- msht.mshID = "ellipsoid-mesh"
-
- if (mshl.flags ==
- defs.JIGSAW_ELLIPSOID_GRID):
-
- msht.mshID = "ellipsoid-grid"
-
- if (mshl.radii.size >= +1):
- #--------------------------------- copy buffer for RADII
- msht.radii = get_ptr_t(
- mshl.radii, jigsaw_msh_t.REALS_t)
-
- ptrl = ct.byref(mshl.radii)
-
- JLIB.jigsaw_free_reals(ptrl)
-
- if (mshl.vert2.size >= +1):
- #--------------------------------- copy buffer for VERT2
- msht.vert2 = get_ptr_t(
- mshl.vert2, jigsaw_msh_t.VERT2_t)
-
- ptrl = ct.byref(mshl.vert2)
-
- JLIB.jigsaw_free_vert2(ptrl)
-
- if (mshl.vert3.size >= +1):
- #--------------------------------- copy buffer for VERT3
- msht.vert3 = get_ptr_t(
- mshl.vert3, jigsaw_msh_t.VERT3_t)
-
- ptrl = ct.byref(mshl.vert3)
-
- JLIB.jigsaw_free_vert3(ptrl)
-
- if (mshl.seed2.size >= +1):
- #--------------------------------- copy buffer for SEED2
- msht.seed2 = get_ptr_t(
- mshl.seed2, jigsaw_msh_t.VERT2_t)
-
- ptrl = ct.byref(mshl.seed2)
-
- JLIB.jigsaw_free_vert2(ptrl)
-
- if (mshl.seed3.size >= +1):
- #--------------------------------- copy buffer for SEED3
- msht.seed3 = get_ptr_t(
- mshl.seed3, jigsaw_msh_t.VERT3_t)
-
- ptrl = ct.byref(mshl.seed3)
-
- JLIB.jigsaw_free_vert3(ptrl)
-
- if (mshl.power.size >= +1):
- #--------------------------------- copy buffer for POWER
- msht.power = get_ptr_t(
- mshl.power, jigsaw_msh_t.REALS_t)
-
- ptrl = ct.byref(mshl.power)
-
- JLIB.jigsaw_free_reals(ptrl)
-
- if (mshl.edge2.size >= +1):
- #--------------------------------- copy buffer for EDGE2
- msht.edge2 = get_ptr_t(
- mshl.edge2, jigsaw_msh_t.EDGE2_t)
-
- ptrl = ct.byref(mshl.edge2)
-
- JLIB.jigsaw_free_edge2(ptrl)
-
- if (mshl.tria3.size >= +1):
- #--------------------------------- copy buffer for TRIA3
- msht.tria3 = get_ptr_t(
- mshl.tria3, jigsaw_msh_t.TRIA3_t)
-
- ptrl = ct.byref(mshl.tria3)
-
- JLIB.jigsaw_free_tria3(ptrl)
-
- if (mshl.quad4.size >= +1):
- #--------------------------------- copy buffer for QUAD4
- msht.quad4 = get_ptr_t(
- mshl.quad4, jigsaw_msh_t.QUAD4_t)
-
- ptrl = ct.byref(mshl.quad4)
-
- JLIB.jigsaw_free_quad4(ptrl)
-
- if (mshl.tria4.size >= +1):
- #--------------------------------- copy buffer for TRIA4
- msht.tria4 = get_ptr_t(
- mshl.tria4, jigsaw_msh_t.TRIA4_t)
-
- ptrl = ct.byref(mshl.tria4)
-
- JLIB.jigsaw_free_tria4(ptrl)
-
- if (mshl.hexa8.size >= +1):
- #--------------------------------- copy buffer for HEXA8
- msht.hexa8 = get_ptr_t(
- mshl.hexa8, jigsaw_msh_t.HEXA8_t)
-
- ptrl = ct.byref(mshl.hexa8)
-
- JLIB.jigsaw_free_hexa8(ptrl)
-
- if (mshl.wedg6.size >= +1):
- #--------------------------------- copy buffer for WEDG6
- msht.wedg6 = get_ptr_t(
- mshl.wedg6, jigsaw_msh_t.WEDG6_t)
-
- ptrl = ct.byref(mshl.wedg6)
-
- JLIB.jigsaw_free_wedg6(ptrl)
-
- if (mshl.pyra5.size >= +1):
- #--------------------------------- copy buffer for PYRA5
- msht.pyra5 = get_ptr_t(
- mshl.pyra5, jigsaw_msh_t.PYRA5_t)
-
- ptrl = ct.byref(mshl.pyra5)
-
- JLIB.jigsaw_free_pyra5(ptrl)
-
- return
+ for name, flag in _MESH_FLAGS.items():
+ if mshl.flags == flag:
+ msht.mshID = name
+ break
+ else:
+ raise ValueError("Invalid MESH.MSHID flag.")
+
+ empty = jigsaw_msh_t()
+ for name, dtype, _, free_type in _MESH_ARRAYS:
+ c_array = getattr(mshl, name)
+ if c_array.size:
+ setattr(msht, name, _copy_and_free(
+ c_array, dtype, free_type))
+ else:
+ setattr(msht, name, getattr(empty, name))
+
+ msht.ndims = (
+ 3 if msht.vert3.size or msht.zgrid.size else
+ 2 if msht.vert2.size or msht.ygrid.size else
+ 1 if msht.xgrid.size else 0)
+
+ if msht.power.size and msht.point is not None:
+ npoint = msht.point.size
+ if msht.power.size % npoint == 0:
+ msht.power = msht.power.reshape(
+ (npoint, msht.power.size // npoint), order="F")
+
+ msht.value = get_msh_values(msht.value, msht, "VALUE") \
+ if msht.value.size else msht.value
+ msht.slope = get_msh_values(msht.slope, msht, "SLOPE") \
+ if msht.slope.size else msht.slope
+
+
+def _init_mesh():
+ msh = libsaw_msh_t()
+ JLIB.jigsaw_init_msh_t(ct.byref(msh))
+ return msh
+
+
+def _init_opts(opts):
+ jig = libsaw_jig_t()
+ JLIB.jigsaw_init_jig_t(ct.byref(jig))
+ put_jig_t(opts, jig)
+ return jig
def jigsaw(opts, geom, mesh, init=None, hfun=None):
@@ -715,51 +295,29 @@ def jigsaw(opts, geom, mesh, init=None, hfun=None):
for details.
"""
-
- #--------------------------------- set-up ctypes objects
-
- ojig = libsaw_jig_t()
-
- JLIB.jigsaw_init_jig_t(ct.byref(ojig))
-
- put_jig_t(opts, ojig)
-
- gmsh = libsaw_msh_t()
- mmsh = libsaw_msh_t()
- imsh = libsaw_msh_t()
- hmsh = libsaw_msh_t()
-
- JLIB.jigsaw_init_msh_t(ct.byref(gmsh))
- JLIB.jigsaw_init_msh_t(ct.byref(mmsh))
- JLIB.jigsaw_init_msh_t(ct.byref(imsh))
- JLIB.jigsaw_init_msh_t(ct.byref(hmsh))
-
- put_msh_t(geom, gmsh)
- put_msh_t(init, imsh)
- put_msh_t(hfun, hmsh)
-
- iptr = ct.byref(imsh)
- if (init is None): iptr = 0
-
- hptr = ct.byref(hmsh)
- if (hfun is None): hptr = 0
-
- #--------------------------------- call to JIGSAW's lib.
-
- retv = JLIB.jigsaw(ct.byref(ojig),
- ct.byref(gmsh),
- iptr, hptr,
- ct.byref(mmsh))
-
- if (retv != +0):
- raise ValueError(
- "JIGSAW returned code: " + str(retv))
-
- #--------------------------------- copy buffers to MSH_t
-
- get_msh_t(mesh, mmsh)
-
- return
+ if not isinstance(mesh, jigsaw_msh_t):
+ raise TypeError("MESH not MSH_t")
+
+ jig = _init_opts(opts)
+ gmsh, mmsh, imsh, hmsh = (
+ _init_mesh(), _init_mesh(), _init_mesh(), _init_mesh())
+ put_msh_t (geom, gmsh)
+ put_msh_t (init, imsh)
+ put_msh_t (hfun, hmsh)
+
+ try:
+ retv = JLIB.jigsaw(
+ ct.byref (jig),
+ ct.byref(gmsh),
+ ct.byref(imsh) if init is not None else 0,
+ ct.byref(hmsh) if hfun is not None else 0,
+ ct.byref(mmsh))
+ if retv:
+ raise ValueError(
+ "JIGSAW returned error code: " + str(retv))
+ get_msh_t(mesh, mmsh)
+ finally:
+ JLIB.jigsaw_free_msh_t(ct.byref(mmsh))
def tripod(opts, init, tria, geom=None):
@@ -775,52 +333,33 @@ def tripod(opts, init, tria, geom=None):
for details.
"""
-
- #--------------------------------- set-up ctypes objects
-
- ojig = libsaw_jig_t()
-
- JLIB.jigsaw_init_jig_t(ct.byref(ojig))
-
- put_jig_t(opts, ojig)
-
- imsh = libsaw_msh_t()
- tmsh = libsaw_msh_t()
- gmsh = libsaw_msh_t()
-
- JLIB.jigsaw_init_msh_t(ct.byref(imsh))
- JLIB.jigsaw_init_msh_t(ct.byref(tmsh))
- JLIB.jigsaw_init_msh_t(ct.byref(gmsh))
-
- put_msh_t(init, imsh)
- put_msh_t(geom, gmsh)
-
- gptr = ct.byref(gmsh)
- if (geom is None): gptr = 0
-
- #--------------------------------- call to JIGSAW's lib.
-
- retv = JLIB.tripod(ct.byref(ojig),
- ct.byref(imsh),
- gptr,
- ct.byref(tmsh))
-
- if (retv != +0):
- raise ValueError(
- "TRIPOD returned code: " + str(retv))
-
- #--------------------------------- copy buffers to MSH_t
-
- get_msh_t(tria, tmsh)
-
- return
+ if not isinstance(tria, jigsaw_msh_t):
+ raise TypeError("TRIA not MSH_t")
+
+ jig = _init_opts(opts)
+ imsh, tmsh, gmsh = _init_mesh(), _init_mesh(), _init_mesh()
+ put_msh_t (init, imsh)
+ put_msh_t (geom, gmsh)
+
+ try:
+ retv = JLIB.tripod(
+ ct.byref (jig),
+ ct.byref(imsh),
+ ct.byref(gmsh) if geom is not None else 0,
+ ct.byref(tmsh))
+ if retv:
+ raise ValueError(
+ "TRIPOD returned error code: " + str(retv))
+ get_msh_t(tria, tmsh)
+ finally:
+ JLIB.jigsaw_free_msh_t(ct.byref(tmsh))
def marche(opts, ffun):
"""
MARCHE API-lib. interface to MARCHE.
- MARCHE(OPTS,FFUN=None)
+ MARCHE(OPTS,FFUN)
Call the "fast-marching" solver MARCHE using the config.
options specified in the OPTS structure. MARCHE solves
@@ -835,29 +374,24 @@ def marche(opts, ffun):
OPTS is a user-defined set of meshing options. See JIG_t
for details.
- """
-
- #--------------------------------- set-up ctypes objects
-
- ojig = libsaw_jig_t()
-
- JLIB.jigsaw_init_jig_t(ct.byref(ojig))
-
- put_jig_t(opts, ojig)
+ FFUN.VALUE must be writable: MARCHE updates it in place.
- fmsh = libsaw_msh_t()
-
- JLIB.jigsaw_init_msh_t(ct.byref(fmsh))
-
- put_msh_t(ffun, fmsh)
-
- #--------------------------------- call to JIGSAW's lib.
-
- retv = JLIB.marche(ct.byref(ojig),
- ct.byref(fmsh))
-
- if (retv != +0):
+ """
+ if not isinstance(ffun, jigsaw_msh_t):
+ raise TypeError("MESH not MSH_t")
+
+ if isinstance(ffun.value, np.ndarray) and \
+ ffun.value.size and not \
+ ffun.value.flags.writeable:
+ raise ValueError("MESH.VALUE must be writable")
+
+ jig = _init_opts(opts)
+ fmsh = _init_mesh()
+ put_msh_t (ffun, fmsh)
+
+ retv = JLIB.marche(ct.byref (jig),
+ ct.byref(fmsh)
+ )
+ if retv:
raise ValueError(
- "MARCHE returned code: " + str(retv))
-
- return
+ "MARCHE returned error code: " + str(retv))
diff --git a/jigsawpy/loadjig.py b/jigsawpy/loadjig.py
index 4507994..7e2dab3 100644
--- a/jigsawpy/loadjig.py
+++ b/jigsawpy/loadjig.py
@@ -3,6 +3,18 @@
from jigsawpy.jig_t import jigsaw_jig_t
+def loadbool(value, stag):
+ value = value.strip().upper()
+
+ if (value == "TRUE"):
+ return True
+
+ if (value == "FALSE"):
+ return False
+
+ raise ValueError("Invalid [BOOLS] data: OPTS." + stag)
+
+
def loadjig(name, opts):
"""
LOADJIG: load a JIG config. obj. from file.
@@ -33,6 +45,7 @@ def loadjig(name, opts):
#----------------------- parse next non-null section
line = line.strip()
+ if (not line): continue
if (line[0] == "#"): continue
ltag = line.split("=")
@@ -66,7 +79,8 @@ def loadjig(name, opts):
opts.geom_seed = int(ltag[1])
if (item == "GEOM_FEAT"):
- opts.geom_feat = bool(ltag[1])
+ opts.geom_feat = loadbool(
+ ltag[1], "GEOM_FEAT")
if (item == "GEOM_PHI1"):
opts.geom_phi1 = float(ltag[1])
@@ -102,18 +116,25 @@ def loadjig(name, opts):
if (item == "MESH_ITER"):
opts.mesh_iter = int(ltag[1])
+ if (item == "MESH_RULE"):
+ opts.mesh_rule = int(ltag[1])
+
if (item == "MESH_ORPH"):
- opts.mesh_orph = bool(ltag[1])
+ opts.mesh_orph = loadbool(
+ ltag[1], "MESH_ORPH")
if (item == "MESH_LOCK"):
- opts.mesh_lock = bool(ltag[1])
+ opts.mesh_lock = loadbool(
+ ltag[1], "MESH_LOCK")
if (item == "MESH_DIMS"):
opts.mesh_dims = int(ltag[1])
if (item == "MESH_TOP1"):
- opts.mesh_top1 = bool(ltag[1])
+ opts.mesh_top1 = loadbool(
+ ltag[1], "MESH_TOP1")
if (item == "MESH_TOP2"):
- opts.mesh_top2 = bool(ltag[1])
+ opts.mesh_top2 = loadbool(
+ ltag[1], "MESH_TOP2")
if (item == "MESH_SIZ1"):
opts.mesh_siz1 = float(ltag[1])
@@ -170,13 +191,17 @@ def loadjig(name, opts):
opts.optm_wmax = float(ltag[1])
if (item == "OPTM_ZIP_"):
- opts.optm_zip_ = bool(ltag[1])
+ opts.optm_zip_ = loadbool(
+ ltag[1], "OPTM_ZIP_")
if (item == "OPTM_DIV_"):
- opts.optm_div_ = bool(ltag[1])
+ opts.optm_div_ = loadbool(
+ ltag[1], "OPTM_DIV_")
if (item == "OPTM_TRIA"):
- opts.optm_tria = bool(ltag[1])
+ opts.optm_tria = loadbool(
+ ltag[1], "OPTM_TRIA")
if (item == "OPTM_DUAL"):
- opts.optm_dual = bool(ltag[1])
+ opts.optm_dual = loadbool(
+ ltag[1], "OPTM_DUAL")
else:
#----------------------- reached end-of-file: done!!
diff --git a/jigsawpy/loadmsh.py b/jigsawpy/loadmsh.py
index 2e03011..1fdaf0d 100644
--- a/jigsawpy/loadmsh.py
+++ b/jigsawpy/loadmsh.py
@@ -1,606 +1,10 @@
from pathlib import Path
-import numpy as np
-from numpy.lib import recfunctions as rfn
from jigsawpy.msh_t import jigsaw_msh_t
-
-def loadmshid(mesh, fptr, ltag):
- """
- LOADMSHID: load the MSHID data segment from file.
-
- """
- data = ltag[1].split(";")
-
- if (len(data) > 1):
- mesh.mshID = data[1].strip().lower()
-
- return
-
-
-def loadradii(mesh, fptr, ltag):
- """
- LOADRADII: load the RADII data segment from file.
-
- """
- rtag = ltag[1].split(";")
-
- mesh.radii = np.empty(
- +3, dtype=jigsaw_msh_t.REALS_t)
-
- if (len(rtag) == +1):
- mesh.radii[0] = float(rtag[0])
- mesh.radii[1] = float(rtag[0])
- mesh.radii[2] = float(rtag[0])
-
- elif (len(rtag) == +3):
- mesh.radii[0] = float(rtag[0])
- mesh.radii[1] = float(rtag[1])
- mesh.radii[2] = float(rtag[2])
-
- else:
- raise ValueError("Invalid RADII: " + ltag)
-
- return
-
-
-def loadvert2(fptr, ltag):
- """
- LOADVERT2: load the 2-dim. vertex pos. from file.
-
- """
- lnum = int(ltag[1]); vnum = 3
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- vert = np.fromstring(
- data, dtype=np.float64, sep=";")
-
- vert = np.reshape(
- vert, (lnum, vnum, ), order="C")
-
- vert = rfn.unstructured_to_structured(
- vert, dtype=jigsaw_msh_t.VERT2_t, align=True)
-
- return vert
-
-
-def loadvert3(fptr, ltag):
- """
- LOADVERT3: load the 3-dim. vertex pos. from file.
-
- """
- lnum = int(ltag[1]); vnum = 4
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- vert = np.fromstring(
- data, dtype=np.float64, sep=";")
-
- vert = np.reshape(
- vert, (lnum, vnum, ), order="C")
-
- vert = rfn.unstructured_to_structured(
- vert, dtype=jigsaw_msh_t.VERT3_t, align=True)
-
- return vert
-
-
-def loadpoint(mesh, fptr, ltag):
- """
- LOADPOINT: load the POINT data segment from file.
-
- """
- if (mesh.ndims == +2):
- mesh.vert2 = loadvert2(fptr, ltag)
-
- elif (mesh.ndims == +3):
- mesh.vert3 = loadvert3(fptr, ltag)
-
- else:
- raise ValueError("Invalid NDIMS: " + ltag)
-
- return
-
-
-def loadseeds(mesh, fptr, ltag):
- """
- LOADSEEDS: load the SEEDS data segment from file.
-
- """
- if (mesh.ndims == +2):
- mesh.seed2 = loadvert2(fptr, ltag)
-
- elif (mesh.ndims == +3):
- mesh.seed3 = loadvert3(fptr, ltag)
-
- else:
- raise ValueError("Invalid NDIMS: " + ltag)
-
- return
-
-
-def loadarray(fptr, ltag, kind):
- """
- LOADARRAY: load the ARRAY data segment from file.
-
- """
- vtag = ltag[1].split(";")
-
- lnum = int(vtag[0])
- vnum = int(vtag[1])
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- vals = np.fromstring(
- data, dtype=kind, sep=";")
-
- vals = np.reshape(
- vals, (lnum, vnum, ), order="F")
-
- return vals
-
-
-def loadpower(mesh, fptr, ltag):
- """
- LOADPOWER: load the POWER data segment from file.
-
- """
- mesh.power = loadarray(fptr, ltag, mesh.REALS_t)
-
- return
-
-
-def loadvalue(mesh, fptr, ltag):
- """
- LOADVALUE: load the VALUE data segment from file.
-
- """
- mesh.value = loadarray(fptr, ltag, mesh.FLT32_t)
-
- return
-
-
-def loadslope(mesh, fptr, ltag):
- """
- LOADSLOPE: load the SLOPE data segment from file.
-
- """
- mesh.slope = loadarray(fptr, ltag, mesh.FLT32_t)
-
- return
-
-
-def loadedge2(mesh, fptr, ltag):
- """
- LOADEDGE2: load the EDGE2 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 3
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.EDGE2_t, align=True)
-
- mesh.edge2 = cell
-
- return
-
-
-def loadtria3(mesh, fptr, ltag):
- """
- LOADTRIA3: load the TRIA3 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 4
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.TRIA3_t, align=True)
-
- mesh.tria3 = cell
-
- return
-
-
-def loadquad4(mesh, fptr, ltag):
- """
- LOADUAD4: load the QUAD4 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 5
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.QUAD4_t, align=True)
-
- mesh.quad4 = cell
-
- return
-
-
-def loadtria4(mesh, fptr, ltag):
- """
- LOADTRIA4: load the TRIA4 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 5
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.TRIA4_t, align=True)
-
- mesh.tria4 = cell
-
- return
-
-
-def loadhexa8(mesh, fptr, ltag):
- """
- LOADHEXA8: load the HEXA8 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 9
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.HEXA8_t, align=True)
-
- mesh.hexa8 = cell
-
- return
-
-
-def loadpyra5(mesh, fptr, ltag):
- """
- LOADPYRA5: load the PYRA5 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 6
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.PYRA5_t, align=True)
-
- mesh.pyra5 = cell
-
- return
-
-
-def loadwedg6(mesh, fptr, ltag):
- """
- LOADWEDG6: load the WEDG6 data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 7
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- cell = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- cell = np.reshape(
- cell, (lnum, vnum), order="C")
-
- cell = rfn.unstructured_to_structured(
- cell, dtype=jigsaw_msh_t.WEDG6_t, align=True)
-
- mesh.wedg6 = cell
-
- return
-
-
-def loadbound(mesh, fptr, ltag):
- """
- LOADBOUND: load the BOUND data segment from file.
-
- """
- lnum = int(ltag[1]); vnum = 3
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- bnds = np.fromstring(
- data, dtype=np.int32, sep=";")
-
- bnds = np.reshape(
- bnds, (lnum, vnum), order="C")
-
- bnds = rfn.unstructured_to_structured(
- bnds, dtype=jigsaw_msh_t.BOUND_t, align=True)
-
- mesh.bound = bnds
-
- return
-
-
-def loadcoord(mesh, fptr, ltag):
- """
- LOADCOORD: load the COORD data segment from file.
-
- """
- ctag = ltag[1].split(";")
-
- idim = int(ctag[0])
- lnum = int(ctag[1])
-
- mesh.ndims = max(mesh.ndims, idim)
-
- data = []
- for line in range(lnum):
- data.append(fptr.readline())
-
- data = " ".join(data).replace("\n", ";")
-
- vals = np.fromstring(
- data, dtype=np.float64, sep=";")
-
- if (idim == +1):
- mesh.xgrid = np.reshape(
- vals, (lnum, ), order="C")
-
- elif (idim == +2):
- mesh.ygrid = np.reshape(
- vals, (lnum, ), order="C")
-
- elif (idim == +3):
- mesh.zgrid = np.reshape(
- vals, (lnum, ), order="C")
-
- return
-
-
-def loadlines(mesh, fptr, line):
- """
- LOADLINES: load the next non-null line from file.
-
- """
-
- #------------------------------ skip any 'comment' lines
-
- line = line.strip()
- if (line[0] != "#"):
-
- #------------------------------ split about '=' charact.
- ltag = line.split("=")
- kind = ltag[0].upper().strip()
-
- if (kind == "MSHID"):
-
- #----------------------------------- parse MSHID struct.
- loadmshid(mesh, fptr, ltag)
-
- elif (kind == "NDIMS"):
-
- #----------------------------------- parse NDIMS struct.
- mesh.ndims = int(ltag[1])
-
- elif (kind == "RADII"):
-
- #----------------------------------- parse RADII struct.
- loadradii(mesh, fptr, ltag)
-
- elif (kind == "POINT"):
-
- #----------------------------------- parse POINT struct.
- loadpoint(mesh, fptr, ltag)
-
- elif (kind == "SEEDS"):
-
- #----------------------------------- parse SEEDS struct.
- loadseeds(mesh, fptr, ltag)
-
- elif (kind == "POWER"):
-
- #----------------------------------- parse POWER struct.
- loadpower(mesh, fptr, ltag)
-
- elif (kind == "VALUE"):
-
- #----------------------------------- parse VALUE struct.
- loadvalue(mesh, fptr, ltag)
-
- elif (kind == "SLOPE"):
-
- #----------------------------------- parse SLOPE struct.
- loadslope(mesh, fptr, ltag)
-
- elif (kind == "EDGE2"):
-
- #----------------------------------- parse EDGE2 struct.
- loadedge2(mesh, fptr, ltag)
-
- elif (kind == "TRIA3"):
-
- #----------------------------------- parse TRIA3 struct.
- loadtria3(mesh, fptr, ltag)
-
- elif (kind == "QUAD4"):
-
- #----------------------------------- parse QUAD4 struct.
- loadquad4(mesh, fptr, ltag)
-
- elif (kind == "TRIA4"):
-
- #----------------------------------- parse TRIA4 struct.
- loadtria4(mesh, fptr, ltag)
-
- elif (kind == "HEXA8"):
-
- #----------------------------------- parse HEXA8 struct.
- loadhexa8(mesh, fptr, ltag)
-
- elif (kind == "PYRA5"):
-
- #----------------------------------- parse PYRA5 struct.
- loadpyra5(mesh, fptr, ltag)
-
- elif (kind == "WEDG6"):
-
- #----------------------------------- parse WEDG6 struct.
- loadwedg6(mesh, fptr, ltag)
-
- elif (kind == "BOUND"):
-
- #----------------------------------- parse BOUND struct.
- loadbound(mesh, fptr, ltag)
-
- elif (kind == "COORD"):
-
- #----------------------------------- parse COORD struct.
- loadcoord(mesh, fptr, ltag)
-
- return
-
-
-def sanitise_grid(mesh, data):
- """
- SANITISE-GRID: reshape the "unrolled" array in DATA such
- that the matrix matches the dimensions of the structured
- grid objects.
-
- """
-
- F = "F" # use fortran matrix ordering
-
- if (data is not None and data.size > +1):
- #--------------------------- finalise VALUE.shape layout
- if (mesh.ndims == +2):
- #--------------------------- reshape data to 2-dim array
- if (mesh.xgrid is None or
- mesh.xgrid.size == 0):
- raise ValueError("Invalid XGRID")
-
- if (mesh.ygrid is None or
- mesh.ygrid.size == 0):
- raise ValueError("Invalid YGRID")
-
- num1 = mesh.ygrid.size
- num2 = mesh.xgrid.size
-
- nprd = (num1 * num2)
-
- nval = mesh.value.size // nprd
-
- size = (num1, num2, nval)
-
- data = np.squeeze(
- np.reshape(data, size, order=F))
-
- if (mesh.ndims == +3):
- #--------------------------- reshape data to 3-dim array
- if (mesh.xgrid is None or
- mesh.xgrid.size == 0):
- raise ValueError("Invalid XGRID")
-
- if (mesh.ygrid is None or
- mesh.ygrid.size == 0):
- raise ValueError("Invalid YGRID")
-
- if (mesh.zgrid is None or
- mesh.zgrid.size == 0):
- raise ValueError("Invalid ZGRID")
-
- num1 = mesh.ygrid.size
- num2 = mesh.xgrid.size
- num3 = mesh.zgrid.size
-
- nprd = (num1 * num2 * num3)
-
- nval = mesh.value.size // nprd
-
- size = (num1, num2, num3, nval)
-
- data = np.squeeze(
- np.reshape(data, size, order=F))
-
- return data
+from jigsawpy.parse.loadmsh import loadmsh as _loadmsh
+from jigsawpy.parse.load_nc import load_nc as _load_nc
def loadmsh(name, mesh):
@@ -616,35 +20,13 @@ def loadmsh(name, mesh):
in the file will be read.
"""
-
if (not isinstance(name, str)):
raise TypeError("Incorrect type: NAME.")
if (not isinstance(mesh, jigsaw_msh_t)):
raise TypeError("Incorrect type: MESH.")
- with Path(name).open("r") as fptr:
- while (True):
-
- #--------------------------- get the next line from file
- line = fptr.readline()
-
- if (len(line) != +0):
-
- #--------------------------- parse next non-null section
- loadlines(mesh, fptr, line)
-
- else:
- #--------------------------- reached end-of-file: done!!
- break
-
- if (mesh.mshID.lower() in
- ["euclidean-grid", "ellipsoid-grid"]):
-
- mesh.value = \
- sanitise_grid(mesh, mesh.value)
-
- mesh.slope = \
- sanitise_grid(mesh, mesh.slope)
-
- return
+ if Path(name).suffix.lower() == ".nc":
+ _load_nc(name, mesh)
+ else:
+ _loadmsh(name, mesh)
diff --git a/jigsawpy/loadprj.py b/jigsawpy/loadprj.py
index a004b89..77e0250 100644
--- a/jigsawpy/loadprj.py
+++ b/jigsawpy/loadprj.py
@@ -33,6 +33,7 @@ def loadprj(name, opts):
#----------------------- parse next non-null section
line = line.strip()
+ if (not line): continue
if (line[0] == "#"): continue
ltag = line.split("=")
diff --git a/jigsawpy/msh_l.py b/jigsawpy/msh_l.py
index 6a3f29e..3f752f1 100644
--- a/jigsawpy/msh_l.py
+++ b/jigsawpy/msh_l.py
@@ -17,7 +17,7 @@ class libsaw_VERT2_items_t(ct.Structure):
class libsaw_VERT2_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_VERT2_p)]
@@ -30,7 +30,7 @@ class libsaw_VERT3_items_t(ct.Structure):
class libsaw_VERT3_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_VERT3_p)]
@@ -45,7 +45,7 @@ class libsaw_EDGE2_items_t(ct.Structure):
class libsaw_EDGE2_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_EDGE2_p)]
@@ -60,7 +60,7 @@ class libsaw_TRIA3_items_t(ct.Structure):
class libsaw_TRIA3_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_TRIA3_p)]
@@ -73,7 +73,7 @@ class libsaw_QUAD4_items_t(ct.Structure):
class libsaw_QUAD4_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_QUAD4_p)]
@@ -88,7 +88,7 @@ class libsaw_TRIA4_items_t(ct.Structure):
class libsaw_TRIA4_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_TRIA4_p)]
@@ -101,7 +101,7 @@ class libsaw_HEXA8_items_t(ct.Structure):
class libsaw_HEXA8_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_HEXA8_p)]
@@ -114,7 +114,7 @@ class libsaw_WEDG6_items_t(ct.Structure):
class libsaw_WEDG6_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_WEDG6_p)]
@@ -127,7 +127,7 @@ class libsaw_PYRA5_items_t(ct.Structure):
class libsaw_PYRA5_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_PYRA5_p)]
@@ -143,7 +143,7 @@ class libsaw_BOUND_items_t(ct.Structure):
class libsaw_BOUND_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_BOUND_p)]
@@ -155,17 +155,17 @@ class libsaw_BOUND_array_t(ct.Structure):
class libsaw_REALS_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_REALS_p)]
class libsaw_FLT32_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_FLT32_p)]
class libsaw_INDEX_array_t(ct.Structure):
- _fields_ = [("size", indx_t),
+ _fields_ = [("size", ct.c_size_t),
("data", libsaw_INDEX_p)]
diff --git a/jigsawpy/msh_t.py b/jigsawpy/msh_t.py
index d325d33..715952f 100644
--- a/jigsawpy/msh_t.py
+++ b/jigsawpy/msh_t.py
@@ -65,8 +65,8 @@
all elements in the geometry are assumed to define
the boundaries of enclosed "parts".
- MESH.VALUE - [NPxNV] array of "values" associated with
- the vertices of the mesh.
+ MESH.VALUE - array of "values" associated with mesh
+ vertices.
.IF. MESH.MSHID == 'ELLIPSOID-MESH':
-----------------------------------
@@ -89,16 +89,16 @@
MESH.ZGRID - [NZx 1] array of "z-axis" grid coordinates.
Values must increase or decrease monotonically.
- MESH.VALUE - [NMxNV] array of "values" associated with
- vertices in the grid, where NM is the product of
- the dimensions of the grid. NV values are associated
- with each vertex.
+ MESH.VALUE - array of "values" associated with grid
+ vertices.
- MESH.SLOPE - [NMx 1] array of "slopes" associated with
- vertices in the grid, where NM is the product of
- the dimensions of the grid. Slope values define the
- gradient-limits ||dh/dx|| used by the Eikonal solver
- MARCHE.
+ MESH.SLOPE - array of "slopes" associated with grid
+ vertices. Slope values define the gradient-limits
+ ||dh/dx|| used by the Eikonal solver MARCHE.
+
+ Non-scalar VALUE and SLOPE arrays have shape (NX,),
+ (NY, NX), or (NY, NX, NZ) for 1D, 2D, or 3D grids.
+ A single scalar value may also be shared over the grid.
See also JIG_t
diff --git a/jigsawpy/parse/load_nc.py b/jigsawpy/parse/load_nc.py
new file mode 100644
index 0000000..0801c5a
--- /dev/null
+++ b/jigsawpy/parse/load_nc.py
@@ -0,0 +1,211 @@
+
+import numpy as np
+
+from jigsawpy.parse.utility import (
+ CELL_TYPES, GRID_KINDS, MESH_KINDS, netcdf_dataset, shape_grid,
+)
+from jigsawpy.msh_t import jigsaw_msh_t
+
+
+def _array(nc, name, dtype):
+ variable = nc.variables[name]
+ variable.set_auto_maskandscale(False)
+ data = np.asarray(variable[:])
+ target = np.dtype(dtype)
+ if data.dtype.kind not in "iuf":
+ raise TypeError(
+ "Invalid NetCDF " + name + " data type")
+ if target.kind == "i":
+ limits = np.iinfo(target)
+ if (not np.isfinite(data).all() or
+ np.any(data < limits.min) or
+ np.any(data > limits.max) ):
+ raise ValueError(
+ "Out-of-range NetCDF " + name + " data")
+ elif target.itemsize < data.dtype.itemsize:
+ limits = np.finfo(target)
+ if np.any(np.isfinite(data) & (np.abs(data) > limits.max)):
+ raise ValueError(
+ "Out-of-range NetCDF " + name + " data")
+ return data.astype(target, copy=False)
+
+
+def _header(nc):
+ if "MSHID" not in nc.ncattrs():
+ raise ValueError("Missing NetCDF MSHID attribute")
+ kind = nc.getncattr("MSHID")
+ if isinstance(kind, bytes):
+ kind = kind.decode("ascii")
+ if not isinstance(kind, str):
+ raise ValueError("Invalid NetCDF MSHID attribute")
+ kind = kind.strip(" \x00").lower()
+ if kind not in MESH_KINDS + GRID_KINDS:
+ raise ValueError("Unsupported NetCDF MSHID: " + kind)
+
+ if "NDIMS" in nc.ncattrs():
+ value = np.asarray(nc.getncattr("NDIMS"))
+ if value.size != 1 or value.dtype.kind not in "iu":
+ raise ValueError("Invalid NetCDF NDIMS attribute")
+ ndim = int(value.reshape(-1)[0])
+ else:
+ ndim = 0
+ for name, dim in (("xgrid_val", 1), ("ygrid_val", 2),
+ ("zgrid_val", 3), ("vert2_pos", 2),
+ ("seed2_pos", 2), ("vert3_pos", 3),
+ ("seed3_pos", 3)):
+ if name in nc.variables: ndim = dim
+ if ndim not in (1, 2, 3):
+ raise ValueError("Missing or invalid NetCDF NDIMS")
+ return kind, ndim
+
+
+def _records(nc, name, dtype, width, field):
+ if field == "coord":
+ data_name = name + "_pos"
+ itag_name = name + "_tag"
+ elif field == "index":
+ data_name = name + "_idx"
+ itag_name = name + "_tag"
+ else:
+ raise ValueError("Invalid NetCDF variable")
+
+ if (data_name not in nc.variables and
+ itag_name not in nc.variables):
+ return None
+
+ if (data_name not in nc.variables or
+ itag_name not in nc.variables):
+ raise ValueError(
+ "NetCDF requires both " + data_name + " and "
+ + itag_name)
+ if field == "coord":
+ data = _array(nc, data_name, np.float64)
+ tags = _array(nc, itag_name, np.int32)
+ elif field == "index":
+ data = _array(nc, data_name, np.int32)
+ tags = _array(nc, itag_name, np.int32)
+ else:
+ raise ValueError("Invalid NetCDF variable")
+
+ if data.ndim != 2 or data.shape[1] != width:
+ raise ValueError(
+ "Invalid NetCDF " + data_name + " dimensions")
+ if tags.shape not in ((data.shape[0],),
+ (data.shape[0], 1)):
+ raise ValueError(
+ "Invalid NetCDF " + itag_name + " dimensions")
+
+ records = np.empty(data.shape [0], dtype=dtype)
+ records[ field ] = data
+ records["IDtag"] = tags.reshape(-1)
+ return records
+
+
+def _values(nc, name, mesh, dtype):
+ if name not in nc.variables: return None
+ data = _array(nc, name, dtype)
+ if data.ndim <= 0 or (
+ data.ndim == 2 and data.shape[1] == 0):
+ raise ValueError(
+ "Invalid NetCDF " + name + " dimensions")
+ if name == "power_val" and data.ndim > 2:
+ raise ValueError(
+ "Invalid NetCDF power_val dimensions")
+
+ if mesh.mshID in GRID_KINDS and \
+ name != "power_val":
+ return shape_grid(data.reshape(-1, order="C"),
+ mesh, name)
+ if data.ndim >= 3:
+ return data.reshape(-1, 1, order="C")
+ if data.ndim == 1:
+ return data.reshape(-1, 1)
+ return data
+
+
+def loadradii(nc, mesh):
+ if "RADII" in nc.ncattrs():
+ radii = np.asarray(
+ nc.getncattr("RADII"), dtype=np.float64)
+ if radii.shape != (3,):
+ raise ValueError("Invalid NetCDF RADII variable")
+ mesh.radii = radii.copy()
+
+
+def loadpoint(nc, mesh):
+ for prefix in ("vert", "seed"):
+ name = prefix + str(mesh.ndims)
+ if mesh.ndims == 2:
+ dtype = mesh.VERT2_t
+ elif mesh.ndims == 3:
+ dtype = mesh.VERT3_t
+ else:
+ raise ValueError("Invalid NetCDF " + name +
+ " dimensions")
+ data = _records(nc, name, dtype, mesh.ndims, "coord")
+ if data is not None: setattr(mesh, name, data)
+
+
+def loadcoord(nc, mesh):
+ for axis, index in (("xgrid", 1), ("ygrid", 2),
+ ("zgrid", 3)):
+ name = axis + "_val"
+ if name in nc.variables:
+ data = _array(nc, name, np.float64)
+ if index > mesh.ndims:
+ raise ValueError(
+ "Invalid NetCDF " + name + " dimensions")
+ if data.ndim not in (1, 2):
+ raise ValueError(
+ "Invalid NetCDF " + name + " dimensions")
+ if data.ndim == 2 and data.shape[1] != 1:
+ raise ValueError(
+ "Invalid NetCDF " + name + " dimensions")
+ setattr(mesh, axis, data.reshape(-1))
+
+
+def loadbound(nc, mesh):
+ if "bound_idx" in nc.variables:
+ data = _array(nc, "bound_idx", np.int32)
+ if data.ndim != 2 or data.shape[1] != 3:
+ raise ValueError(
+ "Incorrect NetCDF bound_idx dimension")
+ mesh.bound = np.empty(
+ data.shape[0], dtype=mesh.BOUND_t)
+ mesh.bound["IDtag"] = data[:, 0]
+ mesh.bound["index"] = data[:, 1]
+ mesh.bound["cells"] = data[:, 2]
+
+
+def loadvalue(nc, mesh):
+ for field, key, dtype in (
+ ("power", "power_val", np.float64),
+ ("value", "value_mat", np.float32),
+ ("slope", "slope_mat", np.float32)):
+ data = _values(nc, key, mesh, dtype)
+ if data is not None: setattr(mesh, field, data)
+
+
+def load_nc(name, mesh):
+ dataset = netcdf_dataset()
+ with dataset(name, "r") as nc:
+ kind, ndim = _header(nc)
+ mesh.mshID, mesh.ndims = kind, ndim
+
+ if kind in ["ellipsoid-mesh", "ellipsoid-grid"]:
+ loadradii(nc, mesh)
+
+ if ndim >= 2:
+ loadpoint(nc, mesh)
+
+ if kind in ["ellipsoid-grid", "euclidean-grid"]:
+ loadcoord(nc, mesh)
+
+ for cell, width, dtype in CELL_TYPES:
+ data = _records(
+ nc, cell, dtype, width, "index")
+ if data is not None: setattr(mesh, cell, data)
+
+ loadbound(nc, mesh)
+
+ loadvalue(nc, mesh)
diff --git a/jigsawpy/parse/loadgeo.py b/jigsawpy/parse/loadgeo.py
index 5723ceb..ab641da 100644
--- a/jigsawpy/parse/loadgeo.py
+++ b/jigsawpy/parse/loadgeo.py
@@ -2,170 +2,258 @@
import numpy as np
import json
import argparse
+import math
-from jigsawpy import jigsaw_msh_t, savemsh
+from jigsawpy import jigsaw_msh_t, jigsaw_def_t, savemsh
-def linegeo(line, nset, eset, nobj, last):
+def loadcoord(coords, stag):
"""
- LINEGEO: read a geoJSON line into a jigsaw msh_t object.
+ LOADCOORD: check vertex positions and retain 2d values.
"""
+ if (not isinstance(coords, list)):
+ raise ValueError("Invalid " + stag + " container.")
- npts = len(line) - 0
+ data = []
+ for pos in coords:
+ if (not isinstance(pos, list) or
+ len(pos) not in (2, 3)):
+ raise ValueError("Invalid " + stag + " coord.")
- if (npts > 0):
-#----------------------------------------- read LINE dataset
- temp = jigsaw_msh_t()
- temp.vert2 = np.zeros(
- (npts + 0), dtype=temp.VERT2_t)
- temp.edge2 = np.zeros(
- (npts - 1), dtype=temp.EDGE2_t)
+ if any(isinstance(val, bool) or
+ not isinstance(val, (int, float)) or
+ not math.isfinite(val) for val in pos):
+ raise ValueError("Invalid " + stag + " coord.")
- temp.edge2["IDtag"][:] = nobj
+ data.append(pos[:2])
- nobj = nobj + 1
+ return np.asarray(
+ data, dtype=jigsaw_msh_t.REALS_t).reshape(-1, 2)
- indx = np.arange(0, npts - 1) + last
- last = last + npts
+def nodegeo(node, nset, eset, pset, nobj, last):
+ """
+ NODEGEO: read a geoJSON node into a jigsaw msh_t object.
+
+ """
+ if (not isinstance(points, list)):
+ raise ValueError("Invalid NODE container.")
+ if (not points): return nobj, last
- temp.vert2["coord"] = line[+0::]
+ data = loadcoord(node, "Point")
+ npts = data.shape[0] - 0
- temp.edge2["index"][:, 0] = indx + 0
- temp.edge2["index"][:, 1] = indx + 1
+ temp = jigsaw_msh_t()
+ temp.vert2 = np.zeros(npts - 0, dtype=temp.VERT2_t)
+ temp.vert2["coord"] = data[:, :2]
+ temp.vert2["IDtag"] = nobj
- nset.append(temp.vert2)
- eset.append(temp.edge2)
+ nset.append(temp.vert2)
- return nobj, last
+ return nobj + 1, last + data.shape[0]
-def polygeo(loop, nset, eset, nobj, last):
+def linegeo(line, nset, eset, pset, nobj, last):
"""
- POLYGEO: read a geoJSON poly into a jigsaw msh_t object.
+ LINEGEO: read a geoJSON line into a jigsaw msh_t object.
"""
+ if (not isinstance(line, list)):
+ raise ValueError("Invalid LINE container.")
+ if (not line): return nobj, last
- npts = len(loop) - 1
+ data = loadcoord(line, "LineString")
+ npts = data.shape[0] - 0
- if (npts > +0):
-#----------------------------------------- read LOOP dataset
- temp = jigsaw_msh_t()
- temp.vert2 = np.zeros(
- (npts + 0), dtype=temp.VERT2_t)
- temp.edge2 = np.zeros(
- (npts - 0), dtype=temp.EDGE2_t)
+ if (npts < 2):
+ raise ValueError(
+ "LINE requires at least two elements.")
- temp.edge2["IDtag"][:] = nobj
+ temp = jigsaw_msh_t()
+ temp.vert2 = np.zeros(npts - 0, dtype=temp.VERT2_t)
+ temp.edge2 = np.zeros(npts - 1, dtype=temp.EDGE2_t)
- nobj = nobj + 1
+ temp.vert2["coord"] = data[:, :2]
+ temp.edge2["IDtag"] = nobj
- indx = np.arange(0, npts - 1) + last
+ indx = np.arange(0, npts - 1) + last
+ temp.edge2["index"][:, 0] = indx + 0
+ temp.edge2["index"][:, 1] = indx + 1
- itop = last + npts - 1
+ nset.append(temp.vert2)
+ eset.append(temp.edge2)
- idx1 = np.full(
- npts, itop, dtype=np.int32)
- idx1[:-1] = indx + 0
+ return nobj + 1, last + npts
- idx2 = np.full(
- npts, last, dtype=np.int32)
- idx2[:-1] = indx + 1
- last = last + npts
+def polygeo(poly, nset, eset, pset, nobj, last):
+ """
+ POLYGEO: read a polygon keeping its rings in one part.
+
+ """
+ if (not isinstance(poly, list)):
+ raise ValueError("Invalid POLY container.")
+ if (not poly): return nobj, last
+
+ for loop in poly:
+ data = loadcoord(loop, "Polygon ring")
+ npts = data.shape[0] - 1
+
+ if (data.shape[0] < 4 or loop[0] != loop[-1]):
+ raise ValueError(
+ "POLY requires four or more elements "
+ "and matching endpoints.")
+
+ temp = jigsaw_msh_t()
+ temp.vert2 = np.zeros(npts, dtype=temp.VERT2_t)
+ temp.edge2 = np.zeros(npts, dtype=temp.EDGE2_t)
- temp.vert2["coord"] = loop[:-1:]
+ temp.vert2["coord"] = data[:-1, :2]
+ temp.edge2["IDtag"] = nobj
- temp.edge2["index"][:, 0] = idx1
- temp.edge2["index"][:, 1] = idx2
+ indx = np.arange(0, npts) + last
+ temp.edge2["index"][:, 0] = indx
+ temp.edge2["index"][:, 1] = np.roll(indx, -1)
+ last = last + npts
nset.append(temp.vert2)
eset.append(temp.edge2)
- return nobj, last
+ pset.append(nobj)
+
+ return nobj + 1, last
-def readgeo(geom, nset, eset, nobj, last):
+def readgeo(geom, nset, eset, pset, nobj, last):
"""
- READGEO: read a geoJSON part into a jigsaw msh_t object.
+ READGEO: read a geoJSON geom, including collections.
"""
+ if (not isinstance(geom, dict)):
+ raise ValueError("Invalid GeoJSON geometry.")
- if (geom["type"] == "LineString"):
+ kind = geom.get("type")
- line = geom["coordinates"]
+ if (kind == "GeometryCollection"):
+ part = geom.get("geometries")
+ if (not isinstance(part, list)):
+ raise ValueError("Invalid GeometryCollection.")
- nobj, last = linegeo(
- line, nset, eset, nobj, last)
+ for part in parts:
+ nobj, last = readgeo(
+ part, nset, eset, pset, nobj, last)
- elif (geom["type"] == "MultiLineString"):
+ return nobj, last
- for line in geom["coordinates"]:
+ if (kind not in ("Point", "MultiPoint", "LineString",
+ "MultiLineString", "Polygon",
+ "MultiPolygon")):
+ raise ValueError(
+ "Unsupported GeoJSON type: " + str(kind))
- nobj, last = linegeo(
- line, nset, eset, nobj, last)
+ coords = geom.get("coordinates")
+ if (not isinstance(coords, list)):
+ raise ValueError("Invalid " + kind + " container.")
- elif (geom["type"] == "Polygon"):
+ if (kind == "Point"):
+ if coords:
+ nobj, last = nodegeo(
+ [coords], nset, eset, pset, nobj, last)
- for loop in geom["coordinates"]:
+ elif (kind == "MultiPoint"):
+ nobj, last = pointgeo(
+ coords, nset, eset, pset, nobj, last)
- nobj, last = polygeo(
- loop, nset, eset, nobj, last)
+ elif (kind == "LineString"):
+ nobj, last = linegeo(
+ coords, nset, eset, pset, nobj, last)
- elif (geom["type"] == "MultiPolygon"):
+ elif (kind == "MultiLineString"):
+ for line in coords:
+ nobj, last = linegeo(
+ line, nset, eset, pset, nobj, last)
- for poly in geom["coordinates"]:
- for loop in poly:
+ elif (kind == "Polygon"):
+ nobj, last = polygeo(
+ coords, nset, eset, pset, nobj, last)
- nobj, last = polygeo(
- loop, nset, eset, nobj, last)
+ elif (kind == "MultiPolygon"):
+ for poly in coords:
+ nobj, last = polygeo(
+ poly, nset, eset, pset, nobj, last)
return nobj, last
def loadgeo(name, mesh):
"""
- LOADGEO: load a geoJSON file into a jigsaw msh_t object.
+ LOADGEO: load GeoJSON geometry into a jigsaw msh_t object.
"""
-
if (not isinstance(name, str)):
- raise Exception("Incorrect type: NAME.")
+ raise TypeError("Incorrect type: NAME.")
if (not isinstance(mesh, jigsaw_msh_t)):
- raise Exception("Incorrect type: MESH.")
-
- nobj = +0; last = +0; nset = []; eset = []
-
- with open(name) as f: geoj = json.load(f)
-
- for feat in geoj["features"]:
-
- geom = (feat["geometry"])
-
- if (geom["type"] != "GeometryCollection"):
-
+ raise TypeError("Incorrect type: MESH.")
+
+ nobj = +0; last = +0; nset = []; eset = []; pset = []
+
+ with open(name, encoding="utf-8") as f:
+ geoj = json.load(f)
+
+ if (not isinstance(geoj, dict)):
+ raise ValueError("Invalid GeoJSON object.")
+
+ kind = geoj.get("type")
+ if (kind == "FeatureCollection"):
+ features = geoj.get("features")
+ if (not isinstance(features, list)):
+ raise ValueError("Invalid FeatureCollection.")
+ elif (kind == "Feature"):
+ features = [geoj]
+ else:
+ features = [{"type": "Feature", "geometry": geoj}]
+
+ for feat in features:
+ if (not isinstance(feat, dict) or
+ feat.get("type") != "Feature" or
+ "geometry" not in feat):
+ raise ValueError("Invalid GeoJSON Feature.")
+
+ geom = feat["geometry"]
+ if (geom is not None):
nobj, last = readgeo(
- geom, nset, eset, nobj, last)
+ geom, nset, eset, pset, nobj, last)
+
+#----------------------------------------- assemble MESH data
+ temp = jigsaw_msh_t()
+ temp.mshID = "euclidean-mesh"
+ temp.ndims = +2
- else:
+ if nset: temp.vert2 = np.concatenate(nset, axis=0)
+ if eset: temp.edge2 = np.concatenate(eset, axis=0)
- for next in geom["geometries"]:
+ if pset:
+#----------------------------------------- define part bounds
+ parts = np.zeros(nobj, dtype=bool)
+ parts[pset] = True
+ keep = parts[temp.edge2["IDtag"]]
- nobj, last = readgeo(
- next, nset, eset, nobj, last)
+ nbnd = np.count_nonzero(keep)
- mesh.vert2 = np.concatenate(nset, axis=0)
- mesh.edge2 = np.concatenate(eset, axis=0)
+ temp.bound = np.zeros(nbnd, dtype=temp.BOUND_t)
+ temp.bound["IDtag"] = temp.edge2["IDtag"][keep]
+ temp.bound["index"] = np.flatnonzero(keep)
+ temp.bound["cells"] = jigsaw_def_t.JIGSAW_EDGE2_TAG
- return
+ mesh.__dict__.update(temp.__dict__)
if (__name__ == "__main__"):
parser = argparse.ArgumentParser(
description=__doc__,
- formatter_class=argparse.RawTextHelpFormatter)
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
"--src-file", dest="src_file", type=str,
diff --git a/jigsawpy/parse/loadmsh.py b/jigsawpy/parse/loadmsh.py
new file mode 100644
index 0000000..02ca6f8
--- /dev/null
+++ b/jigsawpy/parse/loadmsh.py
@@ -0,0 +1,272 @@
+
+from pathlib import Path
+import numpy as np
+from numpy.lib import recfunctions as rfn
+
+from jigsawpy.msh_t import jigsaw_msh_t
+from jigsawpy.parse.utility import shape_grid
+
+
+_CELL_TYPES = {
+ "EDGE2": ("edge2", 3, jigsaw_msh_t.EDGE2_t),
+ "TRIA3": ("tria3", 4, jigsaw_msh_t.TRIA3_t),
+ "QUAD4": ("quad4", 5, jigsaw_msh_t.QUAD4_t),
+ "TRIA4": ("tria4", 5, jigsaw_msh_t.TRIA4_t),
+ "HEXA8": ("hexa8", 9, jigsaw_msh_t.HEXA8_t),
+ "WEDG6": ("wedg6", 7, jigsaw_msh_t.WEDG6_t),
+ "PYRA5": ("pyra5", 6, jigsaw_msh_t.PYRA5_t),
+ "BOUND": ("bound", 3, jigsaw_msh_t.BOUND_t),
+}
+
+def _read_rows(fptr, nrows, ncols, dtype):
+ lines = []
+ for _ in range(nrows):
+ lines.append(fptr.readline())
+ text = " ".join(lines).replace("\n", ";")
+ data = np.fromstring(text, dtype=dtype, sep=";")
+ return data.reshape((nrows, ncols), order="C")
+
+
+def _read_data(fptr, nrows, ncols, dtype, out_dtype):
+ data = _read_rows(fptr, nrows, ncols, dtype)
+ return rfn.unstructured_to_structured(
+ data, dtype=out_dtype, align=True)
+
+
+def _load_cell(mesh, fptr, ltag, kind):
+ name, ncols, dtype = _CELL_TYPES[kind]
+ setattr(mesh, name, _read_data(
+ fptr, int(ltag[+1]), ncols, np.int32, dtype))
+
+
+def _shape_val(mesh, data):
+ if data is not None and data.size > 1:
+ if mesh.ndims in (1, 2, 3):
+ for axis in ("xgrid", "ygrid",
+ "zgrid")[:mesh.ndims]:
+ coords = getattr(mesh, axis)
+ if coords is None or coords.size == 0:
+ raise ValueError(
+ "Invalid " + axis.upper())
+
+ data = shape_grid(data, mesh,
+ None, squeeze=False)
+ return data
+
+
+def loadmshid(mesh, fptr, ltag):
+ """
+ LOADMSHID: load the MSHID data segment from file.
+
+ """
+ data = ltag[1].split(";")
+ if (len(data) > 1):
+ mesh.mshID = data[1].strip().lower()
+
+
+def loadradii(mesh, fptr, ltag):
+ """
+ LOADRADII: load the RADII data segment from file.
+
+ """
+ rtag = ltag[1].split(";")
+
+ mesh.radii = np.empty(
+ +3, dtype=jigsaw_msh_t.REALS_t)
+
+ if (len(rtag) == +1):
+ mesh.radii[0] = float(rtag[0])
+ mesh.radii[1] = float(rtag[0])
+ mesh.radii[2] = float(rtag[0])
+
+ elif (len(rtag) == +3):
+ mesh.radii[0] = float(rtag[0])
+ mesh.radii[1] = float(rtag[1])
+ mesh.radii[2] = float(rtag[2])
+
+ else:
+ raise ValueError("Invalid RADII: " + ltag)
+
+
+def loadvert2(fptr, ltag):
+ """
+ LOADVERT2: load the 2-dim. vertex pos. from file.
+
+ """
+ return _read_data(fptr, int(ltag[1]),
+ 3, np.float64, jigsaw_msh_t.VERT2_t)
+
+
+def loadvert3(fptr, ltag):
+ """
+ LOADVERT3: load the 3-dim. vertex pos. from file.
+
+ """
+ return _read_data(fptr, int(ltag[1]),
+ 4, np.float64, jigsaw_msh_t.VERT3_t)
+
+
+def loadpoint(mesh, fptr, ltag):
+ """
+ LOADPOINT: load the POINT data segment from file.
+
+ """
+ if (mesh.ndims == +2):
+ mesh.vert2 = loadvert2(fptr, ltag)
+
+ elif (mesh.ndims == +3):
+ mesh.vert3 = loadvert3(fptr, ltag)
+
+ else:
+ raise ValueError("Invalid NDIMS: " + ltag)
+
+
+def loadseeds(mesh, fptr, ltag):
+ """
+ LOADSEEDS: load the SEEDS data segment from file.
+
+ """
+ if (mesh.ndims == +2):
+ mesh.seed2 = loadvert2(fptr, ltag)
+
+ elif (mesh.ndims == +3):
+ mesh.seed3 = loadvert3(fptr, ltag)
+
+ else:
+ raise ValueError("Invalid NDIMS: " + ltag)
+
+
+def loadarray(fptr, ltag, kind):
+ """
+ LOADARRAY: load the ARRAY data segment from file.
+
+ """
+ nrows, ncols = map(int, ltag[1].split(";")[:2])
+ return _read_rows(fptr, nrows, ncols, kind)
+
+
+def loadpower(mesh, fptr, ltag):
+ """
+ LOADPOWER: load the POWER data segment from file.
+
+ """
+ mesh.power = loadarray(fptr, ltag, mesh.REALS_t)
+
+
+def loadvalue(mesh, fptr, ltag):
+ """
+ LOADVALUE: load the VALUE data segment from file.
+
+ """
+ mesh.value = loadarray(fptr, ltag, mesh.FLT32_t)
+
+
+def loadslope(mesh, fptr, ltag):
+ """
+ LOADSLOPE: load the SLOPE data segment from file.
+
+ """
+ mesh.slope = loadarray(fptr, ltag, mesh.FLT32_t)
+
+
+def loadcoord(mesh, fptr, ltag):
+ """
+ LOADCOORD: load the COORD data segment from file.
+
+ """
+ ndim, nrow = map(int, ltag[1].split(";")[:2])
+ mesh.ndims = max(mesh.ndims, ndim)
+ values = _read_rows(
+ fptr, nrow, 1, np.float64).reshape((nrow,))
+
+ if ndim == 1:
+ mesh.xgrid = values
+ elif ndim == 2:
+ mesh.ygrid = values
+ elif ndim == 3:
+ mesh.zgrid = values
+
+
+def loadlines(mesh, fptr, line):
+ """
+ LOADLINES: load the next non-null line from file.
+
+ """
+ line = line.strip()
+ if (not line): return
+
+ if (line[0] != "#"):
+ ltag = line.split("=")
+ kind = ltag[0].upper().strip()
+
+ if kind == "MSHID":
+ loadmshid(mesh, fptr, ltag)
+
+ elif kind == "NDIMS":
+ mesh.ndims = int(ltag[1])
+
+ elif kind == "RADII":
+ loadradii(mesh, fptr, ltag)
+
+ elif kind == "POINT":
+ loadpoint(mesh, fptr, ltag)
+
+ elif kind == "SEEDS":
+ loadseeds(mesh, fptr, ltag)
+
+ elif kind == "POWER":
+ loadpower(mesh, fptr, ltag)
+
+ elif kind == "VALUE":
+ loadvalue(mesh, fptr, ltag)
+
+ elif kind == "SLOPE":
+ loadslope(mesh, fptr, ltag)
+
+ elif kind == "EDGE2":
+ _load_cell(mesh, fptr, ltag, "EDGE2")
+
+ elif kind == "TRIA3":
+ _load_cell(mesh, fptr, ltag, "TRIA3")
+
+ elif kind == "QUAD4":
+ _load_cell(mesh, fptr, ltag, "QUAD4")
+
+ elif kind == "TRIA4":
+ _load_cell(mesh, fptr, ltag, "TRIA4")
+
+ elif kind == "HEXA8":
+ _load_cell(mesh, fptr, ltag, "HEXA8")
+
+ elif kind == "PYRA5":
+ _load_cell(mesh, fptr, ltag, "PYRA5")
+
+ elif kind == "WEDG6":
+ _load_cell(mesh, fptr, ltag, "WEDG6")
+
+ elif kind == "BOUND":
+ _load_cell(mesh, fptr, ltag, "BOUND")
+
+ elif kind == "COORD":
+ loadcoord(mesh, fptr, ltag)
+
+
+def loadmsh(name, mesh):
+ with Path(name).open("r") as fptr:
+ while True:
+ #--------------------------- get the next line from file
+ line = fptr.readline()
+
+ if (len(line) != 0):
+ #--------------------------- parse next non-null section
+ loadlines(mesh, fptr, line)
+
+ else:
+ #--------------------------- reached end-of-file: done!!
+ break
+
+ if (mesh.mshID.lower() in ["euclidean-grid",
+ "ellipsoid-grid"]):
+ #--------------------------- from flat to multi-dim data
+ mesh.value = _shape_val(mesh, mesh.value)
+ mesh.slope = _shape_val(mesh, mesh.slope)
diff --git a/jigsawpy/parse/save_nc.py b/jigsawpy/parse/save_nc.py
new file mode 100644
index 0000000..e370c99
--- /dev/null
+++ b/jigsawpy/parse/save_nc.py
@@ -0,0 +1,183 @@
+
+from pathlib import Path
+
+import numpy as np
+
+from jigsawpy.parse.utility import (
+ CELL_TYPES, GRID_KINDS, MESH_KINDS,
+)
+from jigsawpy.parse.utility import (
+ netcdf_dataset, present, grid_shape,
+)
+from jigsawpy.certify import certify
+from jigsawpy.msh_t import jigsaw_msh_t
+
+
+def _write_variable(nc, name, data, dimensions, dtype):
+ nc.createVariable(
+ name, dtype, dimensions)[:] = data
+
+
+def _write_verts(nc, name, data, ndim):
+ if not present(data): return
+ row, col = name + "_row", name + "_col"
+ ids = "singleton"
+ nc.createDimension(row, data.size)
+ nc.createDimension(col, ndim)
+ _write_variable(
+ nc, name + "_pos", data["coord"], (row, col), "f8")
+ _write_variable(
+ nc, name + "_tag", data["IDtag"], (row, ids), "i4")
+
+
+def _write_cells(nc, name, data, width):
+ if not present(data): return
+ row, col = name + "_row", name + "_col"
+ ids = "singleton"
+ nc.createDimension(row, data.size)
+ nc.createDimension(col, width)
+ _write_variable(
+ nc, name + "_idx", data["index"], (row, col), "i4")
+ _write_variable(
+ nc, name + "_tag", data["IDtag"], (row, ids), "i4")
+
+
+def _write_values(nc, name, data, mesh, ndim, grid):
+ if not present(data): return
+ if grid:
+ shape = grid_shape(mesh, ndim)
+ if data.size == 1 and np.prod(shape) != 1:
+ data = data.reshape(1)
+ dim = ("singleton",)
+ else:
+ if ndim == 1:
+ dim = ("xgrid_row",)
+ elif ndim == 2:
+ dim = ("xgrid_row", "ygrid_row")
+ else:
+ dim = ("zgrid_row", "xgrid_row",
+ "ygrid_row",)
+ data = np.asarray(data).reshape(-1, order="F")
+ data = data.reshape(
+ tuple(len(nc.dimensions[d]) for d in dim))
+
+ dtype = "f8" if name == "power_val" else "f4"
+
+ _write_variable(nc, name, data, dim, dtype)
+ else:
+ vert = "vert" + str(ndim) + "_row"
+ if data.size == 1:
+ row = "singleton"
+ elif vert in nc.dimensions and \
+ data.shape[0] == len(nc.dimensions[vert]):
+ row = vert
+ else:
+ raise ValueError(
+ "Incorrect NetCDF "
+ + name + " size for vert" + str(ndim))
+
+ dim = (row, "singleton")
+
+ dtype = "f8" if name == "power_val" else "f4"
+
+ _write_variable(nc, name, data, tuple(dim), dtype)
+
+
+def _write_coord(nc, mesh):
+ for axis in ("xgrid", "ygrid", "zgrid"):
+ values = getattr(mesh, axis)
+ name_val = axis + "_val"
+ name_dim = axis + "_row"
+ if present(values):
+ nc.createDimension(name_dim, values.size)
+ _write_variable(
+ nc, name_val, values, (name_dim,), "f8")
+
+
+def _write_bound(nc, mesh):
+ if present(mesh.bound):
+ nc.createDimension("bound_row", mesh.bound.size)
+ nc.createDimension("bound_col", 3)
+ bound = np.column_stack((mesh.bound["IDtag"],
+ mesh.bound["index"],
+ mesh.bound["cells"]))
+ _write_variable(
+ nc, "bound_idx", bound, ("bound_row",
+ "bound_col"), "i4")
+
+
+def save_nc(name, mesh):
+ certify(mesh)
+ dataset = netcdf_dataset()
+
+ kind = mesh.mshID.lower()
+ ndim = 0
+ if present(getattr(mesh, "xgrid")): ndim = 1
+ if present(getattr(mesh, "ygrid")): ndim = 2
+ if present(getattr(mesh, "zgrid")): ndim = 3
+
+ if present(getattr(mesh, "vert2")): ndim = 2
+ if present(getattr(mesh, "vert3")): ndim = 3
+
+ if present(getattr(mesh, "seed2")): ndim = 2
+ if present(getattr(mesh, "seed3")): ndim = 3
+
+ if (not isinstance(mesh.ndims, (int, np.integer)) or
+ isinstance(mesh.ndims, (bool, np.bool_))):
+ raise ValueError("Invalid MESH.NDIMS")
+
+ if not ndim:
+ ndim = mesh.ndims
+ if not ndim and kind == "ellipsoid-mesh" and \
+ present(mesh.radii):
+ ndim = 3
+ elif mesh.ndims not in (0,ndim):
+ raise ValueError("Inconsistent MESH.NDIMS")
+
+ if ndim <= 0:
+ raise ValueError("Invalid MESH.NDIMS")
+
+ with dataset(name, "w", format="NETCDF4") as nc:
+ nc.createDimension("singleton", +1)
+
+ nc.setncattr("MSHID", kind.upper())
+ nc.setncattr("NDIMS", np.int32(ndim))
+
+ title = Path(name).name \
+ + "; created by JIGSAW's PYTHON interface"
+ nc.setncattr("title", title)
+
+ if present(mesh.radii):
+ nc.setncattr("RADII", mesh.radii)
+
+ if kind in MESH_KINDS and ndim > 1:
+ name = "vert" + str(ndim)
+ _write_verts(
+ nc, name, getattr(mesh, name), ndim)
+
+ name = "seed" + str(ndim)
+ _write_verts(
+ nc, name, getattr(mesh, name), ndim)
+
+ _write_values(nc, "power_val", mesh.power,
+ mesh, ndim, kind in GRID_KINDS)
+
+ if kind in MESH_KINDS:
+ for cell, width, _ in CELL_TYPES:
+ _write_cells(
+ nc, cell, getattr(mesh, cell), width)
+
+ _write_bound(nc, mesh)
+
+ _write_values(nc, "value_mat", mesh.value,
+ mesh, ndim, kind in GRID_KINDS)
+ _write_values(nc, "slope_mat", mesh.slope,
+ mesh, ndim, kind in GRID_KINDS)
+
+ if kind in GRID_KINDS:
+ _write_coord(nc, mesh)
+
+ _write_values(nc, "value_mat", mesh.value,
+ mesh, ndim, kind in GRID_KINDS)
+ _write_values(nc, "slope_mat", mesh.slope,
+ mesh, ndim, kind in GRID_KINDS)
diff --git a/jigsawpy/parse/savemsh.py b/jigsawpy/parse/savemsh.py
new file mode 100644
index 0000000..fee88e7
--- /dev/null
+++ b/jigsawpy/parse/savemsh.py
@@ -0,0 +1,225 @@
+
+from pathlib import Path
+import numpy as np
+from numpy.lib import recfunctions as rfn
+
+from jigsawpy.msh_t import jigsaw_msh_t
+from jigsawpy.certify import certify
+
+
+_CHUNK_ROWS = 2 ** 19
+_MESH_RECORDS = (
+ ("edge2", "EDGE2", 3),
+ ("tria3", "TRIA3", 4),
+ ("quad4", "QUAD4", 5),
+ ("tria4", "TRIA4", 5),
+ ("hexa8", "HEXA8", 9),
+ ("wedg6", "WEDG6", 7),
+ ("pyra5", "PYRA5", 6),
+ ("bound", "BOUND", 3),
+)
+
+def _write_rows(fptr, data, nrows, formats, dtype=None):
+ row_format = ";".join(formats) + "\n"
+
+ start = 0
+ while start < nrows:
+ end = min(start + _CHUNK_ROWS, nrows)
+ rows = data[start:end]
+ if dtype is not None:
+ values = rfn.structured_to_unstructured(
+ rows, dtype=dtype).ravel()
+ else:
+ values = rows.ravel()
+
+ text_format = row_format * (end - start)
+ fptr.write(text_format % tuple(values))
+ start = end
+
+
+def _write_data(ftag, data, fptr, formats, dtype):
+ fptr.write(ftag + "=" + str(data.size) + "\n")
+ _write_rows(fptr, data, data.size, formats, dtype)
+
+
+def _save_cells(data, fptr, ftag, ncols):
+ _write_data(ftag, data, fptr, ["%d"] * ncols, np.int32)
+
+
+def saveradii(mesh, fptr):
+ """
+ SAVERADII: save the RADII data structure to *.msh file.
+
+ """
+ if (mesh.radii.size == +3):
+ fptr.write(
+ "RADII="
+ f"{mesh.radii[0]:.17g};"
+ f"{mesh.radii[1]:.17g};"
+ f"{mesh.radii[2]:.17g}\n")
+
+ elif (mesh.radii.size == +1):
+ fptr.write(
+ "RADII="
+ f"{mesh.radii[0]:.17g};"
+ f"{mesh.radii[0]:.17g};"
+ f"{mesh.radii[0]:.17g}\n")
+
+ return
+
+
+def savevert2(ftag, data, fptr):
+ """
+ SAVEVERT2: save the POINT data structure to *.msh file.
+
+ """
+ _write_data(ftag, data, fptr,
+ ["%.17g", "%.17g", "%d"], np.float64)
+
+
+def savevert3(ftag, data, fptr):
+ """
+ SAVEVERT3: save the POINT data structure to *.msh file.
+
+ """
+ _write_data(ftag, data, fptr,
+ ["%.17g", "%.17g", "%.17g", "%d"], np.float64)
+
+
+def savevalue(ftag, data, fptr):
+ """
+ SAVEVALUE: save the ARRAY data structure to *.msh file.
+
+ """
+ if data.ndim == 1:
+ data = data.reshape((data.size, 1))
+
+ prec = 9 if data.dtype == np.float32 else 17
+
+ nrows, ncols = data.shape
+ fptr.write(f"{ftag}={nrows};{ncols}\n")
+ _write_rows(fptr, data, nrows, [f"%.{prec}g"] * ncols)
+
+
+def savecoord(data, fptr, inum):
+ """
+ SAVECOORD: save the COORD data structure to *.msh file.
+
+ """
+ fptr.write(f"COORD={inum};{data.size}\n")
+ _write_rows(fptr, data, data.size, ["%.17g"])
+
+
+def savendmat(ftag, data, fptr):
+ """
+ SAVENDMAT: save the VALUE data structure to *.msh file.
+
+ """
+ fptr.write(f"{ftag}={data.size}; 1\n")
+
+ prec = 9 if data.dtype == np.float32 else 17
+
+ vals = data.reshape(-1, order="F")
+ _write_rows(fptr, vals, vals.size, [f"%.{prec}g"])
+
+
+def save_mesh_file(mesh, fptr, args, kind):
+ fptr.write("MSHID=" + str(args.nver) + ";" + kind + "\n")
+
+ ndim = 0
+ if mesh.vert2 is not None and mesh.vert2.size:
+ ndim = +2
+ if mesh.vert3 is not None and mesh.vert3.size:
+ ndim = +3
+ if mesh.seed2 is not None and mesh.seed2.size:
+ ndim = +2
+ if mesh.seed3 is not None and mesh.seed3.size:
+ ndim = +3
+
+ if ndim == 2: fptr.write("NDIMS=2\n")
+ if ndim == 3: fptr.write("NDIMS=3\n")
+
+ if mesh.radii is not None and mesh.radii.size:
+ saveradii(mesh, fptr)
+
+ if mesh.vert2 is not None and mesh.vert2.size:
+ savevert2("POINT", mesh.point, fptr)
+ if mesh.vert3 is not None and mesh.vert3.size:
+ savevert3("POINT", mesh.point, fptr)
+ if mesh.seed2 is not None and mesh.seed2.size:
+ savevert2("SEEDS", mesh.seeds, fptr)
+ if mesh.seed3 is not None and mesh.seed3.size:
+ savevert3("SEEDS", mesh.seeds, fptr)
+
+ for name in ("power", "value", "slope"):
+ data = getattr(mesh, name)
+ if data is not None and data.size:
+ savevalue(name.upper(), data, fptr)
+
+ for name, tag, ncols in _MESH_RECORDS:
+ data = getattr(mesh, name)
+ if data is not None and data.size:
+ _save_cells(data, fptr, tag, ncols)
+
+
+def save_grid_file(mesh, fptr, args, kind):
+ fptr.write("MSHID=" + str(args.nver) + ";" + kind + "\n")
+
+ if mesh.radii is not None and mesh.radii.size:
+ saveradii(mesh, fptr)
+
+ coordinates = (
+ ("xgrid",1), ("ygrid",2), ("zgrid",3))
+ present = [
+ (getattr(mesh, name), axis)
+ for name, axis in coordinates
+ if getattr(mesh, name) is not None and
+ getattr(mesh, name).size
+ ]
+ if present:
+ fptr.write(f"NDIMS={len(present)}\n")
+ for data, axis in present:
+ savecoord(data, fptr, axis)
+
+ for name in ("value", "slope"):
+ data = getattr(mesh, name)
+ if data is not None and data.size:
+ savendmat(name.upper(), data, fptr)
+
+
+def savemsh(name, mesh):
+ certify(mesh)
+
+ class stub(object): pass
+
+ args = stub() ## savmsh params
+ args.kind = "ascii"
+ args.nver = 3
+
+ fext = Path(name).suffix
+
+ if (fext.strip() != ".msh"): name += ".msh"
+
+ kind = mesh.mshID.lower()
+
+ with Path(name).open("w") as fptr:
+ #----------------------------------- write JIGSAW object
+ fptr.write(
+ "# " + Path(name).name +
+ "; created by JIGSAW's PYTHON interface \n")
+
+ if (kind == "euclidean-mesh"):
+ save_mesh_file(
+ mesh, fptr, args, "euclidean-mesh")
+
+ if (kind == "euclidean-grid"):
+ save_grid_file(
+ mesh, fptr, args, "euclidean-grid")
+
+ if (kind == "ellipsoid-mesh"):
+ save_mesh_file(
+ mesh, fptr, args, "ellipsoid-mesh")
+
+ if (kind == "ellipsoid-grid"):
+ save_grid_file(
+ mesh, fptr, args, "ellipsoid-grid")
diff --git a/jigsawpy/parse/saveoff.py b/jigsawpy/parse/saveoff.py
index c0c02e0..5c0df09 100644
--- a/jigsawpy/parse/saveoff.py
+++ b/jigsawpy/parse/saveoff.py
@@ -1,9 +1,11 @@
import warnings
+import argparse
from pathlib import Path
from jigsawpy.msh_t import jigsaw_msh_t
from jigsawpy.certify import certify
+from jigsawpy.loadmsh import loadmsh
def savepoint(data, fptr, ndim):
@@ -190,3 +192,24 @@ def saveoff(name, mesh):
"MESH.mshID is not supported!!")
return
+
+
+if (__name__ == "__main__"):
+ parser = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+
+ parser.add_argument(
+ "--src-file", dest="src_file", type=str,
+ required=True, help="Input *.msh file to load")
+
+ parser.add_argument(
+ "--dst-file", dest="dst_file", type=str,
+ required=True, help="Output .off file to save")
+
+ args = parser.parse_args()
+
+ mesh = jigsaw_msh_t()
+
+ loadmsh(name=args.src_file, mesh=mesh)
+ saveoff(name=args.dst_file, mesh=mesh)
diff --git a/jigsawpy/parse/savevtk.py b/jigsawpy/parse/savevtk.py
index a31cbd7..2bd0324 100644
--- a/jigsawpy/parse/savevtk.py
+++ b/jigsawpy/parse/savevtk.py
@@ -1,9 +1,11 @@
from pathlib import Path
import numpy as np
+import argparse
from jigsawpy.msh_t import jigsaw_msh_t
from jigsawpy.certify import certify
+from jigsawpy.loadmsh import loadmsh
def savepoint(data, fptr, ndim):
@@ -392,3 +394,24 @@ def savevtk(name, mesh):
"MESH.mshID is not supported!!")
return
+
+
+if (__name__ == "__main__"):
+ parser = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+
+ parser.add_argument(
+ "--src-file", dest="src_file", type=str,
+ required=True, help="Input *.msh file to load")
+
+ parser.add_argument(
+ "--dst-file", dest="dst_file", type=str,
+ required=True, help="Output .vtk file to save")
+
+ args = parser.parse_args()
+
+ mesh = jigsaw_msh_t()
+
+ loadmsh(name=args.src_file, mesh=mesh)
+ savevtk(name=args.dst_file, mesh=mesh)
diff --git a/jigsawpy/parse/savewav.py b/jigsawpy/parse/savewav.py
index f7ac9dc..8d37ba3 100644
--- a/jigsawpy/parse/savewav.py
+++ b/jigsawpy/parse/savewav.py
@@ -1,10 +1,12 @@
import warnings
+import argparse
from pathlib import Path
import numpy as np
from jigsawpy.msh_t import jigsaw_msh_t
from jigsawpy.certify import certify
+from jigsawpy.loadmsh import loadmsh
def savepoint(data, fptr, ndim, ctag):
@@ -158,3 +160,24 @@ def savewav(name, mesh):
"MESH.mshID is not supported!!")
return
+
+
+if (__name__ == "__main__"):
+ parser = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+
+ parser.add_argument(
+ "--src-file", dest="src_file", type=str,
+ required=True, help="Input *.msh file to load")
+
+ parser.add_argument(
+ "--dst-file", dest="dst_file", type=str,
+ required=True, help="Output .obj file to save")
+
+ args = parser.parse_args()
+
+ mesh = jigsaw_msh_t()
+
+ loadmsh(name=args.src_file, mesh=mesh)
+ savewav(name=args.dst_file, mesh=mesh)
diff --git a/jigsawpy/parse/utility.py b/jigsawpy/parse/utility.py
new file mode 100644
index 0000000..b3d8986
--- /dev/null
+++ b/jigsawpy/parse/utility.py
@@ -0,0 +1,69 @@
+
+import numpy as np
+
+from jigsawpy.msh_t import jigsaw_msh_t
+
+
+MESH_KINDS = ("euclidean-mesh", "ellipsoid-mesh")
+GRID_KINDS = ("euclidean-grid", "ellipsoid-grid")
+CELL_TYPES = (
+ ("edge2", 2, jigsaw_msh_t.EDGE2_t),
+ ("tria3", 3, jigsaw_msh_t.TRIA3_t),
+ ("quad4", 4, jigsaw_msh_t.QUAD4_t),
+ ("tria4", 4, jigsaw_msh_t.TRIA4_t),
+ ("hexa8", 8, jigsaw_msh_t.HEXA8_t),
+ ("wedg6", 6, jigsaw_msh_t.WEDG6_t),
+ ("pyra5", 5, jigsaw_msh_t.PYRA5_t),
+)
+
+
+def netcdf_dataset():
+ try:
+ from netCDF4 import Dataset
+ except ModuleNotFoundError as error:
+ if error.name != "netCDF4":
+ raise
+ raise ImportError(
+ "NetCDF mesh I/O requires netCDF4; "
+ "install jigsawpy[netcdf].") from error
+ return Dataset
+
+
+def present(data):
+ return data is not None and data.size > 0
+
+
+def grid_shape(mesh, ndim=None):
+ axes = [data.size if present(data) else 0
+ for data in (mesh.xgrid, mesh.ygrid,
+ mesh.zgrid)]
+ ndim = mesh.ndims if ndim is None else ndim
+ if ndim == 1 and axes[0]:
+ return (axes[0],)
+ if ndim == 2 and axes[0] and axes[1]:
+ return (axes[1], axes[0])
+ if ndim == 3 and all(axes):
+ return (axes[1], axes[0], axes[2])
+ raise ValueError(
+ "Incorrect NetCDF grid coordinates for NDIMS")
+
+
+def shape_grid(data, mesh, name, squeeze=False):
+ shape = grid_shape(mesh)
+ if data.size == 1: return data.reshape((1, 1))
+
+ count = int(np.prod(shape))
+ if data.size % count:
+ if name is None:
+ raise ValueError("Invalid grid data size")
+ raise ValueError(
+ "Invalid NetCDF " + name + " size")
+
+ nvalues = data.size // count
+ if squeeze:
+ return np.squeeze(
+ data.reshape(shape + (nvalues,), order="F")
+ )
+ if nvalues == 1:
+ return data.reshape(shape, order="F")
+ return data.reshape(shape + (nvalues,), order="F")
diff --git a/jigsawpy/project.py b/jigsawpy/project.py
index ea247a9..121746b 100644
--- a/jigsawpy/project.py
+++ b/jigsawpy/project.py
@@ -6,6 +6,35 @@
from jigsawpy.tools.projector import stereo3
+def _scale_shape(data, scal, stag):
+ if data.ndim == 0 or data.shape[0] != scal.size:
+ raise ValueError("Invalid MESH." + stag + " size")
+
+ return (scal.size,) + (1,) * (data.ndim - 1)
+
+
+def _scale_value(data, scal, stag):
+ data *= scal.reshape(_scale_shape(data, scal, stag))
+ return data
+
+
+def _scale_flat_value(data, scal, stag):
+ if not scal.size or data.size % scal.size:
+ raise ValueError("Invalid MESH." + stag + " size")
+
+ data = np.reshape(data, data.size)
+ data.reshape((scal.size, -1))[:]*= scal[:, np.newaxis]
+ return data
+
+
+def _expand_scalar(data, size):
+ if data.size == 1:
+ if data.ndim == 0:
+ data = data.reshape(1)
+ return np.repeat(data, size, axis=0)
+ return data
+
+
def project(mesh, proj, sign):
"""
PROJECT cartographic projections for JIGSAW MSH objects.
@@ -35,13 +64,16 @@ def project(mesh, proj, sign):
if (not isinstance(sign, str)):
raise TypeError("Incorrect type: SIGN.")
+ sign = sign.lower()
+ if sign not in ("fwd", "inv"):
+ raise ValueError("Incorrect projection PRJID flags.")
+
certify(mesh)
kind = mesh.mshID.lower()
if (kind == "euclidean-mesh" or
kind == "ellipsoid-mesh"):
-
#------------------------------- proj. from MESH to MESH
if (mesh.vert2 is not None and
@@ -52,64 +84,54 @@ def project(mesh, proj, sign):
#----------------------------------- proj. geometry parts
if (proj.prjID.lower() == "stereographic"):
-
XNEW, YNEW, SCAL = stereo3(
proj.radii, XPOS, YPOS,
proj.xbase, proj.ybase, sign)
-
- """
- elif (proj.prjID.lower() == "hammer-aitoff"):
-
- XNEW, YNEW, SCAL = hammer3(
- proj.radii, XPOS, YPOS,
- proj.xbase, proj.ybase, sign)
- """
-
else:
-
raise ValueError(
"Projection operator not suppoted.")
#----------------------------------- setup proj.'d object
- if (sign.lower() == "fwd"):
-
- mesh.mshID = "euclidean-mesh"
-
- if (mesh.radii is not None):
- mesh.radii = None
-
- elif (sign.lower() == "inv"):
-
- mesh.mshID = "ellipsoid-mesh"
-
- mesh.radii = np.full(
- +3, proj.radii,
- dtype=jigsaw_msh_t.REALS_t)
-
+ if (sign == "fwd"):
+ kind = "euclidean-mesh"
+ radii = None
else:
-
- raise ValueError(
- "Incorrect projection PRJID flags.")
-
+ kind = "ellipsoid-mesh"
+ radii = np.full(
+ +3, proj.radii,
+ dtype=jigsaw_msh_t.REALS_t)
+
+ if mesh.value is not None and mesh.value.size:
+ if mesh.value.size != 1: \
+ _scale_shape(mesh.value, SCAL, "VALUE")
+
+ SPOW = (
+ SCAL ** 2 if mesh.power is not None and
+ mesh.power.size else None
+ )
+ if mesh.power is not None and mesh.power.size:
+ _scale_shape(mesh.power, SPOW, "POWER")
+
+ mesh.mshID = kind
+ mesh.radii = radii
mesh.point["coord"][:, 0] = XNEW
mesh.point["coord"][:, 1] = YNEW
#----------------------------------- setup proj.'d extras
- if (mesh.value is not None and
- mesh.value.size != +0):
-
- mesh.value*= SCAL.reshape(mesh.value.shape)
+ if mesh.value is not None and mesh.value.size:
+ mesh.value = \
+ _expand_scalar(mesh.value, SCAL.size)
+ _scale_value(mesh.value, SCAL, "VALUE")
- if (mesh.power is not None and
- mesh.power.size != +0):
+ if mesh.slope is not None and mesh.slope.size:
+ mesh.slope = \
+ _expand_scalar(mesh.slope, SCAL.size)
- SPOW = np.sqrt(SCAL)
-
- mesh.power*= SPOW.reshape(mesh.power.shape)
+ if mesh.power is not None and mesh.power.size:
+ _scale_value(mesh.power, SPOW, "POWER")
elif (kind == "euclidean-grid" or
kind == "ellipsoid-grid"):
-
#------------------------------- proj. from GRID to MESH
if (mesh.xgrid is not None and
@@ -125,48 +147,36 @@ def project(mesh, proj, sign):
#----------------------------------- proj. geometry parts
if (proj.prjID.lower() == "stereographic"):
-
XNEW, YNEW, SCAL = stereo3(
proj.radii, XPOS, YPOS,
proj.xbase, proj.ybase, sign)
-
- """
- elif (proj.prjID.lower() == "hammer-aitoff"):
-
- XNEW, YNEW, SCAL = hammer3(
- proj.radii, XPOS, YPOS,
- proj.xbase, proj.ybase, sign)
- """
-
else:
-
raise ValueError(
"Projection operator not suppoted.")
#----------------------------------- setup proj.'d object
- mesh.point = np.empty(
- XNEW.size, dtype=jigsaw_msh_t.VERT2_t)
-
- if (sign.lower() == "fwd"):
-
- mesh.mshID = "euclidean-mesh"
-
- if (mesh.radii is not None):
- mesh.radii = None
-
- elif (sign.lower() == "inv"):
-
- mesh.mshID = "ellipsoid-mesh"
-
- mesh.radii = np.full(
+ if (sign == "fwd"):
+ kind = "euclidean-mesh"
+ radii = None
+ else:
+ kind = "ellipsoid-mesh"
+ radii = np.full(
+3, proj.radii,
- dtype=jigsaw_msh_t.REALS_t)
+ dtype=jigsaw_msh_t.REALS_t)
- else:
+ if mesh.value is not None and mesh.value.size:
+ if mesh.value.size != 1 and \
+ mesh.value.size % SCAL.size:
+ raise ValueError("Invalid MESH.VALUE size")
- raise ValueError(
- "Incorrect projection PRJID flags.")
+ if mesh.power is not None and mesh.power.size:
+ if mesh.power.size % SCAL.size:
+ raise ValueError("Invalid MESH.POWER size")
+ mesh.mshID = kind
+ mesh.radii = radii
+ mesh.point = np.empty(
+ XNEW.size, dtype=jigsaw_msh_t.VERT2_t)
mesh.point["IDtag"] = +0
mesh.point["coord"][:, 0] = XNEW
mesh.point["coord"][:, 1] = YNEW
@@ -177,10 +187,8 @@ def project(mesh, proj, sign):
dim1 = mesh.xgrid.size
mesh.xgrid = None
-
dim2 = mesh.ygrid.size
mesh.ygrid = None
-
tset = []
for jpos in range(dim2 - 1):
@@ -223,28 +231,20 @@ def project(mesh, proj, sign):
mesh.tria3 = np.concatenate(tset, axis=0)
#----------------------------------- setup proj.'d extras
- if (mesh.slope is not None and
- mesh.slope.size != +0):
-
+ if mesh.slope is not None and mesh.slope.size:
+ mesh.slope = \
+ _expand_scalar(mesh.slope, SCAL.size)
mesh.slope = np.reshape(
mesh.slope, mesh.slope.size)
- if (mesh.value is not None and
- mesh.value.size != +0):
-
- mesh.value = np.reshape(
- mesh.value, mesh.value.size)
-
- mesh.value*= SCAL.reshape(mesh.value.shape)
-
- if (mesh.power is not None and
- mesh.power.size != +0):
-
- mesh.power = np.reshape(
- mesh.power, mesh.power.size)
-
- SPOW = np.sqrt(SCAL)
+ if mesh.value is not None and mesh.value.size:
+ mesh.value = \
+ _expand_scalar(mesh.value, SCAL.size)
+ mesh.value = _scale_flat_value(
+ mesh.value, SCAL ** 1, "VALUE")
- mesh.power*= SPOW.reshape(mesh.power.shape)
+ if mesh.power is not None and mesh.power.size:
+ mesh.power = _scale_flat_value(
+ mesh.power, SCAL ** 2, "POWER")
return
diff --git a/jigsawpy/savejig.py b/jigsawpy/savejig.py
index 2c41ccd..7724243 100644
--- a/jigsawpy/savejig.py
+++ b/jigsawpy/savejig.py
@@ -146,6 +146,9 @@ def savejig(name, opts):
if (opts.mesh_iter is not None):
saveints(fptr, opts.mesh_iter, "MESH_ITER")
+ if (opts.mesh_rule is not None):
+ saveints(fptr, opts.mesh_rule, "MESH_RULE")
+
if (opts.mesh_orph is not None):
savebool(fptr, opts.mesh_orph, "MESH_ORPH")
if (opts.mesh_lock is not None):
diff --git a/jigsawpy/savemsh.py b/jigsawpy/savemsh.py
index da61d8a..2c16f6a 100644
--- a/jigsawpy/savemsh.py
+++ b/jigsawpy/savemsh.py
@@ -1,598 +1,10 @@
from pathlib import Path
-import numpy as np
-from numpy.lib import recfunctions as rfn
from jigsawpy.msh_t import jigsaw_msh_t
-from jigsawpy.certify import certify
-
-def saveradii(mesh, fptr, args):
- """
- SAVERADII: save the RADII data structure to *.msh file.
-
- """
- if (mesh.radii.size == +3):
- fptr.write(
- "RADII="
- f"{mesh.radii[0]:.17g};"
- f"{mesh.radii[1]:.17g};"
- f"{mesh.radii[2]:.17g}\n")
-
- elif (mesh.radii.size == +1):
- fptr.write(
- "RADII="
- f"{mesh.radii[0]:.17g};"
- f"{mesh.radii[0]:.17g};"
- f"{mesh.radii[0]:.17g}\n")
-
- return
-
-
-def savevert2(ftag, data, fptr, args):
- """
- SAVEVERT2: save the POINT data structure to *.msh file.
-
- """
- fptr.write(ftag + "=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0; prec = 17
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = "%%.%ug" % prec
-
- sfmt = ";".join([sfmt] * 2) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.float64).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savevert3(ftag, data, fptr, args):
- """
- SAVEVERT3: save the POINT data structure to *.msh file.
-
- """
- fptr.write(ftag + "=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0; prec = 17
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = "%%.%ug" % prec
-
- sfmt = ";".join([sfmt] * 3) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.float64).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savevalue(ftag, data, fptr, args):
- """
- SAVEVALUE: save the ARRAY data structure to *.msh file.
-
- """
- if (np.ndim(data) == +1):
- data = np.reshape(data, (data.size, +1))
-
- npos = np.size(data, 0)
- nval = np.size(data, 1)
-
- fptr.write(
- ftag + "=" + str(npos) + ";" + str(nval) + "\n")
-
- rmax = 2 ** 19; next = 0; prec = 17
-
- if (data.dtype == np.float32):
- prec = 9
-
- while (next < data.shape[0]):
-
- nrow = min(rmax, data.shape[0] - next)
- nend = next + nrow
-
- sfmt = "%%.%ug" % prec
-
- sfmt = ";".join([sfmt] * nval) + "\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(data[next:nend:, :].ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def saveedge2(data, fptr, args):
- """
- SAVEEDGE2: save the EDGE2 data structure to *.msh file.
-
- """
- fptr.write("EDGE2=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 2) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savetria3(data, fptr, args):
- """
- SAVETRIA3: save the TRIA3 data structure to *.msh file.
-
- """
- fptr.write("TRIA3=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 3) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savequad4(data, fptr, args):
- """
- SAVEQUAD4: save the QUAD4 data structure to *.msh file.
-
- """
- fptr.write("QUAD4=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 4) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savetria4(data, fptr, args):
- """
- SAVETRIA4: save the TRIA4 data structure to *.msh file.
-
- """
- fptr.write("TRIA4=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 4) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savehexa8(data, fptr, args):
- """
- SAVEHEXA8: save the HEXA8 data structure to *.msh file.
-
- """
- fptr.write("HEXA8=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 8) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savewedg6(data, fptr, args):
- """
- SAVEWEDG6: save the WEDG6 data structure to *.msh file.
-
- """
- fptr.write("WEDG6=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 6) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savepyra5(data, fptr, args):
- """
- SAVEPYRA5: save the PYRA5 data structure to *.msh file.
-
- """
- fptr.write("PYRA5=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = ";".join(["%d"] * 5) + ";%d\n"
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savebound(data, fptr, args):
- """
- SAVEBOUND: save the BOUND data structure to *.msh file.
-
- """
- fptr.write("BOUND=" + str(data.size) + "\n")
-
- rmax = 2 ** 19; next = 0
-
- while (next < data.size):
-
- nrow = min(rmax, data.size - next)
- nend = next + nrow
-
- sfmt = "%d;%d;%d\n" * nrow
-
- fdat = sfmt % tuple(
- rfn.structured_to_unstructured(
- data[next:nend], dtype=np.int32).ravel())
-
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savecoord(data, fptr, args, inum):
- """
- SAVECOORD: save the COORD data structure to *.msh file.
-
- """
- nnum = np.prod(data.shape)
-
- fptr.write(
- "COORD=" + str(inum) + ";" + str(nnum) + "\n")
-
- rmax = 2 ** 19; next = 0; prec = 17
-
- while (next < data.shape[0]):
-
- nrow = min(rmax, data.shape[0] - next)
-
- sfmt = "%%.%ug\n" % prec
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(data[next:next+nrow].ravel())
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def savendmat(ftag, data, fptr, args):
- """
- SAVENDMAT: save the VALUE data structure to *.msh file.
-
- """
- nnum = np.prod(data.shape)
-
- fptr.write(
- ftag + "=" + str(nnum) + "; 1" + "\n")
-
- dptr = data.reshape(-1, order="F")
-
- rmax = 2 ** 19; next = 0; prec = 17
-
- if (dptr.dtype == np.float32):
- prec = 9
-
- while (next < dptr.shape[0]):
-
- nrow = min(rmax, dptr.shape[0] - next)
-
- sfmt = "%%.%ug\n" % prec
- sfmt = sfmt * nrow
-
- fdat = sfmt % tuple(dptr[next:next+nrow].ravel())
- fptr.write(fdat)
-
- next = next + nrow
-
- return
-
-
-def save_mesh_file(mesh, fptr, args, kind):
-
- fptr.write("MSHID=" + str(args.nver) + ";" + kind + "\n")
-
- if (mesh.vert2 is not None and
- mesh.vert2.size != +0):
-
- #----------------------------------- write NDIMS struct.
- fptr.write("NDIMS=2\n")
-
- if (mesh.vert3 is not None and
- mesh.vert3.size != +0):
-
- #----------------------------------- write NDIMS struct.
- fptr.write("NDIMS=3\n")
-
- if (mesh.radii is not None and
- mesh.radii.size != +0):
-
- #----------------------------------- write RADII struct.
- saveradii(mesh, fptr, args)
-
- if (mesh.vert2 is not None and
- mesh.vert2.size != +0):
-
- #----------------------------------- write VERT2 struct.
- savevert2("POINT",
- mesh.point, fptr, args)
-
- if (mesh.vert3 is not None and
- mesh.vert3.size != +0):
-
- #----------------------------------- write VERT3 struct.
- savevert3("POINT",
- mesh.point, fptr, args)
-
- if (mesh.seed2 is not None and
- mesh.seed2.size != +0):
-
- #----------------------------------- write VERT2 struct.
- savevert2("SEEDS",
- mesh.seeds, fptr, args)
-
- if (mesh.seed3 is not None and
- mesh.seed3.size != +0):
-
- #----------------------------------- write VERT3 struct.
- savevert3("SEEDS",
- mesh.seeds, fptr, args)
-
- if (mesh.power is not None and
- mesh.power.size != +0):
-
- #----------------------------------- write POWER struct.
- savevalue("POWER",
- mesh.power, fptr, args)
-
- if (mesh.value is not None and
- mesh.value.size != +0):
-
- #----------------------------------- write VALUE struct.
- savevalue("VALUE",
- mesh.value, fptr, args)
-
- if (mesh.slope is not None and
- mesh.slope.size != +0):
-
- #----------------------------------- write SLOPE struct.
- savevalue("SLOPE",
- mesh.slope, fptr, args)
-
- if (mesh.edge2 is not None and
- mesh.edge2.size != +0):
-
- #----------------------------------- write EDGE2 struct.
- saveedge2(mesh.edge2, fptr, args)
-
- if (mesh.tria3 is not None and
- mesh.tria3.size != +0):
-
- #----------------------------------- write TRIA3 struct.
- savetria3(mesh.tria3, fptr, args)
-
- if (mesh.quad4 is not None and
- mesh.quad4.size != +0):
-
- #----------------------------------- write QUAD4 struct.
- savequad4(mesh.quad4, fptr, args)
-
- if (mesh.tria4 is not None and
- mesh.tria4.size != +0):
-
- #----------------------------------- write TRIA4 struct.
- savetria4(mesh.tria4, fptr, args)
-
- if (mesh.hexa8 is not None and
- mesh.hexa8.size != +0):
-
- #----------------------------------- write HEXA8 struct.
- savehexa8(mesh.hexa8, fptr, args)
-
- if (mesh.wedg6 is not None and
- mesh.wedg6.size != +0):
-
- #----------------------------------- write WEDG6 struct.
- savewedg6(mesh.wedg6, fptr, args)
-
- if (mesh.pyra5 is not None and
- mesh.pyra5.size != +0):
-
- #----------------------------------- write PYRA5 struct.
- savepyra5(mesh.pyra5, fptr, args)
-
- if (mesh.bound is not None and
- mesh.bound.size != +0):
-
- #----------------------------------- write BOUND struct.
- savebound(mesh.bound, fptr, args)
-
- return
-
-
-def save_grid_file(mesh, fptr, args, kind):
-
- fptr.write("MSHID=" + str(args.nver) + ";" + kind + "\n")
-
- if (mesh.radii is not None and
- mesh.radii.size != +0):
-
- #----------------------------------- write RADII struct.
- saveradii(mesh, fptr, args)
-
- #----------------------------------- calc. NDIMS struct.
- ndim = +0
- if (mesh.xgrid is not None and
- mesh.xgrid.size != +0):
- ndim += +1
-
- if (mesh.ygrid is not None and
- mesh.ygrid.size != +0):
- ndim += +1
-
- if (mesh.zgrid is not None and
- mesh.zgrid.size != +0):
- ndim += +1
-
- if (ndim >= +1):
- #----------------------------------- write NDIMS struct.
- fptr.write("NDIMS="
- + str(ndim) + "\n")
-
- if (mesh.xgrid is not None and
- mesh.xgrid.size != +0):
-
- #----------------------------------- write XGRID struct.
- savecoord(mesh.xgrid, fptr, args, +1)
-
- if (mesh.ygrid is not None and
- mesh.ygrid.size != +0):
-
- #----------------------------------- write YGRID struct.
- savecoord(mesh.ygrid, fptr, args, +2)
-
- if (mesh.zgrid is not None and
- mesh.zgrid.size != +0):
-
- #----------------------------------- write ZGRID struct.
- savecoord(mesh.zgrid, fptr, args, +3)
-
- if (mesh.value is not None and
- mesh.value.size != +0):
-
- #----------------------------------- write VALUE struct.
- savendmat("VALUE",
- mesh.value, fptr, args)
-
- if (mesh.slope is not None and
- mesh.slope.size != +0):
-
- #----------------------------------- write SLOPE struct.
- savendmat("SLOPE",
- mesh.slope, fptr, args)
-
- return
+from jigsawpy.parse.savemsh import savemsh as _savemsh
+from jigsawpy.parse.save_nc import save_nc as _save_nc
def savemsh(name, mesh):
@@ -607,48 +19,21 @@ def savemsh(name, mesh):
Data in MESH is written as-needed -- any objects defined
will be saved to file.
- """
+ For NetCDF grids, VALUE and SLOPE use dimensions (x),
+ (x, y), or (z, x, y), preserving y-fast ordering.
+ Mesh fields use the vertex-row dimension; a shared scalar
+ slope is stored separately.
+ Radius-only ellipsoid meshes default to NDIMS=3 when
+ MESH.NDIMS is unspecified.
+ """
if (not isinstance(name, str)):
raise TypeError("Incorrect type: NAME.")
if (not isinstance(mesh, jigsaw_msh_t)):
raise TypeError("Incorrect type: MESH.")
- certify(mesh)
-
- class stub(object): pass
-
- args = stub() ## savmsh params
- args.kind = "ascii"
- args.nver = 3
-
- fext = Path(name).suffix
-
- if (fext.strip() != ".msh"): name += ".msh"
-
- kind = mesh.mshID.lower()
-
- with Path(name).open("w") as fptr:
- #----------------------------------- write JIGSAW object
- fptr.write(
- "# " + Path(name).name +
- "; created by JIGSAW's PYTHON interface \n")
-
- if (kind == "euclidean-mesh"):
- save_mesh_file(
- mesh, fptr, args, "euclidean-mesh")
-
- if (kind == "euclidean-grid"):
- save_grid_file(
- mesh, fptr, args, "euclidean-grid")
-
- if (kind == "ellipsoid-mesh"):
- save_mesh_file(
- mesh, fptr, args, "ellipsoid-mesh")
-
- if (kind == "ellipsoid-grid"):
- save_grid_file(
- mesh, fptr, args, "ellipsoid-grid")
-
- return
+ if Path(name).suffix.lower() == ".nc":
+ _save_nc(name, mesh)
+ else:
+ _savemsh(name, mesh)
diff --git a/jigsawpy/tools/meshutils.py b/jigsawpy/tools/meshutils.py
index 7f9e060..39292b1 100644
--- a/jigsawpy/tools/meshutils.py
+++ b/jigsawpy/tools/meshutils.py
@@ -66,11 +66,11 @@ def jumble(mesh, frac):
xdat = np.random.rand(xdat.size) * xdat
- next = np.squeeze(np.asarray(csr_matrix(
- (xdat, (ipos, jpos))).argmax(axis=1)))
+ next = np.asarray(csr_matrix(
+ (xdat, (ipos, jpos))).argmax(axis=1)).ravel()
#-------------------------- push toward "matched" centre
- tria = mesh.tria3["index"][next, :]
+ tria = mesh.tria3["index"][next[have], :]
pmid = tribal2(mesh.point["coord"], tria)
pmid = pmid[:, :-1]
@@ -97,11 +97,11 @@ def jumble(mesh, frac):
xdat = np.random.rand(xdat.size) * xdat
- next = np.squeeze(np.asarray(csr_matrix(
- (xdat, (ipos, jpos))).argmax(axis=1)))
+ next = np.asarray(csr_matrix(
+ (xdat, (ipos, jpos))).argmax(axis=1)).ravel()
#-------------------------- push toward "matched" centre
- tria = mesh.tria4["index"][next, :]
+ tria = mesh.tria4["index"][next[have], :]
pmid = tribal3(mesh.point["coord"], tria)
pmid = pmid[:, :-1]
diff --git a/jigsawpy/tools/predicate.py b/jigsawpy/tools/predicate.py
index 1579734..2ad598d 100644
--- a/jigsawpy/tools/predicate.py
+++ b/jigsawpy/tools/predicate.py
@@ -31,8 +31,8 @@ def istri_1(ppos, tri1):
if (tri1.shape[1] < +2):
raise ValueError("Invalid TRIA shape.")
- if (np.min(tri1[:, 0:1]) < +0 or
- np.max(tri1[:, 0:1]) >= nump):
+ if (np.any(tri1[:, :2] < +0) or
+ np.any(tri1[:, :2] >= nump)):
raise IndexError("Invalid TRIA index.")
return okay
@@ -67,8 +67,8 @@ def istri_2(ppos, tri2):
if (tri2.shape[1] < +3):
raise ValueError("Invalid TRIA shape.")
- if (np.min(tri2[:, 0:2]) < +0 or
- np.max(tri2[:, 0:2]) >= nump):
+ if (np.any(tri2[:, :3] < +0) or
+ np.any(tri2[:, :3] >= nump)):
raise IndexError("Invalid TRIA index.")
return okay
@@ -103,8 +103,8 @@ def istri_3(ppos, tri3):
if (tri3.shape[1] < +4):
raise ValueError("Invalid TRIA shape.")
- if (np.min(tri3[:, 0:3]) < +0 or
- np.max(tri3[:, 0:3]) >= nump):
+ if (np.any(tri3[:, :4] < +0) or
+ np.any(tri3[:, :4] >= nump)):
raise IndexError("Invalid TRIA index.")
return okay
diff --git a/jigsawpy/tools/projector.py b/jigsawpy/tools/projector.py
index 9974012..d10e205 100644
--- a/jigsawpy/tools/projector.py
+++ b/jigsawpy/tools/projector.py
@@ -62,10 +62,8 @@ def stereo3_i(rrad, xpos, ypos, xmid, ymid):
#------------------------------------ do inverse mapping
- rval = np.sqrt(xpos**2 + ypos**2)
-
- rval = np.maximum(
- 1.0E-16 * np.max(rval), rval)
+ rval = np.hypot(xpos, ypos)
+ zero = (rval == 0.)
cval = +2.0 * np.arctan2(rval, +2.0 * rrad)
@@ -78,10 +76,14 @@ def stereo3_i(rrad, xpos, ypos, xmid, ymid):
xtmp = rval * ccym * cccv - ypos * ssym * sscv
xnew = xmid + np.arctan2(xpos * sscv, xtmp)
+ xnew = np.where(zero, xmid, xnew)
ytmp = ypos * ccym * sscv
- ynew = np.arcsin(cccv * ssym + ytmp / rval)
+ rlim = np.where(zero, +1.0, rval)
+ ynew = np.arcsin(np.clip(
+ cccv * ssym + ytmp / rlim, -1.0, +1.0))
+ ynew = np.where(zero, ymid, ynew)
#------------------------------------ compute indicatrix
@@ -113,6 +115,7 @@ def stereo3_i(rrad, xpos, ypos, xmid, ymid):
scal = \
rrad * +1.0 / np.sqrt(dxdy**2 + dydy**2)
+ scal = np.where(zero, 1., scal)
return xnew, ynew, scal
@@ -137,9 +140,9 @@ def stereo3(rrad, xpos, ypos, xmid, ymid, kind):
with [XPOS,YPOS] the stereographic coordinates, and
[XNEW,YNEW] the resulting lon-lat spherical angles.
- SCAL is the scale-factor associated with the forward ma-
- pping. This array stores the relative length distortion
- induced by the projection for all points in [XNEW,YNEW].
+ SCAL is the local length scale-factor for the requested
+ mapping: plane length / sphere length for "FWD", and its
+ reciprocal for "INV", at each corresponding point.
"""
diff --git a/jigsawpy/tools/scorecard.py b/jigsawpy/tools/scorecard.py
index 620abb8..d5b14b1 100644
--- a/jigsawpy/tools/scorecard.py
+++ b/jigsawpy/tools/scorecard.py
@@ -105,12 +105,13 @@ def trideg2(ppos, tri2):
triangulation.
VDEG = TRIDEG2(VERT,TRIA) returns the no. of triangles
- incident to each vertex. VDEG is a V-by-1 array of
- vertex degrees, VERT is a V-by-D array of XYZ coord. and
+ incident to each vertex. VDEG is a length-V array of
+ vertex degrees, including zero for isolated vertices.
+ VERT is a V-by-D array of XYZ coord. and
TRIA is a T-by-3 array of vertex indexes, where each row
defines a triangle, such that VERT[TRIA[II,0],:],
VERT[TRIA[II,1],:] and VERT[TRIA[II,2],:] are the coord.
- of the II-TH triangle.
+ of the II-TH triangle. Extra TRIA columns are ignored.
"""
@@ -119,7 +120,7 @@ def trideg2(ppos, tri2):
#------------------------------------- compute vertex degree
return np.bincount(
- np.reshape(tri2, (tri2.size)))
+ tri2[:, :3].reshape(-1), minlength=ppos.shape[0])
def trideg3(ppos, tri3):
@@ -128,12 +129,14 @@ def trideg3(ppos, tri3):
triangulation.
VDEG = TRIDEG3(VERT,TRIA) returns the no. of tetrahedra
- incident to each vertex. VDEG is a V-by-1 array of
- vertex degrees, VERT is a V-by-D array of XYZ coord. and
+ incident to each vertex. VDEG is a length-V array of
+ vertex degrees, including zero for isolated vertices.
+ VERT is a V-by-D array of XYZ coord. and
TRIA is a T-by-4 array of vertex indexes, where each row
defines a tetrahedron, such that VERT[TRIA[II,0],:],
VERT[TRIA[II,1],:], VERT[TRIA[II,2],:] and
- VERT[TRIA[II,3],:] are the coord. of the II-TH triangle.
+ VERT[TRIA[II,3],:] are the coord. of the II-TH simplex.
+ Extra TRIA columns are ignored.
"""
@@ -142,7 +145,7 @@ def trideg3(ppos, tri3):
#------------------------------------- compute vertex degree
return np.bincount(
- np.reshape(tri3, (tri3.size)))
+ tri3[:, :4].reshape(-1), minlength=ppos.shape[0])
def triang2(ppos, tri2):
@@ -390,7 +393,7 @@ def pwrscr2(ppos, ppwr, tri2):
ll33 = +0.25 * np.sum(
vvec ** 2, axis=1, keepdims=True)
- lf00 = (ll11 * ll11 * ll33) ** (1./3)
+ lf00 = (ll11 * ll22 * ll33) ** (1./3)
#--------------------------------------- form quality metric
qf00 = +1.00 - df00 / lf00
@@ -536,7 +539,7 @@ def pwrscr3(ppos, ppwr, tri3):
ll66 = +0.25 * np.sum(
vvec ** 2, axis=1, keepdims=True)
- lt00 = (ll11 * ll22 * ll33 +
+ lt00 = (ll11 * ll22 * ll33 *
ll44 * ll55 * ll66) ** (1./6)
#--------------------------------------- form quality metric
diff --git a/pyproject.toml b/pyproject.toml
index bda84de..4a5cccb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,10 +1,10 @@
[build-system]
-requires = ["setuptools"]
+requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "jigsawpy"
-version = "1.1.0"
+version = "1.1.1"
description = "Python interface for the JIGSAW meshing library."
readme = "README.md"
authors = [
@@ -16,7 +16,9 @@ license-files = ["LICENSE.md"]
dependencies = ["numpy", "scipy"]
classifiers = [
"Development Status :: 5 - Production/Stable",
- "Operating System :: OS Independent",
+ "Operating System :: Microsoft :: Windows",
+ "Operating System :: POSIX :: Linux",
+ "Operating System :: MacOS",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
@@ -27,10 +29,12 @@ classifiers = [
"Topic :: Scientific/Engineering :: Visualization"
]
+[project.optional-dependencies]
+netcdf = ["netCDF4"]
+
[project.urls]
homepage = "https://dengwirda.github.io/"
source = "https://github.com/dengwirda/jigsaw-python/"
[tool.setuptools.package-data]
"jigsawpy" = ["_bin/*", "_lib/*"]
-
diff --git a/requirements.txt b/requirements.txt
index 6bad103..ae06e75 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
numpy
scipy
+netCDF4
diff --git a/setup.cfg b/setup.cfg
index c1dc057..f1ee56f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,3 +2,4 @@
ignore = W503,W504,E115,E265,E271,E701,E702,E704,F401
exclude = jigsawpy/msh_l.py,
jigsawpy/jig_l.py
+
diff --git a/setup.py b/setup.py
index 0bc53fd..b4ddec8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,10 @@
import io
import os
-from setuptools import setup, find_packages, Command
+import importlib.util
+import platform
+from setuptools import setup, find_packages, Command, Distribution
+from wheel.bdist_wheel import bdist_wheel
#-- old setup.py workflow for backwards compatibility
#-- python setup.py build_external
@@ -13,7 +16,7 @@
AUTHOR = "Darren Engwirda"
AUTHOR_EMAIL = "d.engwirda@gmail.com"
URL = "https://github.com/dengwirda/"
-VERSION = "1.1.0"
+VERSION = "1.1.1"
REQUIRES_PYTHON = ">=3.6.0"
KEYWORDS = "Mesh-generation Delaunay Voronoi"
@@ -23,7 +26,9 @@
CLASSIFY = [
"Development Status :: 5 - Production/Stable",
- "Operating System :: OS Independent",
+ "Operating System :: Microsoft :: Windows",
+ "Operating System :: POSIX :: Linux",
+ "Operating System :: MacOS",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
@@ -57,7 +62,48 @@ def finalize_options(self): pass
def run(self):
if (self.dry_run): return
- import build; build.build_external()
+ spec = importlib.util.spec_from_file_location(
+ "jigsaw_build",
+ os.path.join(HERE, "build.py"))
+ build = importlib.util.module_from_spec (spec)
+ spec.loader.exec_module(build)
+ build.build_external()
+
+
+class BinaryDistribution(Distribution):
+ def has_ext_modules(self):
+ return True
+
+
+class build_wheel(bdist_wheel):
+ def run(self):
+ system = platform.system()
+ libraries = {
+ "Windows": "jigsaw.dll",
+ "Linux": "libjigsaw.so",
+ "Darwin": "libjigsaw.dylib",
+ }
+ if system not in libraries:
+ raise RuntimeError(
+ "Unsupported wheel platform: " + system)
+
+ suffix = ".exe" if system == "Windows" else ""
+ required = [
+ os.path.join(HERE, "jigsawpy", "_bin", name + suffix)
+ for name in ("jigsaw", "tripod", "marche")
+ ]
+ required.append(os.path.join(
+ HERE, "jigsawpy", "_lib", libraries[system]))
+ missing = [
+ path for path in required if not os.path.isfile(path)
+ ]
+ if missing:
+ raise RuntimeError(
+ "Missing JIGSAW backend binaries: " +
+ ", ".join(missing) + ". Run python build.py "
+ "before building a wheel."
+ )
+ super().run()
setup(
@@ -72,9 +118,11 @@ def run(self):
keywords=KEYWORDS,
url=URL,
packages=find_packages(exclude=["tests",]),
- cmdclass={"build_external": build_external},
+ cmdclass={"build_external": build_external,
+ "bdist_wheel": build_wheel},
+ distclass=BinaryDistribution,
package_data={"jigsawpy": ["_bin/*", "_lib/*"]},
install_requires=REQUIRED,
+ extras_require={"netcdf": ["netCDF4"]},
classifiers=CLASSIFY
)
-
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29..8d1c8b6 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/case_0_.py b/tests/case_0_.py
index 39f7211..e8d902e 100644
--- a/tests/case_0_.py
+++ b/tests/case_0_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its api.-lib. interface.
*
* Writes "case_0x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_1_.py b/tests/case_1_.py
index 8a421a0..fc3a351 100644
--- a/tests/case_1_.py
+++ b/tests/case_1_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its api.-lib. interface.
*
* Writes "case_1x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_2_.py b/tests/case_2_.py
index 0eee2a2..bb2a044 100644
--- a/tests/case_2_.py
+++ b/tests/case_2_.py
@@ -1,11 +1,11 @@
"""
* DEMO-2 --- Build planar meshes for the "lakes" geometry.
-% Compare performance of "delaunay" + "delfront" algorithms.
+* Compare performance of "delaunay" + "delfront" algorithms.
*
* These examples call to JIGSAW via its cmd.-line interface.
*
* Writes "case_2x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_3_.py b/tests/case_3_.py
index 0d5f274..d4867ef 100644
--- a/tests/case_3_.py
+++ b/tests/case_3_.py
@@ -1,11 +1,11 @@
"""
* DEMO-3 --- Build surface meshes for the "bunny" geometry.
-% Compare performance of "delaunay" + "delfront" algorithms.
+* Compare performance of "delaunay" + "delfront" algorithms.
*
* These examples call to JIGSAW via its cmd.-line interface.
*
* Writes "case_3x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_4_.py b/tests/case_4_.py
index bea4511..ea65f1e 100644
--- a/tests/case_4_.py
+++ b/tests/case_4_.py
@@ -1,11 +1,11 @@
"""
* DEMO-4 --- Build volume meshes for the "bunny" geometry.
-% Compare performance of "delaunay" + "delfront" algorithms.
+* Compare performance of "delaunay" + "delfront" algorithms.
*
* These examples call to JIGSAW via its cmd.-line interface.
*
* Writes "case_4x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_5_.py b/tests/case_5_.py
index 9f603b3..f639c03 100644
--- a/tests/case_5_.py
+++ b/tests/case_5_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its cmd.-line interface.
*
* Writes "case_5x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_6_.py b/tests/case_6_.py
index 297bc03..9da6ca6 100644
--- a/tests/case_6_.py
+++ b/tests/case_6_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its cmd.-line interface.
*
* Writes "case_6x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_7_.py b/tests/case_7_.py
index dd1d355..4882c44 100644
--- a/tests/case_7_.py
+++ b/tests/case_7_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its api.-lib. interface.
*
* Writes "case_7x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os
diff --git a/tests/case_8_.py b/tests/case_8_.py
index 7f00189..2094dad 100644
--- a/tests/case_8_.py
+++ b/tests/case_8_.py
@@ -5,7 +5,7 @@
* These examples call to JIGSAW via its api.-lib. interface.
*
* Writes "case_8x.vtk" files on output for vis. in PARAVIEW.
-*
+*
"""
import os