From 83d0d6d1fbef5f0a929cd2270b7027e5c19455b1 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Sat, 24 Dec 2022 13:15:18 -0700 Subject: [PATCH 01/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Initial support for thread-parallelism in optim. phase. - Use of "symmetric" Gauss-Seidel sweeping within mesh optimisation kernels. - New "skewed-cosine" optimisation metric, useful to build "well-centred" primal-dual meshes. - New "momentum" type optimisation approach, with the two-parameter quasi-hyperbolic method (QHM) implemented. - Support "masked-out" entries in MARCHE solvers. - Fix a point-location bug wrt. unstructured h(x) data types. - Modify refinement rules to "defer" insertion of points that encroach on boundaries. (Typically) leads to slightly sparser tessellatons. - Support ellipsoidal-type initial conditions. - Translate-to-origin to reduce FP precision issues. - BREAKING: encode h(x) values as 32-bit floating point data, to support "very-large" h(x) types. --- example.jig | 26 +- inc/jigsaw_const.h | 16 +- inc/jigsaw_jig_t.h | 56 +- inc/jigsaw_msh_t.h | 16 +- inc/lib_jigsaw.h | 16 +- src/CMakeLists.txt | 78 +- src/geo_load.hpp | 16 +- src/hfn_init.hpp | 16 +- src/hfn_load.hpp | 16 +- src/hfn_save.inc | 18 +- src/ini_load.hpp | 16 +- src/jig_load.hpp | 90 +- src/jig_read.hpp | 45 +- src/jigsaw.cpp | 52 +- src/jigsaw.hpp | 32 +- src/libcpp/aabb_tree/aabb_mesh_k.hpp | 33 +- src/libcpp/aabb_tree/aabb_pred_k.hpp | 16 +- src/libcpp/aabb_tree/aabb_tree_k.hpp | 469 +++- src/libcpp/aabb_tree/aabb_type_k.hpp | 32 +- src/libcpp/aabbtree.hpp | 18 +- src/libcpp/algorithms.hpp | 18 +- src/libcpp/algorithms/find.hpp | 34 +- src/libcpp/algorithms/sort.hpp | 151 +- src/libcpp/allocators.hpp | 16 +- src/libcpp/allocators/alloc_base.hpp | 16 +- src/libcpp/allocators/alloc_item.hpp | 18 +- src/libcpp/allocators/alloc_pool.hpp | 16 +- src/libcpp/allocators/alloc_wrap.hpp | 16 +- src/libcpp/basebase.hpp | 18 +- src/libcpp/containers.hpp | 19 +- src/libcpp/containers/array.hpp | 2 +- src/libcpp/containers/arraylist.hpp | 4 +- src/libcpp/containers/basic_stack.hpp | 2 +- src/libcpp/containers/block_array.hpp | 2 +- src/libcpp/containers/block_iter.hpp | 2 +- src/libcpp/containers/hashtable.hpp | 2 +- src/libcpp/containers/hashtwice.hpp | 2 +- src/libcpp/containers/priorityidx.hpp | 725 +++++ src/libcpp/containers/prioritymap.hpp | 6 +- src/libcpp/containers/priorityset.hpp | 2 +- src/libcpp/containers/single_list.hpp | 2 +- src/libcpp/expansion/dd_float.hpp | 18 +- src/libcpp/expansion/ia_float.hpp | 18 +- src/libcpp/expansion/mp_basic.hpp | 18 +- src/libcpp/expansion/mp_float.hpp | 16 +- src/libcpp/expansion/mp_utils.hpp | 18 +- src/libcpp/geom_base/cell_ball_k.hpp | 18 +- src/libcpp/geom_base/cell_base_k.hpp | 82 +- src/libcpp/geom_base/intersect_k.hpp | 18 +- src/libcpp/geom_base/vect_base_k.hpp | 18 +- src/libcpp/geom_reps/geom_base_2.hpp | 16 +- src/libcpp/geom_reps/geom_base_3.hpp | 16 +- .../geom_reps/geom_mesh_ellipsoid_3.hpp | 23 +- .../geom_reps/geom_mesh_euclidean_2.hpp | 27 +- .../geom_reps/geom_mesh_euclidean_3.hpp | 40 +- src/libcpp/geometry.hpp | 18 +- src/libcpp/geompred.hpp | 18 +- src/libcpp/geomreps.hpp | 18 +- src/libcpp/hashfunc.hpp | 14 +- src/libcpp/interpolate.hpp | 18 +- src/libcpp/interpolate/hfun_base_k.hpp | 18 +- src/libcpp/interpolate/hfun_clip_k.hpp | 447 ++-- .../interpolate/hfun_constant_value_k.hpp | 18 +- .../interpolate/hfun_grid_ellipsoid_3.hpp | 222 +- .../interpolate/hfun_grid_euclidean_2.hpp | 211 +- .../interpolate/hfun_grid_euclidean_3.hpp | 28 +- .../interpolate/hfun_mesh_ellipsoid_3.hpp | 180 +- .../interpolate/hfun_mesh_euclidean_2.hpp | 180 +- .../interpolate/hfun_mesh_euclidean_3.hpp | 210 +- src/libcpp/iter_mesh/_bfs_mesh_2.inc | 283 ++ src/libcpp/iter_mesh/_zip_mesh_2.inc | 642 +++++ src/libcpp/iter_mesh/cost_mesh_2.inc | 293 ++ src/libcpp/iter_mesh/flip_mesh_2.inc | 523 ++++ src/libcpp/iter_mesh/iter_divs_2.inc | 108 +- src/libcpp/iter_mesh/iter_divs_3.inc | 20 +- src/libcpp/iter_mesh/iter_dual_2.inc | 67 +- src/libcpp/iter_mesh/iter_dual_3.inc | 18 +- src/libcpp/iter_mesh/iter_flip_2.inc | 216 +- src/libcpp/iter_mesh/iter_flip_3.inc | 18 +- src/libcpp/iter_mesh/iter_mesh_2.hpp | 2379 +++-------------- src/libcpp/iter_mesh/iter_mesh_3.hpp | 18 +- .../iter_mesh/iter_mesh_euclidean_2.hpp | 16 +- .../iter_mesh/iter_mesh_euclidean_3.hpp | 16 +- src/libcpp/iter_mesh/iter_node_1.inc | 18 +- src/libcpp/iter_mesh/iter_node_2.inc | 16 +- src/libcpp/iter_mesh/iter_node_3.inc | 18 +- .../iter_mesh/iter_pred_ellipsoid_3.hpp | 16 +- .../iter_mesh/iter_pred_euclidean_2.hpp | 16 +- src/libcpp/iter_mesh/iter_timers.hpp | 42 +- src/libcpp/iter_mesh/iter_zips_2.inc | 1018 ++++--- src/libcpp/iter_mesh/iter_zips_3.inc | 18 +- src/libcpp/iter_mesh/move_mesh_2.inc | 1442 ++++++++++ src/libcpp/iter_mesh/part_mesh_2.inc | 347 +++ src/libcpp/iter_mesh/sort_mesh_2.inc | 345 +++ src/libcpp/itermesh.hpp | 18 +- src/libcpp/mathutil.hpp | 16 +- src/libcpp/mesh_reps/base_complex_k.hpp | 40 +- src/libcpp/mesh_reps/hash_complex_k.hpp | 18 +- src/libcpp/mesh_reps/mesh_complex_1.hpp | 34 +- src/libcpp/mesh_reps/mesh_complex_2.hpp | 50 +- src/libcpp/mesh_reps/mesh_complex_3.hpp | 77 +- src/libcpp/mesh_reps/mesh_complex_type_k.hpp | 68 +- src/libcpp/mesh_reps/tria_complex_1.hpp | 34 +- src/libcpp/mesh_reps/tria_complex_2.hpp | 45 +- src/libcpp/mesh_reps/tria_complex_3.hpp | 55 +- src/libcpp/meshreps.hpp | 16 +- src/libcpp/mpfloats.hpp | 18 +- src/libcpp/parameters/iter_params.hpp | 73 +- src/libcpp/parameters/mesh_params.hpp | 31 +- src/libcpp/predicate/bisect_k.hpp | 18 +- src/libcpp/predicate/inball_k.hpp | 18 +- src/libcpp/predicate/orient_k.hpp | 18 +- src/libcpp/predicate/predicate_k.hpp | 18 +- src/libcpp/rdel_mesh/rdel_base_2.hpp | 50 +- src/libcpp/rdel_mesh/rdel_base_3.hpp | 78 +- src/libcpp/rdel_mesh/rdel_complex_2.hpp | 29 +- src/libcpp/rdel_mesh/rdel_complex_3.hpp | 38 +- src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc | 72 +- src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc | 103 +- src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc | 145 +- src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc | 234 +- src/libcpp/rdel_mesh/rdel_create_init_2.inc | 16 +- src/libcpp/rdel_mesh/rdel_create_init_3.inc | 16 +- src/libcpp/rdel_mesh/rdel_filt_k.hpp | 16 +- src/libcpp/rdel_mesh/rdel_make_2.hpp | 44 +- src/libcpp/rdel_mesh/rdel_make_3.hpp | 46 +- src/libcpp/rdel_mesh/rdel_mesh_2.hpp | 223 +- src/libcpp/rdel_mesh/rdel_mesh_3.hpp | 259 +- src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc | 115 +- src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc | 175 +- src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp | 16 +- src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp | 16 +- src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp | 55 +- src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp | 109 +- src/libcpp/rdel_mesh/rdel_refine_ball_2.inc | 16 +- src/libcpp/rdel_mesh/rdel_refine_ball_3.inc | 16 +- src/libcpp/rdel_mesh/rdel_refine_base_2.inc | 17 +- src/libcpp/rdel_mesh/rdel_refine_base_3.inc | 17 +- src/libcpp/rdel_mesh/rdel_refine_face_2.inc | 16 +- src/libcpp/rdel_mesh/rdel_refine_face_3.inc | 16 +- src/libcpp/rdel_mesh/rdel_refine_topo_2.inc | 16 +- src/libcpp/rdel_mesh/rdel_refine_topo_3.inc | 16 +- src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc | 18 +- src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc | 18 +- src/libcpp/rdel_mesh/rdel_test_bounds_2.inc | 47 +- src/libcpp/rdel_mesh/rdel_test_bounds_3.inc | 76 +- src/libcpp/rdel_mesh/rdel_timers.hpp | 35 +- src/libcpp/rdel_mesh/rdel_update_face_2.inc | 49 +- src/libcpp/rdel_mesh/rdel_update_face_3.inc | 60 +- src/libcpp/rdel_mesh/rdel_update_topo_2.inc | 50 +- src/libcpp/rdel_mesh/rdel_update_topo_3.inc | 80 +- src/libcpp/rdelmesh.hpp | 16 +- src/libcpp/tessellate.hpp | 16 +- src/libcpp/tessellate/delaunay_scan_tria.inc | 18 +- src/libcpp/tessellate/delaunay_star_void.inc | 18 +- src/libcpp/tessellate/delaunay_tri_k.hpp | 16 +- src/libcpp/tessellate/delaunay_tri_pred_2.hpp | 18 +- src/libcpp/tessellate/delaunay_tri_pred_3.hpp | 18 +- src/libcpp/tessellate/delaunay_tri_pred_4.hpp | 18 +- src/libcpp/tessellate/delaunay_tri_type_2.hpp | 18 +- src/libcpp/tessellate/delaunay_tri_type_3.hpp | 18 +- src/libcpp/tessellate/delaunay_tri_type_4.hpp | 18 +- src/libcpp/tessellate/delaunay_walk_mesh.inc | 18 +- src/libcpp/tessellate/laguerre_tri_pred_2.hpp | 18 +- src/libcpp/tessellate/laguerre_tri_pred_3.hpp | 18 +- src/libcpp/tessellate/laguerre_tri_pred_4.hpp | 18 +- src/libcpp/textutil.hpp | 16 +- src/libcpp/useropts.hpp | 18 +- src/liblib/init_jig_t.hpp | 44 +- src/liblib/init_msh_t.hpp | 16 +- src/liblib/load_jig_t.hpp | 41 +- src/liblib/load_msh_t.hpp | 16 +- src/liblib/save_jig_t.hpp | 28 +- src/liblib/save_msh_t.hpp | 18 +- src/marche.hpp | 28 +- src/msh_copy.hpp | 391 ++- src/msh_init.hpp | 18 +- src/msh_read.hpp | 16 +- src/msh_save.hpp | 16 +- src/msh_save.inc | 16 +- src/netcdf/ncutil.h | 46 + src/offset.hpp | 20 +- src/rdt_save.inc | 16 +- src/tri_save.inc | 16 +- src/tripod.hpp | 30 +- version.txt | 10 + 186 files changed, 10588 insertions(+), 5588 deletions(-) create mode 100644 src/libcpp/containers/priorityidx.hpp create mode 100644 src/libcpp/iter_mesh/_bfs_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/_zip_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/cost_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/flip_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/move_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/part_mesh_2.inc create mode 100644 src/libcpp/iter_mesh/sort_mesh_2.inc diff --git a/example.jig b/example.jig index 264c3f5..229bab2 100644 --- a/example.jig +++ b/example.jig @@ -305,19 +305,21 @@ # cases a hybrid formulation is employed, using a # "blend" of the ODT/CVT updates, and gradients of a # "fall-back" mesh quality function Q. +# # OPTM_KERN = CVT+DQDX # ---> OPTM_COST - {default='area-len'} mesh optimisation - cost metric, choice of area-length (COST='area-len') - or skewed-cosine (COST='skew-cos') functions. - The area-length metric is symmetric wrt. both small - and large cell angles, and is typically appropriate - for simplex-only meshes. The skewed-cosine metric is - based on an asymmetric penalisation of large cell - angles, and may be useful for staggered primal-dual - tessellations. +# cost metric, choice of area-length (COST='area-len') +# or skewed-cosine (COST='skew-cos') functions. +# The area-length metric is symmetric wrt. both small +# and large cell angles, and is typically appropriate +# for simplex-only meshes. The skewed-cosine metric is +# based on an asymmetric penalisation of large cell +# angles, and may be useful for staggered primal-dual +# tessellations. +# # OPTM_COST = SKEW-COS @@ -387,4 +389,12 @@ # VERBOSITY = 1 +# ---> NUMTHREAD - {default=0} control for thread-parallel +# implementations. Set NUMTHREAD <= 0 to autodetect a +# machine's max-thread allocation. +# + +# NUMTHREAD = 4 + + diff --git a/inc/jigsaw_const.h b/inc/jigsaw_const.h index e3e0a9b..220a5f8 100644 --- a/inc/jigsaw_const.h +++ b/inc/jigsaw_const.h @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/inc/jigsaw_jig_t.h b/inc/jigsaw_jig_t.h index 5df4f43..f1b6e15 100644 --- a/inc/jigsaw_jig_t.h +++ b/inc/jigsaw_jig_t.h @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda @@ -60,6 +64,16 @@ indx_t _verbosity ; + /* + -------------------------------------------------------- + * NUMTHREAD - {default=0} control for thread-parallel + * implementations. Set NUMTHREAD <= 0 to autodetect a + * machine's max-thread allocation. + -------------------------------------------------------- + */ + + indx_t _numthread ; + /* -------------------------------------------------------- * GEOM-SEED - {default = 8} number of "seed" vertices @@ -396,6 +410,30 @@ indx_t _optm_cost ; + /* + -------------------------------------------------------- + * OPTM_BETA - {default=0.4950} "momentum"-type biases + * for gradient descent updates, such that + * DX' = BETA * DX(K-1) + (1-BETA) * DX(K). + * Momentum typically improves the convergence of mesh + * optimisation. + -------------------------------------------------------- + */ + + real_t _optm_beta ; + + /* + -------------------------------------------------------- + * OPTM_ZETA - {default=0.7500} "momentum"-type biases + * for search direction updates, such that + * DX* = ZETA * DX' (K) + (1-ZETA) * DX(K). + * Momentum typically improves the convergence of mesh + * optimisation. + -------------------------------------------------------- + */ + + real_t _optm_zeta ; + /* -------------------------------------------------------- * OPTM_QTOL - {default=1.E-04} tolerance on mesh cost @@ -409,7 +447,7 @@ /* -------------------------------------------------------- - * OPTM_QLIM - {default=0.9375} threshold on mesh cost + * OPTM_QLIM - {default=0.9333} threshold on mesh cost * function above which gradient-based optimisation is * attempted. -------------------------------------------------------- diff --git a/inc/jigsaw_msh_t.h b/inc/jigsaw_msh_t.h index be180ab..e5ae417 100644 --- a/inc/jigsaw_msh_t.h +++ b/inc/jigsaw_msh_t.h @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/inc/lib_jigsaw.h b/inc/lib_jigsaw.h index 18995a9..a6aec2b 100644 --- a/inc/lib_jigsaw.h +++ b/inc/lib_jigsaw.h @@ -41,12 +41,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 218def5..29d58be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,12 +9,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set (GCXX_LIKE TRUE) - message (">> GCXX-like compiler detected") + message (STATUS "GCXX-like compiler detected") endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set (MSVC_LIKE TRUE) - message (">> MSVC-like compiler detected") + message (STATUS "MSVC-like compiler detected") endif () if (DEFINED MSVC_LIKE) @@ -29,28 +29,43 @@ endif () if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set (INSTALL_LOCAL TRUE) - message (">> Installing locally") + message (STATUS "Installing locally") else () - message (">> Installing to ${CMAKE_INSTALL_PREFIX}") + message (STATUS "Installing to ${CMAKE_INSTALL_PREFIX}") endif () find_library (NETCDF_LIBRARY NAMES netcdf) if (NETCDF_LIBRARY) - message (">> NetCDF library found") + message (STATUS "NetCDF library found") message (STATUS "NetCDF inc. lib: ${NETCDF_LIBRARY}") else () - message (">> NetCDF library not found") + message (STATUS "NetCDF library not found") +endif () + +find_package (OpenMP) + +if (OpenMP_CXX_FOUND) + message (STATUS "OpenMP library found") + message (STATUS "OpenMP inc. lib: ${OpenMP_CXX_LIB_NAMES}") +else () + message (STATUS "OpenMP library not found") endif () add_executable (jigsaw-cmd jigsaw.cpp) +target_compile_definitions (jigsaw-cmd PRIVATE CMD_JIGSAW) + if (NETCDF_LIBRARY) - target_compile_definitions (jigsaw-cmd PRIVATE CMD_JIGSAW USE_NETCDF) - target_link_libraries (jigsaw-cmd ${NETCDF_LIBRARY}) + target_compile_definitions (jigsaw-cmd PRIVATE USE_NETCDF) + target_link_libraries (jigsaw-cmd PRIVATE ${NETCDF_LIBRARY}) + set_target_properties (jigsaw-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +endif () + +if (OpenMP_CXX_FOUND) + target_compile_definitions (jigsaw-cmd PRIVATE USE_OPENMP) + target_link_libraries (jigsaw-cmd PRIVATE OpenMP::OpenMP_CXX) set_target_properties (jigsaw-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) -else () - target_compile_definitions (jigsaw-cmd PRIVATE CMD_JIGSAW) endif () set_target_properties (jigsaw-cmd PROPERTIES OUTPUT_NAME jigsaw) @@ -62,15 +77,20 @@ endif () add_executable (tripod-cmd jigsaw.cpp) +target_compile_definitions (tripod-cmd PRIVATE CMD_TRIPOD) + if (NETCDF_LIBRARY) - target_compile_definitions (tripod-cmd PRIVATE CMD_TRIPOD USE_NETCDF) - target_link_libraries (tripod-cmd ${NETCDF_LIBRARY}) + target_compile_definitions (tripod-cmd PRIVATE USE_NETCDF) + target_link_libraries (tripod-cmd PRIVATE ${NETCDF_LIBRARY}) + set_target_properties (tripod-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +endif () + +if (OpenMP_CXX_FOUND) + target_compile_definitions (tripod-cmd PRIVATE USE_OPENMP) + target_link_libraries (tripod-cmd PRIVATE OpenMP::OpenMP_CXX) set_target_properties (tripod-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) -else () - target_compile_definitions (tripod-cmd PRIVATE CMD_TRIPOD) endif () -target_compile_definitions (tripod-cmd PRIVATE CMD_TRIPOD) set_target_properties (tripod-cmd PROPERTIES OUTPUT_NAME tripod) if (DEFINED INSTALL_LOCAL) install (TARGETS tripod-cmd DESTINATION "${PROJECT_SOURCE_DIR}/bin") @@ -80,12 +100,18 @@ endif () add_executable (marche-cmd jigsaw.cpp) +target_compile_definitions (marche-cmd PRIVATE CMD_MARCHE) + if (NETCDF_LIBRARY) - target_compile_definitions (marche-cmd PRIVATE CMD_MARCHE USE_NETCDF) - target_link_libraries (marche-cmd ${NETCDF_LIBRARY}) + target_compile_definitions (marche-cmd PRIVATE USE_NETCDF) + target_link_libraries (marche-cmd PRIVATE ${NETCDF_LIBRARY}) + set_target_properties (marche-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +endif () + +if (OpenMP_CXX_FOUND) + target_compile_definitions (marche-cmd PRIVATE USE_OPENMP) + target_link_libraries (marche-cmd PRIVATE OpenMP::OpenMP_CXX) set_target_properties (marche-cmd PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) -else () - target_compile_definitions (marche-cmd PRIVATE CMD_MARCHE) endif () set_target_properties (marche-cmd PROPERTIES OUTPUT_NAME marche) @@ -97,12 +123,18 @@ endif () add_library (jigsaw-lib SHARED jigsaw.cpp) +target_compile_definitions (jigsaw-lib PRIVATE LIB_JIGSAW) + if (NETCDF_LIBRARY) - target_compile_definitions (jigsaw-lib PRIVATE LIB_JIGSAW USE_NETCDF) - target_link_libraries (jigsaw-lib ${NETCDF_LIBRARY}) + target_compile_definitions (jigsaw-lib PRIVATE USE_NETCDF) + target_link_libraries (jigsaw-lib PRIVATE ${NETCDF_LIBRARY}) + set_target_properties (jigsaw-lib PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +endif () + +if (OpenMP_CXX_FOUND) + target_compile_definitions (jigsaw-lib PRIVATE USE_OPENMP) + target_link_libraries (jigsaw-lib PRIVATE OpenMP::OpenMP_CXX) set_target_properties (jigsaw-lib PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) -else () - target_compile_definitions (jigsaw-lib PRIVATE LIB_JIGSAW) endif () set_target_properties (jigsaw-lib PROPERTIES OUTPUT_NAME jigsaw) diff --git a/src/geo_load.hpp b/src/geo_load.hpp index 078ab09..1c796e3 100644 --- a/src/geo_load.hpp +++ b/src/geo_load.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/hfn_init.hpp b/src/hfn_init.hpp index c78565b..2db9670 100644 --- a/src/hfn_init.hpp +++ b/src/hfn_init.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/hfn_load.hpp b/src/hfn_load.hpp index 03813df..a45b390 100644 --- a/src/hfn_load.hpp +++ b/src/hfn_load.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/hfn_save.inc b/src/hfn_save.inc index 270a395..6a7bcdc 100644 --- a/src/hfn_save.inc +++ b/src/hfn_save.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -1025,7 +1029,7 @@ /*------------------------- disambiguate via file-ext */ std::string _path, _name, _fext; file_part( - _jcfg._mesh_file, _path, _name, _fext) ; + _jcfg._hfun_file, _path, _name, _fext) ; if(_fext.find("msh") != std::string::npos) { diff --git a/src/ini_load.hpp b/src/ini_load.hpp index c28a1d8..5d70d7d 100644 --- a/src/ini_load.hpp +++ b/src/ini_load.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/jig_load.hpp b/src/jig_load.hpp index 05f38d2..45cf2d3 100644 --- a/src/jig_load.hpp +++ b/src/jig_load.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -85,6 +89,23 @@ this->_jjig-> _iter_opts.verb() = _verb; } + __normal_call void_type push_numthread ( + std::int32_t _nprt + ) + { + if (_nprt <= 0 ) + # ifdef __use_openmp + _nprt = omp_get_num_procs() ; + # else + _nprt = +1 ; + # endif//__use_openmp + + this->_jjig->_numthread = _nprt ; + this->_jjig-> + _mesh_opts.nprt() = _nprt; + this->_jjig-> + _iter_opts.nprt() = _nprt; + } /*------------------------------------- GEOM keywords */ __normal_call void_type push_geom_file ( @@ -370,6 +391,20 @@ this->_jjig-> _iter_opts.iter() = _iter; } + __normal_call void_type push_optm_beta ( + double _beta + ) + { + this->_jjig-> + _iter_opts.beta() = _beta; + } + __normal_call void_type push_optm_zeta ( + double _zeta + ) + { + this->_jjig-> + _iter_opts.zeta() = _zeta; + } __normal_call void_type push_optm_qtol ( double _qtol ) @@ -471,7 +506,7 @@ __normal_call iptr_type copy_jcfg ( jcfg_data &_jcfg , jlog_data &_jlog , - jigsaw_jig_t const&_jjig + jigsaw_jig_t &_jjig ) { iptr_type _errv = __no_error ; @@ -488,6 +523,21 @@ _jcfg._iter_opts. verb() = _jjig._verbosity ; + if (_jjig._numthread <= 0 ) + # ifdef __use_openmp + _jjig._numthread = + omp_get_num_procs(); + # else + _jjig._numthread = +1 ; + # endif//__use_openmp + + _jcfg._numthread = + _jjig._numthread ; + _jcfg._mesh_opts. + nprt() = _jjig._numthread ; + _jcfg._iter_opts. + nprt() = _jjig._numthread ; + /*------------------------------------- BNDS keywords */ if (_jjig._bnds_kern == JIGSAW_BNDS_TRIACELL) @@ -622,6 +672,11 @@ _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. @@ -835,6 +890,15 @@ (iptr_type) + 0, std::numeric_limits:: max()) + __testREAL("OPTM-BETA", + _jcfg._iter_opts.beta(), + (real_type) 0., + (real_type) .5) + __testREAL("OPTM-ZETA", + _jcfg._iter_opts.zeta(), + (real_type) 0., + (real_type) 1.) + __testREAL("OPTM-QTOL", _jcfg._iter_opts.qtol(), (real_type) 0., @@ -901,6 +965,9 @@ _jlog.push("\n") ; + _jlog.push(" NUMTHREAD = " + + __pushIVAL(_jcfg._numthread) + "\n" ) ; + if (_jcfg._verbosity > +0) { /*---------------------------- push GEOM keywords */ @@ -1032,6 +1099,11 @@ jcfg_data::iter_cost::skew_cos) _jlog.push(" OPTM-COST = SKEW-COS \n") ; + _jlog.push(" OPTM-BETA = " + + __pushRVAL(_jcfg._iter_opts.beta())); + _jlog.push(" OPTM-ZETA = " + + __pushRVAL(_jcfg._iter_opts.zeta())); + _jlog.push(" OPTM-QTOL = " + __pushRVAL(_jcfg._iter_opts.qtol())); _jlog.push(" OPTM-QLIM = " + diff --git a/src/jig_read.hpp b/src/jig_read.hpp index 5c2a2b6..501e2c5 100644 --- a/src/jig_read.hpp +++ b/src/jig_read.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -53,6 +57,9 @@ __normal_call void_type push_verbosity ( std::int32_t /*_verb*/ ) { } + __normal_call void_type push_numthread ( + std::int32_t /*_nprt*/ + ) { } __normal_call void_type push_geom_file ( std::string /*_file*/ @@ -173,6 +180,12 @@ __normal_call void_type push_optm_cost ( std::int32_t /*_cost*/ ) { } + __normal_call void_type push_optm_beta ( + double /*_beta*/ + ) { } + __normal_call void_type push_optm_zeta ( + double /*_zeta*/ + ) { } __normal_call void_type push_optm_qtol ( double /*_qtol*/ ) { } @@ -423,6 +436,11 @@ __putINTS(push_verbosity, _stok) ; } else + if (_stok[0] == "NUMTHREAD") + { + __putINTS(push_numthread, _stok) ; + } + else /*---------------------------- read GEOM keywords */ if (_stok[0] == "GEOM_FILE") { @@ -619,6 +637,16 @@ __putCOST(push_optm_cost, _stok) ; } else + if (_stok[0] == "OPTM_BETA") + { + __putREAL(push_optm_beta, _stok) ; + } + else + if (_stok[0] == "OPTM_ZETA") + { + __putREAL(push_optm_zeta, _stok) ; + } + else if (_stok[0] == "OPTM_QTOL") { __putREAL(push_optm_qtol, _stok) ; @@ -666,7 +694,6 @@ #undef __putREAL #undef __putINTS #undef __putBOOL - } } ; diff --git a/src/jigsaw.cpp b/src/jigsaw.cpp index 767e1d9..4fed4ce 100644 --- a/src/jigsaw.cpp +++ b/src/jigsaw.cpp @@ -21,6 +21,7 @@ // // -DUSE_NETCDF -lnetcdf // -DUSE_TIMERS + // -fopenmp // // -Wfloat-conversion -Wsign-conversion -Wshadow // @@ -40,9 +41,9 @@ * JIGSAW: an unstructured mesh generation library. -------------------------------------------------------- * - * JIGSAW release 0.9.15.x + * JIGSAW release 1.0.0.x * - * Last updated: 28 May, 2022 + * Last updated: 11 Dec., 2022 * * Copyright 2013 -- 2022 * Darren Engwirda @@ -69,12 +70,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor the National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -188,13 +193,17 @@ -------------------------------------------------------- */ -# define __JGSWVSTR "JIGSAW VERSION 0.9.15" +# define __JGSWVSTR "JIGSAW VERSION 1.0.0" # if defined( USE_NETCDF) # define __use_netcdf # endif # if defined( USE_TIMERS) # define __use_timers +# endif + +# if defined( _OPENMP) +# define __use_openmp # endif // define __cmd_jigsaw // the cmd-ln exe's @@ -241,6 +250,12 @@ # include + /*---------------------------------- openmp threading */ + +# ifdef __use_openmp +# include +# endif//__use_openmp + /*---------------------------------- to do cpu timing */ # define __use_timers @@ -337,6 +352,13 @@ iptr_type _verbosity = 0 ; + # ifdef __use_openmp + iptr_type _numthread = + omp_get_num_procs() ; + # else + iptr_type _numthread = 1 ; + # endif//__use_openmp + /*--------------------------------- geom-bnd. kernels */ struct bnds_pred { enum enum_data { @@ -707,9 +729,9 @@ { public : /*-------------------------- a "real" log-file writer */ - std::ofstream _file ; + std::ofstream _file ; - iptr_type _verbosity ; + iptr_type _verbosity = +0; public : @@ -749,7 +771,8 @@ data_type const&_data ) { - std :: cout << _data ; + if (this->_verbosity > -2) + std::cout << _data ; this->_file << _data ; } @@ -759,8 +782,7 @@ { public : /*-------------------------- a "null" log-file writer */ - - iptr_type _verbosity ; + iptr_type _verbosity = +0; public : @@ -782,9 +804,7 @@ { /*-------------------------- def. no: for lib_jigsaw! */ if (this->_verbosity > +0) - { std::cout << _data ; - } } } ; diff --git a/src/jigsaw.hpp b/src/jigsaw.hpp index e602239..e6ba8ef 100644 --- a/src/jigsaw.hpp +++ b/src/jigsaw.hpp @@ -14,9 +14,9 @@ * JIGSAW: an unstructured mesh generation library. -------------------------------------------------------- * - * Last updated: 28 Aug., 2021 + * Last updated: 10 Jun., 2022 * - * Copyright 2013 -- 2021 + * Copyright 2013 -- 2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda @@ -41,12 +41,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor the National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- */ @@ -1665,15 +1669,10 @@ /*--------------------------------- setup *.JLOG file */ jlog_text _jlog(_jcfg) ; - _jlog.push(JIGSAW:: - asciibanner) ; - + if(!_jcfg._jcfg_file.empty()) { /*--------------------------------- parse *.JCFG file */ - _jlog.push ( - " Reading CFG. file...\n\n" ) ; - # ifdef __use_timers _ttic = _time.now(); # endif//__use_timers @@ -1684,6 +1683,11 @@ return _retv ; } + _jlog._verbosity = + _jcfg._verbosity ; + + _jlog.push ( JIGSAW::asciibanner ) ; + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/src/libcpp/aabb_tree/aabb_mesh_k.hpp b/src/libcpp/aabb_tree/aabb_mesh_k.hpp index 08b1f1d..3b3d373 100644 --- a/src/libcpp/aabb_tree/aabb_mesh_k.hpp +++ b/src/libcpp/aabb_tree/aabb_mesh_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 11 September, 2017 + * Last updated: 11 Sept., 2017 * * Copyright 2013-2017 * Darren Engwirda @@ -79,8 +83,7 @@ bool_type operator() ( face_type const&_fdat ) const - { - __unreferenced (_fdat) ; + { __unreferenced (_fdat) ; return ( true ) ; } @@ -102,12 +105,12 @@ allocators::basic_alloc > __normal_call void_type aabb_mesh ( - node_list& _nset , - face_list& _fset , - tree_type& _tree , - REAL_TYPE* _btol , - IPTR_TYPE _nbox = + 32, - push_pred _push = push_aabb() + node_list& _nset , // array of mesh nodes + face_list& _fset , // array of mesh cells + tree_type& _tree , // tree to load into + REAL_TYPE* _btol , // expand tree bbox over axes + IPTR_TYPE _nbox = + 32, // cells-per-bbox lim. + push_pred _push = push_aabb() // filter scheme ) { IPTR_TYPE constexpr _nnod = diff --git a/src/libcpp/aabb_tree/aabb_pred_k.hpp b/src/libcpp/aabb_tree/aabb_pred_k.hpp index 09665c2..2dc557e 100644 --- a/src/libcpp/aabb_tree/aabb_pred_k.hpp +++ b/src/libcpp/aabb_tree/aabb_pred_k.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/aabb_tree/aabb_tree_k.hpp b/src/libcpp/aabb_tree/aabb_tree_k.hpp index 78dda69..932b0f8 100644 --- a/src/libcpp/aabb_tree/aabb_tree_k.hpp +++ b/src/libcpp/aabb_tree/aabb_tree_k.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 Jul., 2021 + * Last updated: 18 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -49,9 +53,9 @@ namespace geom_tree { template < - typename I , - size_t K , - typename N = aabb_node_base_k, + typename I , // item-to-be-stored typedef + size_t K , // number of geometric dimensions + typename N = aabb_node_base_k, // inner node typedef typename A = allocators::basic_alloc > class aabb_tree @@ -70,6 +74,10 @@ iptr_type static constexpr _dims = K ; + iptr_type static constexpr middle_split = +0 ; + iptr_type static constexpr median_split = +1 ; + iptr_type static constexpr window_split = +2 ; + typedef geom_tree::aabb_tree < item_type , _dims , @@ -90,6 +98,7 @@ real_type _pmax[ K] ; /*------------------------------- linkedlist of items */ item_data *_hptr; + iptr_type _size = 0 ; /*------------------------------- tree-based pointers */ node_type *_pptr; node_data *_lptr; @@ -135,10 +144,8 @@ item_data, wrap_pool> item_pool ; - typedef node_type* node_ptrt ; - - typedef containers::array < - node_ptrt, + typedef containers::array < + node_type* , allocator> work_list ; public : @@ -146,6 +153,7 @@ node_type _rdat ; node_type *_root ; iptr_type _size ; + iptr_type _imax ; work_list _work ; @@ -157,7 +165,7 @@ item_pool _item_pool ; /*------------------------------------- tree shape params */ - iptr_type _imax ; + iptr_type _npop ; real_type _long ; real_type _vtol ; @@ -246,7 +254,7 @@ __inline_call aabb_tree ( allocator const&_asrc = allocator() ) : _root(nullptr) , - _size( +0) , + _size(+0) , _imax(+0), _work( _asrc) , /*-------------------------------------- "base" pools */ _node_base ( @@ -263,6 +271,15 @@ // pool'd alloc. takes care of dealloc... + __inline_call void_type clear ( + ) + { + this->_root = nullptr ; + this->_size = +0; + this->_imax = +0; + this->_node_base.clear() ; + this->_item_base.clear() ; + } /*------------- return container count / empty statistics */ __inline_call bool_type empty ( @@ -302,7 +319,17 @@ _iptr != nullptr; _iptr = _iptr->_next) { - for(auto _idim = _dims ; _idim-- != +0; ) + push_aabb_node(_nptr, _iptr) ; + } + } + + __static_call + __inline_call void_type push_aabb_node ( + node_type *_nptr, // node to update + item_data *_iptr // item to update with + ) + { + for (auto _idim = _dims; _idim-- != +0; ) { /*------------------------ find max. on each axis */ if (_nptr->_pmax[_idim] < @@ -319,7 +346,6 @@ _iptr->_data.pmin(_idim); } } - } } /*------------- helper - calc. best "split" axis for node */ @@ -353,20 +379,32 @@ /*------------------------------ form aabb dimensions */ rect_data _rect [_dims]; - iptr_type _best = 0; + iptr_type _best = +0 ; for(auto _idim = _dims ; _idim-- != +0; ) { + /*------------------------------ find long bbox. axis */ real_type _alen; - _alen = _node->_pmax[_idim] - - _node->_pmin[_idim]; - + _alen = _node->_pmax[_idim] - + _node->_pmin[_idim] ; + _rect[_idim]._alen = _alen ; _rect[_idim]._axis = _idim ; } /*------------------------------ sort aabb dimensions */ algorithms::ssort ( - &_rect[0], &_rect[_dims], rect_less()) ; + &_rect[0], &_rect[_dims], rect_less()) ; + + /*------------------------------ shortcuts: item=node */ + if (!item_type::_is_a_rect) + { + auto _last = _dims - 1; + + _bdim = _rect[_last]._axis ; + _blen = this->_long * + _rect[_last]._alen ; + return ; + } /*------------------------------ scan aabb dimensions */ for(auto _idim = _dims ; _idim-- != +0; ) @@ -382,12 +420,12 @@ iptr_type _cnum = +0 ; /*------------------ partition "long"/inner items */ - for(item_data*_iptr = _node->_hptr; - _iptr != nullptr ; - _iptr = _iptr->_next) + for (auto _iptr = _node->_hptr; + _iptr != nullptr ; + _iptr = _iptr->_next) { if (_iptr-> - _data.plen(_axis) >= +_llen) + _data.plen(_axis) >= _llen) { _pnum += +1 ; } @@ -407,6 +445,7 @@ if (_pnum == +0) break ; } } + } /*--- top-down assembly of aabb-tree via recursive splits */ @@ -414,21 +453,22 @@ typename iter_type > __normal_call void_type load ( - iter_type _head , - iter_type _tend , - iptr_type _IMAX = + 32 , - real_type _LONG = +.75 , - real_type _VTOL = +.50 + iter_type _head , // head of items array to load + iter_type _tend , // last of items array to load + iptr_type _NPOP = + 32 , // leaf population lim. + iptr_type _RULE = window_split , // split scheme + real_type _LONG = +.75 , // "too-long" item lim. + real_type _VTOL = +.50 // leaf vol. split lim. ) { if (_tend <= _head) return ; this->_root = &this->_rdat ; - + this->_root->_size = +0 ; this->_size = +1 ; /*------------------------------ set node fill params */ - this->_imax = _IMAX ; + this->_npop = _NPOP ; this->_long = _LONG ; this->_vtol = _VTOL ; @@ -446,6 +486,11 @@ /*------------------------------ alloc. and push item */ make_item(*_head, _idat); push_item( _hptr, _idat); + + this->_root->_size += +1; + + this->_imax = std::max( + this->_imax,_head->ipos ()) ; } this->_root->_hptr = _hptr ; } @@ -453,11 +498,12 @@ init_aabb_node (this->_root); /*-------------------------- a list of un-split nodes */ - this->_work.set_count( +0); + this->_work.clear() ; this->_work. push_tail(this->_root); /*--- refine tree until all nodes satisfy constraints */ + containers::array _sort; for( ; !this->_work.empty() ; ) { node_type *_pnod = nullptr; @@ -479,17 +525,23 @@ item_data *_rptr = nullptr; /*-------------------------- _pop node from stack */ - this->_work._pop_tail(_pnod) ; + this->_work._pop_tail (_pnod); /*---------- find best "split" axis for this node */ find_best_axis (_pnod, _bdim , _blen) ; - if (_bdim == -1) continue ; + if (_bdim == -1) continue; - /*---------- partition list - remove "long" items */ - for(item_data *_iptr = _pnod-> - _hptr ; + /*---------- compute split-pos. via user-def RULE */ + real_type _spos = (real_type)+0. ; + iptr_type _nnum = _pnod->_size ; + item_data*_hptr = _pnod->_hptr ; + if (_RULE == middle_split) + { + /*---------- split pos. - middle of items in node */ + double _SPOS = +0. ; + for(item_data *_iptr = _hptr ; _iptr != nullptr ; _iptr = _next ) { @@ -498,53 +550,132 @@ if (_iptr->_data .plen (_bdim) > _blen) { - push_item(_pptr,_iptr); - _pnum += +1 ; + push_item(_pptr, _iptr); + _pnum += +1 ; } else { - push_item(_cptr,_iptr); - _cnum += +1 ; + push_item(_cptr, _iptr); + _cnum += +1 ; + + _SPOS += + _iptr->_data.pmid(_bdim); } } - if (_cnum == +0) continue ; + _spos = (real_type)(_SPOS/_cnum); + } + else + if (_RULE == median_split) + { + /*---------- split pos. - median of items in node */ - /*---------- split pos. - mean of non-long aabb's */ - double _SPOS = +0. ; - for(item_data *_iptr = _cptr ; + // (1+-a)-approx. with probability p + // require: 1/a^2 + log(1/p) samples + size_t _nsel = 500 * std::log2(_nnum + 1) + 1 ; + + size_t _filt = _nnum / _nsel + 1; + size_t _njmp = _filt ; + size_t _inum = +0; + _sort.clear(); + for(item_data *_iptr = _hptr ; _iptr != nullptr ; - _iptr = _next ) + _iptr = _next , + _inum += +1 ) { _next = _iptr->_next ; + /*------------------------------- partition items */ + if (_iptr->_data + .plen (_bdim) > _blen) + { + push_item(_pptr, _iptr); + _pnum += +1 ; + } + else + { + push_item(_cptr, _iptr); + _cnum += +1 ; + + if(_inum >= _njmp) + { + _sort.push_tail( + _iptr->_data.pmid(_bdim)) ; - _SPOS +=_iptr-> - _data.pmid (_bdim); + _njmp += _filt; + } + } } - real_type _spos = - (real_type)(_SPOS / _cnum); + if(!_sort.empty()) + { + algorithms::qsort( + _sort.head(), _sort.tend(), + std::less()) ; - /*---------- partition list - split on left|right */ - for(item_data *_iptr = _cptr ; + _spos = _sort[_sort.count() / 2]; + } + } + else + if (_RULE == window_split) + { + /*---------- split pos. - window of items in node */ + + // (1+-a)-approx. with probability p + // require: 1/a^2 + log(1/p) samples + size_t _nsel = 500 * std::log2(_nnum + 1) + 1 ; + + size_t _filt = _nnum / _nsel + 1; + size_t _njmp = _filt ; + size_t _inum = +0; + double _SPOS = +0. ; + _sort.clear(); + for(item_data *_iptr = _hptr ; _iptr != nullptr ; - _iptr = _next ) + _iptr = _next , + _inum += +1 ) { _next = _iptr->_next ; /*------------------------------- partition items */ if (_iptr->_data - .pmid (_bdim) > _spos) + .plen (_bdim) > _blen) { - push_item(_rptr,_iptr); - _rnum += +1 ; + push_item(_pptr, _iptr); + _pnum += +1 ; } else { - push_item(_lptr,_iptr); - _lnum += +1 ; + push_item(_cptr, _iptr); + _cnum += +1 ; + + _SPOS += + _iptr->_data.pmid(_bdim); + + if(_inum >= _njmp) + { + _sort.push_tail( + _iptr->_data.pmid(_bdim)) ; + + _njmp += _filt; + } } } + if(!_sort.empty()) // middle-median blend + { + algorithms::qsort( + _sort.head(), _sort.tend(), + std::less()) ; + + _spos = _sort[_sort.count() / 2]; + _SPOS/= _cnum ; + + _spos = (real_type)+1./3. * _spos + + (real_type)+2./3. * _SPOS ; + } + } + + if (_cnum == +0) continue ; + /*-------------------- alloc. new child node data */ make_node(_ndat); _lnod = &_ndat->_node[ 0] ; @@ -555,19 +686,48 @@ _pnod->_hptr = _pptr ; _pnod->_lptr = _ndat ; - _lnod->_hptr = _lptr ; + _lnod->_hptr = nullptr ; _lnod->_lptr = nullptr ; _lnod->_pptr = _pnod ; - _rnod->_hptr = _rptr ; + init_aabb_node (_lnod , _pnod); + + _rnod->_hptr = nullptr ; _rnod->_lptr = nullptr ; _rnod->_pptr = _pnod ; - init_aabb_node (_lnod, _pnod); - init_aabb_node (_rnod, _pnod); + init_aabb_node (_rnod , _pnod); + + /*---------- partition list - split on left|right */ + for(item_data *_iptr = _cptr ; + _iptr != nullptr ; + _iptr = _next ) + { + _next = _iptr->_next ; + /*------------------------------- partition items */ + if (_iptr->_data + .pmid (_bdim) > _spos) + { + push_aabb_node( _rnod, _iptr) ; + push_item(_rptr,_iptr); + _rnum += +1 ; + } + else + { + push_aabb_node( _lnod, _iptr) ; + push_item(_lptr,_iptr); + _lnum += +1 ; + } + } + + _rnod->_hptr = _rptr ; + _rnod->_size = _rnum ; + + _lnod->_hptr = _lptr ; + _lnod->_size = _lnum ; /*------------------ push new children onto stack */ - if (_cnum < this->_imax) + if (_cnum < this->_npop) { double _volp, _voll, _volr ; @@ -596,10 +756,8 @@ /*--------------- push children due to vol. ratio */ if (_lnum < _cnum && _rnum < _cnum) { - this->_work - .push_tail(_rnod); - this->_work - .push_tail(_lnod); + _work.push_tail (_rnod); + _work.push_tail (_lnod); } } @@ -609,39 +767,69 @@ /*--------------- push children due to items cap. */ if (_lnum < _cnum && _rnum < _cnum) { - this->_work - .push_tail(_rnod); - this->_work - .push_tail(_lnod); + _work.push_tail (_rnod); + _work.push_tail (_lnod); } } } } +/*-------- _pop items from tree while preserving geometry */ + __normal_call void_type _pop ( + ) + { + if (this->_root == nullptr) return ; + + this->_work.clear() ; + this->_work.push_tail(this->_root) ; + + /*---------------------------- nullify lists per node */ + for ( ; !this->_work.empty() ; ) + { + node_type *_node = nullptr ; + this->_work._pop_tail(_node) ; + + if (_node->items () != nullptr) + { + _node->_hptr = nullptr ; + } + + if (_node->lower(0) != nullptr) + { + { + this->_work.push_tail ( + _node->lower( 0)) ; + + this->_work.push_tail ( + _node->lower( 1)) ; + } + } + } + /*---------------------------- clear item linked list */ + this->_item_base.clear() ; + } + /*-------- form a biased, spatially-local insertion order */ template < typename iptr_list > __normal_call void_type brio ( - iptr_list &_iset + iptr_list &_iset // return brio indices for item ) { - containers::array _next; + containers::array_next ; - if (this->_root - == nullptr) return ; + if (this->_root == nullptr) return ; - this->_work.set_count( +0) ; - this->_work. - push_tail(this->_root) ; + this->_work.clear() ; + this->_work.push_tail(this->_root) ; /*---------------------------- init. leading item ptr */ for ( ; !this->_work.empty() ; ) { node_type *_node = nullptr ; - this->_work. - _pop_tail(_node) ; + this->_work._pop_tail(_node) ; if (_node->items () != nullptr) { @@ -708,11 +896,82 @@ } } +/*-------- get items-per-nodes, as a sparse list-of-lists */ + template < + typename lptr_list, + typename iptr_list + > + __normal_call void_type dcmp ( + lptr_list &_lptr, // ith list: _lp[i]:_lp[i+1]-1 + iptr_list &_iset // unrolled list of item index + ) + { + if (this->_root == nullptr) return; + + this->_work.clear() ; + this->_work.push_tail(this->_root); + + _lptr.push_tail(_iset.count () ) ; + + for ( ; !this->_work.empty() ; ) + { + node_type *_node = nullptr ; + this->_work._pop_tail(_node) ; + + /*---------------------------- push items to CCS list */ + if (_node->items () != nullptr) + { + for (auto + _item = _node->items() ; + _item != nullptr; + _item = _item->_next ) + { + _iset.push_tail( + _item->_data.ipos()); + } + _lptr. + push_tail(_iset.count()) ; + } + + /*---------------------------- descend to child nodes */ + if (_node->lower(0) != nullptr) + { + uint32_t _rsiz = + sizeof(real_type) * +K ; + uint32_t _usiz = + sizeof(uint32_t ) * +1 ; + + uint32_t _hash ; + _hash = hash::hashword ( + (uint32_t*)_node->_pmin, + _rsiz / _usiz, +13) ; + + if (_hash % 2 == +0 ) + { + this->_work.push_tail ( + _node->lower( 0)) ; + + this->_work.push_tail ( + _node->lower( 1)) ; + } + else + { + this->_work.push_tail ( + _node->lower( 1)) ; + + this->_work.push_tail ( + _node->lower( 0)) ; + } + } + } + } + /*-------- helper: calc. "distance" between pos. and aabb */ + __static_call __normal_call real_type calc_rect_dist ( - real_type *_ppos, - real_type *_bmin, - real_type *_bmax + __const_ptr(real_type) _ppos, + __const_ptr(real_type) _bmin, + __const_ptr(real_type) _bmax ) { real_type _dist = (real_type)0.; @@ -753,20 +1012,18 @@ if (this->_root == nullptr) return false ; /*----------------- maintain stack of unvisited nodes */ - this->_work.set_count( +0) ; + this->_work.clear() ; if (_pred(this->_root->_pmin, this->_root->_pmax) ) - this->_work. - push_tail(this->_root) ; + this->_work.push_tail(this->_root); /*----------------- traverse while _pred remains true */ bool_type _find = false ; for ( ; !this->_work.empty() ; ) { node_type *_node = nullptr ; - this->_work. - _pop_tail(_node) ; + this->_work._pop_tail(_node) ; if (_node->_hptr!= nullptr ) { @@ -802,8 +1059,8 @@ typename projector > __normal_call bool_type near ( - real_type *_ppos , - projector &_proj + __const_ptr(real_type) _ppos , // point to index + projector &_proj // closest distance projector ) { class node_dist @@ -839,10 +1096,9 @@ node_dist _ndat ; _ndat._node = _root ; - _ndat._dsqr = - calc_rect_dist(_ppos , - &_root->_pmin[0], - &_root->_pmax[0]) ; + _ndat._dsqr = calc_rect_dist(_ppos, + &_root->_pmin[ 0] , + &_root->_pmax[ 0]); _nnpq.push (_ndat); /*----------------- traverse tree while len. reducing */ @@ -862,12 +1118,15 @@ /*------------------------ descend if maybe close */ if (_ndat. - _node-> _hptr != nullptr) + _node-> _hptr != nullptr || + _ndat. + _node->lower(0) == nullptr) { /*------------------------ leaf: update item-dist */ _find = true ; _dsqr = _proj( + _ndat._node , _ndat._node->_hptr) ; } @@ -883,17 +1142,17 @@ _ndat._node = _inod ; _ndat._dsqr = - calc_rect_dist(_ppos , - &_inod->_pmin[ 0], - &_inod->_pmax[ 0]) ; + calc_rect_dist(_ppos, + &_inod->_pmin[ 0], + &_inod->_pmax[ 0]) ; _nnpq.push(_ndat) ; _ndat._node = _jnod ; _ndat._dsqr = - calc_rect_dist(_ppos , - &_jnod->_pmin[ 0], - &_jnod->_pmax[ 0]) ; + calc_rect_dist(_ppos, + &_jnod->_pmin[ 0], + &_jnod->_pmax[ 0]) ; _nnpq.push(_ndat) ; } diff --git a/src/libcpp/aabb_tree/aabb_type_k.hpp b/src/libcpp/aabb_tree/aabb_type_k.hpp index dd8cd43..11d5ff2 100644 --- a/src/libcpp/aabb_tree/aabb_type_k.hpp +++ b/src/libcpp/aabb_tree/aabb_type_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 10 September, 2017 + * Last updated: 10 Sept., 2017 * * Copyright 2013-2017 * Darren Engwirda @@ -57,9 +61,9 @@ template < - typename R, - typename I, - size_t K + typename R, // reals typedef + typename I, // integer typedef + size_t K // number of geometric dimensions > class aabb_item_rect_k { @@ -70,6 +74,7 @@ typedef I iptr_type; iptr_type static constexpr _dims = K ; + bool_type static constexpr _is_a_rect = true ; private : @@ -128,9 +133,9 @@ template < - typename R, - typename I, - size_t K + typename R, // reals typedef + typename I, // integer typedef + size_t K // number of geometric dimensions > class aabb_item_node_k { @@ -141,6 +146,7 @@ typedef I iptr_type; iptr_type static constexpr _dims = K ; + bool_type static constexpr _is_a_rect = false; private : diff --git a/src/libcpp/aabbtree.hpp b/src/libcpp/aabbtree.hpp index 52deac5..71b8e84 100644 --- a/src/libcpp/aabbtree.hpp +++ b/src/libcpp/aabbtree.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 13 August, 2018 + * Last updated: 13 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/algorithms.hpp b/src/libcpp/algorithms.hpp index 330e328..f0703f0 100644 --- a/src/libcpp/algorithms.hpp +++ b/src/libcpp/algorithms.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 September, 2017 + * Last updated: 01 Sept., 2017 * * Copyright 2013-2017 * Darren Engwirda diff --git a/src/libcpp/algorithms/find.hpp b/src/libcpp/algorithms/find.hpp index 3564454..bcc573e 100644 --- a/src/libcpp/algorithms/find.hpp +++ b/src/libcpp/algorithms/find.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 September, 2017 + * Last updated: 01 Sept., 2017 * * Copyright 2013-2017 * Darren Engwirda @@ -62,10 +66,10 @@ typename pred_type > __normal_call iter_type lower_bound ( - iter_type _head , - iter_type _tend , - data_type _xval , - pred_type _less + iter_type _head , // head of sequence to search + iter_type _tend , // last of sequence to search + data_type _xval , // value to search for + pred_type _less // comparison predicate ) { iter_type _iter ; @@ -109,10 +113,10 @@ typename pred_type > __normal_call iter_type upper_bound ( - iter_type _head , - iter_type _tend , - data_type _xval , - pred_type _less + iter_type _head , // head of sequence to search + iter_type _tend , // last of sequence to search + data_type _xval , // value to search for + pred_type _less // comparison predicate ) { iter_type _iter ; diff --git a/src/libcpp/algorithms/sort.hpp b/src/libcpp/algorithms/sort.hpp index f161c7e..68e1b50 100644 --- a/src/libcpp/algorithms/sort.hpp +++ b/src/libcpp/algorithms/sort.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 24 July, 2019 + * Last updated: 24 Jul., 2019 * * Copyright 2013-2019 * Darren Engwirda @@ -61,9 +65,9 @@ typename pred_type > __normal_call bool_type is_sorted ( - iter_type _head , - iter_type _tail , - pred_type _less + iter_type _head , // head of sequence to test + iter_type _tail , // last of sequence to test + pred_type _less // comparison predicate ) { for ( ; _head+1 != _tail; ++_head ) @@ -159,9 +163,9 @@ typename pred_type > __normal_call void_type isort ( - iter_type _head, - iter_type _tend, - pred_type _less + iter_type _head, // head of sequence to sort + iter_type _tend, // last of sequence to sort + pred_type _less // comparison predicate ) { /*--------------------------- sort small input ranges */ @@ -244,9 +248,9 @@ typename pred_type > __normal_call void_type ssort ( - iter_type _head, - iter_type _tend, - pred_type _less + iter_type _head, // head of sequence to sort + iter_type _tend, // head of sequence to sort + pred_type _less // comparison predicate ) { /*--------------------------- sort small input ranges */ @@ -350,14 +354,14 @@ pred_type const&_less ) { - typename containers:: - iterator_traits:: - diff_type static constexpr _LONG = 256; + //typename containers:: + // iterator_traits:: + //diff_type static constexpr _LONG = 256; iter_type _imid = _head + (_tail - _head) / 2 ; - if (_tail - _head >= _LONG) + if (false) //(_tail - _head >= _LONG) { /*-------------- median-of-5 choice for pivot element */ typename containers:: @@ -388,9 +392,9 @@ typename pred_type > __normal_call void_type qsort ( // unrolled quick sort - iter_type _head, - iter_type _tend, - pred_type _less + iter_type _head, + iter_type _tend, // last of sequence to sort + pred_type _less // comparison predicate ) { typedef containers:: @@ -436,26 +440,32 @@ iter_type _hh, _tt, _mm; /* _pop next partition bounds from stack */ ( --_nptr)->_pop(_hh, _tt); + if (_tt - _hh + 1 < _LONG) { /* leave small partitions */ continue ; } + /* find pivot item for current partition */ _mm = pivot(_hh, _tt, _less); - /* push pivot onto a local copy */ - typename - iter_base::data_type _pp = *_mm; + /* reduce partition around pivot element */ iter_type _ll = _hh + 1; iter_type _rr = _tt - 1; for ( ; _ll < _rr; ) { - for(;_less(*_ll, _pp);) ++_ll; - for(;_less( _pp, *_rr);) --_rr; + for(;_less(*_ll, *_mm);) ++_ll; + for(;_less(*_mm, *_rr);) --_rr; if (_ll < _rr) { /* swap elements */ - std::swap(*_ll, + if (_ll == _mm) + _mm = _rr; + else + if (_rr == _mm) + _mm = _ll; + + std::swap(*_ll, *_rr) ; } if (_ll <= _rr) @@ -463,6 +473,7 @@ ++_ll; --_rr ; } } + /* push partitions onto stack, big first */ if (_rr - _hh > _tt - _ll) { @@ -481,6 +492,88 @@ isort (_head , _tend, _less) ; } + /* + -------------------------------------------------------- + * Q-SIFT: quick select; sort kth element + -------------------------------------------------------- + */ + + template < + typename iter_type , + typename pred_type + > + __normal_call void_type qsift ( // quick select + iter_type _head, + iter_type _kk, // pos. in sequence to find + iter_type _tend, // last of sequence to parition + pred_type _less // comparison predicate + ) + { + 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 ; + } + + /* + if (_tt - _hh + 1 <= 4) + { + isort ( _hh, _tt, _less); + break ; + } + */ + + /* find pivot item for current partition */ + _mm = pivot(_hh, _tt, _less); + + /* reduce partition around pivot element */ + iter_type _ll = _hh + 1; + iter_type _rr = _tt - 1; + for ( ; _ll < _rr; ) + { + for(;_less(*_ll, *_mm);) ++_ll; + for(;_less(*_mm, *_rr);) --_rr; + + if (_ll < _rr) + { /* swap elements */ + if (_ll == _mm) + _mm = _rr; + else + if (_rr == _mm) + _mm = _ll; + + std::swap(*_ll, + *_rr) ; + } + if (_ll <= _rr) + { /* shrink bounds */ + ++_ll; --_rr ; + } + } + + //if (_mm == _kk) break ; + + if (_kk < _rr) _tt = _rr; + else + if (_kk > _ll) _hh = _ll; + else + { + _hh = _rr+1; _tt = _ll-1; + } + } + while (true) ; + } + } diff --git a/src/libcpp/allocators.hpp b/src/libcpp/allocators.hpp index 7f7e57a..18e73a2 100644 --- a/src/libcpp/allocators.hpp +++ b/src/libcpp/allocators.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/allocators/alloc_base.hpp b/src/libcpp/allocators/alloc_base.hpp index 75f3d5c..d6059da 100644 --- a/src/libcpp/allocators/alloc_base.hpp +++ b/src/libcpp/allocators/alloc_base.hpp @@ -29,12 +29,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/allocators/alloc_item.hpp b/src/libcpp/allocators/alloc_item.hpp index b9c1727..ab68109 100644 --- a/src/libcpp/allocators/alloc_item.hpp +++ b/src/libcpp/allocators/alloc_item.hpp @@ -29,16 +29,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 06 September, 2018 + * Last updated: 06 Sept., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/allocators/alloc_pool.hpp b/src/libcpp/allocators/alloc_pool.hpp index 68c839d..99dc087 100644 --- a/src/libcpp/allocators/alloc_pool.hpp +++ b/src/libcpp/allocators/alloc_pool.hpp @@ -32,12 +32,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/allocators/alloc_wrap.hpp b/src/libcpp/allocators/alloc_wrap.hpp index 5eb8404..c04eeee 100644 --- a/src/libcpp/allocators/alloc_wrap.hpp +++ b/src/libcpp/allocators/alloc_wrap.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/basebase.hpp b/src/libcpp/basebase.hpp index d62e11b..f297273 100644 --- a/src/libcpp/basebase.hpp +++ b/src/libcpp/basebase.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 02 March, 2020 + * Last updated: 02 Mar., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/containers.hpp b/src/libcpp/containers.hpp index 31e6b6f..bbe0623 100644 --- a/src/libcpp/containers.hpp +++ b/src/libcpp/containers.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 December, 2018 + * Last updated: 21 Dec., 2018 * * Copyright 2013-2018 * Darren Engwirda @@ -72,6 +76,7 @@ # include "containers/priorityset.hpp" # include "containers/prioritymap.hpp" +# include "containers/priorityidx.hpp" # endif//__CONTAINERS__ diff --git a/src/libcpp/containers/array.hpp b/src/libcpp/containers/array.hpp index 5b89fe7..f916409 100644 --- a/src/libcpp/containers/array.hpp +++ b/src/libcpp/containers/array.hpp @@ -41,7 +41,7 @@ * ------------------------------------------------------------ * - * Last updated: 27 April, 2020 + * Last updated: 27 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/containers/arraylist.hpp b/src/libcpp/containers/arraylist.hpp index 5bf8f9d..1c8b99b 100644 --- a/src/libcpp/containers/arraylist.hpp +++ b/src/libcpp/containers/arraylist.hpp @@ -37,7 +37,7 @@ * ------------------------------------------------------------ * - * Last updated: 11 April, 2018 + * Last updated: 11 Apr., 2018 * * Copyright 2013-2018 * Darren Engwirda @@ -332,7 +332,7 @@ ) { /*------------------------------ clear lists of items */ - this-> empty(_kind) ; + this-> empty() ; /*------------------------------ resize backing array */ this->_lptr .clear(_kind) ; } diff --git a/src/libcpp/containers/basic_stack.hpp b/src/libcpp/containers/basic_stack.hpp index 2153dfa..6f6d4fb 100644 --- a/src/libcpp/containers/basic_stack.hpp +++ b/src/libcpp/containers/basic_stack.hpp @@ -39,7 +39,7 @@ * ------------------------------------------------------------ * - * Last updated: 21 December, 2018 + * Last updated: 21 Dec., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/containers/block_array.hpp b/src/libcpp/containers/block_array.hpp index 35f853e..141c8b0 100644 --- a/src/libcpp/containers/block_array.hpp +++ b/src/libcpp/containers/block_array.hpp @@ -43,7 +43,7 @@ * ------------------------------------------------------------ * - * Last updated: 27 April, 2020 + * Last updated: 27 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/containers/block_iter.hpp b/src/libcpp/containers/block_iter.hpp index d658e4a..ad8013f 100644 --- a/src/libcpp/containers/block_iter.hpp +++ b/src/libcpp/containers/block_iter.hpp @@ -43,7 +43,7 @@ * ------------------------------------------------------------ * - * Last updated: 03 July, 2019 + * Last updated: 03 Jul., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/containers/hashtable.hpp b/src/libcpp/containers/hashtable.hpp index 77af72b..aca9678 100644 --- a/src/libcpp/containers/hashtable.hpp +++ b/src/libcpp/containers/hashtable.hpp @@ -37,7 +37,7 @@ * ------------------------------------------------------------ * - * Last updated: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/containers/hashtwice.hpp b/src/libcpp/containers/hashtwice.hpp index d82d64d..cb3371a 100644 --- a/src/libcpp/containers/hashtwice.hpp +++ b/src/libcpp/containers/hashtwice.hpp @@ -40,7 +40,7 @@ * ------------------------------------------------------------ * - * Last updated: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/containers/priorityidx.hpp b/src/libcpp/containers/priorityidx.hpp new file mode 100644 index 0000000..a505e2c --- /dev/null +++ b/src/libcpp/containers/priorityidx.hpp @@ -0,0 +1,725 @@ + +/* +------------------------------------------------------------ + * an "n-ary"-heap based priority queue. +------------------------------------------------------------ + * + * PRIORITY-IDX utilises an "n-ary" heap data-structure, + * designed to maintain sorted precedence in mutable + * collections. This "n-ary" heap simply generalises + * a standard binary heap (i.e. a 2-heap) to trees with + * "n" children per level. + * +------------------------------------------------------------ + * + * This program may be freely redistributed under the + * condition that the copyright notices (including this + * entire header) are not removed, and no compensation + * is received through use of the software. Private, + * research, and institutional use is free. You may + * distribute modified versions of this code UNDER THE + * CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE + * TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE + * ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE + * MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR + * NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution + * of this code as part of a commercial system is + * permissible ONLY BY DIRECT ARRANGEMENT WITH THE + * AUTHOR. (If you are not directly supplying this + * code to a customer, and you are instead telling them + * how they can obtain it for free, then you are not + * required to make any arrangement with me.) + * + * Disclaimer: Neither I nor: Columbia University, The + * Massachusetts Institute of Technology, The + * University of Sydney, nor The National Aeronautics + * and Space Administration warrant this code in any + * way whatsoever. This code is provided "as-is" to be + * used at your own risk. + * +------------------------------------------------------------ + * + * Last updated: 15 Jun., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * +------------------------------------------------------------ + */ + +# pragma once + +# ifndef __PRIORITY_IDX__ +# define __PRIORITY_IDX__ + +# include "array.hpp" + + namespace containers { + +# define __cont containers + + template < + typename T , + typename I + > + class _idx_pair + { +/*----------- local data-pair for an indexed "n"-ary heap */ + public : + typedef T data_type ; + typedef I iptr_type ; + + public : + data_type _data ; // heap data + iptr_type _kidx ; // keys idx. + } ; + +# define D _idx_pair + + template < + typename T , + typename K , + typename P = std::less , + typename A = allocators::basic_alloc , + typename C = containers::array + > + class priorityidx + { +/*----------- a dynamic priority queue as an "n"-ary heap */ + public : + + #undef D + + typedef T data_type ; + typedef K iptr_type ; + typedef C container ; + typedef P pred_type ; + typedef A allocator ; + + typedef containers::priorityidx < + data_type , + iptr_type , + pred_type , + allocator , + container > self_type ; + + typedef typename + container::data_type pair_type ; + typedef typename + container::size_type size_type ; + + typedef typename + container::_write_it _write_it ; + typedef typename + container::_const_it _const_it ; + + typedef containers::array < + iptr_type , + allocator > iptr_list ; + + size_type static constexpr _nfan = +8 ; // fan out + + public : + + container _heap ; + + iptr_list _keys ; + + pred_type _pred ; + + public : + +/*------------- helper - set "null" item marker as maxint */ + __static_call + __inline_call iptr_type const null ( + ) + { return std::numeric_limits::max() ; + } + + private : + +/*------------- helper - push "hole" into sorted position */ + __normal_call _write_it push_upper ( + _write_it _head, + _write_it _ipos, + data_type const&_data + ) + { + for (; _ipos != _head ; ) + { + /*----------------------- find position of parent */ + _write_it _ppos = + _head + (_ipos-_head-1) / _nfan; + /*----------------------- swap parent with "hole" */ + if (this->_pred(_data,_ppos->_data)) + { + /*------------------ update heap-keys mapping */ + _ipos->_data = + std::move(_ppos->_data); + _ipos->_kidx = + std::move(_ppos->_kidx); + /*------------------ update keys-heap mapping */ + this->_keys [_ipos->_kidx] = + _ipos- _head ; + /*------------------ traverse to upper levels */ + _ipos =_ppos ; + } + else break ; + } + + return (_ipos) ; + } + +/*------------- helper - push "hole" into sorted position */ + __normal_call _write_it push_lower ( + _write_it _head, + _write_it _tail, + _write_it _ipos, + data_type const&_data + ) + { + if (_head == _tail) return _ipos ; + /*-- find position of root of last partial (sub)-tree */ + _write_it _cpos ; + _write_it _imin ; + _write_it _iend = _head; + if (_tail - _head > 0) + { + _iend = + _head + (_tail-_head-1) / _nfan ; + } + /*-- push "hole" into sorted position on lower levels */ + for ( ; _ipos < _iend; ) + { + /*---------------------------- pos of right child */ + _cpos = _head + + _nfan * (_ipos - _head) + _nfan ; + /*---------------------------- find minimum child */ + _imin = _cpos; + switch (_nfan) + { + case 8 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 7 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 6 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 5 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 4 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 3 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 2 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + } + /*---------------------- update heap-keys mapping */ + _ipos->_data = + std::move(_imin->_data); + _ipos->_kidx = + std::move(_imin->_kidx); + /*---------------------- update keys-heap mapping */ + this->_keys [_ipos->_kidx] = + _ipos- _head ; + /*---------------------- move onto next child pos */ + _ipos =_imin ; + } + + /*-- deal with special case - last partial sub - tree */ + if (_ipos == _iend) + { + size_type _inum = + _tail-_head-_nfan*(_ipos-_head); + if (_inum > +0) + { + /*---------------------------- pos of right child */ + _cpos = _head + + _nfan * (_ipos -_head) + _inum ; + /*---------------------------- find minimum child */ + _imin = _cpos; + switch (_inum) + { + case 8 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 7 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 6 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 5 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 4 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 3 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + case 2 : + if (this->_pred((--_cpos)->_data , + _imin ->_data)) + _imin=_cpos; // falls through + } + /*---------------------- update heap-keys mapping */ + _ipos->_data = + std::move(_imin->_data); + _ipos->_kidx = + std::move(_imin->_kidx); + /*---------------------- update keys-heap mapping */ + this->_keys [_ipos->_kidx] = + _ipos- _head ; + /*---------------------- move onto next child pos */ + _ipos =_imin ; + } + } + + /*--- push "hole" into final position sorted position */ + return push_upper(_head, _ipos, _data) ; + } + + public : + +/*--------------------------- default c'tor - do nothing! */ + __inline_call priorityidx ( + allocator const&_asrc = allocator(), + pred_type const&_psrc = pred_type() + ) : _heap(_asrc), + _keys(_asrc), + _pred(_psrc) {} + +/*--------------------------- default c'tor - initialisor */ + __inline_call priorityidx ( + pred_type const&_psrc + ) : _heap(allocator()), + _keys(allocator()), + _pred(_psrc) {} + + __inline_call~priorityidx() = default ; + + __inline_call priorityidx ( + self_type const&_src + ) = default ; + __inline_call priorityidx ( + self_type && _src + ) = default ; + + __inline_call + self_type & operator= ( + self_type const&_src + ) = default ; + __inline_call + self_type & operator= ( + self_type && _src + ) = default ; + +/*------------------------------------- peek at heap root */ + + __inline_call data_type const& root ( + ) const + { return this->_heap[ +0 ]._data ; + } + +/*------------------------------------- peek at heap item */ + __inline_call data_type const& peek ( + size_type _hpos = +0 + ) const + { return this->_heap[_hpos]._data ; + } + +/*------------------------------------- peek at item idx. */ + __inline_call iptr_type const keys ( + size_type _kpos = +0 + ) const + { return this->_keys[_kpos] ; + } + +/*-------------------------------------------- empty test */ + __inline_call bool_type empty ( + ) const + { return ( this->_heap. empty() ) ; + } + +/*-------------------------------------------- heap count */ + __inline_call size_type count ( + ) const + { return ( this->_heap. count() ) ; + } + +/*-------------------------------------------- heap alloc */ + __inline_call size_type alloc ( + ) const + { return ( this->_heap. alloc() ) ; + } + +/*-------------------------------------------- _set alloc */ + __inline_call size_type set_alloc ( + size_type _asiz + ) + { this->_heap.set_alloc( _asiz) ; + } + +/*------------------------------------- (const) iterators */ + __inline_call _const_it head ( + ) const + { return this->_heap. head() ; + } + __inline_call _const_it tail ( + ) const + { return this->_heap. tail() ; + } + __inline_call _const_it hend ( + ) const + { return this->_heap. hend() ; + } + __inline_call _const_it tend ( + ) const + { return this->_heap. tend() ; + } + + /* + -------------------------------------------------------- + * PUSH: push data onto heap + -------------------------------------------------------- + */ + + __inline_call void_type push ( // copy + iptr_type _kpos, + data_type const&_data + ) + {/*---------------- make room for new item in mapping */ + iptr_type _size = + (iptr_type) this->_keys .count() ; + if (_size <= _kpos) + this->_keys.set_count( + _kpos + 1 , + containers::loose_alloc, null()); + + if (this->_keys[_kpos] != null()) + throw std::invalid_argument( + "priorityidx.push: key in use") ; + + /*----------------- push _data onto tail of container */ + size_type _tpos = + this->_heap.push_tail() ; + /*----------------- sort corresponding "hole" to pos. */ + _write_it _ipos = push_upper ( + this->_heap.head() , + this->_heap.head() + _tpos , + __copy(data_type, _data)) ; + + /*------------------------- copy new data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __copy(data_type, _data) ; + + /*------------------------- map _item to _data "hole" */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + __inline_call void_type push ( // move + iptr_type _kpos, + data_type && _data + ) + {/*---------------- make room for new item in mapping */ + iptr_type _size = + (iptr_type) this->_keys .count() ; + if (_size <= _kpos) + this->_keys.set_count( + _kpos + 1 , + containers::loose_alloc, null()); + + if (this->_keys[_kpos] != null()) + throw std::invalid_argument( + "priorityidx.push: key in use") ; + + /*----------------- push _data onto tail of container */ + size_type _tpos = + this->_heap.push_tail() ; + /*----------------- sort corresponding "hole" to pos. */ + _write_it _ipos = push_upper ( + this->_heap.head() , + this->_heap.head() + _tpos , + __copy(data_type, _data)) ; + + /*------------------------- move new data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __move(data_type, _data) ; + + /*------------------------- map _item to _data "hole" */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + /* + -------------------------------------------------------- + * _POP: _pop data from heap + -------------------------------------------------------- + */ + + __inline_call void_type _pop_root ( + ) + { + /*---------------------------- _pop root, cache temp. */ + data_type _temp ; + _pop( +0, _temp); + } + __inline_call void_type _pop_root ( + iptr_type &_kpos , + data_type &_data + ) + { + /*---------------------------- _pop item, return data */ + size_type _hpos = +0 ; + _kpos = this->_heap[_hpos]._kidx ; + _data = + std::move (this->_heap[_hpos]._data); + /*----------------------- push "hole" to lower levels */ + if (this->_heap.head() + _hpos != + this->_heap.tail() ) + { + /*----------- sort "hole" at root to updated position */ + _write_it _ipos = push_lower ( + this->_heap.head() , + this->_heap.tail() - 1 , + this->_heap.head() + _hpos, + this->_heap.tail()-> _data) ; + + /*----------- copy current tail into updated position */ + _ipos->_data = std::move( + this->_heap.tail()-> _data) ; + _ipos->_kidx = std::move( + this->_heap.tail()-> _kidx) ; + + /*---------------------- update mapping for tail item */ + this->_keys[_ipos->_kidx] = + _ipos - this->_heap.head() ; + } + this->_heap._pop_tail(); + + this->_keys[_kpos] = null() ; + } + + __inline_call void_type _pop ( + iptr_type _kpos + ) + { + /*---------------------------- _pop data, cache temp. */ + data_type _temp ; + _pop(_kpos,_temp); + } + __normal_call void_type _pop ( + iptr_type _kpos , + data_type &_data + ) + { + if (this->_keys[_kpos] == null()) + return ; + /*---------------------------- _pop item, return data */ + size_type _hpos = this->_keys[_kpos]; + _data = + std::move (this->_heap[_hpos]._data); + /*----------------------- push "hole" to lower levels */ + if (this->_heap.head() + _hpos != + this->_heap.tail() ) + { + /*----------- sort "hole" at root to updated position */ + _write_it _ipos = push_lower ( + this->_heap.head() , + this->_heap.tail() - 1 , + this->_heap.head() + _hpos, + this->_heap.tail()-> _data) ; + + /*----------- copy current tail into updated position */ + _ipos->_data = std::move( + this->_heap.tail()-> _data) ; + _ipos->_kidx = std::move( + this->_heap.tail()-> _kidx) ; + + /*---------------------- update mapping for tail item */ + this->_keys[_ipos->_kidx] = + _ipos - this->_heap.head() ; + } + this->_heap._pop_tail(); + + this->_keys[_kpos] = null() ; + } + + /* + -------------------------------------------------------- + * UPDATE: update data in heap + -------------------------------------------------------- + */ + + __inline_call void_type update ( // copy + iptr_type _kpos, + data_type const&_data + ) + {/*------------------ move "hole" to updated position */ + size_type _hpos = + this->_keys[_kpos]; + _write_it _ipos = + this->_heap.tend(); + + /*------------------------ push "hole" to lower level */ + _ipos = push_lower ( + this-> _heap.head(), + this-> _heap.tail(), + this-> _heap.head()+_hpos , + __copy(data_type,_data)) ; + + /*------------------------ copy this data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __copy(data_type,_data) ; + + /*------------------------ copy position into mapping */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + __inline_call void_type update ( // move + iptr_type _kpos, + data_type &&_data + ) + {/*------------------ move "hole" to updated position */ + size_type _hpos = + this->_keys[_kpos]; + _write_it _ipos = + this->_heap.tend(); + + /*------------------------ push "hole" to lower level */ + _ipos = push_lower ( + this-> _heap.head(), + this-> _heap.tail(), + this-> _heap.head()+_hpos , + __copy(data_type,_data)) ; + + /*------------------------ copy this data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __move(data_type,_data) ; + + /*------------------------ copy position into mapping */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + /* + -------------------------------------------------------- + * REDUCE: update data in heap ("lower" priority) + -------------------------------------------------------- + */ + + __inline_call void_type reduce ( // copy + iptr_type _kpos, + data_type const&_data + ) + {/*------------------ move "hole" to updated position */ + size_type _hpos = + this->_keys[_kpos]; + _write_it _ipos = push_upper ( + this->_heap.head(), + this->_heap.head()+_hpos , + __copy(data_type,_data)) ; + + /*------------------------ copy this data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __copy(data_type,_data) ; + + /*------------------------ copy position into mapping */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + __inline_call void_type reduce ( // move + iptr_type _kpos, + data_type &&_data + ) + {/*------------------ move "hole" to updated position */ + size_type _hpos = + this->_keys[_kpos]; + _write_it _ipos = push_upper ( + this->_heap.head(), + this->_heap.head()+_hpos , + __copy(data_type,_data)) ; + + /*------------------------ copy this data into "hole" */ + _ipos->_kidx = _kpos ; + _ipos->_data = + __move(data_type,_data) ; + + /*------------------------ copy position into mapping */ + this->_keys[_kpos] = + _ipos - this->_heap.head() ; + } + + /* + -------------------------------------------------------- + * test heap validity (debug only!) + -------------------------------------------------------- + */ + + __normal_call bool_type test_heap ( + ) + { +# ifdef _DEBUG + /*------------------ test relationships for all nodes */ + size_type _ipos = +1 ; + size_type _iend = + this->_heap.count () ; + for ( ; _ipos < _iend; ++_ipos) + { + /*------------------ heap is invalid if lower < upper */ + size_type _ppos = + (_ipos - 1)/_nfan ; + + if (this->_pred( + this->_heap[_ipos]._data, + this->_heap[_ppos]._data + ) ) + return false ; + } +# endif + + /*------------------ must be valid if we got this far */ + return true ; + } + + } ; + +# undef __cont + + + } + +# endif //__PRIORITY_IDX__ + + + diff --git a/src/libcpp/containers/prioritymap.hpp b/src/libcpp/containers/prioritymap.hpp index 944b83e..27648a2 100644 --- a/src/libcpp/containers/prioritymap.hpp +++ b/src/libcpp/containers/prioritymap.hpp @@ -64,7 +64,7 @@ typename T , typename K > - class heap_pair + class _map_pair { /*----------- local data-pair for an indexed "n"-ary heap */ public : @@ -76,7 +76,7 @@ kptr_type _kptr ; // keys iptr } ; -# define D heap_pair +# define D _map_pair template < typename T , @@ -123,7 +123,7 @@ size_type , allocator > free_list ; - size_type static constexpr _nfan = +4 ; // fan out + size_type static constexpr _nfan = +8 ; // fan out public : diff --git a/src/libcpp/containers/priorityset.hpp b/src/libcpp/containers/priorityset.hpp index 54d9cf1..b8e4b6b 100644 --- a/src/libcpp/containers/priorityset.hpp +++ b/src/libcpp/containers/priorityset.hpp @@ -90,7 +90,7 @@ typedef typename container::_const_it _const_it ; - size_type static constexpr _nfan = +4; // fan out + size_type static constexpr _nfan = +8; // fan out public : diff --git a/src/libcpp/containers/single_list.hpp b/src/libcpp/containers/single_list.hpp index 0e58672..f4e0649 100644 --- a/src/libcpp/containers/single_list.hpp +++ b/src/libcpp/containers/single_list.hpp @@ -41,7 +41,7 @@ * ------------------------------------------------------------ * - * Last updated: 21 December, 2018 + * Last updated: 21 Dec., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/expansion/dd_float.hpp b/src/libcpp/expansion/dd_float.hpp index d53e547..5ddba25 100644 --- a/src/libcpp/expansion/dd_float.hpp +++ b/src/libcpp/expansion/dd_float.hpp @@ -37,16 +37,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 16 April, 2020 + * Last updated: 16 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/expansion/ia_float.hpp b/src/libcpp/expansion/ia_float.hpp index 341b6a5..0d4b5f8 100644 --- a/src/libcpp/expansion/ia_float.hpp +++ b/src/libcpp/expansion/ia_float.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 10 April, 2020 + * Last updated: 10 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/expansion/mp_basic.hpp b/src/libcpp/expansion/mp_basic.hpp index 684d3cb..aa15870 100644 --- a/src/libcpp/expansion/mp_basic.hpp +++ b/src/libcpp/expansion/mp_basic.hpp @@ -50,16 +50,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 16 April, 2020 + * Last updated: 16 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/expansion/mp_float.hpp b/src/libcpp/expansion/mp_float.hpp index a7b9759..ac04050 100644 --- a/src/libcpp/expansion/mp_float.hpp +++ b/src/libcpp/expansion/mp_float.hpp @@ -46,12 +46,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/expansion/mp_utils.hpp b/src/libcpp/expansion/mp_utils.hpp index 36f3b0c..d7d0621 100644 --- a/src/libcpp/expansion/mp_utils.hpp +++ b/src/libcpp/expansion/mp_utils.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 March, 2020 + * Last updated: 03 Mar., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/geom_base/cell_ball_k.hpp b/src/libcpp/geom_base/cell_ball_k.hpp index 0035b92..cb94df4 100644 --- a/src/libcpp/geom_base/cell_ball_k.hpp +++ b/src/libcpp/geom_base/cell_ball_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 26 July, 2020 + * Last updated: 26 Jul., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/geom_base/cell_base_k.hpp b/src/libcpp/geom_base/cell_base_k.hpp index abea7ba..d6e6c0f 100644 --- a/src/libcpp/geom_base/cell_base_k.hpp +++ b/src/libcpp/geom_base/cell_base_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 24 Jan., 2022 + * Last updated: 12 Jul., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -565,6 +569,8 @@ __const_ptr (real_type) _p3 ) { // "skewed-cosine"; penalty for obtuse + // Engwirda, D. (2022): + // An 'asymmetric-cosine' metric for primal-dual mesh optimisation. real_type _vv12[2] ; real_type _vv23[2] ; real_type _vv31[2] ; @@ -579,37 +585,29 @@ real_type _ll31 = geometry::length_2d (_vv31) ; + // -ve due to ccw sign of vectors real_type _dd11 = geometry::dot_2d( - _vv12, _vv23) / _ll12 / _ll23 ; + _vv31, _vv12) / _ll31 / _ll12 ; real_type _dd22 = geometry::dot_2d( - _vv23, _vv31) / _ll23 / _ll31 ; + _vv12, _vv23) / _ll12 / _ll23 ; real_type _dd33 = geometry::dot_2d( - _vv31, _vv12) / _ll31 / _ll12 ; - - _dd11 = (real_type)-2./3. * ( - _dd11 + (real_type)+.5) ; - _dd22 = (real_type)-2./3. * ( - _dd22 + (real_type)+.5) ; - _dd33 = (real_type)-2./3. * ( - _dd33 + (real_type)+.5) ; + _vv23, _vv31) / _ll23 / _ll31 ; + + _dd11 += (real_type)+ 1./2. ; + _dd22 += (real_type)+ 1./2. ; + _dd33 += (real_type)+ 1./2. ; real_type _skew = - (real_type) +9. / 11. * ( + (real_type) +4. / 11. * ( std::pow(_dd11, 2) + std::pow(_dd22, 2) + std::pow(_dd33, 2) ) ; - _skew = (real_type)+1. - _skew ; - - real_type _alen = - tria_quality_2d(_p1, _p2, _p3) ; - - return - (real_type)(1. - 1./2.) * _skew + - (real_type)(0. + 1./2.) * _alen ; + return std::pow( + (real_type) +1. - _skew, +4./3.) ; } template < @@ -622,6 +620,8 @@ __const_ptr (real_type) _p3 ) { // "skewed-cosine"; penalty for obtuse + // Engwirda, D. (2022): + // An 'asymmetric-cosine' metric for primal-dual mesh optimisation. real_type _vv12[3] ; real_type _vv23[3] ; real_type _vv31[3] ; @@ -636,37 +636,29 @@ real_type _ll31 = geometry::length_3d (_vv31) ; + // -ve due to ccw sign of vectors real_type _dd11 = geometry::dot_3d( - _vv12, _vv23) / _ll12 / _ll23 ; + _vv31, _vv12) / _ll31 / _ll12 ; real_type _dd22 = geometry::dot_3d( - _vv23, _vv31) / _ll23 / _ll31 ; + _vv12, _vv23) / _ll12 / _ll23 ; real_type _dd33 = geometry::dot_3d( - _vv31, _vv12) / _ll31 / _ll12 ; - - _dd11 = (real_type)-2./3. * ( - _dd11 + (real_type)+.5) ; - _dd22 = (real_type)-2./3. * ( - _dd22 + (real_type)+.5) ; - _dd33 = (real_type)-2./3. * ( - _dd33 + (real_type)+.5) ; + _vv23, _vv31) / _ll23 / _ll31 ; + + _dd11 += (real_type)+ 1./2. ; + _dd22 += (real_type)+ 1./2. ; + _dd33 += (real_type)+ 1./2. ; real_type _skew = - (real_type) +9. / 11. * ( + (real_type) +4. / 11. * ( std::pow(_dd11, 2) + std::pow(_dd22, 2) + std::pow(_dd33, 2) ) ; - _skew = (real_type)+1. - _skew ; - - real_type _alen = - tria_quality_3d(_p1, _p2, _p3) ; - - return - (real_type)(1. - 1./2.) * _skew + - (real_type)(0. + 1./2.) * _alen ; + return std::pow( + (real_type) +1. - _skew, +4./3.) ; } /* diff --git a/src/libcpp/geom_base/intersect_k.hpp b/src/libcpp/geom_base/intersect_k.hpp index 0759c7a..bad6ce8 100644 --- a/src/libcpp/geom_base/intersect_k.hpp +++ b/src/libcpp/geom_base/intersect_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2019 + * Last updated: 12 Aug., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/geom_base/vect_base_k.hpp b/src/libcpp/geom_base/vect_base_k.hpp index d99555e..495a435 100644 --- a/src/libcpp/geom_base/vect_base_k.hpp +++ b/src/libcpp/geom_base/vect_base_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/geom_reps/geom_base_2.hpp b/src/libcpp/geom_reps/geom_base_2.hpp index 55d5e13..b521fb0 100644 --- a/src/libcpp/geom_reps/geom_base_2.hpp +++ b/src/libcpp/geom_reps/geom_base_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/geom_reps/geom_base_3.hpp b/src/libcpp/geom_reps/geom_base_3.hpp index f16395d..95ff03f 100644 --- a/src/libcpp/geom_reps/geom_base_3.hpp +++ b/src/libcpp/geom_reps/geom_base_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp b/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp index 1de02c4..778e087 100644 --- a/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp +++ b/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -1996,6 +2000,11 @@ ball_intersect < hits_func > hits_pred ; + float static const _RTOL = + std::pow ( + std::numeric_limits + ::epsilon(), (float).675) ; + float _PMID[3] = { (float) _ball. _pmid[0] , (float) _ball. _pmid[1] , @@ -2005,6 +2014,8 @@ float _RRAD = (float) _ball. _rrad; + _RRAD *= (+1. + _RTOL) ; + /*------------------ call actual intersection testing */ real_type _rmin[3] = { _ball._pmid[0] -_ball. _rrad, diff --git a/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp b/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp index d7f5b09..8d2b1e7 100644 --- a/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp +++ b/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -1366,11 +1370,15 @@ /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr , + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + real_type _qtmp[+2] = {+0.}; for ( ; _iptr != nullptr; @@ -1451,6 +1459,11 @@ ball_line_pred < hits_func > hits_pred ; + float static const _RTOL = + std::pow ( + std::numeric_limits + ::epsilon(), (float).675) ; + float _PMID[2] = { (float) _ball. _pmid[0] , (float) _ball. _pmid[1] , @@ -1459,6 +1472,8 @@ float _RRAD = (float) _ball. _rrad; + _RRAD *= (+1. + _RTOL) ; + /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; hits_pred _func(_ball. _pmid, diff --git a/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp b/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp index 85778f7..733d971 100644 --- a/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp +++ b/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -2121,11 +2125,15 @@ /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr , + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + real_type _qtmp[+3] = {+0.}; for ( ; _iptr != nullptr; @@ -2218,11 +2226,15 @@ /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr , + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + real_type _qtmp[+3] = {+0.}; for ( ; _iptr != nullptr; @@ -2442,6 +2454,11 @@ ball_line_pred < hits_func > hits_pred ; + float static const _RTOL = + std::pow ( + std::numeric_limits + ::epsilon(), (float).675) ; + float _PMID[3] = { (float) _ball. _pmid[0] , (float) _ball. _pmid[1] , @@ -2451,6 +2468,8 @@ float _RRAD = (float) _ball. _rrad; + _RRAD *= (+1. + _RTOL) ; + /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; hits_pred _func(_ball. _pmid, @@ -2491,6 +2510,11 @@ __unreferenced(_sbal) ; + float static const _RTOL = + std::pow ( + std::numeric_limits + ::epsilon(), (float).675) ; + float _PMID[3] = { (float) _disc. _pmid[0] , (float) _disc. _pmid[1] , @@ -2500,6 +2524,8 @@ float _RRAD = (float) _disc. _rrad; + _RRAD *= (+1. + _RTOL) ; + /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; hits_pred _func(_disc. _pmid, @@ -2834,7 +2860,7 @@ real_type static const _RTOL= std::pow ( std::numeric_limits - ::epsilon(), (real_type)+.625) ; + ::epsilon(), (real_type)+.675) ; real_type _BTOL = ( this->_bmax[0] - diff --git a/src/libcpp/geometry.hpp b/src/libcpp/geometry.hpp index 56a2124..4d0bc61 100644 --- a/src/libcpp/geometry.hpp +++ b/src/libcpp/geometry.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 November, 2017 + * Last updated: 01 Nov., 2017 * * Copyright 2013-2017 * Darren Engwirda diff --git a/src/libcpp/geompred.hpp b/src/libcpp/geompred.hpp index d4965a6..79a50cd 100644 --- a/src/libcpp/geompred.hpp +++ b/src/libcpp/geompred.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 March, 2020 + * Last updated: 01 Mar., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/geomreps.hpp b/src/libcpp/geomreps.hpp index 995fc7b..90a7a6f 100644 --- a/src/libcpp/geomreps.hpp +++ b/src/libcpp/geomreps.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 20 February, 2020 + * Last updated: 20 Feb., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/hashfunc.hpp b/src/libcpp/hashfunc.hpp index 65b164a..9f3b2b8 100644 --- a/src/libcpp/hashfunc.hpp +++ b/src/libcpp/hashfunc.hpp @@ -173,9 +173,9 @@ hashlittle() has to dance around fitting the key bytes into registers. ------------------------------------------------------------------------------- */ uint32_t hashword ( -__const_ptr(uint32_t) k, /* the key, an array of uint32_t values */ -size_t length, /* the length of the key, in uint32_ts */ -uint32_t initval) /* the previous hash, or an arbitrary value */ + const uint32_t *k, /* the key, an array of uint32_t values */ + size_t length, /* the length of the key, in uint32_ts */ + uint32_t initval) /* the previous hash, or an arbitrary value */ { uint32_t a,b,c; @@ -217,10 +217,10 @@ both be initialized with seeds. If you pass in (*pb)==0, the output ------------------------------------------------------------------------------- */ void hashword2 ( -__const_ptr(uint32_t) k, /* the key, an array of uint32_t values */ -size_t length, /* the length of the key, in uint32_ts */ -__write_ptr(uint32_t) pc, /* IN: seed OUT: primary hash value */ -__write_ptr(uint32_t) pb) /* IN: more seed OUT: secondary hash value */ + const uint32_t *k, /* the key, an array of uint32_t values */ + size_t length, /* the length of the key, in uint32_ts */ + uint32_t *pc, /* IN: seed OUT: primary hash value */ + uint32_t *pb) /* IN: more seed OUT: secondary hash value */ { uint32_t a,b,c; diff --git a/src/libcpp/interpolate.hpp b/src/libcpp/interpolate.hpp index 5feaa72..6e9d2f6 100644 --- a/src/libcpp/interpolate.hpp +++ b/src/libcpp/interpolate.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 June, 2019 + * Last updated: 30 Jun., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/interpolate/hfun_base_k.hpp b/src/libcpp/interpolate/hfun_base_k.hpp index 6e0ac70..451ec78 100644 --- a/src/libcpp/interpolate/hfun_base_k.hpp +++ b/src/libcpp/interpolate/hfun_base_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 June, 2019 + * Last updated: 30 Jun., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/interpolate/hfun_clip_k.hpp b/src/libcpp/interpolate/hfun_clip_k.hpp index d91d3c5..d9322bd 100644 --- a/src/libcpp/interpolate/hfun_clip_k.hpp +++ b/src/libcpp/interpolate/hfun_clip_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 Mar., 2022 + * Last updated: 29 Jun., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -52,7 +56,7 @@ typename real_type , typename vals_type > - __normal_call bool_type EIKONAL_edge_2d ( + __inline_call bool_type EIKONAL_edge_2d ( __const_ptr (real_type) _p1 , vals_type _h1 , vals_type _g1 , @@ -80,7 +84,7 @@ typename real_type , typename vals_type > - __normal_call bool_type EIKONAL_edge_3d ( + __inline_call bool_type EIKONAL_edge_3d ( __const_ptr (real_type) _p1 , vals_type _h1 , vals_type _g1 , @@ -150,8 +154,7 @@ _aa * _aa - _rr * _cc; vals_type _hn = - std::numeric_limits - ::infinity() ; + std::numeric_limits::infinity() ; real_type _tt[2] ; if (!math:: @@ -159,12 +162,12 @@ { /*-------------------------- test flow along boundary */ return EIKONAL_edge_2d ( - _p1, _h1, _gg, - _p3, _h3, _gg) + _p1, _h1, _g1, + _p3, _h3, _g3) | EIKONAL_edge_2d ( - _p2, _h2, _gg, - _p3, _h3, _gg) ; + _p2, _h2, _g2, + _p3, _h3, _g3) ; } else { @@ -257,8 +260,7 @@ _aa * _aa - _rr * _cc; vals_type _hn = - std::numeric_limits - ::infinity() ; + std::numeric_limits::infinity() ; real_type _tt[2] ; if (!math:: @@ -266,12 +268,12 @@ { /*-------------------------- test flow along boundary */ return EIKONAL_edge_3d ( - _p1, _h1, _gg, - _p3, _h3, _gg) + _p1, _h1, _g1, + _p3, _h3, _g3) | EIKONAL_edge_3d ( - _p2, _h2, _gg, - _p3, _h3, _gg) ; + _p2, _h2, _g2, + _p3, _h3, _g3) ; } else { @@ -327,6 +329,7 @@ __normal_call bool_type eikonal_edge_2d ( __const_ptr (real_type) _p1 , __const_ptr (real_type) _p2 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type _g1 , @@ -336,21 +339,23 @@ /*---------------------- limit h-values within EDGE-2 */ bool_type _clip = false ; - vals_type _h0 = std::min(_h1,_h2) ; - - if (_h2 > _h0) + if (_h2 > _hb) /*--------------------------------- 1st node ordering */ - if (EIKONAL_edge_2d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) - _clip = true ; - - if (_h1 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (EIKONAL_edge_2d ( + _p1, _h1, _g1 , + _p2, _h2, _g2 ) ) + _clip = true ; + + if (_h1 > _hb) /*--------------------------------- 2nd node ordering */ - if (EIKONAL_edge_2d ( - _p2, _h2, _g2 , - _p1, _h1, _g1 ) ) - _clip = true ; + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (EIKONAL_edge_2d ( + _p2, _h2, _g2 , + _p1, _h1, _g1 ) ) + _clip = true ; return ( _clip ) ; } @@ -362,6 +367,7 @@ __normal_call bool_type eikonal_edge_3d ( __const_ptr (real_type) _p1 , __const_ptr (real_type) _p2 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type _g1 , @@ -371,21 +377,23 @@ /*---------------------- limit h-values within EDGE-2 */ bool_type _clip = false ; - vals_type _h0 = std::min(_h1,_h2) ; - - if (_h2 > _h0) + if (_h2 > _hb) /*--------------------------------- 1st node ordering */ - if (EIKONAL_edge_3d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) - _clip = true ; - - if (_h1 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (EIKONAL_edge_3d ( + _p1, _h1, _g1 , + _p2, _h2, _g2 ) ) + _clip = true ; + + if (_h1 > _hb) /*--------------------------------- 2nd node ordering */ - if (EIKONAL_edge_3d ( - _p2, _h2, _g2 , - _p1, _h1, _g1 ) ) - _clip = true ; + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (EIKONAL_edge_3d ( + _p2, _h2, _g2 , + _p1, _h1, _g1 ) ) + _clip = true ; return ( _clip ) ; } @@ -398,6 +406,7 @@ __const_ptr (real_type) _p1 , __const_ptr (real_type) _p2 , __const_ptr (real_type) _p3 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type& _h3 , @@ -409,32 +418,38 @@ /*---------------------- limit h-values within TRIA-3 */ bool_type _clip = false ; - vals_type _h0 = - std::min( _h3, std::min(_h1,_h2)) ; - - if (_h3 > _h0) + if (_h3 > _hb) /*--------------------------------- 1st node ordering */ - if (EIKONAL_tria_2d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 , - _p3, _h3, _g3 ) ) - _clip = true ; - - if (_h1 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_2d ( + _p1, _h1, _g1 , + _p2, _h2, _g2 , + _p3, _h3, _g3 ) ) + _clip = true ; + + if (_h1 > _hb) /*--------------------------------- 2nd node ordering */ - if (EIKONAL_tria_2d ( - _p2, _h2, _g2 , - _p3, _h3, _g3 , - _p1, _h1, _g1 ) ) - _clip = true ; - - if (_h2 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_2d ( + _p2, _h2, _g2 , + _p3, _h3, _g3 , + _p1, _h1, _g1 ) ) + _clip = true ; + + if (_h2 > _hb) /*--------------------------------- 3rd node ordering */ - if (EIKONAL_tria_2d ( - _p3, _h3, _g3 , - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) - _clip = true ; + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_2d ( + _p3, _h3, _g3 , + _p1, _h1, _g1 , + _p2, _h2, _g2 ) ) + _clip = true ; return ( _clip ) ; } @@ -447,6 +462,7 @@ __const_ptr (real_type) _p1 , __const_ptr (real_type) _p2 , __const_ptr (real_type) _p3 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type& _h3 , @@ -458,32 +474,38 @@ /*---------------------- limit h-values within TRIA-3 */ bool_type _clip = false ; - vals_type _h0 = - std::min( _h3, std::min(_h1,_h2)) ; - - if (_h3 > _h0) + if (_h3 > _hb) /*--------------------------------- 1st node ordering */ - if (EIKONAL_tria_3d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 , - _p3, _h3, _g3 ) ) - _clip = true ; - - if (_h1 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_3d ( + _p1, _h1, _g1 , + _p2, _h2, _g2 , + _p3, _h3, _g3 ) ) + _clip = true ; + + if (_h1 > _hb) /*--------------------------------- 2nd node ordering */ - if (EIKONAL_tria_3d ( - _p2, _h2, _g2 , - _p3, _h3, _g3 , - _p1, _h1, _g1 ) ) - _clip = true ; - - if (_h2 > _h0) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_3d ( + _p2, _h2, _g2 , + _p3, _h3, _g3 , + _p1, _h1, _g1 ) ) + _clip = true ; + + if (_h2 > _hb) /*--------------------------------- 3rd node ordering */ - if (EIKONAL_tria_3d ( - _p3, _h3, _g3 , - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) - _clip = true ; + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (EIKONAL_tria_3d ( + _p3, _h3, _g3 , + _p1, _h1, _g1 , + _p2, _h2, _g2 ) ) + _clip = true ; return ( _clip ) ; } @@ -497,6 +519,7 @@ __const_ptr (real_type) _p2 , __const_ptr (real_type) _p3 , __const_ptr (real_type) _p4 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type& _h3 , @@ -520,20 +543,14 @@ { _okay = true ; /*--------------------------------- 1st tria ordering */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. && - _h3 >=(real_type)+0. ) if (eikonal_tria_2d ( - _p1, _p2, _p3 , + _p1, _p2, _p3 , _hb, _h1, _h2, _h3 , _g1, _g2, _g3 ) ) _clip = true ; - if (_h1 >=(real_type)+0. && - _h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_2d ( - _p1, _p3, _p4 , + _p1, _p3, _p4 , _hb, _h1, _h3, _h4 , _g1, _g3, _g4 ) ) _clip = true ; @@ -548,20 +565,14 @@ { _okay = true ; /*--------------------------------- 2nd tria ordering */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_2d ( - _p1, _p2, _p4 , + _p1, _p2, _p4 , _hb, _h1, _h2, _h4 , _g1, _g2, _g4 ) ) _clip = true ; - if (_h2 >=(real_type)+0. && - _h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_2d ( - _p2, _p3, _p4 , + _p2, _p3, _p4 , _hb, _h2, _h3, _h4 , _g2, _g3, _g4 ) ) _clip = true ; @@ -570,32 +581,90 @@ if (!_okay) { /*--------------------------------- a degenerate quad */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. ) - if (EIKONAL_edge_2d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (eikonal_edge_2d ( + _p1, _p2, _hb , + _h1, _h2, _g1 , _g2) ) _clip = true ; - if (_h2 >=(real_type)+0. && - _h3 >=(real_type)+0. ) - if (EIKONAL_edge_2d ( - _p2, _h2, _g2 , - _p3, _h3, _g3 ) ) + if (_h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (eikonal_edge_2d ( + _p2, _p3, _hb , + _h2, _h3, _g2 , _g3) ) _clip = true ; - if (_h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) - if (EIKONAL_edge_2d ( - _p3, _h3, _g3 , - _p4, _h4, _g4 ) ) + if (_h3 >=(vals_type)+0. && + _h4 >=(vals_type)+0. ) + if (eikonal_edge_2d ( + _p3, _p4, _hb , + _h3, _h4, _g3 , _g4) ) _clip = true ; - if (_h4 >=(real_type)+0. && - _h1 >=(real_type)+0. ) - if (EIKONAL_edge_2d ( - _p4, _h4, _g4 , - _p1, _h1, _g1 ) ) + if (_h4 >=(vals_type)+0. && + _h1 >=(vals_type)+0. ) + if (eikonal_edge_2d ( + _p4, _p1, _hb , + _h4, _h1, _g4 , _g1) ) + _clip = true ; + } + + return ( _clip ) ; + } + + template < + typename real_type , + typename vals_type + > + __normal_call bool_type eikonal_grid_2d ( + __const_ptr (real_type) _p1 , + __const_ptr (real_type) _p2 , + __const_ptr (real_type) _p3 , + __const_ptr (real_type) _p4 , + vals_type _hb , // current anchor + vals_type& _h1 , + vals_type& _h2 , + vals_type& _h3 , + vals_type& _h4 , + vals_type _g1 , + vals_type _g2 , + vals_type _g3 , + vals_type _g4 + ) + { + /*---------------------- limit h-values within GRID-4 */ + bool_type _clip = false ; + + if (true) + { + /*--------------------------------- 1st tria ordering */ + if (eikonal_tria_2d ( + _p1, _p2, _p3 , _hb, + _h1, _h2, _h3 , + _g1, _g2, _g3 ) ) + _clip = true ; + + if (eikonal_tria_2d ( + _p1, _p3, _p4 , _hb, + _h1, _h3, _h4 , + _g1, _g3, _g4 ) ) + _clip = true ; + } + + if (true) + { + /*--------------------------------- 2nd tria ordering */ + if (eikonal_tria_2d ( + _p1, _p2, _p4 , _hb, + _h1, _h2, _h4 , + _g1, _g2, _g4 ) ) + _clip = true ; + + if (eikonal_tria_2d ( + _p2, _p3, _p4 , _hb, + _h2, _h3, _h4 , + _g2, _g3, _g4 ) ) _clip = true ; } @@ -611,6 +680,7 @@ __const_ptr (real_type) _p2 , __const_ptr (real_type) _p3 , __const_ptr (real_type) _p4 , + vals_type _hb , // current anchor vals_type& _h1 , vals_type& _h2 , vals_type& _h3 , @@ -637,20 +707,14 @@ { _okay = true ; /*--------------------------------- 1st tria ordering */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. && - _h3 >=(real_type)+0. ) if (eikonal_tria_3d ( - _p1, _p2, _p3 , + _p1, _p2, _p3 , _hb, _h1, _h2, _h3 , _g1, _g2, _g3 ) ) _clip = true ; - if (_h1 >=(real_type)+0. && - _h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_3d ( - _p1, _p3, _p4 , + _p1, _p3, _p4 , _hb, _h1, _h3, _h4 , _g1, _g3, _g4 ) ) _clip = true ; @@ -668,20 +732,14 @@ { _okay = true ; /*--------------------------------- 2nd tria ordering */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_3d ( - _p1, _p2, _p4 , + _p1, _p2, _p4 , _hb, _h1, _h2, _h4 , _g1, _g2, _g4 ) ) _clip = true ; - if (_h2 >=(real_type)+0. && - _h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) if (eikonal_tria_3d ( - _p2, _p3, _p4 , + _p2, _p3, _p4 , _hb, _h2, _h3, _h4 , _g2, _g3, _g4 ) ) _clip = true ; @@ -690,32 +748,90 @@ if (!_okay) { /*--------------------------------- a degenerate quad */ - if (_h1 >=(real_type)+0. && - _h2 >=(real_type)+0. ) - if (EIKONAL_edge_3d ( - _p1, _h1, _g1 , - _p2, _h2, _g2 ) ) + if (_h1 >=(vals_type)+0. && + _h2 >=(vals_type)+0. ) + if (eikonal_edge_3d ( + _p1, _p2, _hb , + _h1, _h2, _g1 , _g2) ) + _clip = true ; + + if (_h2 >=(vals_type)+0. && + _h3 >=(vals_type)+0. ) + if (eikonal_edge_3d ( + _p2, _p3, _hb , + _h2, _h3, _g2 , _g3) ) + _clip = true ; + + if (_h3 >=(vals_type)+0. && + _h4 >=(vals_type)+0. ) + if (eikonal_edge_3d ( + _p3, _p4, _hb , + _h3, _h4, _g3 , _g4) ) + _clip = true ; + + if (_h4 >=(vals_type)+0. && + _h1 >=(vals_type)+0. ) + if (eikonal_edge_3d ( + _p4, _p1, _hb , + _h4, _h1, _g4 , _g1) ) + _clip = true ; + } + + return ( _clip ) ; + } + + template < + typename real_type , + typename vals_type + > + __normal_call bool_type eikonal_grid_3d ( + __const_ptr (real_type) _p1 , + __const_ptr (real_type) _p2 , + __const_ptr (real_type) _p3 , + __const_ptr (real_type) _p4 , + vals_type _hb , // current anchor + vals_type& _h1 , + vals_type& _h2 , + vals_type& _h3 , + vals_type& _h4 , + vals_type _g1 , + vals_type _g2 , + vals_type _g3 , + vals_type _g4 + ) + { + /*---------------------- limit h-values within GRID-4 */ + bool_type _clip = false ; + + if (true) + { + /*--------------------------------- 1st tria ordering */ + if (eikonal_tria_3d ( + _p1, _p2, _p3 , _hb, + _h1, _h2, _h3 , + _g1, _g2, _g3 ) ) _clip = true ; - if (_h2 >=(real_type)+0. && - _h3 >=(real_type)+0. ) - if (EIKONAL_edge_3d ( - _p2, _h2, _g2 , - _p3, _h3, _g3 ) ) + if (eikonal_tria_3d ( + _p1, _p3, _p4 , _hb, + _h1, _h3, _h4 , + _g1, _g3, _g4 ) ) _clip = true ; + } - if (_h3 >=(real_type)+0. && - _h4 >=(real_type)+0. ) - if (EIKONAL_edge_3d ( - _p3, _h3, _g3 , - _p4, _h4, _g4 ) ) + if (true) + { + /*--------------------------------- 2nd tria ordering */ + if (eikonal_tria_3d ( + _p1, _p2, _p4 , _hb, + _h1, _h2, _h4 , + _g1, _g2, _g4 ) ) _clip = true ; - if (_h4 >=(real_type)+0. && - _h1 >=(real_type)+0. ) - if (EIKONAL_edge_3d ( - _p4, _h4, _g4 , - _p1, _h1, _g1 ) ) + if (eikonal_tria_3d ( + _p2, _p3, _p4 , _hb, + _h2, _h3, _h4 , + _g2, _g3, _g4 ) ) _clip = true ; } @@ -731,6 +847,7 @@ __const_ptr (real_type) /*_p2*/ , __const_ptr (real_type) /*_p3*/ , __const_ptr (real_type) /*_p4*/ , + vals_type /*_hb*/ , // current anchor vals_type& /*_h1*/ , vals_type& /*_h2*/ , vals_type& /*_h3*/ , diff --git a/src/libcpp/interpolate/hfun_constant_value_k.hpp b/src/libcpp/interpolate/hfun_constant_value_k.hpp index bd9ac7c..362c093 100644 --- a/src/libcpp/interpolate/hfun_constant_value_k.hpp +++ b/src/libcpp/interpolate/hfun_constant_value_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 August, 2017 + * Last updated: 21 Aug., 2017 * * Copyright 2013-2017 * Darren Engwirda diff --git a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp index 37fe3aa..7eb5dce 100644 --- a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Mar., 2022 + * Last updated: 15 Jun., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -304,13 +308,11 @@ { /*-------------------- "LESS-THAN" operator for queue */ public : - typename - vals_list::_write_it _hptr; + typename vals_list::_write_it _hptr ; public : __inline_call less_than ( - typename - vals_list::_write_it _hsrc + typename vals_list::_write_it _hsrc ) : _hptr(_hsrc) {} __inline_call @@ -323,23 +325,20 @@ } } ; - typedef typename - allocator:: size_type uint_type ; - - uint_type static constexpr - _null = - std::numeric_limits::max() ; + size_t static constexpr _imax = + std::numeric_limits::max() ; - containers::prioritymap < + containers::priorityidx < + iptr_type , iptr_type , less_than , allocator > _sort((less_than(this->_hmat.head()))); - containers:: array < - typename - allocator:: size_type, - allocator > _keys; + /*-------------------- check matrix size against type */ + if (this->_hmat.count() >= _imax) + throw std::out_of_range( + "hfun.clip: data size limit exceeded"); /*-------------------- init. values for periodic bc's */ iptr_type IBEG = +0; @@ -375,10 +374,6 @@ } /*-------------------- push nodes onto priority queue */ - _keys.set_count ( - _hmat.count(), - containers::tight_alloc, _null) ; - { iptr_type _inum = +0; for (auto _iter = @@ -387,7 +382,7 @@ this->_hmat.tend() ; ++_iter , ++_inum) { - _keys[_inum] = _sort.push(_inum); + _sort.push(_inum, _inum ) ; } } @@ -433,12 +428,20 @@ } /*-------------------- compute h(x) via fast-marching */ + vals_type static constexpr + _FTOL = std::pow( + std::numeric_limits::epsilon(), .75) ; + + # define ISALIVE(__idx) \ + (_sort.keys(__idx) != _sort.null()) + + # define UPDATED(__new, __old) \ + std::abs(__new - __old) > _FTOL*std::abs(__new) + for ( ; !_sort.empty() ; ) { - iptr_type _base ; - _sort._pop_root(_base) ; - - _keys[_base] = _null ; + iptr_type _base, _bidx; + _sort._pop_root( _bidx, _base) ; iptr_type _ipos, _jpos ; subs_from_indx( @@ -488,6 +491,15 @@ _lpii, _lpjj, _lnod); /*-------------------- skip cells due to sorted order */ + if (_inod != _base && + !ISALIVE(_inod)) continue ; + if (_jnod != _base && + !ISALIVE(_jnod)) continue ; + if (_knod != _base && + !ISALIVE(_knod)) continue ; + if (_lnod != _base && + !ISALIVE(_lnod)) continue ; + vals_type _hmax; _hmax = this->_hmat[_inod] ; _hmax = std::max( @@ -562,9 +574,9 @@ if (this->_dhdx.count() >1) { /*-------------------- update adj. set, g = g(x) case */ - if (eikonal_quad_3d ( + if (eikonal_grid_3d ( _IXYZ , _JXYZ , - _KXYZ , _LXYZ , + _KXYZ , _LXYZ , _hnow , _inew , _jnew , _knew , _lnew , this->_dhdx[_inod], @@ -573,36 +585,39 @@ this->_dhdx[_lnod]) ) { - if (_keys[_inod] != _null) - if (_inew != _iold) + // push updates one-at-a-time to ensure heap + // maintains its sorted order + + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) { - _hmat[_inod] = _inew; - _sort.reduce( - _keys[_inod] , _inod) ; + _hmat[_inod] = _inew; + _sort.reduce(_inod , _inod) ; } - if (_keys[_jnod] != _null) - if (_knew != _jold) + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) { - _hmat[_jnod] = _jnew; - _sort.reduce( - _keys[_jnod] , _jnod) ; + _hmat[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; } - if (_keys[_knod] != _null) - if (_knew != _kold) + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) { - _hmat[_knod] = _knew; - _sort.reduce( - _keys[_knod] , _knod) ; + _hmat[_knod] = _knew; + _sort.reduce(_knod , _knod) ; } - if (_keys[_lnod] != _null) - if (_lnew != _lold) + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) { - _hmat[_lnod] = _lnew; - _sort.reduce( - _keys[_lnod] , _lnod) ; + _hmat[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; } if (this->_wrap) @@ -617,10 +632,10 @@ this->_hmat [_pair] = this->_hmat [_inod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_inod] != _iold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_jpjj==JEND) @@ -632,10 +647,10 @@ this->_hmat [_pair] = this->_hmat [_jnod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_jnod] != _jold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_kpjj==JEND) @@ -647,10 +662,10 @@ this->_hmat [_pair] = this->_hmat [_knod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_knod] != _kold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_lpjj==JBEG) @@ -662,10 +677,10 @@ this->_hmat [_pair] = this->_hmat [_lnod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_lnod] != _lold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } } @@ -675,9 +690,9 @@ if (this->_dhdx.count()==1) { /*-------------------- update adj. set, const. g case */ - if (eikonal_quad_3d ( + if (eikonal_grid_3d ( _IXYZ , _JXYZ , - _KXYZ , _LXYZ , + _KXYZ , _LXYZ , _hnow , _inew , _jnew , _knew , _lnew , this->_dhdx[ +0 ], @@ -686,36 +701,39 @@ this->_dhdx[ +0 ]) ) { - if (_keys[_inod] != _null) - if (_inew != _iold) + // push updates one-at-a-time to ensure heap + // maintains its sorted order + + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) { - _hmat[_inod] = _inew; - _sort.reduce( - _keys[_inod] , _inod) ; + _hmat[_inod] = _inew; + _sort.reduce(_inod , _inod) ; } - if (_keys[_jnod] != _null) - if (_knew != _jold) + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) { - _hmat[_jnod] = _jnew; - _sort.reduce( - _keys[_jnod] , _jnod) ; + _hmat[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; } - if (_keys[_knod] != _null) - if (_knew != _kold) + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) { - _hmat[_knod] = _knew; - _sort.reduce( - _keys[_knod] , _knod) ; + _hmat[_knod] = _knew; + _sort.reduce(_knod , _knod) ; } - if (_keys[_lnod] != _null) - if (_lnew != _lold) + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) { - _hmat[_lnod] = _lnew; - _sort.reduce( - _keys[_lnod] , _lnod) ; + _hmat[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; } if (this->_wrap) @@ -730,10 +748,10 @@ this->_hmat [_pair] = this->_hmat [_inod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_inod] != _iold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_jpjj==JEND) @@ -745,10 +763,10 @@ this->_hmat [_pair] = this->_hmat [_jnod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_jnod] != _jold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_kpjj==JEND) @@ -760,10 +778,10 @@ this->_hmat [_pair] = this->_hmat [_knod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_knod] != _kold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } if (_lpjj==JBEG) @@ -775,10 +793,10 @@ this->_hmat [_pair] = this->_hmat [_lnod] ; - if (_keys[_pair] != _null) + if (_sort. + keys(_pair) != _sort.null()) if (_hmat[_lnod] != _lold) - _sort.reduce( - _keys[_pair] , _pair) ; + _sort.reduce(_pair , _pair) ; } } @@ -789,6 +807,8 @@ } } + # undef ISALIVE + # undef UPDATED } /* @@ -896,8 +916,8 @@ } /*---------------------------- find enclosing x-range */ - iptr_type _ipos = (iptr_type) -1 ; - iptr_type _jpos = (iptr_type) -1 ; + auto _ipos = this-> null_hint() ; + auto _jpos = this-> null_hint() ; if (this->_xvar) { diff --git a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp index c7a1dcc..aca5467 100644 --- a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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. Feb, 2021 + * Last updated: 15 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -140,13 +144,11 @@ { /*-------------------- "LESS-THAN" operator for queue */ public : - typename - vals_list::_write_it _hptr; + typename vals_list::_write_it _hptr ; public : __inline_call less_than ( - typename - vals_list::_write_it _hsrc + typename vals_list::_write_it _hsrc ) : _hptr(_hsrc) {} __inline_call @@ -159,29 +161,14 @@ } } ; - typedef typename - allocator:: size_type uint_type ; - - uint_type static constexpr - _null = - std::numeric_limits::max() ; - - containers::prioritymap < + containers::priorityidx < + iptr_type , iptr_type , less_than , allocator > _sort((less_than(this->_hmat.head()))); - containers:: array < - typename - allocator:: size_type, - allocator > _keys; - /*-------------------- push nodes onto priority queue */ - _keys.set_count ( - _hmat.count(), - containers::tight_alloc, _null) ; - iptr_type _inum = +0; for (auto _iter = this->_hmat.head() ; @@ -189,10 +176,14 @@ this->_hmat.tend() ; ++_iter , ++_inum) { - _keys[_inum] = _sort.push (_inum) ; + _sort.push(_inum, _inum ) ; } /*-------------------- compute h(x) via fast-marching */ + vals_type static constexpr + _FTOL = std::pow( + std::numeric_limits::epsilon(), .75) ; + iptr_type IBEG = +0; iptr_type IEND = (iptr_type)this->_ypos.count() - 1 ; @@ -201,12 +192,16 @@ iptr_type JEND = (iptr_type)this->_xpos.count() - 1 ; + # define ISALIVE(__idx) \ + (_sort.keys(__idx) != _sort.null()) + + # define UPDATED(__new, __old) \ + std::abs(__new - __old) > _FTOL*std::abs(__new) + for ( ; !_sort.empty() ; ) { - iptr_type _base ; - _sort._pop_root(_base) ; - - _keys[_base] = _null ; + iptr_type _base, _bidx; + _sort._pop_root( _bidx, _base) ; iptr_type _ipos, _jpos ; subs_from_indx( @@ -253,17 +248,16 @@ indx_from_subs( _lpii, _lpjj, _lnod); - /*-------------------- skip any cells with null nodes */ - if (_keys[_inod] == _null && - _inod != _base) continue ; - if (_keys[_jnod] == _null && - _jnod != _base) continue ; - if (_keys[_knod] == _null && - _knod != _base) continue ; - if (_keys[_lnod] == _null && - _lnod != _base) continue ; - /*-------------------- skip cells due to sorted order */ + if (_inod != _base && + !ISALIVE(_inod)) continue ; + if (_jnod != _base && + !ISALIVE(_jnod)) continue ; + if (_knod != _base && + !ISALIVE(_knod)) continue ; + if (_lnod != _base && + !ISALIVE(_lnod)) continue ; + vals_type _hmax; _hmax = this->_hmat[_inod] ; _hmax = std::max( @@ -302,41 +296,63 @@ vals_type _lold = this->_hmat[_lnod] ; + vals_type _inew = + this->_hmat[_inod] ; + vals_type _jnew = + this->_hmat[_jnod] ; + vals_type _knew = + this->_hmat[_knod] ; + vals_type _lnew = + this->_hmat[_lnod] ; + if (this->_dhdx.count() >1) { /*-------------------- update adj. set, g = g(x) case */ - if (eikonal_quad_2d ( + if (eikonal_grid_2d ( _IXYZ , _JXYZ , - _KXYZ , _LXYZ , - this->_hmat[_inod], - this->_hmat[_jnod], - this->_hmat[_knod], - this->_hmat[_lnod], + _KXYZ , _LXYZ , _hnow , + _inew , _jnew , + _knew , _lnew , this->_dhdx[_inod], this->_dhdx[_jnod], this->_dhdx[_knod], this->_dhdx[_lnod]) ) { - if (_keys[_inod] != _null) - if (_hmat[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hmat[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hmat[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } - if (_keys[_knod] != _null) - if (_hmat[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hmat[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_lnod] != _null) - if (_hmat[_lnod] != _lold) - _sort.update( - _keys[_lnod] , _lnod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hmat[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } + + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) + { + _hmat[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; + } } } @@ -344,38 +360,51 @@ if (this->_dhdx.count()==1) { /*-------------------- update adj. set, const. g case */ - if (eikonal_quad_2d ( + if (eikonal_grid_2d ( _IXYZ , _JXYZ , - _KXYZ , _LXYZ , - this->_hmat[_inod], - this->_hmat[_jnod], - this->_hmat[_knod], - this->_hmat[_lnod], + _KXYZ , _LXYZ , _hnow , + _inew , _jnew , + _knew , _lnew , this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ]) ) { - if (_keys[_inod] != _null) - if (_hmat[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hmat[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hmat[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } + + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hmat[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_knod] != _null) - if (_hmat[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hmat[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } - if (_keys[_lnod] != _null) - if (_hmat[_lnod] != _lold) - _sort.update( - _keys[_lnod] , _lnod) ; + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) + { + _hmat[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; + } } } @@ -384,6 +413,8 @@ } } + # undef ISALIVE + # undef UPDATED } /* @@ -511,8 +542,8 @@ _YPOS = *this->_ypos.tail() ; /*---------------------------- find enclosing x-range */ - iptr_type _ipos = (iptr_type)-1 ; - iptr_type _jpos = (iptr_type)-1 ; + auto _ipos = this-> null_hint() ; + auto _jpos = this-> null_hint() ; if (this->_xvar == true) { diff --git a/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp b/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp index 1a30a67..a9445a9 100644 --- a/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp +++ b/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 Feb., 2021 + * Last updated: 15 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -291,10 +295,10 @@ _ZPOS = *this->_zpos.tail() ; /*---------------------------- find enclosing x-range */ - iptr_type _ipos = (iptr_type)-1 ; - iptr_type _jpos = (iptr_type)-1 ; - iptr_type _kpos = (iptr_type)-1 ; - + auto _ipos = this-> null_hint() ; + auto _jpos = this-> null_hint() ; + auto _kpos = this-> null_hint() ; + if (this->_xvar == true) { auto _joff = diff --git a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp index 753e374..9b56bac 100644 --- a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 31 Mar., 2021 + * Last updated: 15 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -306,13 +310,11 @@ { /*-------------------- "LESS-THAN" operator for queue */ public : - typename - vals_list::_write_it _hptr; + typename vals_list::_write_it _hptr ; public : __inline_call less_than ( - typename - vals_list::_write_it _hsrc + typename vals_list::_write_it _hsrc ) : _hptr(_hsrc) {} __inline_call @@ -325,32 +327,17 @@ } } ; - typedef typename - allocator:: size_type uint_type ; - - uint_type static constexpr - _null = - std::numeric_limits::max() ; - - containers::prioritymap < + containers::priorityidx < + iptr_type , iptr_type , less_than , allocator > _sort((less_than(this->_hval.head()))); - containers:: array < - typename - allocator:: size_type, - allocator > _keys; - typename mesh_type::connector _conn; /*-------------------- push nodes onto priority queue */ - _keys.set_count ( - _mesh.node().count() , - containers::tight_alloc, _null) ; - iptr_type _inum = +0; for (auto _iter = this->_mesh.node().head(); @@ -360,18 +347,25 @@ { if (_iter->mark() >= +0 ) { - _keys[_inum] = - _sort.push(_inum) ; + _sort.push(_inum, _inum) ; } } /*-------------------- compute h(x) via fast-marching */ + vals_type static constexpr + _FTOL = std::pow( + std::numeric_limits::epsilon(), .75) ; + + # define ISALIVE(__idx) \ + (_sort.keys(__idx) != _sort.null()) + + # define UPDATED(__new, __old) \ + std::abs(__new - __old) > _FTOL*std::abs(__new) + for ( ; !_sort.empty() ; ) { - iptr_type _base ; - _sort._pop_root(_base) ; - - _keys[_base] = _null ; + iptr_type _base, _bidx ; + _sort._pop_root( _bidx , _base); _conn.set_count( +0) ; this->_mesh. @@ -395,15 +389,14 @@ auto _knod = this-> _mesh. tri3( _cell).node(2); - /*-------------------- skip any cells with null nodes */ - if (_keys[_inod] == _null && - _inod != _base) continue ; - if (_keys[_jnod] == _null && - _jnod != _base) continue ; - if (_keys[_knod] == _null && - _knod != _base) continue ; - /*-------------------- skip cells due to sorted order */ + if (_inod != _base && + !ISALIVE(_inod)) continue ; + if (_jnod != _base && + !ISALIVE(_jnod)) continue ; + if (_knod != _base && + !ISALIVE(_knod)) continue ; + vals_type _hmax; _hmax = this->_hval[_inod] ; _hmax = std::max( @@ -421,6 +414,13 @@ vals_type _kold = this->_hval[_knod] ; + vals_type _inew = + this->_hval[_inod] ; + vals_type _jnew = + this->_hval[_jnod] ; + vals_type _knew = + this->_hval[_knod] ; + if (this->_dhdx.count() >1) { /*-------------------- update adj. set, g = g(x) case */ @@ -431,28 +431,39 @@ _mesh. node( _jnod).pval(0), &this-> _mesh. node( _knod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], + _hnow, + _inew, _jnew, _knew, this->_dhdx[_inod], this->_dhdx[_jnod], this->_dhdx[_knod]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } + + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } } } @@ -467,28 +478,39 @@ _mesh. node( _jnod).pval(0), &this-> _mesh. node( _knod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], + _hnow, + _inew, _jnew, _knew, this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } + + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } } } @@ -505,6 +527,8 @@ } } + # undef ISALIVE + # undef UPDATED } /* @@ -533,7 +557,8 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call @@ -593,16 +618,21 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr, + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + for ( ; _iptr != nullptr; _iptr = _iptr->_next) { diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp index f7b4876..3d04977 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 31 Mar., 2021 + * Last updated: 15 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -234,13 +238,11 @@ { /*-------------------- "LESS-THAN" operator for queue */ public : - typename - vals_list::_write_it _hptr; + typename vals_list::_write_it _hptr ; public : __inline_call less_than ( - typename - vals_list::_write_it _hsrc + typename vals_list::_write_it _hsrc ) : _hptr(_hsrc) {} __inline_call @@ -253,32 +255,17 @@ } } ; - typedef typename - allocator:: size_type uint_type ; - - uint_type static constexpr - _null = - std::numeric_limits::max() ; - - containers::prioritymap < + containers::priorityidx < + iptr_type , iptr_type , less_than , allocator > _sort((less_than(this->_hval.head()))); - containers:: array < - typename - allocator:: size_type, - allocator > _keys; - typename mesh_type::connector _conn; /*-------------------- push nodes onto priority queue */ - _keys.set_count ( - _mesh.node().count() , - containers::tight_alloc, _null) ; - iptr_type _inum = +0; for (auto _iter = this->_mesh.node().head(); @@ -288,18 +275,25 @@ { if (_iter->mark() >= +0 ) { - _keys[_inum] = - _sort.push(_inum) ; + _sort.push(_inum, _inum) ; } } /*-------------------- compute h(x) via fast-marching */ + vals_type static constexpr + _FTOL = std::pow( + std::numeric_limits::epsilon(), .75) ; + + # define ISALIVE(__idx) \ + (_sort.keys(__idx) != _sort.null()) + + # define UPDATED(__new, __old) \ + std::abs(__new - __old) > _FTOL*std::abs(__new) + for ( ; !_sort.empty() ; ) { - iptr_type _base ; - _sort._pop_root(_base) ; - - _keys[_base] = _null ; + iptr_type _base, _bidx ; + _sort._pop_root( _bidx , _base); _conn.set_count( +0) ; this->_mesh. @@ -323,15 +317,14 @@ auto _knod = this-> _mesh. tri3( _cell).node(2); - /*-------------------- skip any cells with null nodes */ - if (_keys[_inod] == _null && - _inod != _base) continue ; - if (_keys[_jnod] == _null && - _jnod != _base) continue ; - if (_keys[_knod] == _null && - _knod != _base) continue ; - /*-------------------- skip cells due to sorted order */ + if (_inod != _base && + !ISALIVE(_inod)) continue ; + if (_jnod != _base && + !ISALIVE(_jnod)) continue ; + if (_knod != _base && + !ISALIVE(_knod)) continue ; + vals_type _hmax; _hmax = this->_hval[_inod] ; _hmax = std::max( @@ -349,6 +342,13 @@ vals_type _kold = this->_hval[_knod] ; + vals_type _inew = + this->_hval[_inod] ; + vals_type _jnew = + this->_hval[_jnod] ; + vals_type _knew = + this->_hval[_knod] ; + if (this->_dhdx.count() >1) { /*-------------------- update adj. set, g = g(x) case */ @@ -359,28 +359,39 @@ _mesh. node( _jnod).pval(0), &this-> _mesh. node( _knod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], + _hnow, + _inew, _jnew, _knew, this->_dhdx[_inod], this->_dhdx[_jnod], this->_dhdx[_knod]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } + + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } } } @@ -395,28 +406,39 @@ _mesh. node( _jnod).pval(0), &this-> _mesh. node( _knod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], + _hnow, + _inew, _jnew, _knew, this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } + + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } } } @@ -433,6 +455,8 @@ } } + # undef ISALIVE + # undef UPDATED } /* @@ -461,7 +485,8 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call @@ -521,16 +546,21 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr, + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + for ( ; _iptr != nullptr; _iptr = _iptr->_next) { diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp index 80a12b7..6a9cf02 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 31 Mar., 2021 + * Last updated: 15 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -252,13 +256,11 @@ { /*-------------------- "LESS-THAN" operator for queue */ public : - typename - vals_list::_write_it _hptr; + typename vals_list::_write_it _hptr ; public : __inline_call less_than ( - typename - vals_list::_write_it _hsrc + typename vals_list::_write_it _hsrc ) : _hptr(_hsrc) {} __inline_call @@ -271,32 +273,17 @@ } } ; - typedef typename - allocator:: size_type uint_type ; - - uint_type static constexpr - _null = - std::numeric_limits::max() ; - - containers::prioritymap < + containers::priorityidx < + iptr_type , iptr_type , less_than , allocator > _sort((less_than(this->_hval.head()))); - containers:: array < - typename - allocator:: size_type, - allocator > _keys; - typename mesh_type::connector _conn; /*-------------------- push nodes onto priority queue */ - _keys.set_count ( - _mesh.node().count() , - containers::tight_alloc, _null) ; - iptr_type _inum = +0; for (auto _iter = this->_mesh.node().head(); @@ -306,18 +293,25 @@ { if (_iter->mark() >= +0 ) { - _keys[_inum] = - _sort.push(_inum) ; + _sort.push(_inum, _inum) ; } } /*-------------------- compute h(x) via fast-marching */ + vals_type static constexpr + _FTOL = std::pow( + std::numeric_limits::epsilon(), .75) ; + + # define ISALIVE(__idx) \ + (_sort.keys(__idx) != _sort.null()) + + # define UPDATED(__new, __old) \ + std::abs(__new - __old) > _FTOL*std::abs(__new) + for ( ; !_sort.empty() ; ) { - iptr_type _base ; - _sort._pop_root(_base) ; - - _keys[_base] = _null ; + iptr_type _base, _bidx ; + _sort._pop_root( _bidx , _base); _conn.set_count( +0) ; this->_mesh. @@ -343,17 +337,16 @@ auto _lnod = this-> _mesh. tri4( _cell).node(3); - /*-------------------- skip any cells with null nodes */ - if (_keys[_inod] == _null && - _inod != _base) continue ; - if (_keys[_jnod] == _null && - _jnod != _base) continue ; - if (_keys[_knod] == _null && - _knod != _base) continue ; - if (_keys[_lnod] == _null && - _lnod != _base) continue ; - /*-------------------- skip cells due to sorted order */ + if (_inod != _base && + !ISALIVE(_inod)) continue ; + if (_jnod != _base && + !ISALIVE(_jnod)) continue ; + if (_knod != _base && + !ISALIVE(_knod)) continue ; + if (_lnod != _base && + !ISALIVE(_lnod)) continue ; + vals_type _hmax; _hmax = this->_hval[_inod] ; _hmax = std::max( @@ -375,6 +368,15 @@ vals_type _lold = this->_hval[_lnod] ; + vals_type _inew = + this->_hval[_inod] ; + vals_type _jnew = + this->_hval[_jnod] ; + vals_type _knew = + this->_hval[_knod] ; + vals_type _lnew = + this->_hval[_lnod] ; + if (this->_dhdx.count() >1) { /*-------------------- update adj. set, g = g(x) case */ @@ -387,35 +389,48 @@ _mesh. node( _knod).pval(0), &this-> _mesh. node( _lnod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], - this->_hval[_lnod], + _hnow, + _inew, _jnew, _knew, _lnew , this->_dhdx[_inod], this->_dhdx[_jnod], this->_dhdx[_knod], this->_dhdx[_lnod]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_lnod] != _null) - if (_hval[_lnod] != _lold) - _sort.update( - _keys[_lnod] , _lnod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } + + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) + { + _hval[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; + } } } @@ -432,35 +447,48 @@ _mesh. node( _knod).pval(0), &this-> _mesh. node( _lnod).pval(0), - this->_hval[_inod], - this->_hval[_jnod], - this->_hval[_knod], - this->_hval[_lnod], + _hnow, + _inew, _jnew, _knew, _lnew , this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ], this->_dhdx[ +0 ]) ) { - if (_keys[_inod] != _null) - if (_hval[_inod] != _iold) - _sort.update( - _keys[_inod] , _inod) ; + // push updates one-at-a-time to ensure heap + // maintains its sorted order + + if (_sort. + keys(_inod) != _sort.null()) + if ( UPDATED(_inew, _iold) ) + { + _hval[_inod] = _inew; + _sort.reduce(_inod , _inod) ; + } - if (_keys[_jnod] != _null) - if (_hval[_jnod] != _jold) - _sort.update( - _keys[_jnod] , _jnod) ; + if (_sort. + keys(_jnod) != _sort.null()) + if ( UPDATED(_jnew, _jold) ) + { + _hval[_jnod] = _jnew; + _sort.reduce(_jnod , _jnod) ; + } - if (_keys[_knod] != _null) - if (_hval[_knod] != _kold) - _sort.update( - _keys[_knod] , _knod) ; + if (_sort. + keys(_knod) != _sort.null()) + if ( UPDATED(_knew, _kold) ) + { + _hval[_knod] = _knew; + _sort.reduce(_knod , _knod) ; + } - if (_keys[_lnod] != _null) - if (_hval[_lnod] != _lold) - _sort.update( - _keys[_lnod] , _lnod) ; + if (_sort. + keys(_lnod) != _sort.null()) + if ( UPDATED(_lnew, _lold) ) + { + _hval[_lnod] = _lnew; + _sort.reduce(_lnod , _lnod) ; + } } } @@ -477,6 +505,8 @@ } } + # undef ISALIVE + # undef UPDATED } /* @@ -505,7 +535,8 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call @@ -565,16 +596,21 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( -1) {} + _tpos( + hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename + tree_type::node_type *_lptr, + typename tree_type::item_data *_iptr ) { if (this->_find) return +0. ; + __unreferenced(_lptr); + for ( ; _iptr != nullptr; _iptr = _iptr->_next) { diff --git a/src/libcpp/iter_mesh/_bfs_mesh_2.inc b/src/libcpp/iter_mesh/_bfs_mesh_2.inc new file mode 100644 index 0000000..7141940 --- /dev/null +++ b/src/libcpp/iter_mesh/_bfs_mesh_2.inc @@ -0,0 +1,283 @@ + + /* + -------------------------------------------------------- + * _BFS-MESH-2: breadth-first-search mesh flips. + -------------------------------------------------------- + * + * 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: 10 Jun., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * FLIP-SIGN: flip cells for +ve iter. cost fn. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type flip_next ( + mesh_type &_mesh, + conn_list &_list, + iptr_type _icel, + iptr_type *_inod, + mark_list &_seen, + conn_list &_conn + ) + { + /*------------------------- flip to match cell "sign" */ + _conn.set_count(0) ; + _mesh.connect_2( + _inod, EDGE2_tag, _conn); + + if (_conn.count() != 2) return; + + iptr_type _jcel, _jfac; + char_type _kind; + if ((iptr_type) + _conn[0]._cell == _icel) + { + _jcel = _conn[ 1]._cell ; + _kind = _conn[ 1]._kind ; + } + else + { + _jcel = _conn[ 0]._cell ; + _kind = _conn[ 0]._kind ; + } + + /*------------------------- match indexing along edge */ + if (_kind == TRIA3_tag) + { + if (_seen._tri3[_jcel] == +0) + { + _list.push_tail(typename + conn_list::data_type(_jcel, _kind)) ; + + _seen._tri3[_jcel] = +1; + + iptr_type _jnod[3] ; + for(_jfac = 3 ; _jfac-- != 0; ) + { + mesh_type::tri3_type:: + face_node(_jnod, _jfac, 2, 1) ; + _jnod[ 0] = _mesh. + tri3(_jcel).node(_jnod[0]) ; + _jnod[ 1] = _mesh. + tri3(_jcel).node(_jnod[1]) ; + _jnod[ 2] = _mesh. + tri3(_jcel).node(_jnod[2]) ; + + if (_jnod[ 2] != _inod[ 0]) + if (_jnod[ 2] != _inod[ 1]) + break ; + } + + if (_jnod[ 0] == _inod[ 0] && + _jnod[ 1] == _inod[ 1]) + { + std::swap ( + _mesh.tri3(_jcel).node( 0), + _mesh.tri3(_jcel).node( 1)) ; + } + } + } + else + if (_kind == QUAD4_tag) + { + if (_seen._quad[_jcel] == +0) + { + _list.push_tail(typename + conn_list::data_type(_jcel, _kind)) ; + + _seen._quad[_jcel] = +1; + + // TODO: reverse quad indexes + } + } + } + + __static_call + __normal_call void_type flip_bfs_ ( + mesh_type &_mesh, + conn_list &_list, + mark_list &_seen + ) + { + conn_list _conn; + for ( ; !_list.empty() ; ) + { + /*------------------------- flip via BFS on cell adj. */ + typename conn_list::data_type _cell ; + _list._pop_tail(_cell) ; + + if (_cell._kind == TRIA3_tag) + { + for(auto _enum = +3; _enum-- != +0; ) + { + auto _cpos = _cell._cell; + + iptr_type _enod[3] ; + mesh_type::tri3_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.tri3( + _cpos).node( _enod[ 0]) ; + _enod[ 1] = _mesh.tri3( + _cpos).node( _enod[ 1]) ; + + flip_next( _mesh, _list, + _cpos, _enod, _seen, _conn) ; + } + } + else + if (_cell._kind == QUAD4_tag) + { + for(auto _enum = +4; _enum-- != +0; ) + { + auto _cpos = _cell._cell; + + iptr_type _enod[4] ; + mesh_type::quad_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.quad( + _cpos).node( _enod[ 0]) ; + _enod[ 1] = _mesh.quad( + _cpos).node( _enod[ 1]) ; + + flip_next( _mesh, _list, + _cpos, _enod, _seen, _conn) ; + } + } + } + } + + __static_call + __normal_call void_type flip_sign ( + mesh_type &_mesh + ) + { + # define SEENTRI3( _CELL) _seen._tri3[_CELL] + # define SEENQUAD( _CELL) _seen._quad[_CELL] + + conn_list _list; + mark_list _seen; + init_mark(_mesh, _seen, +0) ; + + /*------------------------- flip to correct mesh sign */ + iptr_type _tnum = +0 ; + for (auto _tria = _mesh.tri3().head(); + _tria != _mesh.tri3().tend(); + ++_tria, ++_tnum ) + { + if (_tria->mark () < +0) continue; + if (SEENTRI3(_tnum) > +0) continue; + + /*--------------------- flip seed for +ve quality */ + real_type _cost = + pred_type::tri3_cost ( + &_mesh. node( + _tria->node(0)).pval(0), + &_mesh. node( + _tria->node(1)).pval(0), + &_mesh. node( + _tria->node(2)).pval(0), + typename + pred_type::cell_kind()) ; + + if (_cost < (real_type) +0.) + { + std::swap ( + _tria->node(0), + _tria->node(1)) ; + } + + /*--------------------- a BFS from seed via topo. */ + _list.push_tail(typename conn_list + ::data_type (_tnum, TRIA3_tag)) ; + + SEENTRI3( _tnum ) = 1 ; + + flip_bfs_(_mesh, _list, _seen) ; + } + + iptr_type _qnum = +0 ; + for (auto _quad = _mesh.quad().head(); + _quad != _mesh.quad().tend(); + ++_quad, ++_qnum ) + { + if (_quad->mark () < +0) continue; + if (SEENQUAD(_qnum) > +0) continue; + + /*--------------------- flip seed for +ve quality */ + real_type _cost = + pred_type::quad_cost ( + &_mesh. node( + _quad->node(0)).pval(0), + &_mesh. node( + _quad->node(1)).pval(0), + &_mesh. node( + _quad->node(2)).pval(0), + &_mesh. node( + _quad->node(3)).pval(0), + typename + pred_type::cell_kind()) ; + + if (_cost < (real_type) +0.) + { + // TODO: reverse quad indexes + } + + /*--------------------- a BFS from seed via topo. */ + _list.push_tail(typename conn_list + ::data_type (_qnum, QUAD4_tag)) ; + + SEENQUAD( _qnum ) = 1 ; + + flip_bfs_(_mesh, _list, _seen) ; + } + + # undef SEENQUAD + # undef SEENTRI3 + } + + + diff --git a/src/libcpp/iter_mesh/_zip_mesh_2.inc b/src/libcpp/iter_mesh/_zip_mesh_2.inc new file mode 100644 index 0000000..52c6d96 --- /dev/null +++ b/src/libcpp/iter_mesh/_zip_mesh_2.inc @@ -0,0 +1,642 @@ + + /* + -------------------------------------------------------- + * _ZIP-MESH-2: merge/split operations. + -------------------------------------------------------- + * + * 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: 11 Dec., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * _ZIP-MESH: edge merge/split operations. + -------------------------------------------------------- + */ + + #include "iter_zips_2.inc" + #include "iter_divs_2.inc" + + __static_call + __normal_call void_type _zip_fcel ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + char_type _kern , + real_list &_hval , // cached node spacing array + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _imrk , // outer iteration marker + iter_opts &_opts , // user options + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iptr_type &_nzip , // number of successful zip's + iptr_type &_ndiv , // number of successful div's + iter_stat &_tcpu // CPU timers/info + ) + { + class sort_data + { + public : + /*------------------------ tuple for edge re-ordering */ + iptr_type _inod , _jnod , + _knod ; + float _cost ; + public : + __inline_call sort_data ( + iptr_type _isrc , + iptr_type _jsrc , + iptr_type _ksrc , + float _csrc + ) : _inod(_isrc), _jnod(_jsrc), + _knod(_ksrc), + _cost(_csrc) {} + } ; + class sort_less + { + public : + /*------------------------ less-than op. for cost-tup */ + __inline_call + bool_type operator () ( + sort_data const&_idat , + sort_data const&_jdat + ) const + { return _idat._cost < _jdat._cost; + } + } ; + + # define MARKNODE(_NODE) _mark._node[_NODE] + + # define PUSHMARK \ + init_mark( _mesh, _mark, \ + std::max(_imrk - 1, +0)); \ + if (std::abs( \ + _mark._node[_nnew])!= _imrk+1) \ + { \ + if (_mark._node[_nnew] >= +0) \ + { \ + _mark._node[_nnew] = +_imrk+1; \ + } \ + else \ + { \ + _mark._node[_nnew] = -_imrk-1; \ + } \ + _nset.push_tail(_nnew) ; \ + } \ + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*------------------------ add/pop nodes to fix topo. */ + typedef containers:: + array sort_list ; + + __unreferenced ( _DLIM ); + + sort_list _sort ; + conn_list _iadj , _jadj, _kadj ; + conn_list _conn , _cset; + conn_list _iset , _jset, _kset ; + real_list _qold , _qnew, _qtmp ; + + _nzip = +0 ; _ndiv = +0 ; + + // assemble list of faces attached to "recent" nodes + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + _sort.set_alloc( + _mesh.tri3().count()) ; + + for (auto _iter = _mesh.tri3().head() ; + _iter != _mesh.tri3().tend() ; + ++_iter ) + { + auto _inod = _iter->node(0) ; + auto _jnod = _iter->node(1) ; + auto _knod = _iter->node(2) ; + + auto _iptr = _mesh. + node().head()+_iter->node(0) ; + auto _jptr = _mesh. + node().head()+_iter->node(1) ; + auto _kptr = _mesh. + node().head()+_iter->node(2) ; + + auto _flag = _imrk - 2 ; // recent + + if (_iter->mark() >= +0 && + ( std::abs( + _mark._node[_inod]) > _flag || + std::abs( + _mark._node[_jnod]) > _flag || + std::abs( + _mark._node[_knod]) > _flag )) + { + float _area = + (float)pred_type::tri3_mass ( + & _iptr->pval(0) , + & _jptr->pval(0) , + & _kptr->pval(0) ) ; + + auto _ndeg = _iptr->ndeg() + + _jptr->ndeg() + + _kptr->ndeg() ; + + _area *= (float) _ndeg; + + _sort.push_tail( + sort_data( + _inod, _jnod, _knod, _area)) ; + } + } + + if (_sort.empty()) return ; + + algorithms::qsort( // sort edge list by lsqr + _sort.head() , + _sort.tend() , sort_less()); + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_zips += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + // scan cells largest-to-smallest and try to div any + // unvisited cells + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _iter = _sort.tail(); + _iter != _sort.hend(); + --_iter ) + { + /*--------------------------- try to "div" local edge */ + iptr_type _tadj, _tnod[3] ; + _tnod[0] = _iter->_inod; + _tnod[1] = _iter->_jnod; + _tnod[2] = _iter->_knod; + + if (MARKNODE(_tnod[0]) < +0 && + MARKNODE(_tnod[1]) < +0 && + MARKNODE(_tnod[2]) < +0 ) continue ; + + if (MARKNODE(_tnod[0])>_imrk|| + MARKNODE(_tnod[1])>_imrk|| + MARKNODE(_tnod[2])>_imrk) continue ; + + if(!_mesh.find_tri3( + _tnod, _tadj) ) continue ; + + if (_opts.div_()) + { + /*--------------------------- "div" for topo. + score */ + iptr_type _nnew = -1; + + bool_type _move = false ; + // _div_tri3( ... + + if (_move) + { + PUSHMARK; _ndiv += +1; + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_divs += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + // scan cells smallest-to-largest and try to zip any + // unvisited cells + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _iter = _sort.head(); + _iter != _sort.tend(); + ++_iter ) + { + /*--------------------------- try to "zip" local edge */ + iptr_type _tadj, _tnod[3] ; + _tnod[0] = _iter->_inod; + _tnod[1] = _iter->_jnod; + _tnod[2] = _iter->_knod; + + if (MARKNODE(_tnod[0]) < +0 || + MARKNODE(_tnod[1]) < +0 || + MARKNODE(_tnod[2]) < +0 ) continue ; + + if (MARKNODE(_tnod[0])>_imrk|| + MARKNODE(_tnod[1])>_imrk|| + MARKNODE(_tnod[2])>_imrk) continue ; + + if(!_mesh.find_tri3( + _tnod, _tadj) ) continue ; + + if (_opts.zip_()) + { + /*--------------------------- "zip" for topo. + score */ + iptr_type _nnew = -1; + + bool_type _move = false ; + _zip_tri3( _geom, _mesh, + _hfun, _hval, _opts, + _mark. _node, + _imrk, _tadj, + _kern, _move, _nnew, + _iset, _jset, _kset, + _iadj, _jadj, _kadj, + _cset, _qold, _qnew, + _qtmp, _QLIM, _tcpu) ; + + if (_move) + { + PUSHMARK; _nzip += +1; + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_zips += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + # undef PUSHMARK + # undef MARKNODE + } + + __static_call + __normal_call void_type _zip_ecel ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + char_type _kern , + real_list &_hval , // cached node spacing array + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _imrk , // outer iteration marker + iter_opts &_opts , // user options + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iptr_type &_nzip , // number of successful zip's + iptr_type &_ndiv , // number of successful div's + iter_stat &_tcpu // CPU timers/info + ) + { + class sort_data + { + public : + /*------------------------ tuple for edge re-ordering */ + iptr_type _inod ; + iptr_type _jnod ; + float _cost ; + public : + __inline_call sort_data ( + iptr_type _isrc , + iptr_type _jsrc , + float _csrc + ) : _inod(_isrc), _jnod(_jsrc), + _cost(_csrc) {} + } ; + class sort_less + { + public : + /*------------------------ less-than op. for cost-tup */ + __inline_call + bool_type operator () ( + sort_data const&_idat , + sort_data const&_jdat + ) const + { return _idat._cost < _jdat._cost; + } + } ; + + # define MARKNODE(_NODE) _mark._node[_NODE] + + # define PUSHMARK \ + init_mark( _mesh, _mark, \ + std::max(_imrk - 1, +0)); \ + if (std::abs( \ + _mark._node[_nnew])!= _imrk+1) \ + { \ + if (_mark._node[_nnew] >= +0) \ + { \ + _mark._node[_nnew] = +_imrk+1; \ + } \ + else \ + { \ + _mark._node[_nnew] = -_imrk-1; \ + } \ + _nset.push_tail(_nnew) ; \ + } \ + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*------------------------ add/pop nodes to fix topo. */ + typedef containers:: + array sort_list ; + + __unreferenced ( _DLIM ); + + sort_list _sort ; + conn_list _aset , _bset, _cset ; + conn_list _conn , _iset, _jset ; + real_list _qold , _qnew, _qtmp ; + + _nzip = +0 ; _ndiv = +0 ; + + // assemble list of edges attached to "recent" nodes + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + _sort.set_alloc( + _mesh.edge().count()) ; + + for (auto _iter = _mesh.edge().head() ; + _iter != _mesh.edge().tend() ; + ++_iter ) + { + auto _inod = _iter->node(0) ; + auto _jnod = _iter->node(1) ; + + auto _iptr = _mesh. + node().head()+_iter->node(0) ; + auto _jptr = _mesh. + node().head()+_iter->node(1) ; + + auto _flag = _imrk - 2 ; // recent + + if (_iter->mark() >= +0 && + ( std::abs( + _mark._node[_inod]) > _flag || + std::abs( + _mark._node[_jnod]) > _flag )) + { + float _lsqr = + (float)pred_type::length_sq ( + & _iptr->pval(0) , + & _jptr->pval(0) ) ; + + auto _ndeg = _iptr->ndeg() + + _jptr->ndeg() ; + + _lsqr *= (float) _ndeg; + + _sort.push_tail( + sort_data(_inod, _jnod, _lsqr)) ; + } + } + + if (_sort.empty()) return ; + + algorithms::qsort( // sort edge list by lsqr + _sort.head() , + _sort.tend() , sort_less()); + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_zips += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + // scan edges longest-to-shortest and try to div any + // unvisited edges + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _iter = _sort.tail(); + _iter != _sort.hend(); + --_iter ) + { + /*--------------------------- try to "div" local edge */ + iptr_type _eadj, _enod[2] ; + _enod[0] = _iter->_inod; + _enod[1] = _iter->_jnod; + + if (MARKNODE(_enod[0]) < +0 && + MARKNODE(_enod[1]) < +0 ) continue ; + + if (MARKNODE(_enod[0])>_imrk|| + MARKNODE(_enod[1])>_imrk) continue ; + + if(!_mesh.find_edge( + _enod, _eadj) ) continue ; + + if (_opts.div_()) + { + /*--------------------------- "div" for topo. + score */ + iptr_type _nnew = -1; + + bool_type _move = false ; + _div_edge( _geom, _mesh, + _hfun, _hval, _opts, + _imrk, _eadj, + _kern, _move, _nnew, + _iset, _jset, + _aset, _bset, + _qold, _qnew, + _qtmp, _QLIM, _tcpu) ; + + if (_move) + { + PUSHMARK; _ndiv += +1; + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_divs += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + // scan edges shortest-to-longest and try to zip any + // unvisited edges + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _iter = _sort.head(); + _iter != _sort.tend(); + ++_iter ) + { + /*--------------------------- try to "zip" local edge */ + iptr_type _eadj, _enod[2] ; + _enod[0] = _iter->_inod; + _enod[1] = _iter->_jnod; + + if (MARKNODE(_enod[0]) < +0 || + MARKNODE(_enod[1]) < +0 ) continue ; + + if (MARKNODE(_enod[0])>_imrk|| + MARKNODE(_enod[1])>_imrk) continue ; + + if(!_mesh.find_edge( + _enod, _eadj) ) continue ; + + if (_opts.zip_()) + { + /*--------------------------- "zip" for topo. + score */ + iptr_type _nnew = -1; + + bool_type _move = false ; + _zip_edge( _geom, _mesh, + _hfun, _hval, _opts, + _mark. _node, + _imrk, _eadj, + _kern, _move, _nnew, + _iset, _jset, + _aset, _bset, _cset, + _qold, _qnew, + _qtmp, _QLIM, _tcpu) ; + + if (_move) + { + PUSHMARK; _nzip += +1; + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_zips += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + # undef PUSHMARK + # undef MARKNODE + } + + __static_call + __normal_call void_type _zip_mesh ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + char_type _kern , + real_list &_hval , // cached node spacing array + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _imrk , // outer iteration marker + iter_opts &_opts , // user options + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iptr_type &_nzip , // number of successful zip's + iptr_type &_ndiv , // number of successful div's + iter_stat &_tcpu // CPU timers/info + ) + { + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*--------------------- zip//div topo. cell hierarchy */ + _zip_fcel( _geom, _mesh, _hfun, + _kern, _hval, + _nset, _mark, _imrk, + _opts, _QLIM, _DLIM, + _nzip, _ndiv, _tcpu) ; + + _zip_ecel( _geom, _mesh, _hfun, + _kern, _hval, + _nset, _mark, _imrk, + _opts, _QLIM, _DLIM, + _nzip, _ndiv, _tcpu) ; + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _iter = _mark._node.head() ; + _iter != _mark._node.tend() ; + ++_iter ) + { + /*--------------------- undo local inc. on node flags */ + if (*_iter > + _imrk) + *_iter = + _imrk; + else + if (*_iter < - _imrk) + *_iter = - _imrk; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_zips += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + } + + + diff --git a/src/libcpp/iter_mesh/cost_mesh_2.inc b/src/libcpp/iter_mesh/cost_mesh_2.inc new file mode 100644 index 0000000..2266099 --- /dev/null +++ b/src/libcpp/iter_mesh/cost_mesh_2.inc @@ -0,0 +1,293 @@ + + /* + -------------------------------------------------------- + * COST-MESH-2: utilities to manip. cell cost vectors. + -------------------------------------------------------- + * + * 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: 10 Jun., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * MOVE-OKAY: TRUE if state sufficiently good. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type move_okay ( + real_list &_cdst , // list of new adj. costs + real_list &_csrc , // list of old adj. costs + iptr_type &_move , // > +0 if move acceptable + real_type _good = +9.25E-01, + real_type _qtol = +1.00E-04, + real_type _xdel = +0.00E+00, + real_type _xtol = + std::numeric_limits::infinity() + ) + { + _move = (iptr_type) -1; + + if (_cdst.empty()) return ; + if (_csrc.empty()) return ; + + /*--------------------- calc. min. + mean metrics */ + real_type _zero = + +std::numeric_limits + ::epsilon (); + real_type _0src = + +std::numeric_limits + ::infinity(); + real_type _0dst = + +std::numeric_limits + ::infinity(); + + /*--------------------- compute harmonic averages */ + _good = std::pow(_good, +7./8.); + + real_type _msrc, _mdst; + _msrc = (real_type) +0. ; + _mdst = (real_type) +0. ; + + for (auto _iter = _csrc.head(), + _tend = _csrc.tend(); + _iter != _tend; + ++_iter ) + { + _0src = + std::min(_0src, *_iter) ; + + _msrc += std::pow( + (real_type)1. / *_iter, +8); + } + for (auto _iter = _cdst.head(), + _tend = _cdst.tend(); + _iter != _tend; + ++_iter ) + { + _0dst = + std::min(_0dst, *_iter) ; + + _mdst += std::pow ( + (real_type)1. / *_iter, +8); + } + + _msrc = std::pow( + _csrc.count() / _msrc, +1./8.0); + _mdst = std::pow( + _cdst.count() / _mdst, +1./8.0); + + _qtol /= + std::pow(_csrc.count(), 1./8.0); + _qtol /= + std::pow(_cdst.count(), 1./8.0); + + /*---------------------------- test move = "okay" */ + if (_0dst >= _good) + { + /*--------------------- okay if moves unconverged */ + if (_xdel > _xtol) + _move = +1; + else + _move = +0; // no iter; too short + + if (_move > +0) return ; + } + + if (_0dst >= _zero) + { + /*--------------------- okay if mean is improving */ + if (_mdst > _msrc+_qtol) + _move = +1; + + if (_move > +0) return ; + } + + } + + /* + -------------------------------------------------------- + * LOOP-COST: cost vector for 1-neighbourhood. + -------------------------------------------------------- + */ + + __static_call + __normal_call real_type loop_cost ( + mesh_type &_mesh , // mesh object + conn_list &_cset , // list of adj. cells + real_list &_cost , // list of adj. costs + cell_kind const& // cell costs on CSET + ) + { + real_type _qmin = (real_type)1. ; + + for (auto _next = _cset.head() , + _tend = _cset.tend() ; + _next != _tend; + ++_next ) + { + real_type _cscr = (real_type)+1. ; + + iptr_type _cell = _next->_cell ; + iptr_type _kind = _next->_kind ; + + switch (_kind) + { + case TRIA3_tag: + { + _cscr = pred_type::tri3_cost ( + &_mesh .node( + _mesh .tri3( + _cell).node(0)).pval(0), + &_mesh .node( + _mesh .tri3( + _cell).node(1)).pval(0), + &_mesh .node( + _mesh .tri3( + _cell).node(2)).pval(0), + typename + pred_type::cell_kind ()) ; + break ; + } + + case QUAD4_tag: + { + _cscr = pred_type::quad_cost ( + &_mesh .node( + _mesh .quad( + _cell).node(0)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(1)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(2)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(3)).pval(0), + typename + pred_type::cell_kind ()) ; + break ; + } + } + + _qmin = + std::min (_qmin, _cscr) ; + + _cost.push_tail (_cscr) ; + } + + return ( _qmin ) ; + } + + __static_call + __normal_call real_type loop_cost ( + mesh_type &_mesh , // mesh object + conn_list &_cset , // list of adj. cells + real_list &_cost , // list of adj. costs + dual_kind const& // dual costs on CSET + ) + { + real_type _qmin = (real_type)1. ; + + for (auto _next = _cset.head() , + _tend = _cset.tend() ; + _next != _tend; + ++_next ) + { + real_type _cscr = (real_type)+1. ; + + iptr_type _cell = _next->_cell ; + iptr_type _kind = _next->_kind ; + + switch (_kind) + { + case TRIA3_tag: + { + _cscr = pred_type::tri3_cost ( + &_mesh .node( + _mesh .tri3( + _cell).node(0)).pval(0), + &_mesh .node( + _mesh .tri3( + _cell).node(1)).pval(0), + &_mesh .node( + _mesh .tri3( + _cell).node(2)).pval(0), + typename + pred_type::dual_kind ()) ; + break ; + } + + case QUAD4_tag: + { + _cscr = pred_type::quad_cost ( + &_mesh .node( + _mesh .quad( + _cell).node(0)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(1)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(2)).pval(0), + &_mesh .node( + _mesh .quad( + _cell).node(3)).pval(0), + typename + pred_type::dual_kind ()) ; + break ; + } + } + + _qmin = + std::min (_qmin, _cscr) ; + + _cost.push_tail (_cscr) ; + } + + return ( _qmin ) ; + } + + + diff --git a/src/libcpp/iter_mesh/flip_mesh_2.inc b/src/libcpp/iter_mesh/flip_mesh_2.inc new file mode 100644 index 0000000..e569c08 --- /dev/null +++ b/src/libcpp/iter_mesh/flip_mesh_2.inc @@ -0,0 +1,523 @@ + + /* + -------------------------------------------------------- + * FLIP-MESH-2: update mesh topologies. + -------------------------------------------------------- + * + * 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: 11 Jun., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * FLIP-TRI3: "flip" mesh topology. + -------------------------------------------------------- + */ + + __static_call + __inline_call void_type flip_tri3 ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + iptr_list &_nmrk , // sets of node/cell flags + iptr_type _cell , // cell to flip + bool_type &_flip , // true if flip + conn_list &_conn , // space for adj. lists + conn_list &_next , // space for adj. lists + real_list &_qold , // list of old adj. costs + real_list &_qnew , // list of new adj. costs + flip_kind _kind + ) + { + auto _coin = (std::rand() % 3) + 1 ; + for (auto _enum = _coin; _enum-- > 0; ) + { + _flip = false ; + /*----------------------------- flip cells about edge */ + iptr_type _enod[3] ; + mesh_type::tri3_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.tri3( + _cell).node( _enod[ 0]) ; + _enod[ 1] = _mesh.tri3( + _cell).node( _enod[ 1]) ; + + _conn.set_count(0) ; + _next.set_count(0) ; + _mesh.connect_2( + &_enod[0], EDGE2_tag, _conn) ; + + if (_conn.count() != +2) continue ; + + if (_conn[0]._kind==TRIA3_tag && + _conn[1]._kind==TRIA3_tag ) + { + flip_t2t2( _geom, _mesh, _nmrk, _enod, + _conn, _next, _flip, + _qold, _qnew, _kind) ; + + if (_flip) return ; + } + else + { + // flip_t1q1( _geom, _mesh, _nmrk, _enod, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + } + + for (auto _enum = 3; _enum-- > _coin; ) + { + _flip = false ; + /*----------------------------- flip cells about edge */ + iptr_type _enod[3] ; + mesh_type::tri3_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.tri3( + _cell).node( _enod[ 0]) ; + _enod[ 1] = _mesh.tri3( + _cell).node( _enod[ 1]) ; + + _conn.set_count(0) ; + _next.set_count(0) ; + _mesh.connect_2( + &_enod[0], EDGE2_tag, _conn) ; + + if (_conn.count() != +2) continue ; + + if (_conn[0]._kind==TRIA3_tag && + _conn[1]._kind==TRIA3_tag ) + { + flip_t2t2( _geom, _mesh, _nmrk, _enod, + _conn, _next, _flip, + _qold, _qnew, _kind) ; + + if (_flip) return ; + } + else + { + // flip_t1q1( _geom, _mesh, _nmrk, _enod, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + } + + } + + /* + -------------------------------------------------------- + * FLIP-QUAD: "flip" mesh topology. + -------------------------------------------------------- + */ + + __static_call + __inline_call void_type flip_quad ( + geom_type/*_geom*/ ,// geometry object + mesh_type &_mesh , // mesh object + iptr_list/*_nmrk*/ ,// sets of node/cell flags + iptr_type _cell , // cell to flip + bool_type &_flip , // true if flip + conn_list &_conn , // space for adj. lists + conn_list &_next , // space for adj. lists + real_list/*_qold*/ ,// list of old adj. costs + real_list/*_qnew*/ ,// list of new adj. costs + flip_kind/*_kind*/ + ) + { + auto _coin = (std::rand() % 4) + 1 ; + for (auto _enum = _coin; _enum-- > 0; ) + { + _flip = false ; + /*----------------------------- flip cells about edge */ + iptr_type _enod[4] ; + mesh_type::quad_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.quad( + _cell).node( _enod[ 0]) ; + _enod[ 1] = _mesh.quad( + _cell).node( _enod[ 1]) ; + + _conn.set_count(0) ; + _next.set_count(0) ; + _mesh.connect_2( + &_enod[0], EDGE2_tag, _conn) ; + + if (_conn.count() != +2) continue ; + + if (_conn[0]._kind==QUAD4_tag && + _conn[1]._kind==QUAD4_tag ) + { + // flip_q2q2( _geom, _mesh, _enod, _nmrk, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + else + { + // flip_t1q1( _geom, _mesh, _enod, _nmrk, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + } + + for (auto _enum = 4; _enum-- > _coin; ) + { + _flip = false ; + /*----------------------------- flip cells about edge */ + iptr_type _enod[4] ; + mesh_type::quad_type:: + face_node(_enod, _enum, +2, +1) ; + _enod[ 0] = _mesh.quad( + _cell).node( _enod[ 0]) ; + _enod[ 1] = _mesh.quad( + _cell).node( _enod[ 1]) ; + + _conn.set_count(0) ; + _next.set_count(0) ; + _mesh.connect_2( + &_enod[0], EDGE2_tag, _conn) ; + + if (_conn.count() != +2) continue ; + + if (_conn[0]._kind==QUAD4_tag && + _conn[1]._kind==QUAD4_tag ) + { + // flip_q2q2( _geom, _mesh, _enod, _nmrk, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + else + { + // flip_t1q1( _geom, _mesh, _enod, _nmrk, + // _conn, _next, _flip, + // _qold, _qnew, _kind) ; + + if (_flip) return ; + } + } + + } + + /* + -------------------------------------------------------- + * FLIP-MESH: "flip" mesh topology. + -------------------------------------------------------- + */ + + #include "iter_flip_2.inc" + + __static_call + __normal_call void_type flip_mesh ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _imrk , // outer iteration marker + iptr_type &_nflp , // number of successful flips + iter_stat &_tcpu // CPU timers/info + ) + { + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + # define MARKTRI3(_CELL) \ + _mark._tri3[_CELL->_cell] + + # define MARKQUAD(_CELL) \ + _mark._quad[_CELL->_cell] + + _nflp = (iptr_type) +0 ; + + init_mark(_mesh, + _mark, std::max(+0 , _imrk - 1) ) ; + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + /*--------------------- init. flip stack as ADJ(NSET) */ + conn_list _flip, _conn ; + for (auto _iter = _nset.head(); + _iter != _nset.tend(); + ++_iter ) + { + if (_mesh.node(*_iter).mark() >= 0) + { + _conn.set_count(0); + _mesh.connect_2( + &*_iter, POINT_tag, _conn) ; + + for (auto _cell = _conn.head(); + _cell != _conn.tend(); + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + if (MARKTRI3( _cell ) != _imrk) + { + MARKTRI3( _cell ) = _imrk ; + + _flip.push_tail( *_cell) ; + } + } + else + if (_cell->_kind == QUAD4_tag) + { + if (MARKQUAD( _cell ) != _imrk) + { + MARKQUAD( _cell ) = _imrk ; + + _flip.push_tail( *_cell) ; + } + } + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_flip + += _tcpu.time_span (_ttic, _ttoc) ; + # endif//__use_timers + + flip_core(_geom, _mesh, _hfun, _flip, _mark, + _nflp,_tcpu) ; + + # undef MARKQUAD + # undef MARKTRI3 + } + + __static_call + __normal_call void_type flip_mesh ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + conn_sets &_CONN , // cached node adj. indexing + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _imrk , // outer iteration marker + iptr_type &_nflp , // number of successful flips + iter_stat &_tcpu // CPU timers/info + ) + { + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + # define MARKTRI3(_CELL) \ + _mark._tri3[_CELL->_cell] + + # define MARKQUAD(_CELL) \ + _mark._quad[_CELL->_cell] + + _nflp = (iptr_type) +0 ; + + init_mark(_mesh, + _mark, std::max(+0 , _imrk - 1) ) ; + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + /*--------------------- init. flip stack as ADJ(NSET) */ + conn_list _flip ; + for (auto _iter = _nset.head(); + _iter != _nset.tend(); + ++_iter ) + { + if (_mesh.node(*_iter).mark() >= 0) + { + for (auto _cell = + _CONN._adj2.head()+_CONN._idx2[*_iter+0] ; + _cell != + _CONN._adj2.head()+_CONN._idx2[*_iter+1] ; + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + if (MARKTRI3( _cell ) != _imrk) + { + MARKTRI3( _cell ) = _imrk ; + + _flip.push_tail( *_cell) ; + } + } + else + if (_cell->_kind == QUAD4_tag) + { + if (MARKQUAD( _cell ) != _imrk) + { + MARKQUAD( _cell ) = _imrk ; + + _flip.push_tail( *_cell) ; + } + } + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_flip + += _tcpu.time_span (_ttic, _ttoc) ; + # endif//__use_timers + + flip_core(_geom, _mesh, _hfun, _flip, _mark, + _nflp,_tcpu) ; + + # undef MARKQUAD + # undef MARKTRI3 + } + + __static_call + __normal_call void_type flip_core ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + conn_list &_flip , // list of cells to flip + mark_list &_mark , // sets of node/cell flags + iptr_type &_nflp , // number of successful flips + iter_stat &_tcpu // CPU timers/info + ) + { + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + __unreferenced(_hfun) ; + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + /*--------------------- exhaustive, incremental flips */ + conn_list _next, _conn, _CONN; + real_list _qold, _qnew ; + for ( ; !_flip.empty() ; ) + { + for (auto _cell = _flip.head(); + _cell != _flip.tend(); + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + if ( _mesh. + tri3(_cell->_cell).mark() >= +0) + { + bool_type _okay = false ; + flip_tri3( _geom, _mesh, + _mark. _node, + _cell->_cell, + _okay, _conn, _CONN, + _qold, _qnew, + (flip_kind)laguerre_flip) ; + + if (_okay) _nflp += +1 ; + + _next.push_tail( + _CONN.head(), _CONN.tend()); + } + } + else + if (_cell->_kind == QUAD4_tag) + { + if ( _mesh. + quad(_cell->_cell).mark() >= +0) + { + bool_type _okay = false ; + flip_quad( _geom, _mesh, + _mark. _node, + _cell->_cell, + _okay, _conn, _CONN, + _qold, _qnew, + (flip_kind)laguerre_flip) ; + + if (_okay) _nflp += +1 ; + + _next.push_tail( + _CONN.head(), _CONN.tend()); + } + } + } + _flip = std::move (_next) ; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_flip += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + } + + + diff --git a/src/libcpp/iter_mesh/iter_divs_2.inc b/src/libcpp/iter_mesh/iter_divs_2.inc index 481628b..0e8ca03 100644 --- a/src/libcpp/iter_mesh/iter_divs_2.inc +++ b/src/libcpp/iter_mesh/iter_divs_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 Sept., 2021 + * Last updated: 11 Jun., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -52,29 +56,29 @@ __static_call __normal_call void_type _div_edge ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - real_list &_hval , - iter_opts &_opts , - iptr_type _iout , - iptr_type _enum , - kern_kind _kern , - bool_type &_okay , - iptr_type &_inew , - conn_list &_cset , - conn_list &_cnew , - conn_list &_iset , - conn_list &_jset , - real_list &_qsrc , - real_list &_qdst , - real_list &_qtmp , - real_type _QLIM , - iter_stat &_tcpu , - real_type _lmin - = (real_type) +1.00E+00 , - real_type _qinc - = (real_type) +1.00E-02 + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + iter_opts &_opts , // user options + iptr_type _iout , // outer iteration marker + iptr_type _enum , // edge number to div. + kern_kind _kern , // optim. kernel selector + bool_type &_okay , // TRUE if div. successful + iptr_type &_inew , // new node index added + conn_list &_cset , // space for adj. cells + conn_list &_cnew , // space for adj. cells + conn_list &_iset , // space for adj. cells + conn_list &_jset , // space for adj. cells + real_list &_qsrc , // space for adj. costs + real_list &_qdst , // space for adj. costs + real_list &_qtmp , // space for adj. costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu , // cpu timers/info + real_type _lmin // div. spacing threshold + = (real_type) +1.000E+00 , + real_type _qinc // div. quality threshold + = (real_type) +3.333E-03 ) { iptr_type static constexpr @@ -176,39 +180,42 @@ real_type static constexpr _lBIG = (real_type)+1.375 ; - iptr_type static constexpr - _dMAX = (iptr_type)+3 ; - - real_type _lmax = - _lBIG *std::pow( _iout , +1./8.) ; + real_type _lmax = // no oscl. wrt. zip + _lBIG *std::pow( _iout , +1./4.) ; - if (_lsqr >= _hbar * _lmax * // no oscl. wrt. zip + if (_lsqr >= _hbar * _lmax * _hbar * _lmax ) { // if more regular geom. is constructed via the edge // div, make it easier to do so! - _qinc = (real_type)(+0.50 * + _qinc = (real_type)(1./2. * (_hbar / std::sqrt(_lsqr) - 1.0)) ; } else - if (_ierr >= _dMAX || _jerr >= _dMAX) + if ( _ierr >= 2 || _jerr >= 2 ) { // try to reduce large vertex valence via refinement - _qinc = (real_type) -0.25 ; - _qinc/= std::pow ( _iout , +1./8.) ; + real_type _qerr = (real_type) -1./16. ; + _qerr*= std::max (_ierr, _jerr ) ; + _qerr/= std::pow (_iout, +1./2.) ; // stop oscl. + _qinc = std::min (_qinc, + _qinc + _qerr) ; } else - if (_ierr > 0 && _jerr > 0 && - (_ierr + _jerr) >= _dMAX) + if ( _ierr > 0 && _jerr > 0 && + (_ierr + _jerr) >= 3 ) { // try to reduce large vertex valence via refinement - _qinc = (real_type) -.125 ; - _qinc/= std::pow ( _iout , +1./8.) ; + real_type _qerr = (real_type) -1./16. ; + _qerr*= std::max (_ierr, _jerr ) ; + _qerr/= std::pow (_iout, +1./2.) ; // stop oscl. + _qinc = std::min (_qinc, + _qinc + _qerr) ; } else @@ -361,7 +368,10 @@ /*--------------------------------- optim. node coord */ iptr_type static - constexpr _INUM = (iptr_type) +2; + constexpr _INUM = (iptr_type) +4; + + real_type _prev[_last + 1] = + {(real_type)+0.}; iptr_type _move = -1; for (auto _iloc = +0; _iloc != _INUM; @@ -377,9 +387,9 @@ move_node( _geom, _mesh, _hfun, _hval, - _opts, _nptr, _kern, - _move, _cnew, - _qtmp, _qdst, + _opts, _nptr, _prev, + _kern, _move, _cnew, + _qtmp, _qdst, _minC, _QLIM, _tcpu) ; if (_move <= +0 ) break; diff --git a/src/libcpp/iter_mesh/iter_divs_3.inc b/src/libcpp/iter_mesh/iter_divs_3.inc index 5eba1ae..5d557d5 100644 --- a/src/libcpp/iter_mesh/iter_divs_3.inc +++ b/src/libcpp/iter_mesh/iter_divs_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda @@ -41,7 +45,7 @@ -------------------------------------------------------- */ - // from iter_mesh_2.hpp + // from iter_mesh_3.hpp /* diff --git a/src/libcpp/iter_mesh/iter_dual_2.inc b/src/libcpp/iter_mesh/iter_dual_2.inc index a0592cf..f7da6ce 100644 --- a/src/libcpp/iter_mesh/iter_dual_2.inc +++ b/src/libcpp/iter_mesh/iter_dual_2.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 Jan., 2022 + * Last updated: 11 Jun., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -61,7 +65,9 @@ real_type _COST , real_type _STEP , real_type _SAVE , - real_type &_DQDW + real_type &_DQDW , + real_type &_dmin , + real_type &_dmax ) { iptr_type static constexpr @@ -79,7 +85,7 @@ /*------------------ local iter. on finite-diff. step */ real_type _wdel = _WINC * _STEP; - real_type _dsup , _dsdn ; + real_type _dsup , _dsdn , _dqdw; { /*------------------ centred finite-diff. for dQ / dw */ _ppos[_last] = _SAVE + _wdel; @@ -119,8 +125,14 @@ /*------------------ finalise gradient and accumulate */ if (_dsup * _dsdn > (real_type)0.) - _DQDW += - (real_type)+.5 * (_dsup + _dsdn) ; + { + _dqdw = +.5 * (_dsup + _dsdn) ; + + _DQDW += _dqdw ; + + _dmin = std::min(_dmin, _dqdw) ; + _dmax = std::max(_dmax, _dqdw) ; + } } /* @@ -140,7 +152,9 @@ real_type _COST , real_type _STEP , real_type _SAVE , - real_type &_DQDW + real_type &_DQDW , + real_type &_dmin , + real_type &_dmax ) { iptr_type static constexpr @@ -158,7 +172,7 @@ /*------------------ local iter. on finite-diff. step */ real_type _wdel = _WINC * _STEP; - real_type _dsup , _dsdn ; + real_type _dsup , _dsdn , _dqdw; { /*------------------ centred finite-diff. for dQ / dw */ _ppos[_last] = _SAVE + _wdel; @@ -202,8 +216,14 @@ /*------------------ finalise gradient and accumulate */ if (_dsup * _dsdn > (real_type)0.) - _DQDW += - (real_type)+.5 * (_dsup + _dsdn) ; + { + _dqdw = +.5 * (_dsup + _dsdn) ; + + _DQDW += _dqdw ; + + _dmin = std::min(_dmin, _dqdw) ; + _dmax = std::max(_dmax, _dqdw) ; + } } /* @@ -313,21 +333,16 @@ { dqdw_tri3_k(_mesh, _cell, _node , _COST, _wadj, _SAVE, - _DQDW ) ; + _DQDW , _dmin, _dmax) ; } else if (_kind == QUAD4_tag) { dqdw_quad_k(_mesh, _cell, _node , _COST, _wadj, _SAVE, - _DQDW ) ; + _DQDW , _dmin, _dmax) ; } - _dmax = - std::max(_dmax, _DQDW) ; - _dmin = - std::min(_dmin, _DQDW) ; - _qlow += _COST ; _lnum += +1 ; } else @@ -336,11 +351,11 @@ } } - if (_dmax * - _dmin < (real_type) +0. ) - _DQDW = (real_type) +0. ; + if (_dmin * + _dmax <=(real_type) +0. ) // check monotone? + _DQDW =(real_type) +0. ; - if (_nnum > +0) + if (_nnum != +0) { _DQDW /= _lnum ; _qlow /= _lnum ; diff --git a/src/libcpp/iter_mesh/iter_dual_3.inc b/src/libcpp/iter_mesh/iter_dual_3.inc index 5d85728..8f13909 100644 --- a/src/libcpp/iter_mesh/iter_dual_3.inc +++ b/src/libcpp/iter_mesh/iter_dual_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/iter_flip_2.inc b/src/libcpp/iter_mesh/iter_flip_2.inc index b706f0c..2008705 100644 --- a/src/libcpp/iter_mesh/iter_flip_2.inc +++ b/src/libcpp/iter_mesh/iter_flip_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -446,203 +450,5 @@ _mesh.push_tri3(_tdat), TRIA3_tag)) ; } - /* - -------------------------------------------------------- - * FLIP-TRI3: "flip" mesh topology. - -------------------------------------------------------- - */ - - __static_call - __inline_call void_type flip_tri3 ( - geom_type &_geom , - mesh_type &_mesh , - iptr_list &_nmrk , - iptr_type _cell , - bool_type &_flip , - conn_list &_conn , - conn_list &_next , - real_list &_qold , - real_list &_qnew , - flip_kind _kind - ) - { - auto _coin = (std::rand() % 3) + 1 ; - for (auto _enum = _coin; _enum-- > 0; ) - { - _flip = false ; - /*----------------------------- flip cells about edge */ - iptr_type _enod[3] ; - mesh_type::tri3_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.tri3( - _cell).node( _enod[ 0]) ; - _enod[ 1] = _mesh.tri3( - _cell).node( _enod[ 1]) ; - - _conn.set_count(0) ; - _next.set_count(0) ; - _mesh.connect_2( - &_enod[0], EDGE2_tag, _conn) ; - - if (_conn.count() != +2) continue ; - - if (_conn[0]._kind==TRIA3_tag && - _conn[1]._kind==TRIA3_tag ) - { - flip_t2t2( _geom, _mesh, _nmrk, _enod, - _conn, _next, _flip, - _qold, _qnew, _kind) ; - - if (_flip) return ; - } - else - { - // flip_t1q1( _geom, _mesh, _nmrk, _enod, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - } - - for (auto _enum = 3; _enum-- > _coin; ) - { - _flip = false ; - /*----------------------------- flip cells about edge */ - iptr_type _enod[3] ; - mesh_type::tri3_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.tri3( - _cell).node( _enod[ 0]) ; - _enod[ 1] = _mesh.tri3( - _cell).node( _enod[ 1]) ; - - _conn.set_count(0) ; - _next.set_count(0) ; - _mesh.connect_2( - &_enod[0], EDGE2_tag, _conn) ; - - if (_conn.count() != +2) continue ; - - if (_conn[0]._kind==TRIA3_tag && - _conn[1]._kind==TRIA3_tag ) - { - flip_t2t2( _geom, _mesh, _nmrk, _enod, - _conn, _next, _flip, - _qold, _qnew, _kind) ; - - if (_flip) return ; - } - else - { - // flip_t1q1( _geom, _mesh, _nmrk, _enod, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - } - - } - - /* - -------------------------------------------------------- - * FLIP-QUAD: "flip" mesh topology. - -------------------------------------------------------- - */ - - __static_call - __inline_call void_type flip_quad ( - geom_type &/*_geom*/ , - mesh_type &_mesh , - iptr_list &_nmrk , - iptr_type _cell , - bool_type &_flip , - conn_list &_conn , - conn_list &_next , - real_list &/*_qold*/ , - real_list &/*_qnew*/ , - flip_kind /*_kind*/ - ) - { - auto _coin = (std::rand() % 4) + 1 ; - for (auto _enum = _coin; _enum-- > 0; ) - { - _flip = false ; - /*----------------------------- flip cells about edge */ - iptr_type _enod[4] ; - mesh_type::quad_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.quad( - _cell).node( _enod[ 0]) ; - _enod[ 1] = _mesh.quad( - _cell).node( _enod[ 1]) ; - - _conn.set_count(0) ; - _next.set_count(0) ; - _mesh.connect_2( - &_enod[0], EDGE2_tag, _conn) ; - - if (_conn.count() != +2) continue ; - - if (_conn[0]._kind==QUAD4_tag && - _conn[1]._kind==QUAD4_tag ) - { - // flip_q2q2( _geom, _mesh, _enod, _nmrk, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - else - { - // flip_t1q1( _geom, _mesh, _enod, _nmrk, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - } - - for (auto _enum = 4; _enum-- > _coin; ) - { - _flip = false ; - /*----------------------------- flip cells about edge */ - iptr_type _enod[4] ; - mesh_type::quad_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.quad( - _cell).node( _enod[ 0]) ; - _enod[ 1] = _mesh.quad( - _cell).node( _enod[ 1]) ; - - _conn.set_count(0) ; - _next.set_count(0) ; - _mesh.connect_2( - &_enod[0], EDGE2_tag, _conn) ; - - if (_conn.count() != +2) continue ; - - if (_conn[0]._kind==QUAD4_tag && - _conn[1]._kind==QUAD4_tag ) - { - // flip_q2q2( _geom, _mesh, _enod, _nmrk, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - else - { - // flip_t1q1( _geom, _mesh, _enod, _nmrk, - // _conn, _next, _flip, - // _qold, _qnew, _kind) ; - - if (_flip) return ; - } - } - - } - - + diff --git a/src/libcpp/iter_mesh/iter_flip_3.inc b/src/libcpp/iter_mesh/iter_flip_3.inc index 5fea529..8ad2b57 100644 --- a/src/libcpp/iter_mesh/iter_flip_3.inc +++ b/src/libcpp/iter_mesh/iter_flip_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/iter_mesh_2.hpp b/src/libcpp/iter_mesh/iter_mesh_2.hpp index 9df7924..55397dc 100644 --- a/src/libcpp/iter_mesh/iter_mesh_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_2.hpp @@ -22,19 +22,24 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 05 Jun., 2022 + * Last updated: 12 Dec., 2022 * * Copyright 2013-2022 - * Darren Engwirda + * Darren Engwirda, + * Marc Tunnell * d.engwirda@gmail.com * https://github.com/dengwirda/ * @@ -110,9 +115,7 @@ real_type , iptr_type > iter_opts ; - typedef mesh::iter_timers < - real_type , - iptr_type > iter_stat ; + typedef mesh::iter_timers iter_stat ; typedef containers ::array< iptr_type > iptr_list ; @@ -121,1956 +124,114 @@ typedef containers ::array< real_type > real_list ; - class mark_list // integer cell markers - { - public : - iptr_list _node; - iptr_list _edge; - iptr_list _tri3; - iptr_list _quad; - } ; - - typedef typename - mesh_type::connector conn_list ; - - class conn_sets - { - public : - conn_list _adj1; - uint_list _idx1; - conn_list _adj2; - uint_list _idx2; - } ; - - public : - - /* - -------------------------------------------------------- - * FLIP-SIGN: flip cells for +ve iter. cost fn. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type flip_next ( - mesh_type &_mesh, - conn_list &_list, - iptr_type _icel, - iptr_type *_inod, - mark_list &_seen, - conn_list &_conn - ) - { - /*------------------------- flip to match cell "sign" */ - _conn.set_count(0) ; - _mesh.connect_2( - _inod, EDGE2_tag, _conn); - - if (_conn.count() != 2) return; - - iptr_type _jcel, _jfac; - char_type _kind; - if ((iptr_type) - _conn[0]._cell == _icel) - { - _jcel = _conn[ 1]._cell ; - _kind = _conn[ 1]._kind ; - } - else - { - _jcel = _conn[ 0]._cell ; - _kind = _conn[ 0]._kind ; - } - - /*------------------------- match indexing along edge */ - if (_kind == TRIA3_tag) - { - if (_seen._tri3[_jcel] == +0) - { - _list.push_tail(typename - conn_list::data_type(_jcel, _kind)) ; - - _seen._tri3[_jcel] = +1; - - iptr_type _jnod[3] ; - for(_jfac = 3 ; _jfac-- != 0; ) - { - mesh_type::tri3_type:: - face_node(_jnod, _jfac, 2, 1) ; - _jnod[ 0] = _mesh. - tri3(_jcel).node(_jnod[0]) ; - _jnod[ 1] = _mesh. - tri3(_jcel).node(_jnod[1]) ; - _jnod[ 2] = _mesh. - tri3(_jcel).node(_jnod[2]) ; - - if (_jnod[ 2] != _inod[ 0]) - if (_jnod[ 2] != _inod[ 1]) - break ; - } - - if (_jnod[ 0] == _inod[ 0] && - _jnod[ 1] == _inod[ 1]) - { - std::swap ( - _mesh.tri3(_jcel).node( 0), - _mesh.tri3(_jcel).node( 1)) ; - } - } - } - else - if (_kind == QUAD4_tag) - { - if (_seen._quad[_jcel] == +0) - { - _list.push_tail(typename - conn_list::data_type(_jcel, _kind)) ; - - _seen._quad[_jcel] = +1; - - // TODO: reverse quad indexes - } - } - } - - __static_call - __normal_call void_type flip_bfs_ ( - mesh_type &_mesh, - conn_list &_list, - mark_list &_seen - ) - { - conn_list _conn; - for ( ; !_list.empty() ; ) - { - /*------------------------- flip via BFS on cell adj. */ - typename conn_list::data_type _cell ; - _list._pop_tail(_cell) ; - - if (_cell._kind == TRIA3_tag) - { - for(auto _enum = +3; _enum-- != +0; ) - { - auto _cpos = _cell._cell; - - iptr_type _enod[3] ; - mesh_type::tri3_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.tri3( - _cpos).node( _enod[ 0]) ; - _enod[ 1] = _mesh.tri3( - _cpos).node( _enod[ 1]) ; - - flip_next( _mesh, _list, - _cpos, _enod, _seen, _conn) ; - } - } - else - if (_cell._kind == QUAD4_tag) - { - for(auto _enum = +4; _enum-- != +0; ) - { - auto _cpos = _cell._cell; - - iptr_type _enod[4] ; - mesh_type::quad_type:: - face_node(_enod, _enum, +2, +1) ; - _enod[ 0] = _mesh.quad( - _cpos).node( _enod[ 0]) ; - _enod[ 1] = _mesh.quad( - _cpos).node( _enod[ 1]) ; - - flip_next( _mesh, _list, - _cpos, _enod, _seen, _conn) ; - } - } - } - } - - __static_call - __normal_call void_type flip_sign ( - mesh_type &_mesh - ) - { - # define SEENTRI3( _CELL) _seen._tri3[_CELL] - # define SEENQUAD( _CELL) _seen._quad[_CELL] - - conn_list _list; - mark_list _seen; - init_mark(_mesh, _seen, +0) ; - - /*------------------------- flip to correct mesh sign */ - iptr_type _tnum = +0 ; - for (auto _tria = _mesh.tri3().head(); - _tria != _mesh.tri3().tend(); - ++_tria, ++_tnum ) - { - if (_tria->mark () < +0) continue; - if (SEENTRI3(_tnum) > +0) continue; - - /*--------------------- flip seed for +ve quality */ - real_type _cost = - pred_type::tri3_cost ( - &_mesh. node( - _tria->node(0)).pval(0), - &_mesh. node( - _tria->node(1)).pval(0), - &_mesh. node( - _tria->node(2)).pval(0), - typename - pred_type::cell_kind()) ; - - if (_cost < (real_type) +0.) - { - std::swap ( - _tria->node(0), - _tria->node(1)) ; - } - - /*--------------------- a BFS from seed via topo. */ - _list.push_tail(typename conn_list - ::data_type (_tnum, TRIA3_tag)) ; - - SEENTRI3( _tnum ) = 1 ; - - flip_bfs_(_mesh, _list, _seen) ; - } - - iptr_type _qnum = +0 ; - for (auto _quad = _mesh.quad().head(); - _quad != _mesh.quad().tend(); - ++_quad, ++_qnum ) - { - if (_quad->mark () < +0) continue; - if (SEENQUAD(_qnum) > +0) continue; - - /*--------------------- flip seed for +ve quality */ - real_type _cost = - pred_type::quad_cost ( - &_mesh. node( - _quad->node(0)).pval(0), - &_mesh. node( - _quad->node(1)).pval(0), - &_mesh. node( - _quad->node(2)).pval(0), - &_mesh. node( - _quad->node(3)).pval(0), - typename - pred_type::cell_kind()) ; - - if (_cost < (real_type) +0.) - { - // TODO: reverse quad indexes - } - - /*--------------------- a BFS from seed via topo. */ - _list.push_tail(typename conn_list - ::data_type (_qnum, QUAD4_tag)) ; - - SEENQUAD( _qnum ) = 1 ; - - flip_bfs_(_mesh, _list, _seen) ; - } - # undef SEENQUAD - # undef SEENTRI3 - } - - /* - -------------------------------------------------------- - * MOVE-OKAY: TRUE if state sufficiently good. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type move_okay ( - real_list &_cdst , - real_list &_csrc , - iptr_type &_move , - real_type _good = +9.25E-01, - real_type _qtol = +1.00E-04, - real_type _xdel = +0.00E+00, - real_type _xtol = - std::numeric_limits::infinity() - ) - { - _move = (iptr_type) -1; - - if (_cdst.empty()) return ; - if (_csrc.empty()) return ; - - /*--------------------- calc. min. + mean metrics */ - real_type _zero = - +std::numeric_limits - ::epsilon (); - real_type _0src = - +std::numeric_limits - ::infinity(); - real_type _0dst = - +std::numeric_limits - ::infinity(); - - /*--------------------- compute harmonic averages */ - _good = std::pow(_good, +7./8.); - - real_type _msrc, _mdst; - _msrc = (real_type) +0. ; - _mdst = (real_type) +0. ; - - for (auto _iter = _csrc.head(), - _tend = _csrc.tend(); - _iter != _tend; - ++_iter ) - { - _0src = - std::min(_0src, *_iter) ; - - _msrc += std::pow( - (real_type)1. / *_iter, +7); - } - for (auto _iter = _cdst.head(), - _tend = _cdst.tend(); - _iter != _tend; - ++_iter ) - { - _0dst = - std::min(_0dst, *_iter) ; - - _mdst += std::pow ( - (real_type)1. / *_iter, +7); - } - - _msrc = std::pow( - _csrc.count() / _msrc, +1./7.0); - _mdst = std::pow( - _cdst.count() / _mdst, +1./7.0); - - _qtol /= - std::pow(_csrc.count(), 1./7.0); - _qtol /= - std::pow(_cdst.count(), 1./7.0); - - /*---------------------------- test move = "okay" */ - if (_0dst >= _good) - { - /*--------------------- okay if moves unconverged */ - if (_xdel > _xtol) - _move = +1; - else - _move = +0; // no iter; too short - - if (_move > +0) return ; - } - - if (_0dst >= _zero) - { - /*--------------------- okay if mean is improving */ - if (_mdst > _msrc+_qtol) - _move = +1; - - if (_move > +0) return ; - } - - } - - /* - -------------------------------------------------------- - * LOOP-COST: cost vector for 1-neighbourhood. - -------------------------------------------------------- - */ - - __static_call - __normal_call real_type loop_cost ( - mesh_type &_mesh , - conn_list &_cset , - real_list &_cost , - cell_kind const& // cell costs on CSET - ) - { - real_type _qmin = (real_type)1. ; - - for (auto _next = _cset.head() , - _tend = _cset.tend() ; - _next != _tend; - ++_next ) - { - real_type _cscr = (real_type)+1. ; - - iptr_type _cell = _next->_cell ; - iptr_type _kind = _next->_kind ; - - switch (_kind) - { - case TRIA3_tag: - { - _cscr = pred_type::tri3_cost ( - &_mesh .node( - _mesh .tri3( - _cell).node(0)).pval(0), - &_mesh .node( - _mesh .tri3( - _cell).node(1)).pval(0), - &_mesh .node( - _mesh .tri3( - _cell).node(2)).pval(0), - typename - pred_type::cell_kind ()) ; - break ; - } - - case QUAD4_tag: - { - _cscr = pred_type::quad_cost ( - &_mesh .node( - _mesh .quad( - _cell).node(0)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(1)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(2)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(3)).pval(0), - typename - pred_type::cell_kind ()) ; - break ; - } - } - - _qmin = - std::min (_qmin, _cscr) ; - - _cost.push_tail (_cscr) ; - } - - return ( _qmin ) ; - } - - __static_call - __normal_call real_type loop_cost ( - mesh_type &_mesh , - conn_list &_cset , - real_list &_cost , - dual_kind const& // dual costs on CSET - ) - { - real_type _qmin = (real_type)1. ; - - for (auto _next = _cset.head() , - _tend = _cset.tend() ; - _next != _tend; - ++_next ) - { - real_type _cscr = (real_type)+1. ; - - iptr_type _cell = _next->_cell ; - iptr_type _kind = _next->_kind ; - - switch (_kind) - { - case TRIA3_tag: - { - _cscr = pred_type::tri3_cost ( - &_mesh .node( - _mesh .tri3( - _cell).node(0)).pval(0), - &_mesh .node( - _mesh .tri3( - _cell).node(1)).pval(0), - &_mesh .node( - _mesh .tri3( - _cell).node(2)).pval(0), - typename - pred_type::dual_kind ()) ; - break ; - } - - case QUAD4_tag: - { - _cscr = pred_type::quad_cost ( - &_mesh .node( - _mesh .quad( - _cell).node(0)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(1)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(2)).pval(0), - &_mesh .node( - _mesh .quad( - _cell).node(3)).pval(0), - typename - pred_type::dual_kind ()) ; - break ; - } - } - - _qmin = - std::min (_qmin, _cscr) ; - - _cost.push_tail (_cscr) ; - } - - return ( _qmin ) ; - } - - /* - -------------------------------------------------------- - * MOVE-NODE: "limited" single node coord. update. - -------------------------------------------------------- - */ - - #include "iter_node_2.inc" - - template < - typename node_iter - > - __static_call - __inline_call void_type move_node ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - real_list &_hval , - iter_opts &_opts , - node_iter _node , - kern_kind _kern , - iptr_type &_move , - conn_list &_conn , - real_list &_qold , - real_list &_qnew , - real_type _QMIN , - real_type _QLIM , - iter_stat &_tcpu - ) - { - /*---------------- try variational; fallback on dQ/dx */ - move_kern( _geom, _mesh, _hfun, - _hval, _opts, _node, - _kern, _move, _conn, - _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; // variational - - if (_move >= +0 ) return ; - - move_kern( _geom, _mesh, _hfun, - _hval, _opts, _node, - dqdx_optimise, - _move, _conn, - _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; // local dQ/dx - - if (_move >= +0 ) return ; - } - - template < - typename node_iter - > - __static_call - __normal_call void_type move_kern ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - real_list &_hval , - iter_opts &_opts , - node_iter _node , - kern_kind _kern , - iptr_type &_move , - conn_list &_conn , - real_list &_qold , - real_list &_qnew , - real_type _QMIN , - real_type _QLIM , - iter_stat &_tcpu - ) - { - /*---------------- optimise single node's coordinates */ - iptr_type static - constexpr _ITER = (iptr_type) +4 ; - - # ifdef __use_timers - typename std ::chrono:: - high_resolution_clock::time_point _ttic ; - typename std ::chrono:: - high_resolution_clock::time_point _ttoc ; - typename std ::chrono:: - high_resolution_clock _time ; - - __unreferenced(_time) ; // why does MSVC need this?? - # endif//__use_timers - - _move = (iptr_type)-1 ; - - real_type _line[geom_dims] = - {(real_type)+0.0} ; - - real_type _save[geom_dims] = - {(real_type)+0.0} ; - - real_type _proj[geom_dims] = - {(real_type)+0.0} ; - - /*---------------- calc. line search direction vector */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - real_type _ladj = (real_type) +0. ; - - if (_kern == _odt_optimise) - { - /*--------------------------- ODT-style update vector */ - _odt_move_2 ( - _geom, _mesh, _hfun, _hval, - _conn, _node, - _line, _ladj) ; - } - else - if (_kern == _cvt_optimise) - { - /*--------------------------- CVT-style update vector */ - _cvt_move_2 ( - _geom, _mesh, _hfun, _hval, - _conn, _node, - _line, _ladj) ; - } - else - if (_kern == dqdx_optimise) - { - if (_QMIN<=_QLIM) - { - /*--------------------------- d./dx Q^T update vector */ - dqdx_move_2 ( - _mesh, _conn, _node, _qold, - _line, _ladj) ; - } - else { return ; } - } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._ldir_node += _tcpu.nano_span(_ttic, _ttoc) ; - # endif//__use_timers - - /*---------------- scale line search direction vector */ - real_type _xeps = // delta_x ~= 0.0 - (real_type)+0.01*_opts.qtol() ; + typedef containers::fixed_array < + real_type , + geom_dims > line_data ; - real_type _xtol = // delta_x reltol - +std::sqrt(_opts.qtol()) / +10.0 ; + typedef containers + ::array< line_data > line_list ; - if (_kern == dqdx_optimise) // test cost-only + class mark_list // integer cell markers { - _QLIM = - +std::numeric_limits::infinity() ; - } - - auto _ppos = &_node->pval(0) ; - - real_type _lsqr ; - _lsqr = std::pow(_ladj, 2) ; - _xeps = std::pow(_xeps, 2) ; - _xtol = std::pow(_xtol, 2) ; - - real_type _scal = // overrelaxation - (real_type) std::sqrt( 2.0 ) ; - - /*---------------- do backtracking line search iter's */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - for (auto _idim = - pred_type::geom_dims; _idim-- != +0; ) - { - _save[_idim] = _ppos [_idim] ; - } - - for (auto _iter = +0 ; - _iter != _ITER; ++_iter ) - { - /*---------------- push update along search direction */ - for (auto _idim = - pred_type::geom_dims; _idim-- != +0; ) - { - _proj[_idim] = - _save[_idim] + - _scal* _line[_idim] ; - } - - pred_type:: - proj_node (_geom, _save, _proj) ; - - for (auto _idim = - pred_type::geom_dims; _idim-- != +0; ) - { - _ppos[_idim] = _proj[_idim] ; - } - - real_type _XEPS = _xeps * _scal ; - real_type _XTOL = _xtol * _scal ; - - real_type _lmov = - pred_type::length_sq(_save, _proj) ; - - if (_lmov <= _XEPS * _lsqr) break; - - //_move = +1 ; return ; - - _scal *= (real_type)+0.5 ; - - /*---------------- test quasi-monotonicity w.r.t. Q^T */ - _qnew.set_count(0) ; - - loop_cost( _mesh, _conn, _qnew, - cell_kind ()) ; - - move_okay( _qnew, _qold, _move, - _QLIM, _opts.qtol(), - _lmov, _XTOL* _lsqr) ; - - if (_move >= +0) break ; - } - - /*---------------- swap with the saved coord. if fail */ - if (_move <= +0) - { - for (auto _idim = - pred_type::geom_dims; _idim-- != +0; ) - { - _ppos[_idim] = _save[_idim] ; - } - } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._lopt_node += _tcpu.nano_span(_ttic, _ttoc) ; - # endif//__use_timers - - } - - /* - -------------------------------------------------------- - * MOVE-DUAL: "limited" single node weight update. - -------------------------------------------------------- - */ - - #include "iter_dual_2.inc" - - template < - typename node_iter - > - __static_call - __normal_call void_type move_dual ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - real_list &_hval , - iter_opts &_opts , - node_iter _node , - iptr_type &_move , - conn_list &_conn , - real_list &_dold , - real_list &_dnew , - real_type _DMIN , - real_type _DLIM , - iter_stat &_tcpu - ) - { - /*---------------- optimise single node's coordinates */ - iptr_type static - constexpr _ITER = (iptr_type) +4 ; - - # ifdef __use_timers - typename std ::chrono:: - high_resolution_clock::time_point _ttic ; - typename std ::chrono:: - high_resolution_clock::time_point _ttoc ; - typename std ::chrono:: - high_resolution_clock _time ; - - __unreferenced(_time) ; // why does MSVC need this?? - # endif//__use_timers - - __unreferenced(_geom); - __unreferenced(_hfun); - __unreferenced(_hval); - - _move = (iptr_type)-1; - - real_type _wadj, _step, _save; - - /*---------------- calc. line search direction vector */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - if (_DMIN <= _DLIM) - { - dqdw_move_2 ( - _mesh, _conn, _node, _dold, - _step, _wadj) ; - } - else { return ; } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._ldir_dual += _tcpu.nano_span(_ttic, _ttoc) ; - # endif//__use_timers - - /*---------------- scale line search direction vector */ - real_type _weps = // delta_w ~= 0.0 - (real_type) .01*_opts.qtol() ; - - _save = _node->pval( - pred_type::real_dims - 1); - - real_type _scal = // overrelaxation - (real_type) std::sqrt( 2.0 ) ; - - /*---------------- do backtracking line search iter's */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - for (auto _iter = +0 ; - _iter != _ITER; ++_iter ) - { - _node->pval(real_dims-1) = - _save + ( _scal * _step ) ; - - _node->pval(real_dims-1) = - std::max(-_wadj , - _node->pval(real_dims-1)); - - _node->pval(real_dims-1) = - std::min(+_wadj , - _node->pval(real_dims-1)); - - real_type _wmov = - std::abs (_save - - _node->pval(real_dims-1)); - - if (_wmov <= - _weps * _scal * _wadj) break; - - _scal *= (real_type)+0.5 ; - - /*---------------- test quasi-monotonicity w.r.t. Q^D */ - _dnew.set_count(0) ; - - loop_cost( _mesh, _conn, _dnew, - dual_kind ()) ; - - move_okay( _dnew, _dold, _move, - _DLIM, _opts.qtol()) ; - - if (_move >= +0) break ; - } - - /*---------------- swap with the saved coord. if fail */ - if (_move <= +0) - { - _node->pval(real_dims-1) = _save ; - } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._lopt_dual += _tcpu.nano_span(_ttic, _ttoc) ; - # endif//__use_timers - - } - - /* - -------------------------------------------------------- - * PULL-CONN: cache node-to-cell adjacency lists. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type pull_conn ( - mesh_type &_mesh , - conn_sets &_conn - ) - { - _conn._adj1.set_count( +0 ) ; - _conn._idx1.set_count( - _mesh.node().count() + 1, - containers::tight_alloc , +0 ) ; - - _conn._adj2.set_count( +0 ) ; - _conn._idx2.set_count( - _mesh.node().count() + 1, - containers::tight_alloc , +0 ) ; - - _conn._adj1.set_alloc( - _mesh.edge().count() * 2) ; - _conn._adj2.set_alloc( - _mesh.tri3().count() * 3 + - _mesh.quad().count() * 4) ; - - iptr_type _npos = +0 ; - for (auto _node = _mesh.node().head() ; - _node != _mesh.node().tend() ; - ++_node, ++_npos) - { - if (_node->mark() >= + 0) - { - /*-------------------- append adj. lists per node */ - _mesh.connect_1( - _npos, POINT_tag, _conn._adj1) ; - - _conn._idx1[_npos+1] = - _conn._adj1.count() ; - - _mesh.connect_2( - _npos, POINT_tag, _conn._adj2) ; - - _conn._idx2[_npos+1] = - _conn._adj2.count() ; - } - else - { - /*-------------------- empty lists for null nodes */ - _conn._idx1[_npos+1] = - _conn._idx1[ _npos] ; - - _conn._idx2[_npos+1] = - _conn._idx2[ _npos] ; - } - } - } - - /* - -------------------------------------------------------- - * SORT-NODE: permutations for node optimisation. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type sort_node ( - mesh_type &_mesh , - conn_sets &_CONN , - iptr_list &_lset , - iptr_list &_aset , - iptr_list &_nmrk , - iptr_list &_amrk , - iptr_type _iout , - iptr_type _isub , - real_type _QLIM , - real_type _DLIM , - iter_opts &_opts - ) - { - # define PUSHSORT(_NODE) \ - if (_amrk[_NODE] != _isub) \ - { \ - _amrk[_NODE] = _isub; \ - _sset.push_tail( \ - cost_pair(_NODE, 1.)) ; \ - } - - # define PUSHCONN(_NODE) \ - if (_amrk[_NODE] != _isub) \ - { \ - _amrk[_NODE] = _isub; \ - _aset.push_tail(_NODE) ; \ - } - - # define PUSHCOST(_NODE , _COST) \ - _qbar[_NODE] += _COST ; \ - _nadj[_NODE] += +1 ;\ - _qmin[_NODE] = \ - std::min (_qmin[_NODE], _COST) ; - - class cost_pair - { - public : - /*------------------------ tuple for node re-ordering */ - iptr_type _node ; - float _cost ; - - /*------------------------ construct inline from src. */ - __inline_call cost_pair ( - iptr_type const&_nsrc , - real_type const&_csrc - ) : - _node (_nsrc), - _cost((float)_csrc) {} - } ; - - class cost_pred - { - public : - /*------------------------ less-than op. for cost-tup */ - __inline_call - bool_type operator () ( - cost_pair const&_idat , - cost_pair const&_jdat - ) const - { return _idat._cost > _jdat._cost ; - } - } ; - - typedef - containers::array cost_list ; - - real_list _qbar, _qmin ; - iptr_list _nadj ; - cost_list _sset ; - - __unreferenced ( _DLIM ) ; - __unreferenced ( _opts ) ; - - if (_isub == (iptr_type) +0) - { - /*-------------------- 1ST SUB-ITER: build full init. */ - _qbar.set_count( - _mesh.node().count(), - containers::tight_alloc, +0.0) ; - _qmin.set_count( - _mesh.node().count(), - containers::tight_alloc, +1.0) ; - _nadj.set_count( - _mesh.node().count(), - containers::tight_alloc, + 0 ) ; - - _sset.set_alloc( - _mesh.node().count()) ; - - pull_conn(_mesh, _CONN) ; - - for (auto _tria = _mesh.tri3().head() ; - _tria != _mesh.tri3().tend() ; - ++_tria ) - { - if (_tria->mark() >= +0) - { - /*-------------------- calc. min. scores at nodes */ - iptr_type _inod, _jnod, _knod; - _inod = _tria->node( 0); - _jnod = _tria->node( 1); - _knod = _tria->node( 2); - - real_type _cost; - _cost = pred_type::tri3_cost ( - &_mesh .node( - _tria->node(0)).pval(0), - &_mesh .node( - _tria->node(1)).pval(0), - &_mesh .node( - _tria->node(2)).pval(0), - typename - pred_type::cell_kind ()) ; - - PUSHSORT( _inod ) - PUSHCOST( _inod, _cost ) - PUSHSORT( _jnod ) - PUSHCOST( _jnod, _cost ) - PUSHSORT( _knod ) - PUSHCOST( _knod, _cost ) - } - } - - for (auto _quad = _mesh.quad().head() ; - _quad != _mesh.quad().tend() ; - ++_quad ) - { - if (_quad->mark() >= +0) - { - /*-------------------- calc. min. scores at nodes */ - iptr_type _inod, _jnod, _knod, - _lnod; - _inod = _quad->node( 0); - _jnod = _quad->node( 1); - _knod = _quad->node( 2); - _lnod = _quad->node( 3); - - real_type _cost; - _cost = pred_type::quad_cost ( - &_mesh .node( - _quad->node(0)).pval(0), - &_mesh .node( - _quad->node(1)).pval(0), - &_mesh .node( - _quad->node(2)).pval(0), - &_mesh .node( - _quad->node(3)).pval(0), - typename - pred_type::cell_kind ()) ; - - PUSHSORT( _inod ) - PUSHCOST( _inod, _cost ) - PUSHSORT( _jnod ) - PUSHCOST( _jnod, _cost ) - PUSHSORT( _knod ) - PUSHCOST( _knod, _cost ) - PUSHSORT( _lnod ) - PUSHCOST( _lnod, _cost ) - } - } - - for (auto _iter = - _qbar.count(); _iter-- != +0; ) - { - /*------------------------ assign score for each node */ - _qbar[_iter] /= - std::max(+1, _nadj [_iter]) ; - } - - for (auto _iter = _sset.head() ; - _iter != _sset.tend() ; - ++_iter ) - { - _iter->_cost = - (float)_qbar [_iter->_node] - - (float)_qmin [_iter->_node] ; - } - - algorithms::qsort( _sset.head() , - _sset.tend() , - cost_pred () ) ; - - iptr_type _FLAG = _iout - 2 ; // only "recent" - - for (auto _iter = _sset.head() ; - _iter != _sset.tend() ; - ++_iter ) - { - /*------------------------ push sorted wrt. min.-cost */ - if (std::abs( - _nmrk[_iter->_node]) >= _FLAG || // recent - _qmin[_iter->_node] <= _QLIM ) // skewed - { - _amrk[_iter->_node] = _isub ; - _aset.push_tail( _iter->_node ) ; - } - } - - } - else - { - /*-------------------- NTH sub-iter: init. from prev. */ - for (auto _iter = _lset.head() ; - _iter != _lset.tend() ; - ++_iter ) - { - PUSHCONN( *_iter ) - } - - /*-------------------- add adj.: 1-ring neighbourhood */ - for (auto _iter = - _aset.count() ; _iter-- != 0; ) - { - auto _apos = _aset [_iter] ; - - /*-------------------- push any 1-cell neighbours */ - for (auto _next = - _CONN._adj1.head()+_CONN._idx1[_apos+0] ; - _next != - _CONN._adj1.head()+_CONN._idx1[_apos+1] ; - ++_next ) - { - if (_next->_kind == EDGE2_tag) - { - auto _eptr = - _mesh. edge().head()+_next->_cell ; - - PUSHCONN( _eptr->node(0) ) - PUSHCONN( _eptr->node(1) ) - } - } - - /*-------------------- push any 2-cell neighbours */ - for (auto _next = - _CONN._adj2.head()+_CONN._idx2[_apos+0] ; - _next != - _CONN._adj2.head()+_CONN._idx2[_apos+1] ; - ++_next ) - { - if (_next->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head()+_next->_cell ; - - PUSHCONN( _tptr->node(0) ) - PUSHCONN( _tptr->node(1) ) - PUSHCONN( _tptr->node(2) ) - } - else - if (_next->_kind == QUAD4_tag) - { - auto _qptr = - _mesh. quad().head()+_next->_cell ; - - PUSHCONN( _qptr->node(0) ) - PUSHCONN( _qptr->node(1) ) - PUSHCONN( _qptr->node(2) ) - PUSHCONN( _qptr->node(3) ) - } - } - } - - } - # undef PUSHCOST - # undef PUSHSORT - # undef PUSHCONN - } - - /* - -------------------------------------------------------- - * MOVE-NODE: do a single node smoothing pass. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type move_node ( - geom_type &_geom , - mesh_type &_mesh , - conn_sets &_CONN , - hfun_type &_hfun , - char_type _kern , - real_list &_hval , - iptr_list &_nset , - iptr_list &_lset , - iptr_list &_aset , - iptr_list &_amrk , - mark_list &_mark , - iptr_type _iout , - iptr_type _isub , - iter_opts &_opts , - iptr_type &_nmov , - real_type _QLIM , - real_type _DLIM , - iter_stat &_tcpu - ) - { - # define MARK(_NODE) _mark._node[_NODE] - - # define HEAD(_PASS)(_PASS == +0 ? \ - _aset.head() : \ - _aset.tail()) - - # define STOP(_PASS)(_PASS == +0 ? \ - _aset.tend() : \ - _aset.hend()) - - # define ITER(_PASS)(_PASS == +0 ? +1 : -1) - - conn_list _conn; - real_list _qold, _qnew, _dold, _dnew; - - # ifdef __use_timers - typename std ::chrono:: - high_resolution_clock::time_point _ttic; - typename std ::chrono:: - high_resolution_clock::time_point _ttoc; - typename std ::chrono:: - high_resolution_clock _time ; - - __unreferenced(_time) ; // why does MSVC need this?? - # endif//__use_timers - - /*-------------------- permute nodes for optimisation */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - _aset.set_count(+0) ; - - sort_node(_mesh, _CONN, _lset, _aset, - _mark._node, _amrk, _iout, _isub, - _QLIM,_DLIM, _opts) ; - - _nmov = (iptr_type)0; - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._init_node += _tcpu.time_span(_ttic, _ttoc) ; - # endif//__use_timers - - /*-------------------- SYMMETRIC GAUSS-SEIDEL on CELL */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - _lset.set_count(+0) ; - - if (_opts .tria()) // 1=>GS, 2=>SGS - { - for (auto _pass = 0; _pass < 2; ++_pass) - for (auto _apos = HEAD(_pass) ; - _apos != STOP(_pass) ; - _apos += ITER(_pass) ) - { - auto _node = - _mesh.node().head()+ *_apos ; - - /*---------------- assemble a local tria. stencil */ - _conn.set_count( +0) ; - _conn.push_tail( - _CONN._adj2.head()+_CONN._idx2[*_apos+0], - _CONN._adj2.head()+_CONN._idx2[*_apos+1] - ) ; - - if (_conn.empty()) continue ; - - if (_mark._node[*_apos] >= +0) - { - /*---------------- attempt to optimise CELL geom. */ - _qold.set_count( +0) ; - _qnew.set_count( +0) ; - - real_type _QMIN = - loop_cost( _mesh, - _conn, _qold, cell_kind()); - - iptr_type _move = -1 ; - - if (_move < +0 ) - { - /*---------------- do optimisation of node coord. */ - move_node( _geom, _mesh, - _hfun, _hval, - _opts, _node, _kern, - _move, _conn, - _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; - } - - if (_move > +0 ) - { - /*---------------- update when state is improving */ - _hval[*_apos] = (real_type)-1; - - if (std::abs( - MARK( *_apos )) !=_iout) - { - if (MARK( *_apos ) >= 0) - MARK( *_apos ) = +_iout; - else - MARK( *_apos ) = -_iout; - - _nset.push_tail (*_apos) ; - } - - _lset.push_tail (*_apos) ; - - _nmov += +1 ; - } - } - } - } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._core_node += _tcpu.time_span(_ttic, _ttoc) ; - # endif//__use_timers - - # undef MARK - # undef HEAD - # undef STOP - # undef ITER - } - - /* - -------------------------------------------------------- - * MOVE-DUAL: do a single dual smoothing pass. - -------------------------------------------------------- - */ - - __static_call - __normal_call void_type move_dual ( - geom_type &_geom , - mesh_type &_mesh , - conn_sets &_CONN , - hfun_type &_hfun , - real_list &_hval , - iptr_list &_nset , - iptr_list &_lset , - iptr_list &_aset , - iptr_list &_amrk , - mark_list &_mark , - iptr_type _iout , - iptr_type _isub , - iter_opts &_opts , - iptr_type &_nmov , - real_type _QLIM , - real_type _DLIM , - iter_stat &_tcpu - ) - { - # define MARK(_NODE) _mark._node[_NODE] - - # define HEAD(_PASS)(_PASS == +0 ? \ - _aset.head() : \ - _aset.tail()) - - # define STOP(_PASS)(_PASS == +0 ? \ - _aset.tend() : \ - _aset.hend()) - - # define ITER(_PASS)(_PASS == +0 ? +1 : -1) - - conn_list _conn; - real_list _qold, _qnew, _dold, _dnew; - - # ifdef __use_timers - typename std ::chrono:: - high_resolution_clock::time_point _ttic ; - typename std ::chrono:: - high_resolution_clock::time_point _ttoc ; - typename std ::chrono:: - high_resolution_clock _time ; - - __unreferenced(_time) ; // why does MSVC need this?? - # endif//__use_timers - - /*-------------------- permute nodes for optimisation */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - _aset.set_count(+0) ; - - sort_node(_mesh, _CONN, _lset, _aset, - _mark._node, _amrk, _iout, _isub, - _QLIM,_DLIM, _opts) ; - - _nmov = (iptr_type)0; - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._init_dual += _tcpu.time_span(_ttic, _ttoc) ; - # endif//__use_timers - - /*-------------------- SYMMETRIC GAUSS-SEIDEL on DUAL */ - - # ifdef __use_timers - _ttic = _time.now() ; - # endif//__use_timers - - _lset.set_count(+0) ; - - if (_opts .dual()) // 1=>GS, 2=>SGS - { - for (auto _pass = 0; _pass < 2; ++_pass) - for (auto _apos = HEAD(_pass) ; - _apos != STOP(_pass) ; - _apos += ITER(_pass) ) - { - auto _node = - _mesh.node().head()+ *_apos ; - - /*---------------- assemble a local tria. stencil */ - _conn.set_count( +0) ; - _conn.push_tail( - _CONN._adj2.head()+_CONN._idx2[*_apos+0], - _CONN._adj2.head()+_CONN._idx2[*_apos+1] - ) ; - - if (_conn.empty()) continue ; - - /*---------------- attempt to optimise DUAL geom. */ - _dold.set_count( +0) ; - _dnew.set_count( +0) ; - - real_type _DMIN = - loop_cost( _mesh, - _conn, _dold, dual_kind()); - - iptr_type _move = -1 ; - - if (_move < +0 ) - { - /*---------------- do optimisation of node weight */ - move_dual( _geom, _mesh, - _hfun, _hval, - _opts, _node, - _move, _conn, - _dold, _dnew, - _DMIN, _DLIM, _tcpu) ; - } - - if (_move > +0 ) - { - /*---------------- update when state is improving */ - if (std::abs( - MARK( *_apos )) !=_iout) - { - if (MARK( *_apos ) >= 0) - MARK( *_apos ) = +_iout; - else - MARK( *_apos ) = -_iout; - - _nset.push_tail (*_apos) ; - } - - _lset.push_tail(*_apos) ; - - _nmov += +1 ; - } - } - } - - # ifdef __use_timers - _ttoc = _time.now() ; - _tcpu._core_dual += _tcpu.time_span(_ttic, _ttoc) ; - # endif//__use_timers - - # undef MARK - # undef HEAD - # undef STOP - # undef ITER - } - - /* - -------------------------------------------------------- - * FLIP-MESH: "flip" mesh topology. - -------------------------------------------------------- - */ - - #include "iter_flip_2.inc" - - __static_call - __normal_call void_type flip_mesh ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - iptr_list &_nset , - mark_list &_mark , - iptr_type _imrk , - iptr_type &_nflp - ) - { - # define MARKTRI3(_CELL) \ - _mark._tri3[_CELL->_cell] - - # define MARKQUAD(_CELL) \ - _mark._quad[_CELL->_cell] - - init_mark(_mesh, _mark , - std::max(+0, _imrk - 1) ) ; - - _nflp = +0 ; - - conn_list _flip, _conn ; - - /*--------------------- init. flip stack as ADJ(NSET) */ - for (auto _iter = _nset.head(); - _iter != _nset.tend(); - ++_iter ) - { - if (_mesh.node(*_iter).mark() >= 0) - { - _conn.set_count(0); - _mesh.connect_2( - &*_iter, POINT_tag, _conn) ; - - for (auto _cell = _conn.head(); - _cell != _conn.tend(); - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - if (MARKTRI3( _cell ) != _imrk) - { - MARKTRI3( _cell ) = _imrk ; - - _flip.push_tail( *_cell) ; - } - } - else - if (_cell->_kind == QUAD4_tag) - { - if (MARKQUAD( _cell ) != _imrk) - { - MARKQUAD( _cell ) = _imrk ; - - _flip.push_tail( *_cell) ; - } - } - } - } - } - - flip_core(_geom, _mesh, _hfun, _flip, _mark, - _nflp) ; - - # undef MARKQUAD - # undef MARKTRI3 - } - - __static_call - __normal_call void_type flip_mesh ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - conn_sets &_CONN , - iptr_list &_nset , - mark_list &_mark , - iptr_type _imrk , - iptr_type &_nflp - ) - { - # define MARKTRI3(_CELL) \ - _mark._tri3[_CELL->_cell] - - # define MARKQUAD(_CELL) \ - _mark._quad[_CELL->_cell] - - init_mark(_mesh, _mark , - std::max(+0, _imrk - 1) ) ; - - _nflp = +0 ; - - conn_list _flip ; - - /*--------------------- init. flip stack as ADJ(NSET) */ - for (auto _iter = _nset.head(); - _iter != _nset.tend(); - ++_iter ) - { - if (_mesh.node(*_iter).mark() >= 0) - { - for (auto _cell = - _CONN._adj2.head()+_CONN._idx2[*_iter+0] ; - _cell != - _CONN._adj2.head()+_CONN._idx2[*_iter+1] ; - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - if (MARKTRI3( _cell ) != _imrk) - { - MARKTRI3( _cell ) = _imrk ; - - _flip.push_tail( *_cell) ; - } - } - else - if (_cell->_kind == QUAD4_tag) - { - if (MARKQUAD( _cell ) != _imrk) - { - MARKQUAD( _cell ) = _imrk ; - - _flip.push_tail( *_cell) ; - } - } - } - } - } + public : + iptr_list _node; + iptr_list _edge; + iptr_list _tri3; + iptr_list _quad; + } ; - flip_core(_geom, _mesh, _hfun, _flip, _mark, - _nflp) ; + class part_sets // mesh parallel decomp. + { + public : + uint_list _lptr; + iptr_list _list; + iptr_list _part; + iptr_list _seqs; + } ; - # undef MARKQUAD - # undef MARKTRI3 - } + class part_data + { + public : + part_sets _full; + part_sets _bnds; + } ; - __static_call - __normal_call void_type flip_core ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - conn_list &_flip , - mark_list &_mark , - iptr_type &_nflp - ) - { - __unreferenced ( _hfun ) ; + typedef typename + mesh_type::connector conn_list ; - /*--------------------- exhaustive, incremental flips */ - conn_list _next, _conn, _CONN; - real_list _qold, _qnew ; - for ( ; !_flip.empty() ; ) - { - for (auto _cell = _flip.head(); - _cell != _flip.tend(); - ++_cell ) + class conn_sets // cache neighbourhoods { - if (_cell->_kind == TRIA3_tag) - { - if ( _mesh. - tri3(_cell->_cell).mark() >= +0) - { - bool_type _okay = false ; - flip_tri3( _geom, _mesh, - _mark. _node, - _cell->_cell, - _okay, _conn, _CONN, - _qold, _qnew, - (flip_kind)laguerre_flip) ; - - if (_okay) _nflp += +1 ; - - _next.push_tail( - _CONN.head(), _CONN.tend()); - } - } - else - if (_cell->_kind == QUAD4_tag) - { - if ( _mesh. - quad(_cell->_cell).mark() >= +0) - { - bool_type _okay = false ; - //flip_quad( _geom, _mesh, - // _mark. _node, - // _cell->_cell, - // _okay, _conn, _CONN, - // _qold, _qnew, - // (flip_kind)laguerre_flip) ; - - if (_okay) _nflp += +1 ; - - _next.push_tail( - _CONN.head(), _CONN.tend()); - } - } - } - _flip = std::move (_next) ; - } - } + public : + conn_list _adj1; + uint_list _idx1; + conn_list _adj2; + uint_list _idx2; + } ; + + public : /* -------------------------------------------------------- - * _ZIP-MESH: edge merge/split operations. + * FLIP-SIGN: flip cells for +ve iter. cost fn. -------------------------------------------------------- */ - #include "iter_zips_2.inc" - #include "iter_divs_2.inc" - - __static_call - __normal_call void_type _zip_mesh ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - char_type _kern , - real_list &_hval , - iptr_list &_nset , - mark_list &_mark , - iptr_type _imrk , - iter_opts &_opts , - real_type _QLIM , - real_type _DLIM , - iptr_type &_nzip , - iptr_type &_ndiv , - iter_stat &_tcpu - ) - { - class sort_pair - { - public : - /*------------------------ tuple for edge re-ordering */ - iptr_type _inod ; - iptr_type _jnod ; - float _cost ; - public : - __inline_call sort_pair ( - iptr_type _isrc , - iptr_type _jsrc , - float _csrc - ) : _inod(_isrc), _jnod(_jsrc), - _cost(_csrc) {} - } ; - class sort_less - { - public : - /*------------------------ less-than op. for cost-tup */ - __inline_call - bool_type operator () ( - sort_pair const&_idat , - sort_pair const&_jdat - ) const - { return _idat._cost < _jdat._cost; - } - } ; - - # define MARKNODE(_NODE) _mark._node[_NODE] - - # define PUSHMARK \ - init_mark( _mesh, _mark, \ - std::max(_imrk - 1, +0)); \ - if (std::abs( \ - _mark._node[_nnew])!= _imrk+1) \ - { \ - if (_mark._node[_nnew] >= +0) \ - { \ - _mark._node[_nnew] = +_imrk+1; \ - } \ - else \ - { \ - _mark._node[_nnew] = -_imrk-1; \ - } \ - _nset.push_tail(_nnew) ; \ - } \ - - /*------------------------ add/pop nodes to fix topo. */ - typedef containers:: - array sort_list ; - - __unreferenced ( _DLIM ); - - sort_list _sort ; - conn_list _aset , _bset, _cset ; - conn_list _conn , _iset, _jset ; - real_list _qold , _qnew, _qtmp ; - - _nzip = +0 ; _ndiv = +0 ; - - // assemble list of edges attached to "recent" nodes - - _sort.set_alloc( - _mesh.edge().count()) ; - - for (auto _iter = _mesh.edge().head() ; - _iter != _mesh.edge().tend() ; - ++_iter ) - { - auto _inod = _iter->node(0) ; - auto _jnod = _iter->node(1) ; - - auto _iptr = _mesh. - node().head()+_iter->node(0) ; - auto _jptr = _mesh. - node().head()+_iter->node(1) ; - - auto _flag = _imrk - 2 ; // recent - - if (_iter->mark() >= +0 && - ( std::abs( - _mark._node[_inod]) > _flag || - std::abs( - _mark._node[_jnod]) > _flag )) - { - float _lsqr = - (float)pred_type::length_sq ( - & _iptr->pval(0) , - & _jptr->pval(0) ) ; + #include "_bfs_mesh_2.inc" - _sort.push_tail( - sort_pair(_inod, _jnod, _lsqr)) ; - } - } - if (_sort.empty()) return ; + /* + -------------------------------------------------------- + * COST-MESH: 1-neighbourhood cost vector util. + -------------------------------------------------------- + */ - algorithms::qsort( // sort edge list by lsqr - _sort.head() , - _sort.tend() , sort_less()); + #include "cost_mesh_2.inc" - // scan edges longest-to-shortest and try to div any - // unvisited edges - for (auto _iter = _sort.tail(); - _iter != _sort.hend(); - --_iter ) - { - /*--------------------------- try to "div" local edge */ - iptr_type _eadj, _enod[2] ; - _enod[0] = _iter->_inod; - _enod[1] = _iter->_jnod; + /* + -------------------------------------------------------- + * PART-MESH: paritions for parallel decomposition. + -------------------------------------------------------- + */ - if (MARKNODE(_enod[0]) < +0 && - MARKNODE(_enod[1]) < +0 ) continue ; + #include "part_mesh_2.inc" - if (MARKNODE(_enod[0])>_imrk|| - MARKNODE(_enod[1])>_imrk) continue ; - if(!_mesh.find_edge( - _enod, _eadj) ) continue ; + /* + -------------------------------------------------------- + * SORT-MESH: greedy ordering for optimisation ops. + -------------------------------------------------------- + */ - if (_opts.div_()) - { - /*--------------------------- "div" for topo. + score */ - iptr_type _nnew = -1; - - bool_type _move = false ; - _div_edge( _geom, _mesh, - _hfun, _hval, _opts, - _imrk, _eadj, - _kern, _move, _nnew, - _iset, _jset, - _aset, _bset, - _qold, _qnew, - _qtmp, _QLIM, _tcpu) ; - - if (_move) - { - PUSHMARK; _ndiv += +1; - } - } - } + #include "sort_mesh_2.inc" - // scan edges shortest-to-longest and try to zip any - // unvisited edges - for (auto _iter = _sort.head(); - _iter != _sort.tend(); - ++_iter ) - { - /*--------------------------- try to "zip" local edge */ - iptr_type _eadj, _enod[2] ; - _enod[0] = _iter->_inod; - _enod[1] = _iter->_jnod; + /* + -------------------------------------------------------- + * MOVE-MESH: do single cell/dual smoothing passes. + -------------------------------------------------------- + */ - if (MARKNODE(_enod[0]) < +0 || - MARKNODE(_enod[1]) < +0 ) continue ; + #include "move_mesh_2.inc" - if (MARKNODE(_enod[0])>_imrk|| - MARKNODE(_enod[1])>_imrk) continue ; - if(!_mesh.find_edge( - _enod, _eadj) ) continue ; + /* + -------------------------------------------------------- + * FLIP-MESH: "flip" mesh topology until Delaunay. + -------------------------------------------------------- + */ - if (_opts.zip_()) - { - /*--------------------------- "zip" for topo. + score */ - iptr_type _nnew = -1; - - bool_type _move = false ; - _zip_edge( _geom, _mesh, - _hfun, _hval, _opts, - _mark. _node, - _imrk, _eadj, - _kern, _move, _nnew, - _iset, _jset, - _aset, _bset, _cset, - _qold, _qnew, - _qtmp, _QLIM, _tcpu) ; - - if (_move) - { - PUSHMARK; _nzip += +1; - } - } - } + #include "flip_mesh_2.inc" - for (auto _iter = _mark._node.head() ; - _iter != _mark._node.tend() ; - ++_iter ) - { - /*--------------------- undo local inc. on node flags */ - if (*_iter > + _imrk) - *_iter = + _imrk; - else - if (*_iter < - _imrk) - *_iter = - _imrk; - } + + /* + -------------------------------------------------------- + * _ZIP-MESH: merge/split operations on cells. + -------------------------------------------------------- + */ - # undef PUSHMARK - # undef MARKNODE - } + #include "_zip_mesh_2.inc" + /*------------------------------ helper: init. marker */ @@ -2111,58 +272,15 @@ containers::loose_alloc, _flag) ; } - /* - -------------------------------------------------------- - * ITER-MESH: "hill-climbing" type mesh optimisation. - -------------------------------------------------------- - */ + /*------------------------------ helper: init. bounds */ - template < - typename text_dump - > __static_call - __normal_call void_type iter_mesh ( - geom_type &_geom , - hfun_type &_hfun , + __normal_call void_type init_bnds ( mesh_type &_mesh , - kern_kind _kern , - iter_opts &_opts , - text_dump &_dump + mark_list &_mark ) { - iter_stat _tcpu ; - - /*------------------------------ push log-file header */ - if (_opts.verb() >= 0 ) - { - _dump.push( - "#------------------------------------------------------------\n" - "# |MOVE.| |FLIP.| |MERGE| |SPLIT| \n" - "#------------------------------------------------------------\n" - ) ; - } - - # ifdef __use_timers - typename std ::chrono:: - high_resolution_clock::time_point _ttic ; - typename std ::chrono:: - high_resolution_clock::time_point _ttoc ; - typename std ::chrono:: - high_resolution_clock _time ; - - __unreferenced(_time) ; // why does MSVC need this?? - # endif//__use_timers - - /*------------------------------ ensure deterministic */ - std::srand( +1 ) ; - - /*------------------------------ push boundary marker */ - iptr_list _nset ; - mark_list _mark ; - - init_mark(_mesh, _mark) ; - - { + /*------------------------------ mark bnd. item <= -1 */ conn_list _conn ; iptr_type _nnN1 = +0 ; for (auto _node = _mesh.node().head() ; @@ -2210,21 +328,27 @@ } } } - } - - flip_sign(_mesh) ; + } - /*------------------------------ do optimisation loop */ - bool_type - static constexpr ITER_FLIP = true; + /*------------------------------ helper: init. scores */ - iptr_type - static constexpr ITER_MIN_ = min_subit ; - iptr_type - static constexpr ITER_MAX_ = max_subit ; + __static_call + __normal_call real_type init_cost ( + mesh_type &_mesh, + iter_opts &_opts + ) + { + # ifdef __use_openmp + omp_set_num_threads(_opts.nprt()) ; + # endif//__use_openmp - real_type _QMIN = (real_type) +1.; + real_type _QMIN = (real_type) +1. ; + # pragma omp parallel default(none) \ + shared(_mesh, _opts, _QMIN) + { + real_type _qmin = (real_type) +1. ; + # pragma omp for nowait schedule(static) for (auto _cell = _mesh.tri3().head() ; _cell != _mesh.tri3().tend() ; ++_cell ) @@ -2243,12 +367,13 @@ typename pred_type::cell_kind ()) ; - _QMIN = std::min (_QMIN, _cost) ; - _QMIN = std::max (_QMIN, + _qmin = std::min (_qmin, _cost) ; + _qmin = std::max (_qmin, _opts.qlim()) ; } } + # pragma omp for nowait schedule(static) for (auto _cell = _mesh.quad().head() ; _cell != _mesh.quad().tend() ; ++_cell ) @@ -2269,23 +394,106 @@ typename pred_type::cell_kind ()) ; - _QMIN = std::min (_QMIN, _cost) ; - _QMIN = std::max (_QMIN, + _qmin = std::min (_qmin, _cost) ; + _qmin = std::max (_qmin, _opts.qlim()) ; } } - for (auto _iter = +1 ; + # ifdef __use_openmp + auto _nprt = omp_get_num_threads(); + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0 ; _rank <_nprt; + ++_rank ) + { + # pragma omp ordered + { + _QMIN = std::min (_QMIN, _qmin) ; + } + } + # endif//__use_openmp + } + + return _QMIN ; + } + + /* + -------------------------------------------------------- + * ITER-MESH: "hill-climbing" type mesh optimisation. + -------------------------------------------------------- + */ + + template < + typename text_dump + > + __static_call + __normal_call void_type iter_mesh ( + geom_type &_geom , // geometry object + hfun_type &_hfun , // spacing object + mesh_type &_mesh , // mesh object + kern_kind _kern , // optim. kernel selector + iter_opts &_opts , // user options + text_dump &_dump // log-file object + ) + { + iter_stat _tcpu ; + + /*------------------------------ push log-file header */ + if (_opts.verb() >= 0 ) + { + _dump.push( + "#------------------------------------------------------------\n" + "# |MOVE.| |FLIP.| |MERGE| |SPLIT| \n" + "#------------------------------------------------------------\n" + ) ; + } + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic ; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc ; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*------------------------------ ensure deterministic */ + std::srand( +1 ) ; + + /*------------------------------ push boundary marker */ + iptr_list _nset ; + mark_list _mark ; + + init_mark(_mesh, _mark) ; + init_bnds(_mesh, _mark) ; + + flip_sign(_mesh); + + /*------------------------------ do optimisation loop */ + bool_type + static constexpr ITER_FLIP = true; + + iptr_type + static constexpr ITER_MIN_ = min_subit ; + iptr_type + static constexpr ITER_MAX_ = max_subit ; + + real_type _QMIN = init_cost (_mesh, _opts) ; + + real_list _hval ; // cache h(x) node val. + _hval.set_count( + _mesh. node().count(), + containers::loose_alloc, (real_type) -1.0) ; + + for (auto _iter = +1; _iter <= _opts.iter(); ++_iter) { /*------------------------------ set-up current iter. */ - init_mark(_mesh, _mark, - std::max(_iter-1, +0)) ; - - real_list _hval; - _hval.set_count( - _mesh. node().count(), - containers::tight_alloc, (real_type)-1.); + init_mark(_mesh , + _mark,std::max(_iter - 1, +0)) ; _nset.set_count( +0); @@ -2294,7 +502,7 @@ iptr_type _nzip = +0 ; iptr_type _ndiv = +0 ; - /*------------------------------ scale quality thresh */ + /*------------------------------ scale quality limits */ iptr_type _nsub = _iter +0 ; _nsub = @@ -2305,12 +513,9 @@ real_type _DLIM = (real_type)+1.-_opts.qtol() ; - real_type _QLIM = - (real_type)+.750 * _QMIN + - (real_type)+.075 * _iter ; - - _QLIM = std::min( - _opts.qlim () , _QLIM) ; + real_type _QLIM = std::min( + _opts.qlim(),_QMIN * + (real_type)(0.90 + 0.05 * (_iter - 1))) ; /*------------------------------ 1. CELL GEOM. PASSES */ @@ -2321,37 +526,35 @@ _ttic = _time.now() ; # endif//__use_timers - iptr_list _amrk, _aset, _lset ; - _amrk.set_count( + line_data _zero ; + _zero.fill((real_type) +0.) ; + + line_list _last ; // for momentum updates + _last.set_count( _mesh.node().count() , - containers::tight_alloc,-1) ; + containers::tight_alloc, _zero) ; - _lset.set_alloc( - _mesh.node().count()) ; - _aset.set_alloc( - _mesh.node().count()) ; + iptr_list _aset ; + _aset.set_alloc( // set of "active" node + _mesh.node().count()); + part_data _part ; conn_sets _conn ; - for (auto _isub = + 0 ; - _isub != _nsub; ++_isub ) + for (auto _isub = 0; _isub != _nsub; ++_isub) { if (_opts.verb() >= +3) _dump.push( "**CALL MOVE-NODE...\n" ) ; - iptr_type _nloc; move_node( _geom, _mesh , _conn , - _hfun, _kern, _hval , - _nset, _lset, _aset , - _amrk, _mark, - _iter, _isub, _opts , - _nloc, _QLIM, _DLIM , _tcpu); - - _nloc = _nloc / 2 ; - - _nmov = std::max (_nmov , _nloc); + _hfun, _kern, _hval , _last , + _nset, _aset, _mark , + _part, _iter, _isub , + _opts, _QLIM, _DLIM , _tcpu); } + _nmov = _nset.count() ; + # ifdef __use_timers _ttoc = _time.now() ; _tcpu._move_node += @@ -2372,7 +575,7 @@ iptr_type _nloc; flip_mesh( _geom, _mesh , _hfun , _conn, _nset, _mark , - +3 * _iter - 2 , _nloc ) ; + +3 * _iter - 2 , _nloc , _tcpu); _nflp += _nloc; } @@ -2393,39 +596,34 @@ _ttic = _time.now() ; # endif//__use_timers - iptr_list _amrk, _lset, _aset ; - _amrk.set_count( + real_list _last ; // for momentum updates + _last.set_count( _mesh.node().count() , - containers::tight_alloc,-1) ; + containers::tight_alloc, +0. ) ; - _lset.set_alloc( - _mesh.node().count()) ; - _aset.set_alloc( - _mesh.node().count()) ; + iptr_list _aset ; + _aset.set_alloc( // set of "active" node + _mesh.node().count()); _nsub = std::max(_nsub/2, +1) ; + part_data _part ; conn_sets _conn ; - for (auto _isub = + 0 ; - _isub != _nsub; ++_isub ) + for (auto _isub = 0; _isub != _nsub; ++_isub) { if (_opts.verb() >= +3) _dump.push( "**CALL MOVE-DUAL...\n" ) ; - iptr_type _nloc; move_dual( _geom, _mesh , _conn , - _hfun, _hval, - _nset, _lset, _aset , - _amrk, _mark, - _iter, _isub, _opts , - _nloc, _QLIM, _DLIM , _tcpu); - - _nloc = _nloc / 2 ; - - _nmov = std::max (_nmov , _nloc); + _hfun, _hval, _last , + _nset, _aset, _mark , + _part, _iter, _isub , + _opts, _QLIM, _DLIM , _tcpu); } + _nmov = _nset.count() ; + # ifdef __use_timers _ttoc = _time.now() ; _tcpu._move_dual += @@ -2446,7 +644,7 @@ iptr_type _nloc; flip_mesh( _geom, _mesh , _hfun , _conn, _nset, _mark , - +3 * _iter - 1 , _nloc ) ; + +3 * _iter - 1 , _nloc , _tcpu); _nflp += _nloc; } @@ -2505,7 +703,7 @@ iptr_type _nloc; flip_mesh( _geom, _mesh , _hfun , _nset, _mark, - +3 * _iter - 0 , _nloc ) ; + +3 * _iter - 0 , _nloc , _tcpu); _nflp += _nloc; } @@ -2552,17 +750,29 @@ _dump.push( std::to_string(_tcpu._init_node)) ; _dump.push("\n"); + _dump.push(" *part-node: "); + _dump.push( + std::to_string(_tcpu._part_node)) ; + _dump.push("\n"); _dump.push(" *core-node: "); _dump.push( - std::to_string(_tcpu._core_node)) ; + std::to_string(_tcpu._core_node)) ; _dump.push("\n"); - _dump.push(" *xDIR-node: "); + _dump.push(" *seqs-node: "); _dump.push( - std::to_string(_tcpu._ldir_node)) ; + std::to_string(_tcpu._seqs_node)) ; _dump.push("\n"); - _dump.push(" *xOPT-node: "); + _dump.push(" *para-node: "); _dump.push( - std::to_string(_tcpu._lopt_node)) ; + std::to_string(_tcpu._para_node)) ; + // _dump.push("\n"); + // _dump.push(" *xDIR-node: "); + // _dump.push( + // std::to_string(_tcpu._ldir_node)) ; + // _dump.push("\n"); + // _dump.push(" *xOPT-node: "); + // _dump.push( + // std::to_string(_tcpu._lopt_node)) ; _dump.push("\n\n"); _dump.push(" MOVE-DUAL: "); @@ -2573,28 +783,81 @@ _dump.push( std::to_string(_tcpu._init_dual)) ; _dump.push("\n"); + _dump.push(" *part-dual: "); + _dump.push( + std::to_string(_tcpu._part_dual)) ; + _dump.push("\n"); _dump.push(" *core-dual: "); _dump.push( std::to_string(_tcpu._core_dual)) ; _dump.push("\n"); - _dump.push(" *xDIR-dual: "); + _dump.push(" *seqs-dual: "); _dump.push( - std::to_string(_tcpu._ldir_dual)) ; + std::to_string(_tcpu._seqs_dual)) ; _dump.push("\n"); - _dump.push(" *xOPT-dual: "); + _dump.push(" *para-dual: "); _dump.push( - std::to_string(_tcpu._lopt_dual)) ; + std::to_string(_tcpu._para_dual)) ; + // _dump.push("\n"); + // _dump.push(" *xDIR-dual: "); + // _dump.push( + // std::to_string(_tcpu._ldir_dual)) ; + // _dump.push("\n"); + // _dump.push(" *xOPT-dual: "); + // _dump.push( + // std::to_string(_tcpu._lopt_dual)) ; _dump.push("\n\n"); _dump.push(" TOPO-FLIP: "); _dump.push( std::to_string(_tcpu._topo_flip)) ; - _dump.push("\n"); + _dump.push("\n"); + _dump.push(" *init-flip: "); + _dump.push( + std::to_string(_tcpu._init_flip)) ; + _dump.push("\n"); + _dump.push(" *core-flip: "); + _dump.push( + std::to_string(_tcpu._core_flip)) ; + _dump.push("\n\n"); _dump.push(" TOPO-ZIPS: "); _dump.push( std::to_string(_tcpu._topo_zips)) ; _dump.push("\n"); + _dump.push(" *init-zips: "); + _dump.push( + std::to_string(_tcpu._init_zips)) ; + _dump.push("\n"); + _dump.push(" *core-divs: "); + _dump.push( + std::to_string(_tcpu._core_divs)) ; + _dump.push("\n"); + _dump.push(" *core-zips: "); + _dump.push( + std::to_string(_tcpu._core_zips)) ; + _dump.push("\n\n"); + + _dump.push(" PARTITION: "); + _dump.push( + std::to_string(_tcpu._full_part)) ; + _dump.push("\n"); + _dump.push(" *tree-part: "); + _dump.push( + std::to_string(_tcpu._tree_part)) ; + // _dump.push("\n"); + // _dump.push(" *redo-part: "); + // _dump.push( + // std::to_string(_tcpu._redo_part)) ; + _dump.push("\n"); + _dump.push(" *part-part: "); + _dump.push( + std::to_string(_tcpu._part_part)) ; + _dump.push("\n"); + _dump.push(" *seqs-part: "); + _dump.push( + std::to_string(_tcpu._seqs_part)) ; + _dump.push("\n"); _dump.push("\n"); } diff --git a/src/libcpp/iter_mesh/iter_mesh_3.hpp b/src/libcpp/iter_mesh/iter_mesh_3.hpp index 6db6b79..c66eceb 100644 --- a/src/libcpp/iter_mesh/iter_mesh_3.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 9 August, 2018 + * Last updated: 9 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp b/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp index 2818e4b..316ffb5 100644 --- a/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp b/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp index f6bdd22..a2cfca9 100644 --- a/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/iter_mesh/iter_node_1.inc b/src/libcpp/iter_mesh/iter_node_1.inc index 2d4b86c..f4e0203 100644 --- a/src/libcpp/iter_mesh/iter_node_1.inc +++ b/src/libcpp/iter_mesh/iter_node_1.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/iter_node_2.inc b/src/libcpp/iter_mesh/iter_node_2.inc index 42a2ba7..e22a70e 100644 --- a/src/libcpp/iter_mesh/iter_node_2.inc +++ b/src/libcpp/iter_mesh/iter_node_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/iter_mesh/iter_node_3.inc b/src/libcpp/iter_mesh/iter_node_3.inc index 84f795e..c592c2d 100644 --- a/src/libcpp/iter_mesh/iter_node_3.inc +++ b/src/libcpp/iter_mesh/iter_node_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp b/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp index abec37b..2c30656 100644 --- a/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp +++ b/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp b/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp index 446a731..b4ee4c5 100644 --- a/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp +++ b/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/iter_mesh/iter_timers.hpp b/src/libcpp/iter_mesh/iter_timers.hpp index 33f7e0c..f845c96 100644 --- a/src/libcpp/iter_mesh/iter_timers.hpp +++ b/src/libcpp/iter_mesh/iter_timers.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 20 Jan., 2022 + * Last updated: 12 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -54,30 +58,25 @@ -------------------------------------------------------- */ - template < - typename R , - typename I - > class iter_timers { public : - typedef R real_type ; - typedef I iptr_type ; - - typedef iter_timers self_type ; - double _iter_full = (double ) +0. ; double _move_node = (double ) +0. ; double _init_node = (double ) +0. ; double _core_node = (double ) +0. ; + double _seqs_node = (double ) +0. ; + double _para_node = (double ) +0. ; double _ldir_node = (double ) +0. ; double _lopt_node = (double ) +0. ; double _move_dual = (double ) +0. ; double _init_dual = (double ) +0. ; double _core_dual = (double ) +0. ; + double _seqs_dual = (double ) +0. ; + double _para_dual = (double ) +0. ; double _ldir_dual = (double ) +0. ; double _lopt_dual = (double ) +0. ; @@ -90,6 +89,17 @@ double _core_zips = (double ) +0. ; double _core_divs = (double ) +0. ; + double _full_part = (double ) +0. ; + double _tree_part = (double ) +0. ; + double _redo_part = (double ) +0. ; + double _part_part = (double ) +0. ; + double _seqs_part = (double ) +0. ; + + double _part_node = (double ) +0. ; + double _part_dual = (double ) +0. ; + double _part_flip = (double ) +0. ; + double _part_topo = (double ) +0. ; + public : /*-------------------------------------- elapsed time */ diff --git a/src/libcpp/iter_mesh/iter_zips_2.inc b/src/libcpp/iter_mesh/iter_zips_2.inc index 1b699ef..778fcc4 100644 --- a/src/libcpp/iter_mesh/iter_zips_2.inc +++ b/src/libcpp/iter_mesh/iter_zips_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 Sept., 2021 + * Last updated: 11 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -44,6 +48,258 @@ // from iter_mesh_2.hpp + __static_call + __normal_call void_type _pop_sets ( + mesh_type &_mesh , // mesh object + conn_list &_ladj // space for adj. cells + ) + { + for (auto _cell = _ladj.head() ; + _cell != _ladj.tend() ; + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + _mesh. + _pop_tri3(_cell->_cell) ; + } + else + if (_cell->_kind == QUAD4_tag) + { + _mesh. + _pop_quad(_cell->_cell) ; + } + } + } + + template < + typename cell_type + > + __static_call + __normal_call void_type _adj_sets ( + mesh_type &_mesh , // mesh object + cell_type &_cdat , // cell to zip + iptr_type _nnod , // no. nodes in cell + conn_list &_list , // space for adj. cells + conn_list &_ladj // space for adj. cells + ) + { + for (auto _cell = _list.head(); + _cell != _list.tend(); + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + /*--------------------------------- set a = { i \ t } */ + auto _tptr = + _mesh. tri3().head()+_cell->_cell; + + iptr_type _nnum, _mnum; + iptr_type _M = _nnod, _same = +0 ; + for(_nnum = 3; _nnum-- != 0; ) + for(_mnum =_M; _mnum-- != 0; ) + { + if (_tptr->node(_nnum) == + _cdat. node(_mnum) ) + { + _same += +1 ; + } + } + + if (_same > +1 ) continue; + } + else + if (_cell->_kind == QUAD4_tag) + { + /*--------------------------------- set a = { i \ q } */ + auto _qptr = + _mesh. quad().head()+_cell->_cell; + + iptr_type _nnum, _mnum; + iptr_type _M = _nnod, _same = +0 ; + for(_nnum = 4; _nnum-- != 0; ) + for(_mnum =_M; _mnum-- != 0; ) + { + if (_qptr->node(_nnum) == + _cdat. node(_mnum) ) + { + _same += +1 ; + } + } + + if (_same > +1 ) continue; + } + + /*----------------- if we got this far, add adj. cell */ + _ladj.push_tail( *_cell ); + } + } + + template < + typename cell_type + > + __static_call + __normal_call void_type _adj_redo ( + mesh_type &_mesh , // mesh object + cell_type &_cdat , // cell to zip + iptr_type _inod , // old node in cell + iptr_type _inew , // new node to push + conn_list &_ladj , // space for adj. cells + conn_list &_lcav // space for adj. cells + ) + { + typename mesh_type::tri3_type _tdat; + typename mesh_type::quad_type _qdat; + + for (auto _cell = _ladj.head(); + _cell != _ladj.tend(); + ++_cell ) + { + if (_cell->_kind == TRIA3_tag) + { + auto _tptr = + _mesh. tri3().head()+_cell->_cell ; + + _tdat.node(0) = _tptr->node(0) ; + _tdat.node(1) = _tptr->node(1) ; + _tdat.node(2) = _tptr->node(2) ; + + _tdat.itag () = _tptr->itag () ; + + iptr_type _nnum ; + for(_nnum = 3; _nnum-- != 0; ) + { + if (_tdat. node(_nnum) == + _cdat. node(_inod) ) + _tdat. node(_nnum) = _inew ; + } + + auto _tnum = + _mesh.push_tri3(_tdat) ; + + _lcav.push_tail( typename + conn_list::data_type(_tnum,TRIA3_tag)); + } + else + if (_cell->_kind == QUAD4_tag) + { + auto _qptr = + _mesh. quad().head()+_cell->_cell ; + + _qdat.node(0) = _qptr->node(0) ; + _qdat.node(1) = _qptr->node(1) ; + _qdat.node(2) = _qptr->node(2) ; + _qdat.node(3) = _qptr->node(3) ; + + _qdat.itag () = _qptr->itag () ; + + iptr_type _nnum ; + for(_nnum = 4; _nnum-- != 0; ) + { + if (_qdat. node(_nnum) == + _cdat. node(_inod) ) + _qdat. node(_nnum) = _inew ; + } + + auto _qnum = + _mesh.push_quad(_qdat) ; + + _lcav.push_tail( typename + conn_list::data_type(_qnum,QUAD4_tag)); + } + } + } + + __static_call + __normal_call void_type _adj_ball ( + mesh_type &_mesh , // mesh object + conn_list &_ladj , // space for adj. cells + real_type *_ball , // accumulate cell ball + real_type &_mass // accumulate cell mass + ) + { + iptr_type static constexpr + _last = pred_type::geom_dims + 0 ; + + for (auto _cell = _ladj.head() ; + _cell != _ladj.tend() ; + ++_cell ) + { + real_type _BALL [_last + 1] = {0}; + real_type _MASS = 0 ; + if (_cell->_kind == TRIA3_tag) + { + /*--------------------------------- accum. ball; tri3 */ + auto _tptr = + _mesh. tri3().head() + _cell->_cell ; + + auto _INOD = _tptr->node(0) ; + auto _JNOD = _tptr->node(1) ; + auto _KNOD = _tptr->node(2) ; + + auto _IPTR = + _mesh. node().head() + _INOD ; + auto _JPTR = + _mesh. node().head() + _JNOD ; + auto _KPTR = + _mesh. node().head() + _KNOD ; + + _MASS = std::abs( + pred_type::tri3_mass( + &_IPTR->pval(+0), + &_JPTR->pval(+0), + &_KPTR->pval(+0)) ) ; + + pred_type::tri3_ball(_BALL, + &_IPTR->pval(+0), + &_JPTR->pval(+0), + &_KPTR->pval(+0), true) ; + } + else + if (_cell->_kind == QUAD4_tag) + { + /*--------------------------------- accum. ball; quad */ + auto _qptr = + _mesh. quad().head() + _cell->_cell ; + + auto _INOD = _qptr->node(0) ; + auto _JNOD = _qptr->node(1) ; + auto _KNOD = _qptr->node(2) ; + auto _LNOD = _qptr->node(3) ; + + auto _IPTR = + _mesh. node().head() + _INOD ; + auto _JPTR = + _mesh. node().head() + _JNOD ; + auto _KPTR = + _mesh. node().head() + _KNOD ; + auto _LPTR = + _mesh. node().head() + _LNOD ; + + _MASS = std::abs( + pred_type::quad_mass( + &_IPTR->pval(+0), + &_JPTR->pval(+0), + &_KPTR->pval(+0), + &_LPTR->pval(+0)) ) ; + + pred_type::quad_ball(_BALL, + &_IPTR->pval(+0), + &_JPTR->pval(+0), + &_KPTR->pval(+0), + &_LPTR->pval(+0), true) ; + } + + for (auto _idim = _last; + _idim-- != +0; ) + { + _ball[_idim] += _MASS * _BALL[_idim] ; + } + _mass += _MASS ; + } + } + + /* -------------------------------------------------------- * _ZIP-EDGE: try edge merge to improve adj. cost-fun. @@ -52,31 +308,31 @@ __static_call __normal_call void_type _zip_edge ( - geom_type &_geom , - mesh_type &_mesh , - hfun_type &_hfun , - real_list &_hval , - iter_opts &_opts , - iptr_list &_nmrk , - iptr_type _iout , - iptr_type _edge , - kern_kind _kern , - bool_type &_okay , - iptr_type &_nnew , - conn_list &_iset , - conn_list &_jset , - conn_list &_aset , - conn_list &_bset , - conn_list &_cset , - real_list &_qsrc , - real_list &_qdst , - real_list &_qtmp , - real_type _QLIM , - iter_stat &_tcpu , - real_type _lmax - = (real_type) +8.00E-01 , - real_type _qinc - = (real_type) +1.00E-02 + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + iter_opts &_opts , // user options + iptr_list &_nmrk , // list of node flags + iptr_type _iout , // outer iteration marker + iptr_type _edge , // edge number to zip. + kern_kind _kern , // optim. kernel selector + bool_type &_okay , // TRUE if zip. successful + iptr_type &_nnew , // new node index added + conn_list &_iset , // space for adj. cells + conn_list &_jset , // space for adj. cells + conn_list &_iadj , // space for adj. cells + conn_list &_jadj , // space for adj. cells + conn_list &_cset , // space for adj. cells + real_list &_qsrc , // space for adj. costs + real_list &_qdst , // space for adj. costs + real_list &_qtmp , // space for adj. costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu , // cpu timers/info + real_type _lmax // zip. spacing threshold + = (real_type) +8.888E-01 , + real_type _qinc // zip. quality threshold + = (real_type) +3.333E-03 ) { iptr_type static constexpr @@ -109,10 +365,11 @@ 0, containers::loose_alloc); _jset.set_count( 0, containers::loose_alloc); - _aset.set_count( + _iadj.set_count( 0, containers::loose_alloc); - _bset.set_count( + _jadj.set_count( 0, containers::loose_alloc); + _cset.set_count( 0, containers::loose_alloc); @@ -214,17 +471,19 @@ // if more regular topo. is constructed via the edge // zip, make it easier to do so! - real_type _qerr = (real_type)( - -1./16.*1./2.*(_ierr + _jerr)); + real_type _qerr = (real_type) + -1./16.*std::max (_ierr, _jerr) ; - real_type _lerr = (real_type)( - +1./16.*1./2.*(_ierr + _jerr)); + real_type _lerr = (real_type) + +1./16.*std::max (_ierr, _jerr) ; if (_dnew < _dnow - 0) { // no oscl. wrt. div - _qerr/= std::pow ( _iout, +1./8.) ; + _qerr/= std::pow ( _iout, +1./4.) ; _qinc = std::min ( _qinc, _qinc + _qerr) ; + + _lerr/= std::pow ( _iout, +1./4.) ; _lmax = std::max ( _lmax, _lmax + _lerr) ; } @@ -282,216 +541,370 @@ /*--------------------------------- get disjoint sets */ _mesh.connect_2(_eptr->node(+0), POINT_tag , _iset) ; - _mesh.connect_2(_eptr->node(+1), - POINT_tag , _jset) ; - - for (auto _cell = _iset.head(); - _cell != _iset.tend(); - ++_cell ) - { - /*--------------------------------- set a = { i \ e } */ - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head()+_cell->_cell ; - - iptr_type _nnum, _same = +0; - for(_nnum = 3; _nnum-- != 0; ) - { - if (_tptr->node(_nnum) == - _eptr->node( 0) ) - _same += +1 ; - - if (_tptr->node(_nnum) == - _eptr->node( 1) ) - _same += +1 ; - } - - if (_same >= +2) continue ; - } - else - if (_cell->_kind == QUAD4_tag) - { - auto _qptr = - _mesh. quad().head()+_cell->_cell ; - iptr_type _nnum, _same = +0; - for(_nnum = 4; _nnum-- != 0; ) - { - if (_qptr->node(_nnum) == - _eptr->node( 0) ) - _same += +1 ; - - if (_qptr->node(_nnum) == - _eptr->node( 1) ) - _same += +1 ; - } - - if (_same >= +2) continue ; - } - - _aset.push_tail( *_cell ) ; - } - - for (auto _cell = _jset.head(); - _cell != _jset.tend(); - ++_cell ) - { - /*--------------------------------- set b = { j \ e } */ - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head()+_cell->_cell ; - - iptr_type _nnum, _same = +0; - for(_nnum = 3; _nnum-- != 0; ) - { - if (_tptr->node(_nnum) == - _eptr->node( 0) ) - _same += +1 ; - - if (_tptr->node(_nnum) == - _eptr->node( 1) ) - _same += +1 ; - } - - if (_same >= +2) continue ; - } - else - if (_cell->_kind == QUAD4_tag) - { - auto _qptr = - _mesh. quad().head()+_cell->_cell ; - - iptr_type _nnum, _same = +0; - for(_nnum = 4; _nnum-- != 0; ) - { - if (_qptr->node(_nnum) == - _eptr->node( 0) ) - _same += +1 ; + _adj_sets( + _mesh, _edat, 2, _iset, _iadj) ; - if (_qptr->node(_nnum) == - _eptr->node( 1) ) - _same += +1 ; - } - - if (_same >= +2) continue ; - } + _mesh.connect_2(_eptr->node(+1), + POINT_tag , _jset) ; - _bset.push_tail( *_cell ) ; - } + _adj_sets( + _mesh, _edat, 2, _jset, _jadj) ; /*--------------------------------- get adjacent cost */ real_type _amin = loop_cost( - _mesh, _iset, _qsrc, cell_kind()) ; + _mesh, + _iset, _qsrc, cell_kind()) ; real_type _bmin = loop_cost( - _mesh, _bset, _qsrc, cell_kind()) ; + _mesh, + _jadj, _qsrc, cell_kind()) ; real_type _qmin = std::min(_amin, _bmin) ; /*--------------------------------- get adjacent ball */ - real_type _ball[_last + 1] = + real_type _ball[_last + 1] = + {(real_type) 0.} ; + real_type _prev[_last + 1] = {(real_type) 0.} ; real_type _mass = (real_type)0.; - for (auto _cell = _iset.head(); - _cell != _iset.tend(); - ++_cell ) + _adj_ball( + _mesh,_iset, _ball, _mass) ; + _adj_ball( + _mesh,_jset, _ball, _mass) ; + + for (auto _idim = + pred_type::geom_dims; _idim-- != 0; ) { - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head() + _cell->_cell ; + _ball[_idim] /= _mass ; + } - auto _INOD = _tptr->node(0) ; - auto _JNOD = _tptr->node(1) ; - auto _KNOD = _tptr->node(2) ; + pred_type:: + proj_node(_geom, _ball, _ball) ; - auto _IPTR = - _mesh. node().head() + _INOD ; - auto _JPTR = - _mesh. node().head() + _JNOD ; - auto _KPTR = - _mesh. node().head() + _KNOD ; + /*--------------------------------- try to merge edge */ + # define NULLHINT hfun_type::null_hint() + # define NULLFEAT null_feat - real_type _BALL [_last + 1] ; - pred_type::tri3_ball(_BALL, - &_IPTR->pval(+0), - &_JPTR->pval(+0), - &_KPTR->pval(+0), true) ; + typename mesh_type::node_type _ndat ; - real_type _MASS = - std::abs(pred_type::tri3_mass ( - &_IPTR->pval(+0), - &_JPTR->pval(+0), - &_KPTR->pval(+0)) ) ; + for (auto _idim = + pred_type::real_dims; _idim-- != 0; ) + { + _ndat.pval(_idim) = _ball[_idim]; + } - _mass += _MASS ; + _ndat.fdim() = (iptr_type) +2 ; + _ndat.feat() = NULLFEAT ; + _ndat.hidx() = NULLHINT ; + _nnew = _mesh.push_node(_ndat); - for (auto _idim = - pred_type::geom_dims; _idim-- != 0; ) - { - _ball[_idim] += - _MASS * _BALL[_idim]; - } - } - } + auto _nptr = + _mesh. node().head () + _nnew ; - for (auto _cell = _jset.head(); - _cell != _jset.tend(); - ++_cell ) + _hval.set_count( std::max( + _nnew+1, (iptr_type)_hval.count())) ; + + _hval[_nnew] = (real_type)-1. ; + + /*--------------------------------- push a new cavity */ + _cset.set_count( +0 ) ; + _adj_redo( _mesh, + _edat, +0, _nnew, _iadj, _cset) ; + + _adj_redo( _mesh, + _edat, +1, _nnew, _jadj, _cset) ; + + /*--------------------------------- optim. node coord */ + iptr_type static + constexpr _INUM = (iptr_type) +4; + + iptr_type _move = -1; + for (auto _iter = +0; _iter != _INUM; + ++_iter ) { - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head() + _cell->_cell ; + _qtmp.set_count( + +0, containers::loose_alloc); - auto _INOD = _tptr->node(0) ; - auto _JNOD = _tptr->node(1) ; - auto _KNOD = _tptr->node(2) ; + real_type _minC = + loop_cost( _mesh, + _cset, _qtmp, cell_kind() + ) ; - auto _IPTR = - _mesh. node().head() + _INOD ; - auto _JPTR = - _mesh. node().head() + _JNOD ; - auto _KPTR = - _mesh. node().head() + _KNOD ; + move_node( _geom, _mesh, + _hfun, _hval, + _opts, _nptr, _prev, + _kern, _move, _cset, + _qtmp, _qdst, + _minC, _QLIM, _tcpu) ; - real_type _BALL [_last + 1] ; - pred_type::tri3_ball(_BALL, - &_IPTR->pval(+0), - &_JPTR->pval(+0), - &_KPTR->pval(+0), true) ; + if (_move <= +0 ) break; + } - real_type _MASS = - std::abs(pred_type::tri3_mass ( - &_IPTR->pval(+0), - &_JPTR->pval(+0), - &_KPTR->pval(+0)) ) ; + /*--------------------------------- is cost improved? */ + _qdst.set_count( + 0, containers::loose_alloc) ; + + real_type _QMIN = + loop_cost( _mesh, + _cset, _qdst, cell_kind()) ; - _mass += _MASS ; + move_okay( _qdst, _qsrc, _move, + std::sqrt( _QLIM) , + _qinc) ; - for (auto _idim = - pred_type::geom_dims; _idim-- != 0; ) - { - _ball[_idim] += - _MASS * _BALL[_idim]; - } - } + if((_okay = _move > 0 && + _QMIN >= _qmin+_qinc)) + { + /*--------------------------------- delete old cavity */ + _pop_sets( _mesh , _iset ); + _pop_sets( _mesh , _jset ); + + _mesh._pop_node ( &_inod ); + _mesh._pop_node ( &_jnod ); + } + else + { + /*--------------------------------- delete new cavity */ + _pop_sets( _mesh , _cset ); + + _mesh._pop_node ( &_nnew ); } + # undef NULLHINT + # undef NULLFEAT + } + + /* + -------------------------------------------------------- + * _ZIP-TRI3: try tri3 merge to improve adj. cost-fun. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type _zip_tri3 ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + iter_opts &_opts , // user options + iptr_list &_nmrk , // list of node flags + iptr_type _iout , // outer iteration marker + iptr_type _tri3 , // tri3 number to zip. + kern_kind _kern , // optim. kernel selector + bool_type &_okay , // TRUE if zip. successful + iptr_type &_nnew , // new node index added + conn_list &_iset , // space for adj. cells + conn_list &_jset , // space for adj. cells + conn_list &_kset , // space for adj. cells + conn_list &_iadj , // space for adj. cells + conn_list &_jadj , // space for adj. cells + conn_list &_kadj , // space for adj. cells + conn_list &_cset , // space for adj. cells + real_list &_qsrc , // space for adj. costs + real_list &_qdst , // space for adj. costs + real_list &_qtmp , // space for adj. costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu , // cpu timers/info + real_type _lmax // zip. spacing threshold + = (real_type) +8.666E-01 , + real_type _qinc // zip. quality threshold + = (real_type) +3.333E-03 + ) + { + iptr_type static constexpr + _last = pred_type::geom_dims + 0 ; + + iptr_type static constexpr + _DEG_TRIA3 = (iptr_type)+6 ; + // iptr_type static constexpr + // _DEG_QUAD4 = (iptr_type)+4 ; + + __unreferenced (_iout) ; + + /*--------------------------------- get face indexing */ + auto _fptr = + _mesh. tri3().head()+_tri3 ; + + typename mesh_type:: + tri3_type _fdat(*_fptr) ; + + iptr_type _inod, _jnod, _knod ; + _inod = _fptr->node(0) ; + _jnod = _fptr->node(1) ; + _knod = _fptr->node(2) ; + + auto _iptr = _mesh. + node().head() + _fptr->node(0); + auto _jptr = _mesh. + node().head() + _fptr->node(1); + auto _kptr = _mesh. + node().head() + _fptr->node(2); + + _okay = false ; + + _iset.set_count( + 0, containers::loose_alloc); + _jset.set_count( + 0, containers::loose_alloc); + _kset.set_count( + 0, containers::loose_alloc); + _iadj.set_count( + 0, containers::loose_alloc); + _jadj.set_count( + 0, containers::loose_alloc); + _kadj.set_count( + 0, containers::loose_alloc); + + _cset.set_count( + 0, containers::loose_alloc); + + _qsrc.set_count( + 0, containers::loose_alloc); + _qdst.set_count( + 0, containers::loose_alloc); + _qtmp.set_count( + 0, containers::loose_alloc); + + /*--------------------------------- exit if FEAT node */ + if (_iptr->feat() != null_feat) + return ; + if (_jptr->feat() != null_feat) + return ; + if (_kptr->feat() != null_feat) + return ; + + /*--------------------------------- calc. local topo. */ + auto _ideg = + _mesh .node(_inod).ndeg(TRIA3_tag) ; + auto _jdeg = + _mesh .node(_jnod).ndeg(TRIA3_tag) ; + auto _kdeg = + _mesh .node(_knod).ndeg(TRIA3_tag) ; + + if (_nmrk[_inod] < 0) _ideg = 6 ; + if (_nmrk[_jnod] < 0) _jdeg = 6 ; + if (_nmrk[_knod] < 0) _kdeg = 6 ; + + auto _ierr = + (iptr_type)(_DEG_TRIA3-_ideg) ; + auto _jerr = + (iptr_type)(_DEG_TRIA3-_jdeg) ; + auto _kerr = + (iptr_type)(_DEG_TRIA3-_kdeg) ; + + auto _ndeg = _ideg + _jdeg + _kdeg - 3*3 ; + + auto _nerr = + (iptr_type)(_DEG_TRIA3-_ndeg) ; + + auto _dnew = std::abs(_nerr) ; + auto _dnow = std::abs(_ierr) + + std::abs(_jerr) + + std::abs(_kerr) ; + + // bail-out early if the topological defect would be + // made worse if the zip is done + + if (_dnew > _dnow + 0) return ; + + /*--------------------------------- get face h-sizing */ + real_type _pbal[ _last + 1 ] ; + pred_type::tri3_ball ( _pbal , + &_iptr->pval( +0 ) , + &_jptr->pval( +0 ) , + &_kptr->pval( +0 ) , true) ; + + pred_type:: + proj_node(_geom, _pbal, _pbal); + + real_type _isiz, _jsiz, _ksiz ; + real_type _bsiz; + _isiz = _hfun.eval( + &_iptr->pval(0), _iptr->hidx()) ; + _jsiz = _hfun.eval( + &_jptr->pval(0), _jptr->hidx()) ; + _ksiz = _hfun.eval( + &_kptr->pval(0), _kptr->hidx()) ; + + auto _hint = _iptr->hidx() ; + + _bsiz = _hfun.eval(_pbal , _hint) ; + + real_type _lsqr = + _pbal[_last] * (real_type)+3. ; + real_type _hbar = + _isiz * (real_type)(1./6.) + + _jsiz * (real_type)(1./6.) + + _ksiz * (real_type)(1./6.) + + _bsiz * (real_type)(3./6.) ; + + /*--------------------------------- exit if too large */ + if (_lsqr >= _hbar * _lmax * + _hbar * _lmax ) + return ; + + /*--------------------------------- get disjoint sets */ + _mesh.connect_2(_fptr->node(+0), + POINT_tag , _iset) ; + + _adj_sets( + _mesh, _fdat, 3, _iset, _iadj) ; + + _mesh.connect_2(_fptr->node(+1), + POINT_tag , _jset) ; + + _adj_sets( + _mesh, _fdat, 3, _jset, _jadj) ; + + _mesh.connect_2(_fptr->node(+2), + POINT_tag , _kset) ; + + _adj_sets( + _mesh, _fdat, 3, _kset, _kadj) ; + + /*--------------------------------- get adjacent cost */ + real_type _amin = loop_cost( + _mesh, + _iset, _qsrc, cell_kind()) ; + + real_type _bmin = loop_cost( + _mesh, + _jadj, _qsrc, cell_kind()) ; + + real_type _cmin = loop_cost( + _mesh, + _kadj, _qsrc, cell_kind()) ; + + real_type _qmin = + std::min( {_amin, _bmin, _cmin} ) ; + + /*--------------------------------- get adjacent ball */ + real_type _ball[_last + 1] = + {(real_type) 0.} ; + real_type _prev[_last + 1] = + {(real_type) 0.} ; + real_type _mass = (real_type)0.; + + _adj_ball( + _mesh,_iset, _ball, _mass) ; + _adj_ball( + _mesh,_jset, _ball, _mass) ; + _adj_ball( + _mesh,_kset, _ball, _mass) ; + for (auto _idim = pred_type::geom_dims; _idim-- != 0; ) { - _ball[_idim] /= _mass; + _ball[_idim] /= _mass ; } pred_type:: - proj_node(_geom, _ball, _ball); + proj_node(_geom, _ball, _ball) ; - /*--------------------------------- try to merge edge */ + /*--------------------------------- try to merge face */ # define NULLHINT hfun_type::null_hint() # define NULLFEAT null_feat @@ -515,131 +928,23 @@ _mesh. node().head () + _nnew ; _hval.set_count( std::max( - _nnew + 1, (iptr_type)_hval.count())) ; + _nnew+1, (iptr_type)_hval.count())) ; _hval[_nnew] = (real_type)-1. ; /*--------------------------------- push a new cavity */ - _cset.set_count(0) ; - for (auto _cell = _aset.head(); - _cell != _aset.tend(); - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head()+_cell->_cell ; - - _tdat.node(0) = _tptr->node(0) ; - _tdat.node(1) = _tptr->node(1) ; - _tdat.node(2) = _tptr->node(2) ; - - _tdat.itag () = _tptr->itag () ; - - iptr_type _nnum ; - for(_nnum = 3; _nnum-- != 0; ) - { - if (_tdat. node(_nnum) == - _edat. node(0) ) - _tdat. node(_nnum) = _nnew ; - } - - auto _tnum = - _mesh.push_tri3(_tdat) ; - - _cset.push_tail( typename - conn_list::data_type(_tnum,TRIA3_tag)); - } - else - if (_cell->_kind == QUAD4_tag) - { - auto _qptr = - _mesh. quad().head()+_cell->_cell ; - - _qdat.node(0) = _qptr->node(0) ; - _qdat.node(1) = _qptr->node(1) ; - _qdat.node(2) = _qptr->node(2) ; - _qdat.node(3) = _qptr->node(3) ; - - _qdat.itag () = _qptr->itag () ; - - iptr_type _nnum ; - for(_nnum = 4; _nnum-- != 0; ) - { - if (_qdat. node(_nnum) == - _edat. node(0) ) - _qdat. node(_nnum) = _nnew ; - } - - auto _qnum = - _mesh.push_quad(_qdat) ; - - _cset.push_tail( typename - conn_list::data_type(_qnum,QUAD4_tag)); - } - } + _adj_redo( _mesh, + _fdat, +0, _nnew, _iadj, _cset) ; - for (auto _cell = _bset.head(); - _cell != _bset.tend(); - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - auto _tptr = - _mesh. tri3().head()+_cell->_cell ; - - _tdat.node(0) = _tptr->node(0) ; - _tdat.node(1) = _tptr->node(1) ; - _tdat.node(2) = _tptr->node(2) ; - - _tdat.itag () = _tptr->itag () ; - - iptr_type _nnum ; - for(_nnum = 3; _nnum-- != 0; ) - { - if (_tdat. node(_nnum) == - _edat. node(1) ) - _tdat. node(_nnum) = _nnew ; - } - - auto _tnum = - _mesh.push_tri3(_tdat) ; - - _cset.push_tail( typename - conn_list::data_type(_tnum,TRIA3_tag)); - } - else - if (_cell->_kind == QUAD4_tag) - { - auto _qptr = - _mesh. quad().head()+_cell->_cell ; - - _qdat.node(0) = _qptr->node(0) ; - _qdat.node(1) = _qptr->node(1) ; - _qdat.node(2) = _qptr->node(2) ; - _qdat.node(3) = _qptr->node(3) ; - - _qdat.itag () = _qptr->itag () ; - - iptr_type _nnum ; - for(_nnum = 4; _nnum-- != 0; ) - { - if (_qdat. node(_nnum) == - _edat. node(1) ) - _qdat. node(_nnum) = _nnew ; - } - - auto _qnum = - _mesh.push_quad(_qdat) ; + _adj_redo( _mesh, + _fdat, +1, _nnew, _jadj, _cset) ; - _cset.push_tail( typename - conn_list::data_type(_qnum,QUAD4_tag)); - } - } + _adj_redo( _mesh, + _fdat, +2, _nnew, _kadj, _cset) ; /*--------------------------------- optim. node coord */ iptr_type static - constexpr _INUM = (iptr_type) +4; + constexpr _INUM = (iptr_type) +4; iptr_type _move = -1; for (auto _iter = +0; _iter != _INUM; @@ -654,10 +959,10 @@ ) ; move_node( _geom, _mesh, - _hfun, _hval, - _opts, _nptr, _kern, - _move, _cset, - _qtmp, _qdst, + _hfun, _hval, + _opts, _nptr, _prev, + _kern, _move, _cset, + _qtmp, _qdst, _minC, _QLIM, _tcpu) ; if (_move <= +0 ) break; @@ -679,61 +984,18 @@ _QMIN >= _qmin+_qinc)) { /*--------------------------------- delete old cavity */ - for (auto _cell = _aset.head() ; - _cell != _aset.tend() ; - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - _mesh. - _pop_tri3(_cell->_cell) ; - } - else - if (_cell->_kind == QUAD4_tag) - { - _mesh. - _pop_quad(_cell->_cell) ; - } - } - for (auto _cell = _jset.head() ; - _cell != _jset.tend() ; - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - _mesh. - _pop_tri3(_cell->_cell) ; - } - else - if (_cell->_kind == QUAD4_tag) - { - _mesh. - _pop_quad(_cell->_cell) ; - } - } + _pop_sets( _mesh , _iset ); + _pop_sets( _mesh , _jset ); + _pop_sets( _mesh , _kset ); _mesh._pop_node ( &_inod ); _mesh._pop_node ( &_jnod ); + _mesh._pop_node ( &_knod ); } else { /*--------------------------------- delete new cavity */ - for (auto _cell = _cset.head() ; - _cell != _cset.tend() ; - ++_cell ) - { - if (_cell->_kind == TRIA3_tag) - { - _mesh. - _pop_tri3(_cell->_cell) ; - } - else - if (_cell->_kind == QUAD4_tag) - { - _mesh. - _pop_quad(_cell->_cell) ; - } - } + _pop_sets( _mesh , _cset ); _mesh._pop_node ( &_nnew ); } diff --git a/src/libcpp/iter_mesh/iter_zips_3.inc b/src/libcpp/iter_mesh/iter_zips_3.inc index ac6ff75..2b75321 100644 --- a/src/libcpp/iter_mesh/iter_zips_3.inc +++ b/src/libcpp/iter_mesh/iter_zips_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 August, 2018 + * Last updated: 12 Aug., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/iter_mesh/move_mesh_2.inc b/src/libcpp/iter_mesh/move_mesh_2.inc new file mode 100644 index 0000000..8c1e119 --- /dev/null +++ b/src/libcpp/iter_mesh/move_mesh_2.inc @@ -0,0 +1,1442 @@ + + /* + -------------------------------------------------------- + * MOVE-MESH-2: update cell/dual geometries. + -------------------------------------------------------- + * + * 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: 11 Dec., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda, + * Marc Tunnell + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * MOVE-NODE: "limited" single node coord. update. + -------------------------------------------------------- + */ + + #include "iter_node_2.inc" + + template < + typename node_iter + > + __static_call + __inline_call void_type move_node ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + 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 + kern_kind _kern , // optim. kernel selector + iptr_type &_move , // > 0 if move successful + conn_list &_conn , // list of adj. cells + real_list &_qold , // list of old adj. costs + real_list &_qnew , // list of new adj. costs + real_type _QMIN , // minimum adj. old costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu // CPU timers/info + ) + { + /*---------------- try variational; fallback on dQ/dx */ + move_kern( _geom, _mesh, _hfun, + _hval, _opts, _node, _last, + _kern, _move, _conn, + _qold, _qnew, + _QMIN, _QLIM, _tcpu) ; // variational + + if (_move >= +0 ) return ; + + move_kern( _geom, _mesh, _hfun, + _hval, _opts, _node, _last, + dqdx_optimise, + _move, _conn, + _qold, _qnew, + _QMIN, _QLIM, _tcpu) ; // local dQ/dx + + if (_move >= +0 ) return ; + } + + template < + typename node_iter + > + __static_call + __normal_call void_type move_kern ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + 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 + kern_kind _kern , // optim. kernel selector + iptr_type &_move , // > 0 if move successful + conn_list &_conn , // list of adj. cells + real_list &_qold , // list of old adj. costs + real_list &_qnew , // list of new adj. costs + real_type _QMIN , // minimum adj. old costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu // CPU timers/info + ) + { + /*---------------- optimise single node's coordinates */ + iptr_type static + constexpr _ITER = (iptr_type) +5 ; + + // ifdef __use_timers + // typename std ::chrono:: + // high_resolution_clock::time_point _ttic ; + // typename std ::chrono:: + // high_resolution_clock::time_point _ttoc ; + // typename std ::chrono:: + // high_resolution_clock _time ; + + // __unreferenced(_time) ; // why does MSVC need this?? + // endif//__use_timers + + __unreferenced(_tcpu) ; + + _move = (iptr_type)-1 ; + + real_type _line[geom_dims] = + {(real_type)+0.0} ; + real_type _step[geom_dims] = + {(real_type)+0.0} ; + real_type _save[geom_dims] = + {(real_type)+0.0} ; + real_type _proj[geom_dims] = + {(real_type)+0.0} ; + + /*---------------- calc. line search direction vector */ + + // ifdef __use_timers + // _ttic = _time.now() ; + // endif//__use_timers + + real_type _ladj = (real_type) +0. ; + + if (_kern == _odt_optimise) + { + /*--------------------------- ODT-style update vector */ + _odt_move_2 ( + _geom, _mesh, _hfun, _hval, + _conn, _node, + _line, _ladj) ; + } + else + if (_kern == _cvt_optimise) + { + /*--------------------------- CVT-style update vector */ + _cvt_move_2 ( + _geom, _mesh, _hfun, _hval, + _conn, _node, + _line, _ladj) ; + } + else + if (_kern == dqdx_optimise) + { + if (_QMIN<=_QLIM) + { + /*--------------------------- d./dx Q^T update vector */ + dqdx_move_2 ( + _mesh, _conn, _node, _qold, + _line, _ladj) ; + } + else { return ; } + } + + // ifdef __use_timers + // _ttoc = _time.now() ; + // _tcpu._ldir_node += _tcpu.nano_span(_ttic, _ttoc) ; + // endif//__use_timers + + /*---------------- scale line search direction vector */ + real_type _xeps = // delta_x ~= 0.0 + (real_type)+0.01*_opts.qtol() ; + + real_type _xtol = // delta_x reltol + +std::sqrt(_opts.qtol()) / +10.0 ; + + if (_kern == dqdx_optimise) // test cost-only + { + _QLIM = + +std::numeric_limits::infinity() ; + } + + auto _ppos = &_node->pval(0) ; + + real_type _lsqr ; + _lsqr = std::pow(_ladj, 2) ; + _xeps = std::pow(_xeps, 2) ; + _xtol = std::pow(_xtol, 2) ; + + real_type _SCAL[_ITER] = { // overrelaxation + (real_type) std::sqrt( 2.0 ) , + (real_type) +1.00, + (real_type) +0.50, + (real_type) +0.25, + (real_type) +.125 } ; + + /*---------------- do backtracking line search iter's */ + + // ifdef __use_timers + // _ttic = _time.now() ; + // endif//__use_timers + + for (auto _idim = + pred_type::geom_dims; _idim-- != +0; ) + { + _save[_idim] = _ppos [_idim] ; + } + + for (auto _iter = +0 ; + _iter != _ITER; ++_iter ) + { + /*---------------- push update along search direction */ + real_type _scal = _SCAL[_iter]; + + real_type _zeta = _opts._zeta * + std::min ((real_type)1.,_scal) ; + + real_type _beta = _opts._beta ; + + for (auto _idim = + pred_type::geom_dims; _idim-- != +0; ) + { + /*---------------- momentum-type bias for search dir. */ + _step[_idim] = + _last[_idim]*((real_type)0.+_beta) + + _line[_idim]*((real_type)1.-_beta) ; + + _proj[_idim] = + _save[_idim] + _scal * ( + _step[_idim]*((real_type)0.+_zeta) + + _line[_idim]*((real_type)1.-_zeta)); + } + + /*---------------- ensure projection is on to surface */ + pred_type:: + proj_node (_geom, _save, _proj) ; + + for (auto _idim = + pred_type::geom_dims; _idim-- != +0; ) + { + _ppos[_idim] = _proj[_idim] ; + } + + real_type _XTOL = _xtol * _scal; // armijo + real_type _XEPS = _xeps * + std::min ((real_type)1.,_scal) ; + + real_type _lmov = + pred_type::length_sq(_save, _proj) ; + + if (_lmov <= _XEPS * _lsqr) break; + + //_move = +1 ; return ; + + /*---------------- test quasi-monotonicity w.r.t. Q^T */ + _qnew.set_count(0) ; + + loop_cost( _mesh, _conn, _qnew, + cell_kind ()) ; + + move_okay( _qnew, _qold, _move, + _QLIM, _opts.qtol(), + _lmov, _XTOL* _lsqr) ; + + if (_move >= +0) break ; + } + + if (_move <= +0) + { + /*---------------- swap with the saved coord. if fail */ + for (auto _idim = + pred_type::geom_dims; _idim-- != +0; ) + { + _ppos[_idim] = _save[_idim] ; + + _last[_idim]/= (real_type)4.; // reset! + } + } + else + { + /*---------------- save line dir. for momentum update */ + for (auto _idim = + pred_type::geom_dims; _idim-- != +0; ) + { + _last[_idim] = _step[_idim] ; + } + } + + // ifdef __use_timers + // _ttoc = _time.now() ; + // _tcpu._lopt_node += _tcpu.nano_span(_ttic, _ttoc) ; + // endif//__use_timers + + } + + /* + -------------------------------------------------------- + * MOVE-DUAL: "limited" single node weight update. + -------------------------------------------------------- + */ + + #include "iter_dual_2.inc" + + template < + typename node_iter + > + __static_call + __normal_call void_type move_dual ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + hfun_type &_hfun , // spacing object + 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 + iptr_type &_move , // > 0 if move successful + conn_list &_conn , // list of adj. cells + real_list &_dold , // list of old adj. costs + real_list &_dnew , // list of new adj. costs + real_type _DMIN , // minimum adj. old costs + real_type _DLIM , // dual quality threshold + iter_stat &_tcpu // CPU timers/info + ) + { + /*---------------- optimise single node's coordinates */ + iptr_type static + constexpr _ITER = (iptr_type) +5 ; + + // ifdef __use_timers + // typename std ::chrono:: + // high_resolution_clock::time_point _ttic ; + // typename std ::chrono:: + // high_resolution_clock::time_point _ttoc ; + // typename std ::chrono:: + // high_resolution_clock _time ; + + // __unreferenced(_time) ; // why does MSVC need this?? + // endif//__use_timers + + __unreferenced(_geom) ; + __unreferenced(_hfun) ; + __unreferenced(_hval) ; + __unreferenced(_tcpu) ; + + _move = (iptr_type)-1 ; + + real_type _wadj, _line, _step; + + /*---------------- calc. line search direction vector */ + + // ifdef __use_timers + // _ttic = _time.now() ; + // endif//__use_timers + + if (_DMIN <= _DLIM) + { + dqdw_move_2 ( + _mesh, _conn, _node, _dold, + _line, _wadj) ; + } + else { return ; } + + // ifdef __use_timers + // _ttoc = _time.now() ; + // _tcpu._ldir_dual += _tcpu.nano_span(_ttic, _ttoc) ; + // endif//__use_timers + + /*---------------- scale line search direction vector */ + real_type _weps = // delta_w ~= 0.0 + (real_type)+.01*_opts.qtol() ; + + real_type _save = + _node->pval( + pred_type::real_dims - 1); + + real_type _SCAL[_ITER] = { // overrelaxation + (real_type) std::sqrt( 2.0 ) , + (real_type) +1.00, + (real_type) +0.50, + (real_type) +0.25, + (real_type) +.125 } ; + + /*---------------- do backtracking line search iter's */ + + // ifdef __use_timers + // _ttic = _time.now() ; + // endif//__use_timers + + for (auto _iter = +0 ; + _iter != _ITER; ++_iter ) + { + real_type _scal = _SCAL[_iter]; + + real_type _zeta = _opts._zeta * + (real_type)3./4. * + std::min((real_type)1.,_scal) ; + + real_type _beta = _opts._beta ; + + /*---------------- momentum-type bias for search dir. */ + _step = + _last * ((real_type)0.+_beta) + + _line * ((real_type)1.-_beta) ; + + _node->pval(real_dims-1) = + _save + _scal * ( + _step * ((real_type)0.+_zeta) + + _line * ((real_type)1.-_zeta)); + + _node->pval(real_dims-1) = + std::max(-_wadj , + _node->pval(real_dims-1)); + + _node->pval(real_dims-1) = + std::min(+_wadj , + _node->pval(real_dims-1)); + + real_type _wmov = + std::abs (_save - + _node->pval(real_dims-1)); + + real_type _wtol = _weps * _wadj * + std::min ((real_type)1.0, _scal); + + if (_wmov <= _wtol) break; + + /*---------------- test quasi-monotonicity w.r.t. Q^D */ + _dnew.set_count(0) ; + + loop_cost( _mesh, _conn, _dnew , + dual_kind ()) ; + + move_okay( _dnew, _dold, _move , + _DLIM, _opts.qtol()) ; + + if (_move >= +0) break ; + } + + /*---------------- swap with the saved coord. if fail */ + if (_move <= +0) + { + _node->pval(real_dims-1) = _save ; + + _last/= (real_type) 4. ; // reset dir., fail + } + else + { + _last = _step ; + } + + // ifdef __use_timers + // _ttoc = _time.now() ; + // _tcpu._lopt_dual += _tcpu.nano_span(_ttic, _ttoc) ; + // endif//__use_timers + + } + + /* + -------------------------------------------------------- + * MOVE-NODE: do a single node smoothing pass. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type move_node ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + conn_sets &_CONN , // cached node adj. indexing + hfun_type &_hfun , // spacing object + char_type _kern , // optim. kernel selector + real_list &_hval , // cached node spacing array + line_list &_last , // lagged line direction + iptr_list &_nset , // list of nodes active + iptr_list &_aset , // space for new active list + mark_list &_mark , // sets of node/cell flags + part_data &_part , // mesh parallel partition + iptr_type _iout , // outer iteration marker + iptr_type _isub , // inner iteration marker + iter_opts &_opts , // user options + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iter_stat &_tcpu // CPU timers/info + ) + { + # define MARK(_NODE) _mark._node[_NODE] + + class move_task // inner loop: MOVE-NODE + { + public : + __inline_call void operator() ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + iptr_type _apos , // index of node to update + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + conn_sets &_CONN , // cached node adj. indexing + char_type _kern , // optim. kernel selector + line_list &_last , // lagged line direction + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _iout , // outer iteration marker + iter_opts &_opts , // user options + conn_list &_conn , // space for connectivity + real_list &_qold , // space for adj. costs + real_list &_qnew , // space for adj. costs + real_type _QLIM , // cell quality threshold + iter_stat &_tcpu // CPU timers/info + ) const + { + /*---------------- apply single move-node updates */ + auto _node = + _mesh.node().head()+ _apos ; + + /*---------------- assemble a local tria. stencil */ + _conn.set_count( +0) ; + _conn.push_tail( + _CONN._adj2.head()+_CONN._idx2[_apos+0], + _CONN._adj2.head()+_CONN._idx2[_apos+1] + ) ; + + if (_conn.empty() ) return ; + + if (_mark._node[_apos] >= +0) + { + /*---------------- attempt to optimise CELL geom. */ + _qold.set_count( +0) ; + _qnew.set_count( +0) ; + + real_type _QMIN = + loop_cost( _mesh, + _conn, _qold, cell_kind()); + + iptr_type _move = -1 ; + + if (_move < +0 ) + { + /*---------------- do optimisation of node coord. */ + move_node( _geom, _mesh, + _hfun, _hval, + _opts, _node, + &_last[ _apos][ +0 ], + _kern, _move, _conn, + _qold, _qnew, + _QMIN, _QLIM, _tcpu) ; + } + + if (_move > +0 ) + { + /*---------------- update when state is improving */ + _hval[_apos] = (real_type)-1 ; + + if (std::abs( + MARK( _apos )) !=_iout) + { + if (MARK( _apos ) >= 0) + MARK( _apos ) = +_iout; + else + MARK( _apos ) = -_iout; + + // pragma omp critical(NS) + { + _nset.push_tail (_apos) ; + } + } + + } + } + } + } ; + + iptr_type constexpr PART_SCAL = +32 ; + iptr_type constexpr BNDS_SCAL = 4096 ; + + # define SBEG(_PASS)(_PASS == +0 ? \ + _aset.head() : _aset.tail()) + + # define SEND(_PASS)(_PASS == +0 ? \ + _aset.tend() : _aset.hend()) + + # define PBEG(_PART, _PASS, _RANK)( \ + _PASS == +0 ? \ + _PART._lptr[_RANK + 0] + 0 : \ + _PART._lptr[_RANK + 1] - 1) + + # define PEND(_PART, _PASS, _RANK)( \ + _PASS == +0 ? \ + _PART._lptr[_RANK + 1] + 0 : \ + _PART._lptr[_RANK + 0] - 1) + + # define ITER(_PASS)(_PASS == +0 ? +1 : -1) + + iptr_type _pful, _pbnd; + conn_list _conn; + real_list _qold, _qnew; + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*-------------------- permute nodes for optimisation */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + if (_isub == +0) + sort_node(_mesh, _CONN, _aset, + _mark._node, + _iout,_isub, _QLIM, _DLIM, _opts) ; + + _pful = std::sqrt(_aset.count ()) / + PART_SCAL ; + _pful = std::min( + _opts. nprt(), _pful + 1) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + if (_pful <= +1 ) + { + /*-------------------- single part: sequential scheme */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + /*-------------------- SYMMETRIC GAUSS-SEIDEL on CELL */ + + if (_opts .tria()) // 1=>GS, 2=>SGS + { + for (auto _pass = 0; _pass < 2; ++_pass) + for (auto _apos = SBEG(_pass) ; + _apos != SEND(_pass) ; + _apos += ITER(_pass) ) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _kern, _last, + _nset , _mark, + _iout , _opts, + _conn , _qold, _qnew, _QLIM, + _tcpu ) ; + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + } + else + { + /*-------------------- multiple-part: thread-parallel */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + if (_isub == +0) + part_mesh(_mesh, _part._full, _pful, + _aset, + _isub, _tcpu) ; + + _pbnd = _part._full._seqs.count() / + BNDS_SCAL ; + _pbnd = std::min( + _opts. nprt(), _pbnd + 1) ; + + if (_isub == +0) + part_mesh(_mesh, _part._bnds, _pbnd, + _part. _full._seqs, + _isub, _tcpu) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._part_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*-------------------- SYMMETRIC GAUSS-SEIDEL on CELL */ + + if (_opts .tria()) // 1=>GS, 2=>SGS + { + /*--------------------------------- purely sequential */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _apos = + _part._bnds._seqs.head(); + _apos != + _part._bnds._seqs.tend(); + _apos += +1) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _kern, _last, + _nset , _mark, + _iout , _opts, + _conn , _qold, _qnew, _QLIM, + _tcpu ) ; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_node += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*--------------------------------- parallel on outer */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + # ifdef __use_openmp + omp_set_num_threads( + _part._bnds._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _kern, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _QOLD, _QNEW; + iptr_list _NSET; + iptr_type _pass = 0u ; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + for (auto _apos = PBEG(_part. _bnds, + _pass, _rank) ; + _apos != PEND(_part. _bnds, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._bnds._list [_apos] ; + + if (_part._bnds._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _kern, _last, + _NSET , _mark, + _iout , _opts, + _CSET , _QOLD, _QNEW, _QLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + /*--------------------------------- parallel on inner */ + # ifdef __use_openmp + omp_set_num_threads( + _part._full._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _kern, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _QOLD, _QNEW; + iptr_list _NSET; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._full._lptr.count()-1; ++_rank) + { + for (auto _pass = 0; _pass < 2; ++_pass) + for (auto _apos = PBEG(_part. _full, + _pass, _rank) ; + _apos != PEND(_part. _full, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._full._list [_apos] ; + + if (_part._full._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _kern, _last, + _NSET , _mark, + _iout , _opts, + _CSET , _QOLD, _QNEW, _QLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._full._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + /*--------------------------------- parallel on outer */ + # ifdef __use_openmp + omp_set_num_threads( + _part._bnds._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _kern, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _QOLD, _QNEW; + iptr_list _NSET; + iptr_type _pass = 1u ; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + for (auto _apos = PBEG(_part. _bnds, + _pass, _rank) ; + _apos != PEND(_part. _bnds, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._bnds._list [_apos] ; + + if (_part._bnds._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _kern, _last, + _NSET , _mark, + _iout , _opts, + _CSET , _QOLD, _QNEW, _QLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._para_node += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*--------------------------------- purely sequential */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _apos = + _part._bnds._seqs.tail(); + _apos != + _part._bnds._seqs.hend(); + _apos += -1) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _kern, _last, + _nset , _mark, + _iout , _opts, + _conn , _qold, _qnew, _QLIM, + _tcpu ) ; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_node += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_node += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + } //if opts.tria + + } //if _nptr > 1 + + # undef MARK + # undef SBEG + # undef SEND + # undef PBEG + # undef PEND + # undef ITER + } + + /* + -------------------------------------------------------- + * MOVE-DUAL: do a single dual smoothing pass. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type move_dual ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + conn_sets &_CONN , // cached node adj. indexing + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + real_list &_last , // lagged line direction + iptr_list &_nset , // list of nodes active + iptr_list &_aset , // space for new active list + mark_list &_mark , // sets of node/cell flags + part_data &_part , // mesh parallel partition + iptr_type _iout , // outer iteration marker + iptr_type _isub , // inner iteration marker + iter_opts &_opts , // user options + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iter_stat &_tcpu // CPU timers/info + ) + { + # define MARK(_NODE) _mark._node[_NODE] + + class move_task // inner loop: MOVE-DUAL + { + public : + __inline_call void operator() ( + geom_type &_geom , // geometry object + mesh_type &_mesh , // mesh object + iptr_type _apos , // index of node to update + hfun_type &_hfun , // spacing object + real_list &_hval , // cached node spacing array + conn_sets &_CONN , // cached node adj. indexing + real_list &_last , // lagged line direction + iptr_list &_nset , // list of nodes active + mark_list &_mark , // sets of node/cell flags + iptr_type _iout , // outer iteration marker + iter_opts &_opts , // user options + conn_list &_conn , // space for connectivity + real_list &_dold , // space for adj. costs + real_list &_dnew , // space for adj. costs + real_type _DLIM , // dual quality threshold + iter_stat &_tcpu // CPU timers/info + ) const + { + /*---------------- apply single move-dual updates */ + auto _node = + _mesh.node().head()+ _apos ; + + /*---------------- assemble a local tria. stencil */ + _conn.set_count( +0) ; + _conn.push_tail( + _CONN._adj2.head()+_CONN._idx2[_apos+0], + _CONN._adj2.head()+_CONN._idx2[_apos+1] + ) ; + + if (_conn.empty() ) return ; + + /*---------------- attempt to optimise DUAL geom. */ + _dold.set_count( +0) ; + _dnew.set_count( +0) ; + + real_type _DMIN = + loop_cost( _mesh, + _conn, _dold, dual_kind()); + + iptr_type _move = -1 ; + + if (_move < +0 ) + { + /*---------------- do optimisation of node weight */ + move_dual( _geom, _mesh, + _hfun, _hval, + _opts, _node, + _last[ _apos] , + _move, _conn, + _dold, _dnew, + _DMIN, _DLIM, _tcpu) ; + } + + if (_move > +0 ) + { + /*---------------- update when state is improving */ + if (std::abs( + MARK( _apos )) !=_iout) + { + if (MARK( _apos ) >= 0) + MARK( _apos ) = +_iout; + else + MARK( _apos ) = -_iout; + + // pragma omp critical(NS) + { + _nset.push_tail (_apos) ; + } + } + + } + } + } ; + + iptr_type constexpr PART_SCAL = +32 ; + iptr_type constexpr BNDS_SCAL = 4096; + + # define SBEG(_PASS)(_PASS == +0 ? \ + _aset.head() : _aset.tail()) + + # define SEND(_PASS)(_PASS == +0 ? \ + _aset.tend() : _aset.hend()) + + # define PBEG(_PART, _PASS, _RANK)( \ + _PASS == +0 ? \ + _PART._lptr[_RANK + 0] + 0 : \ + _PART._lptr[_RANK + 1] - 1) + + # define PEND(_PART, _PASS, _RANK)( \ + _PASS == +0 ? \ + _PART._lptr[_RANK + 1] + 0 : \ + _PART._lptr[_RANK + 0] - 1) + + # define ITER(_PASS)(_PASS == +0 ? +1 : -1) + + iptr_type _pful, _pbnd; + conn_list _conn; + real_list _dold, _dnew; + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic ; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc ; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + /*-------------------- permute nodes for optimisation */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + if (_isub == +0) + sort_node(_mesh, _CONN, _aset, + _mark._node, + _iout,_isub, _QLIM, _DLIM, _opts) ; + + _pful = std::sqrt(_aset.count ()) / + PART_SCAL ; + _pful = std::min( + _opts. nprt(), _pful + 1) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._init_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + if (_pful <= +1 ) + { + /*-------------------- single part: sequential scheme */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + /*-------------------- SYMMETRIC GAUSS-SEIDEL on DUAL */ + + if (_opts .dual()) // 1=>GS, 2=>SGS + { + for (auto _pass = 0; _pass < 2; ++_pass) + for (auto _apos = SBEG(_pass) ; + _apos != SEND(_pass) ; + _apos += ITER(_pass) ) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _last, + _nset , _mark, + _iout , _opts, + _conn , _dold, _dnew, _DLIM, + _tcpu ) ; + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._core_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + } + else + { + /*-------------------- multiple-part: thread-parallel */ + + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + if (_isub == +0) + part_mesh(_mesh, _part._full, _pful, + _aset, + _isub, _tcpu) ; + + _pbnd = _part._full._seqs.count() / + BNDS_SCAL ; + _pbnd = std::min( + _opts. nprt(), _pbnd + 1) ; + + if (_isub == +0) + part_mesh(_mesh, _part._bnds, _pbnd, + _part. _full._seqs, + _isub, _tcpu) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._part_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*-------------------- SYMMETRIC GAUSS-SEIDEL on DUAL */ + + if (_opts .dual()) // 1=>GS, 2=>SGS + { + /*--------------------------------- purely sequential */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _apos = + _part._bnds._seqs.head(); + _apos != + _part._bnds._seqs.tend(); + _apos += +1) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _last, + _nset , _mark, + _iout , _opts, + _conn , _dold, _dnew, _DLIM, + _tcpu ) ; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_dual += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*--------------------------------- parallel on outer */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + # ifdef __use_openmp + omp_set_num_threads( + _part._bnds._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _DOLD, _DNEW; + iptr_list _NSET; + iptr_type _pass = 0u ; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + for (auto _apos = PBEG(_part. _bnds, + _pass, _rank) ; + _apos != PEND(_part. _bnds, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._bnds._list [_apos] ; + + if (_part._bnds._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _last, + _NSET , _mark, + _iout , _opts, + _CSET , _DOLD, _DNEW, _DLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + /*--------------------------------- parallel on inner */ + # ifdef __use_openmp + omp_set_num_threads( + _part._full._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _DOLD, _DNEW; + iptr_list _NSET; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._full._lptr.count()-1; ++_rank) + { + for (auto _pass = 0; _pass < 2; ++_pass) + for (auto _apos = PBEG(_part. _full, + _pass, _rank) ; + _apos != PEND(_part. _full, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._full._list [_apos] ; + + if (_part._full._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _last, + _NSET , _mark, + _iout , _opts, + _CSET , _DOLD, _DNEW, _DLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._full._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + /*--------------------------------- parallel on outer */ + # ifdef __use_openmp + omp_set_num_threads( + _part._bnds._lptr.count()-1 ) ; + # endif//__use_openmp + + # pragma omp parallel default(none) \ + shared(_part, _geom, _mesh, \ + _hfun, _hval, \ + _CONN, _last, \ + _nset, _mark, \ + _iout, _isub, _opts, \ + _QLIM, _DLIM, _tcpu) + { + conn_list _CSET; // thread-local arrays + real_list _DOLD, _DNEW; + iptr_list _NSET; + iptr_type _pass = 1u ; + iptr_type _anum; + # pragma omp for nowait schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + for (auto _apos = PBEG(_part. _bnds, + _pass, _rank) ; + _apos != PEND(_part. _bnds, + _pass, _rank) ; + _apos += ITER(_pass) ) + { + _anum = _part._bnds._list [_apos] ; + + if (_part._bnds._part[_anum] < 0) + continue ; // skip if interface + + move_task()(_geom, _mesh, _anum, + _hfun , _hval, + _CONN , _last, + _NSET , _mark, + _iout , _opts, + _CSET , _DOLD, _DNEW, _DLIM, + _tcpu ) ; + } + } + + # pragma omp for ordered schedule(static,1) + for (auto _rank = 0u ; + _rank < + _part._bnds._lptr.count()-1; ++_rank) + { + # pragma omp ordered + { + _nset.push_tail( + _NSET.head(), _NSET.tend()); + } + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._para_dual += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*--------------------------------- purely sequential */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _apos = + _part._bnds._seqs.tail(); + _apos != + _part._bnds._seqs.hend(); + _apos += -1) + { + move_task()(_geom, _mesh,*_apos, + _hfun , _hval, + _CONN , _last, + _nset , _mark, + _iout , _opts, + _conn , _dold, _dnew, _DLIM, + _tcpu ) ; + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_dual += _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._core_dual += _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + } //if opts.dual + + } //if _nptr > 1 + + # undef MARK + # undef SBEG + # undef SEND + # undef PBEG + # undef PEND + # undef ITER + } + + + diff --git a/src/libcpp/iter_mesh/part_mesh_2.inc b/src/libcpp/iter_mesh/part_mesh_2.inc new file mode 100644 index 0000000..7690abd --- /dev/null +++ b/src/libcpp/iter_mesh/part_mesh_2.inc @@ -0,0 +1,347 @@ + + /* + -------------------------------------------------------- + * PART-MESH-2: form dynamic parallel partitions. + -------------------------------------------------------- + * + * 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: 15 Dec., 2022 + * + * Copyright 2013-2022 + * Marc Tunnell, + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + __static_call + __normal_call void_type part_mesh ( + 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_type _isub, // inner iteration marker + iter_stat &_tcpu // CPU timers/info + ) + { + # define PUSH_BNDS( _PNUM ) \ + __isflip(_PNUM) ? _PNUM : __doflip(_PNUM) + + # define PART_LIMS( _PNUM ) \ + if (_PNUM != -1) \ + { \ + _have += +1 ; \ + _pmin = std::min( \ + _pmin, __unflip(_PNUM)); \ + _pmax = std::max( \ + _pmax, __unflip(_PNUM)); \ + } + + # ifdef __use_timers + typename std ::chrono:: + high_resolution_clock::time_point _ttic; + typename std ::chrono:: + high_resolution_clock::time_point _ttoc; + typename std ::chrono:: + high_resolution_clock _time ; + + __unreferenced(_time) ; // why does MSVC need this?? + # endif//__use_timers + + __unreferenced(_isub) ; + + if (_nprt > +1) + { + /*------ define AABB-tree for recursive partition */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + typedef geom_tree::aabb_item_node_k < + real_type, + iptr_type, + pred_type::geom_dims> tree_item ; + + typedef geom_tree::aabb_tree< + tree_item, + pred_type::geom_dims> tree_type ; + + tree_type _tree; + + auto _npop = // no. nodes per part for nprts + (8 * _aset.count()) / _nprt / 3 ; + + /*-------------------- populate tree: xyz + index */ + containers::array _item ; + for (auto _apos = _aset.tail() ; + _apos != _aset.hend() ; + --_apos ) // backward maintains sort? + { + auto _aptr = + _mesh.node().head() + *_apos; + + if (_aptr->mark() >= 0 && + (_aptr->ndeg(TRIA3_tag) > 0 || + _aptr->ndeg(QUAD4_tag) > 0 )) + { + _item.push_tail(); + _item.tail()->ipos() = *_apos; + + for (auto _idim = geom_dims; + _idim-- != 0; ) + _item.tail()->pval(_idim) = + _aptr ->pval(_idim); + } + } + + /*-------------------- split: npop nodes per leaf */ + _tree.load( + _item.head(), _item.tend(), + _npop , // pop. threshold, for leaf div. + _tree.median_split , + +1.0 , // set LONG=1, only div. by pop. + +0.0) ; // set VTOL=0, only div. by pop. + + /*-------------------- form sparse lists for part */ + + // LIST[LPTR[K]:LPTR[K+1]-1]: list of nodes that + // comprise the K-th partition + + _part._lptr.clear() ; + _part._list.clear() ; + _part._part.clear() ; + _part._seqs.clear() ; + + _tree.dcmp(_part._lptr,_part._list) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._tree_part += + _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._full_part += + _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*-------------------- and build reverse indexing */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + _part._part.set_count( + _mesh.node().count(), + containers::loose_alloc, -1) ; + + // PART[J] = K: the partition for J-th mesh node + + for (auto + _lnum = _part._lptr.count() - 1 ; + _lnum-- != 0 ; ) + { + for (auto _iptr = _part._lptr[_lnum+0]; + _iptr < _part._lptr[_lnum+1]; + ++_iptr ) + _part._part[_part._list[_iptr]] = _lnum ; + } + + // PART[J] =-1: the J-th node is on an interface + + for (auto _tria = _mesh.tri3().head() ; + _tria != _mesh.tri3().tend() ; + ++_tria ) + { + if (_tria->mark() >= +0) + { + /*-------------- interface if cell straddles part */ + iptr_type _inod, _jnod, _knod; + _inod = _tria->node( 0); + _jnod = _tria->node( 1); + _knod = _tria->node( 2); + + iptr_type _have = 0; + iptr_type _pmin = + std::numeric_limits::max() ; + iptr_type _pmax = + std::numeric_limits::min() ; + + PART_LIMS(_part._part[_inod]); + PART_LIMS(_part._part[_jnod]); + PART_LIMS(_part._part[_knod]); + + if (_have==0 || _pmin == _pmax) + continue ; + + _part._part[_inod] = PUSH_BNDS ( + _part._part[_inod]); + _part._part[_jnod] = PUSH_BNDS ( + _part._part[_jnod]); + _part._part[_knod] = PUSH_BNDS ( + _part._part[_knod]); + } + } + + for (auto _quad = _mesh.quad().head() ; + _quad != _mesh.quad().tend() ; + ++_quad ) + { + if (_quad->mark() >= +0) + { + /*-------------- interface if cell straddles part */ + iptr_type _inod, _jnod, _knod, + _lnod; + _inod = _quad->node( 0); + _jnod = _quad->node( 1); + _knod = _quad->node( 2); + _lnod = _quad->node( 3); + + iptr_type _have = 0; + iptr_type _pmin = + std::numeric_limits::max() ; + iptr_type _pmax = + std::numeric_limits::min() ; + + PART_LIMS(_part._part[_inod]); + PART_LIMS(_part._part[_jnod]); + PART_LIMS(_part._part[_knod]); + PART_LIMS(_part._part[_lnod]); + + if (_have==0 || _pmin == _pmax) + continue ; + + _part._part[_inod] = PUSH_BNDS ( + _part._part[_inod]); + _part._part[_jnod] = PUSH_BNDS ( + _part._part[_jnod]); + _part._part[_knod] = PUSH_BNDS ( + _part._part[_knod]); + _part._part[_lnod] = PUSH_BNDS ( + _part._part[_lnod]); + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._part_part += + _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._full_part += + _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + + /*-------------- add interface to sequential list */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + for (auto _apos = _aset.head() ; + _apos != _aset.tend() ; + ++_apos ) // aset sweep ensures sort + { + if (_part._part[*_apos] < -1) + { + _part._seqs.push_tail(*_apos); + } + } + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_part += + _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._full_part += + _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + } + else + { + /*-------------- dummy part lists for single part */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + + _part._lptr.set_count(+2); + _part._list.set_alloc(_aset.count()) ; + _part._part.set_count( + _mesh.node().count(), + containers::loose_alloc, +0) ; + + _part._lptr[0] = +0; + _part._lptr[1] = _aset.count() ; + _part._list.push_tail( + _aset.head(), _aset.tend()); + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._seqs_part += + _tcpu.time_span(_ttic, _ttoc) ; + _tcpu._full_part += + _tcpu.time_span(_ttic, _ttoc) ; + # endif//__use_timers + } + + /* + iptr_type _ipos = +0; + for (auto _iter = _mesh.node().head(); + _iter != _mesh.node().tend(); + ++_iter, ++_ipos) + { + // just for debug: output part idx. to node itag + if (_iter->mark() >= 0) + { + _iter->itag() = _part._part[_ipos]; + } + } + + iptr_type _pmin = + std::numeric_limits::max(); + iptr_type _pmax = + std::numeric_limits::min(); + for (auto _rank = 0u ; + _rank<_part._lptr.count()-1; ++_rank) + { + // just for debug: output min/max sizes of part's + iptr_type _size = + _part._lptr[_rank+1] - + _part._lptr[_rank+0] ; + _pmin = std::min(_pmin, _size); + _pmax = std::max(_pmax, _size); + } + std::cout << _pmin << ", " << _pmax << std::endl; + */ + + # undef PART_LIMS + # undef PUSH_BNDS + } + diff --git a/src/libcpp/iter_mesh/sort_mesh_2.inc b/src/libcpp/iter_mesh/sort_mesh_2.inc new file mode 100644 index 0000000..76abe5a --- /dev/null +++ b/src/libcpp/iter_mesh/sort_mesh_2.inc @@ -0,0 +1,345 @@ + + /* + -------------------------------------------------------- + * SORT-MESH-2: greedy ordering for mesh optim. + -------------------------------------------------------- + * + * 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: 18 Dec., 2022 + * + * Copyright 2013-2022 + * Darren Engwirda, + * Marc Tunnell + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + + // from iter_mesh_2.hpp + + + /* + -------------------------------------------------------- + * PULL-CONN: cache node-to-cell adjacency lists. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type pull_conn ( + mesh_type &_mesh , // mesh object + conn_sets &_conn // cached node spacing array + ) + { + _conn._adj1.set_count( +0 ) ; + _conn._idx1.set_count( + _mesh.node().count() + 1, + containers::tight_alloc , +0 ) ; + + _conn._adj2.set_count( +0 ) ; + _conn._idx2.set_count( + _mesh.node().count() + 1, + containers::tight_alloc , +0 ) ; + + _conn._adj1.set_alloc( + _mesh.edge().count() * 2) ; + _conn._adj2.set_alloc( + _mesh.tri3().count() * 3 + + _mesh.quad().count() * 4) ; + + iptr_type _npos = +0 ; + for (auto _node = _mesh.node().head() ; + _node != _mesh.node().tend() ; + ++_node, ++_npos) + { + if (_node->mark() >= + 0) + { + /*-------------------- append adj. lists per node */ + _mesh.connect_1( + _npos, POINT_tag, _conn._adj1) ; + + _conn._idx1[_npos+1] = + _conn._adj1.count() ; + + _mesh.connect_2( + _npos, POINT_tag, _conn._adj2) ; + + _conn._idx2[_npos+1] = + _conn._adj2.count() ; + } + else + { + /*-------------------- empty lists for null nodes */ + _conn._idx1[_npos+1] = + _conn._idx1[ _npos] ; + + _conn._idx2[_npos+1] = + _conn._idx2[ _npos] ; + } + } + } + + /* + -------------------------------------------------------- + * SORT-NODE: permutations for node optimisation. + -------------------------------------------------------- + */ + + __static_call + __normal_call void_type sort_node ( + mesh_type &_mesh , // mesh object + conn_sets &_CONN , // cached node adj. indexing + iptr_list &_aset , // list of nodes to try next + iptr_list &_nmrk , // sets of node flags + iptr_type _iout , // outer iteration marker + iptr_type _isub , // inner iteration marker + real_type _QLIM , // cell quality threshold + real_type _DLIM , // dual quality threshold + iter_opts &_opts // user options + ) + { + # define PUSHCOST(_NODE , _COST) \ + _qbar[_NODE] += _COST ; \ + _qmin[_NODE] = \ + std::min (_qmin[_NODE], _COST) ; + + class cost_pair + { + public : + /*------------------------ tuple for node re-ordering */ + iptr_type _node ; + float _cost ; + + /*------------------------ construct inline from src. */ + __inline_call cost_pair ( + iptr_type const&_nsrc , + real_type const&_csrc + ) : + _node (_nsrc), + _cost((float)_csrc) {} + } ; + + class cost_pred + { + public : + /*------------------------ less-than op. for cost-tup */ + __inline_call + bool_type operator () ( + cost_pair const&_idat , + cost_pair const&_jdat + ) const + { return _idat._cost > _jdat._cost ; + } + } ; + + typedef + containers::array cost_list ; + + real_list _qbar, _qmin, _cost ; + cost_list _sset ; + + __unreferenced ( _DLIM ) ; + __unreferenced ( _opts ) ; + __unreferenced ( _isub ) ; + + /*-------------------- 1ST SUB-ITER: build full init. */ + _qbar.set_count( + _mesh.node().count(), + containers::tight_alloc, +0.0) ; + _qmin.set_count( + _mesh.node().count(), + containers::tight_alloc, +1.0) ; + + pull_conn(_mesh, _CONN) ; + + # ifdef __use_openmp + omp_set_num_threads(_opts.nprt()) ; + # endif//__use_openmp + + _cost.set_count( + _mesh.tri3().count(), + containers::loose_alloc, +0.0) ; + + # pragma omp parallel for schedule(static) \ + default(none) \ + shared(_mesh, _cost) + for (auto _tpos = +0u ; + _tpos < _mesh.tri3().count() ; + ++_tpos ) + { + auto _tria = + _mesh.tri3().head() + _tpos; + + if (_tria->mark() >= +0) + { + /*-------------------- calc. min. scores at cells */ + _cost[_tpos] = + pred_type::tri3_cost ( + &_mesh .node( + _tria->node(0)).pval(0), + &_mesh .node( + _tria->node(1)).pval(0), + &_mesh .node( + _tria->node(2)).pval(0), + typename + pred_type::cell_kind ()) ; + } + } + + iptr_type _tpos = 0; + for (auto _tria = _mesh.tri3().head() ; + _tria != _mesh.tri3().tend() ; + ++_tria, ++_tpos) + { + if (_tria->mark() >= +0) + { + /*-------------------- dist. min. scores to nodes */ + iptr_type _inod, _jnod, _knod; + _inod = _tria->node( 0); + _jnod = _tria->node( 1); + _knod = _tria->node( 2); + + real_type _cval = _cost[_tpos] ; + + PUSHCOST( _inod, _cval ) + PUSHCOST( _jnod, _cval ) + PUSHCOST( _knod, _cval ) + } + } + + _cost.set_count( + _mesh.quad().count(), + containers::loose_alloc, +0.0) ; + + # pragma omp parallel for schedule(static) \ + default(none) \ + shared(_mesh, _cost) + for (auto _qpos = +0u ; + _qpos < _mesh.quad().count() ; + ++_qpos ) + { + auto _quad = + _mesh.quad().head() + _qpos; + + if (_quad->mark() >= +0) + { + /*-------------------- calc. min. scores at cells */ + _cost[_qpos] = + pred_type::quad_cost ( + &_mesh .node( + _quad->node(0)).pval(0), + &_mesh .node( + _quad->node(1)).pval(0), + &_mesh .node( + _quad->node(2)).pval(0), + &_mesh .node( + _quad->node(3)).pval(0), + typename + pred_type::cell_kind ()) ; + } + } + + iptr_type _qpos = 0; + for (auto _quad = _mesh.quad().head() ; + _quad != _mesh.quad().tend() ; + ++_quad, ++_qpos) + { + if (_quad->mark() >= +0) + { + /*-------------------- dist. min. scores to nodes */ + iptr_type _inod, _jnod, _knod, + _lnod; + _inod = _quad->node( 0); + _jnod = _quad->node( 1); + _knod = _quad->node( 2); + _lnod = _quad->node( 3); + + real_type _cval = _cost[_qpos] ; + + PUSHCOST( _inod, _cval ) + PUSHCOST( _jnod, _cval ) + PUSHCOST( _knod, _cval ) + PUSHCOST( _lnod, _cval ) + } + } + + iptr_type _FLAG = _iout - 2 ; // only "recent" + + _sset.set_alloc( + _mesh.node().count()) ; + + iptr_type _ipos = +0 ; + for (auto _node = _mesh.node().head() ; + _node != _mesh.node().tend() ; + ++_node, ++_ipos) + { + /*------------------------ assign score for each node */ + if (_node->mark() >= +0) + { + if (std::abs( + _nmrk[_ipos]) >= _FLAG || // recent + _qmin[_ipos] <= _QLIM ) // skewed + { + auto _nadj = + _node->ndeg(TRIA3_tag) + + _node->ndeg(QUAD4_tag) ; + + _nadj = std::max(1, _nadj) ; + + float _cval = + (float)_qbar[_ipos]/_nadj - + (float)_qmin[_ipos] ; + + _sset.push_tail ( + cost_pair(_ipos , _cval)) ; + } + } + } + + algorithms::qsort( _sset.head() , + _sset.tend() , + cost_pred () ) ; + + for (auto _iter = _sset.head() ; + _iter != _sset.tend() ; + ++_iter ) + { + /*------------------------ push sorted wrt. min.-cost */ + _aset.push_tail(_iter->_node) ; + } + + # undef PUSHCOST + } + + + diff --git a/src/libcpp/itermesh.hpp b/src/libcpp/itermesh.hpp index 102ab69..d96f6df 100644 --- a/src/libcpp/itermesh.hpp +++ b/src/libcpp/itermesh.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 02 March, 2019 + * Last updated: 02 Mar., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/mathutil.hpp b/src/libcpp/mathutil.hpp index 60d7948..dd2633b 100644 --- a/src/libcpp/mathutil.hpp +++ b/src/libcpp/mathutil.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/mesh_reps/base_complex_k.hpp b/src/libcpp/mesh_reps/base_complex_k.hpp index bd318c9..06fa7f8 100644 --- a/src/libcpp/mesh_reps/base_complex_k.hpp +++ b/src/libcpp/mesh_reps/base_complex_k.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 Sept., 2021 + * Last updated: 11 Dec., 2022 * - * Copyright 2020--2021 + * Copyright 2020--2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -1488,6 +1492,10 @@ { __unreferenced(_kind); // maybe, per TOPODIM + if (_mesh. + _llN1[_npos].mark() < +0 ) + return ; // is already removed + if (_itop != -1) { /*---- deleteing (d+k)-face: scan adj. and _pop _itop */ @@ -1558,6 +1566,10 @@ __unreferenced(_kind); // maybe, per TOPODIM + if (_mesh. + _llE2[_epos].mark() < +0 ) + return ; // is already removed + if (_itop == -1) { _mesh.node(_mesh.edge(_epos).node(0)). @@ -1651,6 +1663,10 @@ __unreferenced(_kind); // maybe, per TOPODIM + if (_mesh. + _llT3[_tpos].mark() < +0 ) + return ; // is already removed + if (_itop == -1) { _mesh.node(_mesh.tri3(_tpos).node(0)). @@ -1758,6 +1774,10 @@ __unreferenced(_kind); // maybe, per TOPODIM + if (_mesh. + _llQ4[_qpos].mark() < +0 ) + return ; // is already removed + if (_itop == -1) { _mesh.node(_mesh.quad(_qpos).node(0)). @@ -1869,6 +1889,10 @@ __unreferenced(_kind); // maybe, per TOPODIM + if (_mesh. + _llT4[_tpos].mark() < +0 ) + return ; // is already removed + if (_itop == -1) { _mesh.node(_mesh.tri4(_tpos).node(0)). diff --git a/src/libcpp/mesh_reps/hash_complex_k.hpp b/src/libcpp/mesh_reps/hash_complex_k.hpp index 57b1ef0..f78b48b 100644 --- a/src/libcpp/mesh_reps/hash_complex_k.hpp +++ b/src/libcpp/mesh_reps/hash_complex_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 27 April, 2020 + * Last updated: 27 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/mesh_reps/mesh_complex_1.hpp b/src/libcpp/mesh_reps/mesh_complex_1.hpp index 32c5b8c..022c02b 100644 --- a/src/libcpp/mesh_reps/mesh_complex_1.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_1.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2020-- * Darren Engwirda @@ -128,8 +132,8 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _a0pl ; conn_list _aaN1 ; @@ -205,17 +209,18 @@ __normal_call mesh_complex_1 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + + _a0pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , /*---------------------------------- init. free lists */ @@ -253,9 +258,6 @@ this->_ffE2.clear (_kind) ; this->_tmp1.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/mesh_reps/mesh_complex_2.hpp b/src/libcpp/mesh_reps/mesh_complex_2.hpp index 9302dc1..40b2c8b 100644 --- a/src/libcpp/mesh_reps/mesh_complex_2.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_2.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2020-- * Darren Engwirda @@ -160,8 +164,12 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _t3pl ; + pool_base _q4pl ; + + pool_base _a0pl ; + pool_base _a1pl ; conn_list _aaN1 ; conn_list _aaE2 ; @@ -289,26 +297,33 @@ __normal_call mesh_complex_2 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + _t3pl(sizeof ( + typename tri3_maps::item_type)), + _q4pl(sizeof ( + typename quad_maps::item_type)), + + _a0pl(sizeof ( + typename conn_list::item_type)), + _a1pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), - _aaE2(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), + _aaE2(pool_wrap(&_a1pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , _mmT3( tri3_hash(& this->_llT3) , tri3_pred(& this->_llT3) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t3pl))) , _mmQ4( quad_hash(& this->_llQ4) , quad_pred(& this->_llQ4) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_q4pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , _llT3(_asrc),_llQ4(_asrc) , @@ -356,9 +371,6 @@ this->_tmp1.clear (_kind) ; this->_tmp2.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/mesh_reps/mesh_complex_3.hpp b/src/libcpp/mesh_reps/mesh_complex_3.hpp index 37034fd..e79ea14 100644 --- a/src/libcpp/mesh_reps/mesh_complex_3.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2020-- * Darren Engwirda @@ -224,8 +228,17 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _t3pl ; + pool_base _q4pl ; + pool_base _t4pl ; + pool_base _h8pl ; + pool_base _w6pl ; + pool_base _p5pl ; + + pool_base _a0pl ; + pool_base _a1pl ; + pool_base _a2pl ; conn_list _aaN1 ; conn_list _aaE2 ; @@ -456,44 +469,61 @@ __normal_call mesh_complex_3 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + _t3pl(sizeof ( + typename tri3_maps::item_type)), + _q4pl(sizeof ( + typename quad_maps::item_type)), + _t4pl(sizeof ( + typename tri4_maps::item_type)), + _h8pl(sizeof ( + typename hexa_maps::item_type)), + _w6pl(sizeof ( + typename wedg_maps::item_type)), + _p5pl(sizeof ( + typename pyra_maps::item_type)), + + _a0pl(sizeof ( + typename conn_list::item_type)), + _a1pl(sizeof ( + typename conn_list::item_type)), + _a2pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), - _aaE2(pool_wrap(&_csrc)), - _aaT3(pool_wrap(&_csrc)), - _aaQ4(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), + _aaE2(pool_wrap(&_a1pl)), + _aaT3(pool_wrap(&_a2pl)), + _aaQ4(pool_wrap(&_a2pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , _mmT3( tri3_hash(& this->_llT3) , tri3_pred(& this->_llT3) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t3pl))) , _mmQ4( quad_hash(& this->_llQ4) , quad_pred(& this->_llQ4) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_q4pl))) , _mmT4( tri4_hash(& this->_llT4) , tri4_pred(& this->_llT4) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t4pl))) , _mmH8( hexa_hash(& this->_llH8) , hexa_pred(& this->_llH8) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_h8pl))) , _mmW6( wedg_hash(& this->_llW6) , wedg_pred(& this->_llW6) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_w6pl))) , _mmP5( pyra_hash(& this->_llP5) , pyra_pred(& this->_llP5) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_p5pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , _llT3(_asrc),_llQ4(_asrc) , @@ -560,9 +590,6 @@ this->_tmp1.clear (_kind) ; this->_tmp2.clear (_kind) ; this->_tmp3.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/mesh_reps/mesh_complex_type_k.hpp b/src/libcpp/mesh_reps/mesh_complex_type_k.hpp index c49a9a8..d911c63 100644 --- a/src/libcpp/mesh_reps/mesh_complex_type_k.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_type_k.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 Sept., 2021 + * Last updated: 10 Jun., 2022 * - * Copyright 2013-2020 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -131,7 +135,8 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char & mark ( @@ -155,10 +160,21 @@ { return this->_ndat [_ipos]; } + __inline_call size_t ndeg ( + ) const + { + size_t _ntot = 0; + for (auto _ipos = 8; _ipos-- != 0 ; ) + _ntot += this->_ndeg [_ipos ] ; + + return _ntot ; + } + __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char const& mark ( @@ -231,7 +247,8 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char & mark ( @@ -255,10 +272,21 @@ { return this->_ndat [_ipos]; } + __inline_call size_t ndeg ( + ) const + { + size_t _ntot = 0; + for (auto _ipos = 8; _ipos-- != 0 ; ) + _ntot += this->_ndeg [_ipos ] ; + + return _ntot ; + } + __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char const& mark ( @@ -331,7 +359,8 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char & mark ( @@ -355,10 +384,21 @@ { return this->_ndat [_ipos]; } + __inline_call size_t ndeg ( + ) const + { + size_t _ntot = 0; + for (auto _ipos = 8; _ipos-- != 0 ; ) + _ntot += this->_ndeg [_ipos ] ; + + return _ntot ; + } + __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return this->_ndeg[_tag_to_ndeg(_cell)] ; + { return + this->_ndeg[_tag_to_ndeg (_cell)] ; } __inline_call char const& mark ( diff --git a/src/libcpp/mesh_reps/tria_complex_1.hpp b/src/libcpp/mesh_reps/tria_complex_1.hpp index f2ad6b6..7da0279 100644 --- a/src/libcpp/mesh_reps/tria_complex_1.hpp +++ b/src/libcpp/mesh_reps/tria_complex_1.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda @@ -128,8 +132,8 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _a0pl ; conn_list _aaN1 ; @@ -205,17 +209,18 @@ __normal_call tria_complex_1 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + + _a0pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , /*---------------------------------- init. free lists */ @@ -253,9 +258,6 @@ this->_ffE2.clear (_kind) ; this->_tmp1.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/mesh_reps/tria_complex_2.hpp b/src/libcpp/mesh_reps/tria_complex_2.hpp index 2508804..10a7b75 100644 --- a/src/libcpp/mesh_reps/tria_complex_2.hpp +++ b/src/libcpp/mesh_reps/tria_complex_2.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda @@ -144,8 +148,11 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _t3pl ; + + pool_base _a0pl ; + pool_base _a1pl ; conn_list _aaN1 ; conn_list _aaE2 ; @@ -248,22 +255,27 @@ __normal_call tria_complex_2 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + _t3pl(sizeof ( + typename tri3_maps::item_type)), + + _a0pl(sizeof ( + typename conn_list::item_type)), + _a1pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), - _aaE2(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), + _aaE2(pool_wrap(&_a1pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , _mmT3( tri3_hash(& this->_llT3) , tri3_pred(& this->_llT3) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t3pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , _llT3(_asrc), @@ -308,9 +320,6 @@ this->_tmp1.clear (_kind) ; this->_tmp2.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/mesh_reps/tria_complex_3.hpp b/src/libcpp/mesh_reps/tria_complex_3.hpp index 08db9de..e9f8a1a 100644 --- a/src/libcpp/mesh_reps/tria_complex_3.hpp +++ b/src/libcpp/mesh_reps/tria_complex_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 April, 2020 + * Last updated: 28 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda @@ -160,8 +164,13 @@ public : - pool_base _hsrc ; - pool_base _csrc ; + pool_base _e2pl ; + pool_base _t3pl ; + pool_base _t4pl ; + + pool_base _a0pl ; + pool_base _a1pl ; + pool_base _a2pl ; conn_list _aaN1 ; conn_list _aaE2 ; @@ -291,27 +300,36 @@ __normal_call tria_complex_3 ( allocator const& _asrc = allocator() - ) : _hsrc(sizeof ( + ) : _e2pl(sizeof ( typename edge_maps::item_type)), - _csrc(sizeof ( + _t3pl(sizeof ( + typename tri3_maps::item_type)), + _t4pl(sizeof ( + typename tri4_maps::item_type)), + + _a0pl(sizeof ( + typename conn_list::item_type)), + _a1pl(sizeof ( + typename conn_list::item_type)), + _a2pl(sizeof ( typename conn_list::item_type)), /*---------------------------------- init. adj. lists */ - _aaN1(pool_wrap(&_csrc)), - _aaE2(pool_wrap(&_csrc)), - _aaT3(pool_wrap(&_csrc)), + _aaN1(pool_wrap(&_a0pl)), + _aaE2(pool_wrap(&_a1pl)), + _aaT3(pool_wrap(&_a2pl)), /*---------------------------------- init. hash lists */ _mmE2( edge_hash(& this->_llE2) , edge_pred(& this->_llE2) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_e2pl))) , _mmT3( tri3_hash(& this->_llT3) , tri3_pred(& this->_llT3) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t3pl))) , _mmT4( tri4_hash(& this->_llT4) , tri4_pred(& this->_llT4) , - +.8, (pool_wrap(&_hsrc))) , + +.8, (pool_wrap(&_t4pl))) , /*---------------------------------- init. face lists */ _llN1(_asrc),_llE2(_asrc) , _llT3(_asrc),_llT4(_asrc) , @@ -361,9 +379,6 @@ this->_tmp1.clear (_kind) ; this->_tmp2.clear (_kind) ; this->_tmp3.clear (_kind) ; - - this->_hsrc.clear (); - this->_csrc.clear (); } /* diff --git a/src/libcpp/meshreps.hpp b/src/libcpp/meshreps.hpp index d750468..a130ca0 100644 --- a/src/libcpp/meshreps.hpp +++ b/src/libcpp/meshreps.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/mpfloats.hpp b/src/libcpp/mpfloats.hpp index df2a796..2d9ce03 100644 --- a/src/libcpp/mpfloats.hpp +++ b/src/libcpp/mpfloats.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 11 April, 2020 + * Last updated: 11 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/parameters/iter_params.hpp b/src/libcpp/parameters/iter_params.hpp index 87bd9b6..1aebee7 100644 --- a/src/libcpp/parameters/iter_params.hpp +++ b/src/libcpp/parameters/iter_params.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 10 Jul., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -69,17 +73,21 @@ typedef iter_params self_type ; - iptr_type _verb ; + iptr_type _verb ; // logfile output verbosity + iptr_type _nprt ; // no. threads + + iptr_type _iter ; // no. iterations - iptr_type _iter ; + real_type _beta ; // QHM momentum coeff. + real_type _zeta ; // QHM momentum coeff. - real_type _qtol ; - real_type _qlim ; + real_type _qtol ; // convergence tolerance + real_type _qlim ; // fallback score threshold - bool_type _zip_ ; - bool_type _div_ ; - bool_type _tria ; - bool_type _dual ; + 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 public : @@ -92,10 +100,17 @@ 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 = @@ -116,12 +131,25 @@ ) { return this->_verb ; } + __inline_call iptr_type & nprt ( + ) + { return this->_nprt ; + } __inline_call iptr_type & iter ( ) { return this->_iter ; } + __inline_call real_type & beta ( + ) + { return this->_beta ; + } + __inline_call real_type & zeta ( + ) + { return this->_zeta ; + } + __inline_call real_type & qtol ( ) { return this->_qtol ; @@ -153,12 +181,25 @@ ) const { return this->_verb ; } + __inline_call iptr_type const& nprt ( + ) const + { return this->_nprt ; + } __inline_call iptr_type const& iter ( ) const { return this->_iter ; } + __inline_call real_type const& beta ( + ) const + { return this->_beta ; + } + __inline_call real_type const& zeta ( + ) const + { return this->_zeta ; + } + __inline_call real_type const& qtol ( ) const { return this->_qtol ; diff --git a/src/libcpp/parameters/mesh_params.hpp b/src/libcpp/parameters/mesh_params.hpp index 859688b..afbddb4 100644 --- a/src/libcpp/parameters/mesh_params.hpp +++ b/src/libcpp/parameters/mesh_params.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 10 Jul., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -81,6 +85,7 @@ last_kind } ; iptr_type _verb ; // logfile output verbosity + iptr_type _nprt ; // no. threads iptr_type _seed ; // no. init. "seed" nodes @@ -147,6 +152,8 @@ this->_verb = iptr_type(_jjig._verbosity) ; + this->_nprt = + iptr_type(_jjig._numthread) ; this->_seed = iptr_type(_jjig._geom_seed) ; @@ -214,6 +221,10 @@ ) { return this->_verb ; } + __inline_call iptr_type & nprt ( + ) + { return this->_nprt ; + } __inline_call iptr_type & rule ( ) @@ -331,6 +342,10 @@ ) const { return this->_verb ; } + __inline_call iptr_type const& nprt ( + ) const + { return this->_nprt ; + } __inline_call iptr_type const& rule ( ) const diff --git a/src/libcpp/predicate/bisect_k.hpp b/src/libcpp/predicate/bisect_k.hpp index d1504ea..d235613 100644 --- a/src/libcpp/predicate/bisect_k.hpp +++ b/src/libcpp/predicate/bisect_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/predicate/inball_k.hpp b/src/libcpp/predicate/inball_k.hpp index 9d7db0e..2306473 100644 --- a/src/libcpp/predicate/inball_k.hpp +++ b/src/libcpp/predicate/inball_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/predicate/orient_k.hpp b/src/libcpp/predicate/orient_k.hpp index 7fcac4b..e82b8d4 100644 --- a/src/libcpp/predicate/orient_k.hpp +++ b/src/libcpp/predicate/orient_k.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/predicate/predicate_k.hpp b/src/libcpp/predicate/predicate_k.hpp index 114303d..19d013f 100644 --- a/src/libcpp/predicate/predicate_k.hpp +++ b/src/libcpp/predicate/predicate_k.hpp @@ -47,16 +47,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2020-- * Darren Engwirda diff --git a/src/libcpp/rdel_mesh/rdel_base_2.hpp b/src/libcpp/rdel_mesh/rdel_base_2.hpp index 7c45b55..1e2e4ca 100644 --- a/src/libcpp/rdel_mesh/rdel_base_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_base_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -138,9 +142,9 @@ > __static_call __normal_call bool_type clip_dual ( - mesh_type &_mesh, - half_list &_hset, - real_type *_ppos, + mesh_type &_mesh, // mesh object + half_list &_hset, // list of halfspace objects + real_type *_ppos, // point to test bool_type &_safe, real_type _rtol ) @@ -205,15 +209,15 @@ __static_call __normal_call bool_type edge_ball ( - geom_type &_geom, - mesh_type &_mesh, - iptr_type _tadj, - iptr_type _eadj, - real_type *_ebal, - real_type *_sbal, - char_type &_feat, - char_type *_topo, - iptr_type &_part + geom_type &_geom, // geometry object + mesh_type &_mesh, // mesh object + iptr_type _tadj, // index of adj. simplex + iptr_type _eadj, // index of edge in adj. cell + real_type *_ebal, // circumball on edge + real_type *_sbal, // circumball on geometry + char_type &_feat, // returned feature kind + char_type *_topo, // returned topology tag + iptr_type &_part // returned geometry tag ) { real_type static const _rEPS = @@ -512,11 +516,11 @@ __static_call __inline_call bool_type tria_ball ( - geom_type &_geom, - mesh_type &_mesh, - iptr_type _tpos, - real_type *_tbal, - iptr_type &_part + geom_type &_geom, // geometry object + mesh_type &_mesh, // mesh object + iptr_type _tpos, // index of adj. simplex + real_type *_tbal, // circumball on cell + iptr_type &_part // returned geometry tag ) { /*--------------------------- assemble local indexing */ diff --git a/src/libcpp/rdel_mesh/rdel_base_3.hpp b/src/libcpp/rdel_mesh/rdel_base_3.hpp index caaa876..bd8b7d4 100644 --- a/src/libcpp/rdel_mesh/rdel_base_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_base_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -150,9 +154,9 @@ > __static_call __normal_call bool_type clip_dual ( - mesh_type &_mesh, - half_list &_hset, - real_type *_ppos, + mesh_type &_mesh, // mesh object + half_list &_hset, // list of halfspace objects + real_type *_ppos, // point to test bool_type &_safe, real_type _rtol ) @@ -225,11 +229,11 @@ > __static_call __normal_call void_type edge_loop ( - mesh_type &_mesh, - iptr_type *_enod, - iptr_type _tadj, - iptr_type _fadj, - list_type &_loop + mesh_type &_mesh, // mesh object + iptr_type *_enod, // array of edge node indexing + iptr_type _tadj, // index of adj. simplex + iptr_type _fadj, // index of face in adj. cell + list_type &_loop // list of cells adj. to edge ) { /*----------------- assemble edge-adj. cells in-order */ @@ -292,15 +296,15 @@ __static_call __normal_call bool_type edge_ball ( - geom_type &_geom, - mesh_type &_mesh, - iptr_type _tadj, - iptr_type _eadj, - real_type *_ebal, - real_type *_sbal, - char_type &_feat, - char_type *_topo, - iptr_type &_part + geom_type &_geom, // geometry object + mesh_type &_mesh, // mesh object + iptr_type _tadj, // index of adj. simplex + iptr_type _eadj, // index of edge in adj. cell + real_type *_ebal, // circumball on edge + real_type *_sbal, // circumball on geometry + char_type &_feat, // returned feature kind + char_type *_topo, // returned topology tag + iptr_type &_part // returned geometry tag ) { real_type static const _rEPS = @@ -639,15 +643,15 @@ __static_call __normal_call bool_type face_ball ( - geom_type &_geom, - mesh_type &_mesh, - iptr_type _tadj, - iptr_type _fadj, - real_type *_fbal, - real_type *_sbal, - char_type &_feat, - char_type *_topo, - iptr_type &_part + geom_type &_geom, // geometry object + mesh_type &_mesh, // mesh object + iptr_type _tadj, // index of adj. simplex + iptr_type _fadj, // index of face in adj. cell + real_type *_fbal, // circumball on edge + real_type *_sbal, // circumball on geometry + char_type &_feat, // returned feature kind + char_type *_topo, // returned topology tag + iptr_type &_part // returned geometry tag ) { real_type static const _rEPS = @@ -986,11 +990,11 @@ __static_call __inline_call bool_type tria_ball ( - geom_type &_geom, - mesh_type &_mesh, - iptr_type _tpos, - real_type *_tbal, - iptr_type &_part + geom_type &_geom, // geometry object + mesh_type &_mesh, // mesh object + iptr_type _tpos, // index of adj. simplex + real_type *_tbal, // circumball on cell + iptr_type &_part // returned geometry tag ) { /*--------------------------- assemble local indexing */ diff --git a/src/libcpp/rdel_mesh/rdel_complex_2.hpp b/src/libcpp/rdel_mesh/rdel_complex_2.hpp index cddc2ff..2bbdac7 100644 --- a/src/libcpp/rdel_mesh/rdel_complex_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_complex_2.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 18 Aug., 2021 + * Last updated: 02 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -383,12 +387,12 @@ pool_base _npol ; pool_base _bpol ; - pool_base _epol ; + pool_base _epol, _e2nd ; pool_base _tpol ; node_list _nset ; ball_list _bset ; - edge_list _eset ; + edge_list _eset, _etwo ; tria_list _tset ; public : @@ -400,6 +404,8 @@ _bpol( sizeof(typename ball_list::item_type)) , _epol( + sizeof(typename edge_list::item_type)) , + _e2nd( sizeof(typename edge_list::item_type)) , _tpol( sizeof(typename tria_list::item_type)) , @@ -413,6 +419,9 @@ _eset(edge_hash(), edge_pred(), +.8, (pool_wrap(&_epol))) , + _etwo(edge_hash(), + edge_pred(), + +.8, (pool_wrap(&_e2nd))) , _tset(tria_hash(), tria_pred(), +.8, (pool_wrap(&_tpol))) diff --git a/src/libcpp/rdel_mesh/rdel_complex_3.hpp b/src/libcpp/rdel_mesh/rdel_complex_3.hpp index 34aefe5..13bcfb2 100644 --- a/src/libcpp/rdel_mesh/rdel_complex_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_complex_3.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 18 Aug., 2021 + * Last updated: 02 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -440,14 +444,14 @@ pool_base _npol ; pool_base _bpol ; - pool_base _epol ; - pool_base _fpol ; + pool_base _epol, _e2nd ; + pool_base _fpol, _f2nd ; pool_base _tpol ; node_list _nset ; ball_list _bset ; - edge_list _eset ; - face_list _fset ; + edge_list _eset, _etwo ; + face_list _fset, _ftwo ; tria_list _tset ; public : @@ -459,8 +463,12 @@ _bpol( sizeof(typename ball_list::item_type)) , _epol( + sizeof(typename edge_list::item_type)) , + _e2nd( sizeof(typename edge_list::item_type)) , _fpol( + sizeof(typename face_list::item_type)) , + _f2nd( sizeof(typename face_list::item_type)) , _tpol( sizeof(typename tria_list::item_type)) , @@ -474,9 +482,15 @@ _eset(edge_hash(), edge_pred(), +.8, (pool_wrap(&_epol))) , + _etwo(edge_hash(), + edge_pred(), + +.8, (pool_wrap(&_e2nd))) , _fset(face_hash(), face_pred(), +.8, (pool_wrap(&_fpol))) , + _ftwo(face_hash(), + face_pred(), + +.8, (pool_wrap(&_f2nd))) , _tset(tria_hash(), tria_pred(), +.8, (pool_wrap(&_tpol))) diff --git a/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc b/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc index 5aa3726..ca6eb9f 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 Apr., 2021 + * Last updated: 01 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -69,6 +73,8 @@ { _kind = mesh::null_item ; + _edat._mark = (iptr_type) +0; + if (_args.dims() < +1) return; /*--------------------------- assemble local indexing */ @@ -89,16 +95,17 @@ return ; /*------------------------- calc. refinement priority */ - _edat._cost = (float) _pmax[2] ; + _edat._cost = + (float)(_pmax[2] + _ebal[2]) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0.; - _esiz += (real_type)+1.*_hfun.eval( + real_type _esiz = (real_type)+0. ; + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)+1.*_hfun.eval( + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -107,14 +114,12 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)+1.0 * + _esiz += (real_type)1./3. * _hfun.eval( _pmax, _hint) ; - _esiz /= (real_type)+3.0 ; - real_type _eave =_pmax [ +2] ; _eave /= _esiz * _esiz ; - _eave *= (real_type)+4.0 ; + _eave *= (real_type)4./1. ; /*------------------------- eval. surface-disc.-error */ real_type _srat = @@ -128,10 +133,8 @@ // least one boundary face. bool_type _trap = - _mesh._tria. - node(_enod[0])->fdim() < +1 && - _mesh._tria. - node(_enod[1])->fdim() < +1 ; + _mesh._tria.node(_enod[0])->fdim() < 1 && + _mesh._tria.node(_enod[1])->fdim() < 1 ; real_type _scal = 1. + _trap * .100 ; @@ -168,6 +171,8 @@ { _kind = mesh::null_item ; + _tdat._mark = (iptr_type) +0 ; + if (_args.dims() < +2) return ; /*--------------------------------- get nodes in tria */ @@ -222,13 +227,12 @@ } /*------------------------- calc. refinement priority */ - bool_type _trap = false ; - - _tdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_enum = +3; _enum-- != +0; ) { + /*------------------------- are there bnd-adj. faces? */ iptr_type _enod[ +3]; mesh_type::tria_type:: tria_type:: @@ -250,8 +254,7 @@ item_type *_eptr = nullptr ; if (_mesh.find_edge(_edat,_eptr)) { - _trap = true ; - + _nbnd += +1 ; _tdat._mark -= +1 ; } } @@ -270,7 +273,7 @@ // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_tnod[0])->fdim() < +2 && _mesh._tria. @@ -286,19 +289,24 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +3 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. @@ -307,14 +315,12 @@ auto _hint = _mesh._tria.node(_tnod[ 2])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./4. * _hfun.eval( _tbal, _hint) ; - _tsiz /= (real_type)+4.0 ; - real_type _eave = _tbal[ +2] ; _eave /= _tsiz * _tsiz; - _eave *= (real_type)+3.0 ; + _eave *= (real_type)3./1. ; /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc b/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc index 44ed9d9..3a4d665 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 Apr., 2021 + * Last updated: 01 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -69,6 +73,8 @@ { _kind = mesh::null_item ; + _edat._mark = (iptr_type) +0; + if (_args.dims() < +1) return; /*--------------------------- assemble local indexing */ @@ -89,16 +95,17 @@ return ; /*------------------------- calc. refinement priority */ - _edat._cost = (float) _pmax[3] ; + _edat._cost = + (float)(_pmax[3] + _ebal[3]) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0.; - _esiz += (real_type)+1.*_hfun.eval( + real_type _esiz = (real_type)+0. ; + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)+1.*_hfun.eval( + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -107,14 +114,12 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)+1.0 * + _esiz += (real_type)1./3. * _hfun.eval( _pmax, _hint) ; - _esiz /= (real_type)+3.0 ; - real_type _eave =_pmax [ +3] ; _eave /= _esiz * _esiz ; - _eave *= (real_type)+4.0 ; + _eave *= (real_type)4./1. ; /*------------------------- eval. surface-disc.-error */ real_type _srat = @@ -128,10 +133,8 @@ // least one boundary face. bool_type _trap = - _mesh._tria. - node(_enod[0])->fdim() < +1 && - _mesh._tria. - node(_enod[1])->fdim() < +1 ; + _mesh._tria.node(_enod[0])->fdim() < 1 && + _mesh._tria.node(_enod[1])->fdim() < 1 ; real_type _scal = 1. + _trap * .100 ; @@ -173,6 +176,8 @@ { _kind = mesh::null_item ; + _fdat._mark = (iptr_type) +0; + if (_args.dims() < +2) return; /*--------------------------- assemble local indexing */ @@ -225,9 +230,7 @@ } /*------------------------- calc. refinement priority */ - bool_type _trap = false ; - - _fdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_enum = +3; _enum-- != +0; ) @@ -253,8 +256,7 @@ item_type *_eptr = nullptr ; if (_mesh.find_edge(_edat,_eptr)) { - _trap = true ; - + _nbnd += +1 ; _fdat._mark -= +1 ; } } @@ -279,7 +281,7 @@ // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_fnod[0])->fdim() < +2 && _mesh._tria. @@ -295,19 +297,24 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +3 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[0])->pval(0) , _mesh._tria. node(_fnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[1])->pval(0) , _mesh._tria. node(_fnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[2])->pval(0) , _mesh._tria. @@ -316,14 +323,12 @@ auto _hint = _mesh._tria.node(_fnod[ 2])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./4. * _hfun.eval( _pmax, _hint) ; - _tsiz /= (real_type)+4.0 ; - real_type _eave =_pmax [ +3] ; _eave /= _tsiz * _tsiz; - _eave *= (real_type)+3.0 ; + _eave *= (real_type)3./1. ; /*------------------------- eval. surface-disc/-error */ real_type _srat = @@ -366,6 +371,8 @@ { _kind = mesh::null_item ; + _tdat._mark = (iptr_type) +0; + if (_args.dims() < +3) return; /*--------------------------------- get nodes in tria */ @@ -459,13 +466,12 @@ } /*------------------------- calc. refinement priority */ - bool_type _trap = false ; - - _tdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_fnum = +4; _fnum-- != +0; ) { + /*------------------------- are there bnd-adj. faces? */ iptr_type _fnod[ +4]; mesh_type::tria_type::tria_type:: face_node(_fnod, _fnum, 3, 2); @@ -491,8 +497,7 @@ item_type *_fptr = nullptr ; if (_mesh.find_face(_fdat,_fptr)) { - _trap = true ; - + _nbnd += +1 ; _tdat._mark -= +1 ; } } @@ -511,7 +516,7 @@ // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_tnod[0])->fdim() < +3 && _mesh._tria. @@ -529,24 +534,29 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +4 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. node(_tnod[2])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[3])->pval(0) , _mesh._tria. @@ -555,15 +565,12 @@ auto _hint = _mesh._tria.node(_tnod[ 3])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./5. * _hfun.eval( _tbal, _hint) ; - _tsiz /= (real_type)+5.0 ; - real_type _eave = _tbal[ +3] ; _eave /= (_tsiz*_tsiz) ; - _eave *= (real_type)+8.0 / - (real_type)+3.0 ; + _eave *= (real_type)8./3. ; /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc index 7068892..b574c7b 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 Apr., 2020 + * Last updated: 01 Aug., 2022 * - * Copyright 2013-2020 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -69,6 +73,8 @@ { _kind = mesh::null_item ; + _edat._mark = (iptr_type) +0; + if (_args.dims() < +1) return; /*--------------------------- assemble local indexing */ @@ -88,31 +94,27 @@ /*--------------------------------- is not restricted */ return ; - /*------------------------- calc. refinement priority */ - _edat._mark = - _mesh._tria.node(_enod[0])->fdim() + - _mesh._tria.node(_enod[1])->fdim() ; - - _edat._cost = - (float) _pmax[2] ; + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_2d(_ebal, _pmax); - // scaling via node numbering seems to make slightly - // better (more topologically regular) meshes - // this implicitly boosts the refinement priority of - // "old" cells, which typically produces meshes with - // fewer "seams"... + /*------------------------- calc. refinement priority */ + _edat._mark += _mesh._tria. + node(_enod[0])->fdim() - 1 ; + _edat._mark += _mesh._tria. + node(_enod[1])->fdim() - 1 ; - _edat._cost/= _enod[0]+1 ; - _edat._cost/= _enod[1]+1 ; + _edat._cost = + (float) _pmax[2] * (_srat + 1.f ); /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0.; - _esiz += (real_type)+1.*_hfun.eval( + real_type _esiz = (real_type)+0. ; + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)+1.*_hfun.eval( + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -121,31 +123,23 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)+1.0 * + _esiz += (real_type)1./3. * _hfun.eval( _pmax, _hint) ; - _esiz /= (real_type)+3.0 ; + _srat /= _esiz * _esiz ; real_type _eave =_pmax [ +2] ; _eave /= _esiz * _esiz ; - _eave *= (real_type)+4.0 ; - - /*------------------------- eval. surface-disc.-error */ - real_type _srat = - geometry::lensqr_2d( - _ebal, _pmax)/(_esiz * _esiz) ; + _eave *= (real_type)4./1. ; /*------------------------- refinement classification */ // flag cells "trapped" between boundaries -- having - // all nodes on lower dimensional facets and with at - // least one boundary face. + // all nodes on lower dimensional facets... bool_type _trap = - _mesh._tria. - node(_enod[0])->fdim() < +1 && - _mesh._tria. - node(_enod[1])->fdim() < +1 ; + _mesh._tria.node(_enod[0])->fdim() < 1 && + _mesh._tria.node(_enod[1])->fdim() < 1 ; real_type _scal = 1. + _trap * .100 ; @@ -182,6 +176,8 @@ { _kind = mesh::null_item ; + _tdat._mark = (iptr_type) +0 ; + if (_args.dims() < +2) return ; /*--------------------------------- get nodes in tria */ @@ -233,21 +229,14 @@ } /*------------------------- calc. refinement priority */ - iptr_type _ebnd = _emin ; - real_type _best = - std::numeric_limits - ::infinity () ; - - bool_type _trap = false ; - - _tdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_enum = +3; _enum-- != +0; ) { + /*------------------------- are there bnd-adj. faces? */ iptr_type _enod[ +3]; - mesh_type::tria_type:: - tria_type:: + mesh_type::tria_type::tria_type:: face_node(_enod, _enum, 2, 1); _enod[ +0] = _tnod[_enod[+0]]; _enod[ +1] = _tnod[_enod[+1]]; @@ -266,48 +255,41 @@ item_type *_eptr = nullptr ; if (_mesh.find_edge(_edat,_eptr)) { - if (_best > _llen[_enum]) - { - _trap = true ; - _ebnd = _enum ; - _best = _llen[_enum]; - } - + _nbnd += +1 ; _tdat._mark -= +1 ; } } # endif /*------------------------- eval. radius--edge ratios */ - real_type _erat = _tbal[ 2] / - _llen[_emin] ; + float _erat = + (float) _tbal[2] / _llen[_emin] ; /*------------------------- calc. refinement priority */ _tdat._cost = - (float) (_tbal[2] * _erat) ; + (float)(_tbal[2] * _erat) ; - // scaling via node numbering seems to make slightly - // better (more topologically regular) meshes - // this implicitly boosts the refinement priority of - // "old" cells, which typically produces meshes with - // fewer "seams"... + /*------------------------- refinement classification */ - iptr_type _enod[ +3]; - mesh_type::tria_type::tria_type:: - face_node(_enod, _ebnd, 2, 1); - _enod[ +0] = _tnod[_enod[+0]]; - _enod[ +1] = _tnod[_enod[+1]]; + // add a scaling with "age" to help prioritise older + // cells on the front. - _tdat._cost/= _enod[0] + 1 ; - _tdat._cost/= _enod[1] + 1 ; + _tdat._cost/= + _mesh._tria._nset.count() + 1 ; + _tdat._cost/= + _mesh._tria._nset.count() + 1 ; - /*------------------------- refinement classification */ + // add a quasi-random scaling to help "break-up" any + // aligned "seam" features. + + _tdat._cost/= + (hash_ball (_tbal) % +3 ) + 1 ; // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_tnod[0])->fdim() < +2 && _mesh._tria. @@ -323,19 +305,24 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +3 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. @@ -344,14 +331,12 @@ auto _hint = _mesh._tria.node(_tnod[ 2])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./4. * _hfun.eval( _tbal, _hint) ; - _tsiz /= (real_type)+4.0 ; - real_type _eave = _tbal[ +2] ; _eave /= _tsiz * _tsiz; - _eave *= (real_type)+3.0 ; + _eave *= (real_type)3./1. ; /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc index 15cbfd0..e699e87 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 21 Apr., 2021 + * Last updated: 01 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -69,6 +73,8 @@ { _kind = mesh::null_item ; + _edat._mark = (iptr_type) +0; + if (_args.dims() < +1) return; /*--------------------------- assemble local indexing */ @@ -88,31 +94,27 @@ /*--------------------------------- is not restricted */ return ; - /*------------------------- calc. refinement priority */ - _edat._mark = - _mesh._tria.node(_enod[0])->fdim() + - _mesh._tria.node(_enod[1])->fdim() ; - - _edat._cost = - (float) _pmax[3] ; + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_3d(_ebal, _pmax); - // scaling via node numbering seems to make slightly - // better (more topologically regular) meshes - // this implicitly boosts the refinement priority of - // "old" cells, which typically produces meshes with - // fewer "seams"... + /*------------------------- calc. refinement priority */ + _edat._mark += _mesh._tria. + node(_enod[0])->fdim() - 1 ; + _edat._mark += _mesh._tria. + node(_enod[1])->fdim() - 1 ; - _edat._cost/= _enod[0]+1 ; - _edat._cost/= _enod[1]+1 ; + _edat._cost = + (float) _pmax[3] * (_srat + 1.f ); /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0.; - _esiz += (real_type)+1.*_hfun.eval( + real_type _esiz = (real_type)+0. ; + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)+1.*_hfun.eval( + _esiz += (real_type)1./3.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -121,31 +123,23 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)+1.0 * + _esiz += (real_type)1./3. * _hfun.eval( _pmax, _hint) ; - _esiz /= (real_type)+3.0 ; + _srat /= _esiz * _esiz ; real_type _eave =_pmax [ +3] ; _eave /= _esiz * _esiz ; - _eave *= (real_type)+4.0 ; - - /*------------------------- eval. surface-disc.-error */ - real_type _srat = - geometry::lensqr_3d ( - _ebal, _pmax)/(_esiz * _esiz) ; + _eave *= (real_type)4./1. ; /*------------------------- refinement classification */ // flag cells "trapped" between boundaries -- having - // all nodes on lower dimensional facets and with at - // least one boundary face. + // all nodes on lower dimensional facets... bool_type _trap = - _mesh._tria. - node(_enod[0])->fdim() < +1 && - _mesh._tria. - node(_enod[1])->fdim() < +1 ; + _mesh._tria.node(_enod[0])->fdim() < 1 && + _mesh._tria.node(_enod[1])->fdim() < 1 ; real_type _scal = 1. + _trap * .100 ; @@ -187,6 +181,8 @@ { _kind = mesh::null_item ; + _fdat._mark = (iptr_type) +0; + if (_args.dims() < +2) return; /*--------------------------- assemble local indexing */ @@ -239,14 +235,7 @@ } /*------------------------- calc. refinement priority */ - iptr_type _ebnd = _emin ; - real_type _best = - std::numeric_limits - ::infinity () ; - - bool_type _trap = false ; - - _fdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_enum = +3; _enum-- != +0; ) @@ -272,48 +261,45 @@ item_type *_eptr = nullptr ; if (_mesh.find_edge(_edat,_eptr)) { - if (_best > _llen[_enum]) - { - _trap = true ; - _ebnd = _enum ; - _best = _llen[_enum]; - } - + _nbnd += +1 ; _fdat._mark -= +1 ; } } # endif + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_3d(_tbal, _pmax); + /*------------------------- eval. radius--edge ratios */ - real_type _prat = _pmax[ 3] / - _llen[_emin] ; + float _prat = (float) + _pmax[3] / _llen[_emin] ; /*------------------------- calc. refinement priority */ - _fdat._cost = - (float) (_pmax[3] * _prat) ; + _fdat._cost = (float) + _pmax[3] * _prat * (1.f + _srat); - // scaling via node numbering seems to make slightly - // better (more topologically regular) meshes - // this implicitly boosts the refinement priority of - // "old" cells, which typically produces meshes with - // fewer "seams"... + /*------------------------- refinement classification */ - iptr_type _enod[ +3]; - mesh_type::tria_type::tria_type:: - face_node(_enod, _ebnd, 2, 1); - _enod[ +0] = _fnod[_enod[+0]]; - _enod[ +1] = _fnod[_enod[+1]]; + // add a scaling with "age" to help prioritise older + // cells on the front. - _fdat._cost/= _enod[0] + 1 ; - _fdat._cost/= _enod[1] + 1 ; + _fdat._cost/= + _mesh._tria._nset.count() + 1 ; + _fdat._cost/= + _mesh._tria._nset.count() + 1 ; - /*------------------------- refinement classification */ + // add a quasi-random scaling to help "break-up" any + // aligned "seam" features. + + _fdat._cost/= + (hash_ball (_pmax) % +3 ) + 1 ; // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_fnod[0])->fdim() < +2 && _mesh._tria. @@ -329,19 +315,24 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +3 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _fbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[0])->pval(0) , _mesh._tria. node(_fnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[1])->pval(0) , _mesh._tria. node(_fnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_fnod[2])->pval(0) , _mesh._tria. @@ -350,19 +341,14 @@ auto _hint = _mesh._tria.node(_fnod[ 2])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./4. * _hfun.eval( _pmax, _hint) ; - _tsiz /= (real_type)+4.0 ; + _srat /= _tsiz * _tsiz ; real_type _eave =_pmax [ +3] ; _eave /= _tsiz * _tsiz; - _eave *= (real_type)+3.0 ; - - /*------------------------- eval. surface-disc.-error */ - real_type _srat = - geometry::lensqr_3d( - _tbal, _pmax)/(_tsiz * _tsiz) ; + _eave *= (real_type)3./1. ; /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; @@ -400,8 +386,7 @@ { _kind = mesh::null_item ; - __unreferenced(_geom); - __unreferenced(_part); + _tdat._mark = (iptr_type) +0 ; if (_args.dims() < +3) return ; @@ -496,18 +481,12 @@ } /*------------------------- calc. refinement priority */ - iptr_type _fbnd = _fmin ; - real_type _best = - std::numeric_limits - ::infinity () ; - - bool_type _trap = false ; - - _tdat._mark = (iptr_type) +0; + iptr_type _nbnd = +0 ; # ifdef __bias_bnds for(_fnum = +4; _fnum-- != +0; ) { + /*------------------------- are there bnd-adj. faces? */ iptr_type _fnod[ +4]; mesh_type::tria_type::tria_type:: face_node(_fnod, _fnum, 3, 2); @@ -533,55 +512,46 @@ item_type *_fptr = nullptr ; if (_mesh.find_face(_fdat,_fptr)) { - if (_best > _frad[_fnum]) - { - _trap = true ; - _fbnd = _fnum ; - _best = _frad[_fnum]; - } - + _nbnd += +1 ; _tdat._mark -= +1 ; } } # endif /*------------------------- eval. radius--edge ratios */ - real_type _erat = _tbal[ +3] / - _llen[_emin] ; + float _erat = + (float) _tbal[3] / _llen[_emin] ; - real_type _frat = _tbal[ +3] / - _frad[_fmin] ; + float _frat = + (float) _tbal[3] / _frad[_fmin] ; - real_type _trat = _erat*_frat; + float _trat = _erat * _frat; /*------------------------- calc. refinement priority */ _tdat._cost = - (float) (_tbal[3] * _trat) ; + (float)(_tbal[3] * _trat) ; - // scaling via node numbering seems to make slightly - // better (more topologically regular) meshes - // this implicitly boosts the refinement priority of - // "old" cells, which typically produces meshes with - // fewer "seams"... + /*------------------------- refinement classification */ - iptr_type _fnod[ +4]; - mesh_type::tria_type::tria_type:: - face_node(_fnod, _fbnd, 3, 2); - _fnod[ +0] = _tnod[_fnod[+0]]; - _fnod[ +1] = _tnod[_fnod[+1]]; - _fnod[ +2] = _tnod[_fnod[+2]]; + // add a scaling with "age" to help prioritise older + // cells on the front. - _tdat._cost/= _fnod[0] + 1 ; - _tdat._cost/= _fnod[1] + 1 ; - _tdat._cost/= _fnod[2] + 1 ; + _tdat._cost/= + _mesh._tria._nset.count() + 1 ; + _tdat._cost/= + _mesh._tria._nset.count() + 1 ; - /*------------------------- refinement classification */ + // add a quasi-random scaling to help "break-up" any + // aligned "seam" features. + + _tdat._cost/= + (hash_ball (_tbal) % +3 ) + 1 ; // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. - _trap = _trap && + bool_type _trap =_nbnd > +0 && _mesh._tria. node(_tnod[0])->fdim() < +3 && _mesh._tria. @@ -599,24 +569,29 @@ _kind = mesh::ring_item; return ; } + if (_nbnd >= +4 ) + { + _kind = mesh::ring_item; return ; + } + /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. node(_tnod[2])->idxh()) ; - _tsiz += (real_type)+1.*_hfun.eval( + _tsiz += (real_type)1./5.*_hfun.eval( &_mesh._tria. node(_tnod[3])->pval(0) , _mesh._tria. @@ -625,15 +600,12 @@ auto _hint = _mesh._tria.node(_tnod[ 3])->idxh() ; - _tsiz += (real_type)+1.0 * + _tsiz += (real_type)1./5. * _hfun.eval( _tbal, _hint) ; - _tsiz /= (real_type)+5.0 ; - real_type _eave = _tbal [+3] ; _eave /= (_tsiz*_tsiz) ; - _eave *= (real_type)+8.0 / - (real_type)+3.0 ; + _eave *= (real_type)8./3. ; /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; diff --git a/src/libcpp/rdel_mesh/rdel_create_init_2.inc b/src/libcpp/rdel_mesh/rdel_create_init_2.inc index 71870b9..496852d 100644 --- a/src/libcpp/rdel_mesh/rdel_create_init_2.inc +++ b/src/libcpp/rdel_mesh/rdel_create_init_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_create_init_3.inc b/src/libcpp/rdel_mesh/rdel_create_init_3.inc index 506bae8..f0e7738 100644 --- a/src/libcpp/rdel_mesh/rdel_create_init_3.inc +++ b/src/libcpp/rdel_mesh/rdel_create_init_3.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_filt_k.hpp b/src/libcpp/rdel_mesh/rdel_filt_k.hpp index 89e20cc..86e9387 100644 --- a/src/libcpp/rdel_mesh/rdel_filt_k.hpp +++ b/src/libcpp/rdel_mesh/rdel_filt_k.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_make_2.hpp b/src/libcpp/rdel_mesh/rdel_make_2.hpp index 222bc5f..1eb46fe 100644 --- a/src/libcpp/rdel_mesh/rdel_make_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_make_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -115,6 +119,8 @@ typedef typename mesh_type::tria_data tria_data ; + typedef mesh::rdel_timers rdel_stat ; + typedef containers::array < iptr_type > iptr_list ; @@ -126,10 +132,6 @@ real_type, iptr_type > rdel_opts ; - typedef mesh::rdel_timers < - real_type , - iptr_type > rdel_stat ; - /* -------------------------------------------------------- * PUSH-EDGE: add new edge to restricted-tria. @@ -386,7 +388,7 @@ /*---------------------- calc. ball in floating-point */ real_type _tbal[3] ; - geometry::circ_ball_2d ( + geometry::perp_ball_2d ( _tbal , &_mesh._tria. node(_tnod[0])->pval(0) , @@ -884,20 +886,20 @@ _dump.push("\n") ; } - if (_args.verb() >= +3 ) + if (_args.verb() >= +2 ) { - /*------------------------- push rDEL memory metrics */ + /*------------------------- more rDEL scheme metrics */ _dump.push("\n") ; _dump.push("**MEMORY statistics...\n") ; - _dump.push(" DELAUNAY object:\n") ; + _dump.push(" xDEL-type:\n") ; _dump.push(" *node-byte = ") ; _dump.push(std::to_string( sizeof(typename mesh_type:: tria_type:: node_type)) ) ; _dump.push("\n") ; - _dump.push(" *node-list = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._tria._nset.alloc())) ; _dump.push("\n") ; @@ -906,18 +908,22 @@ sizeof(typename mesh_type:: tria_type:: tria_type)) ) ; _dump.push("\n") ; - _dump.push(" *tria-list = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tria._tset.alloc())) ; _dump.push("\n") ; + _dump.push(" *pool-byte = ") ; + _dump.push(std::to_string( + _mesh._tria._fpol.bytes())) ; + _dump.push("\n") ; - _dump.push(" RESTRICTED tria:\n") ; + _dump.push(" rDEL-type:\n") ; _dump.push(" *edge-byte = ") ; _dump.push(std::to_string( sizeof( typename mesh_type::edge_item)) ) ; _dump.push("\n") ; - _dump.push(" *edge-hash = ") ; + _dump.push(" *eset-size = ") ; _dump.push(std::to_string( _mesh._eset._lptr.alloc())) ; _dump.push("\n") ; @@ -930,7 +936,7 @@ sizeof( typename mesh_type::tria_item)) ) ; _dump.push("\n") ; - _dump.push(" *tria-hash = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tset._lptr.alloc())) ; _dump.push("\n") ; diff --git a/src/libcpp/rdel_mesh/rdel_make_3.hpp b/src/libcpp/rdel_mesh/rdel_make_3.hpp index 5c653ac..5777dbb 100644 --- a/src/libcpp/rdel_mesh/rdel_make_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_make_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -117,6 +121,8 @@ typedef typename mesh_type::tria_data tria_data ; + typedef mesh::rdel_timers rdel_stat ; + typedef containers::array < iptr_type > iptr_list ; @@ -128,10 +134,6 @@ real_type, iptr_type > rdel_opts ; - typedef mesh::rdel_timers < - real_type , - iptr_type > rdel_stat ; - /* -------------------------------------------------------- * PUSH-EDGE: add new edge to restricted-tria. @@ -489,7 +491,7 @@ /*---------------------- calc. ball in floating-point */ real_type _tbal[4] ; - geometry::circ_ball_3d ( + geometry::perp_ball_3d ( _tbal , &_mesh._tria. node(_tnod[0])->pval(0) , @@ -1054,19 +1056,19 @@ } - if (_args.verb() >= +3 ) + if (_args.verb() >= +2 ) { - /*------------------------- push rDEL memory metrics */ + /*------------------------- more rDEL scheme metrics */ _dump.push("\n") ; _dump.push("**MEMORY statistics...\n") ; - _dump.push(" DELAUNAY-OBJECT:\n") ; + _dump.push(" xDEL-type:\n") ; _dump.push(" *node-byte = ") ; _dump.push(std::to_string( sizeof(typename mesh_type:: tria_type:: node_type)) ) ; _dump.push("\n") ; - _dump.push(" *node-list = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._tria._nset.alloc())) ; _dump.push("\n") ; @@ -1075,19 +1077,23 @@ sizeof(typename mesh_type:: tria_type:: tria_type)) ) ; _dump.push("\n") ; - _dump.push(" *tria-list = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tria._tset.alloc())) ; _dump.push("\n") ; + _dump.push(" *pool-byte = ") ; + _dump.push(std::to_string( + _mesh._tria._fpol.bytes())) ; + _dump.push("\n") ; _dump.push("\n") ; - _dump.push(" RESTRICTED-TRIA:\n") ; + _dump.push(" rDEL-type:\n") ; _dump.push(" *edge-byte = ") ; _dump.push(std::to_string( sizeof( typename mesh_type::edge_item)) ) ; _dump.push("\n") ; - _dump.push(" *edge-hash = ") ; + _dump.push(" *eset-size = ") ; _dump.push(std::to_string( _mesh._eset._lptr.alloc())) ; _dump.push("\n") ; @@ -1100,7 +1106,7 @@ sizeof( typename mesh_type::face_item)) ) ; _dump.push("\n") ; - _dump.push(" *face-hash = ") ; + _dump.push(" *fset-size = ") ; _dump.push(std::to_string( _mesh._fset._lptr.alloc())) ; _dump.push("\n") ; @@ -1113,7 +1119,7 @@ sizeof( typename mesh_type::tria_item)) ) ; _dump.push("\n") ; - _dump.push(" *tria-hash = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tset._lptr.alloc())) ; _dump.push("\n") ; diff --git a/src/libcpp/rdel_mesh/rdel_mesh_2.hpp b/src/libcpp/rdel_mesh/rdel_mesh_2.hpp index ccdc560..e0db9ac 100644 --- a/src/libcpp/rdel_mesh/rdel_mesh_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_mesh_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -176,14 +180,12 @@ typedef typename mesh_type::tria_list tria_hash ; + typedef mesh::rdel_timers rdel_stat ; + typedef mesh::mesh_params < real_type, iptr_type > rdel_opts ; - typedef mesh::rdel_timers < - real_type , - iptr_type > rdel_stat ; - typedef containers::array < iptr_type > iptr_list ; @@ -359,8 +361,7 @@ if(!_eepq.empty()) { - iptr_type _dead = +0 ; - iptr_type _okay = +0 ; + iptr_type _dead = +0, _okay = +0 ; for (auto _hpos = _eepq.count() - 1 ; _hpos > +0 ; @@ -420,8 +421,7 @@ if(!_ttpq.empty()) { - iptr_type _dead = +0 ; - iptr_type _okay = +0 ; + iptr_type _dead = +0, _okay = +0 ; for (auto _hpos = _ttpq.count() - 1 ; _hpos > +0 ; @@ -788,7 +788,12 @@ # ifdef _DEBUG iptr_type _jlog_freq = +250 ; # else - iptr_type _jlog_freq = +75000 ; + iptr_type _jlog_tens = + (iptr_type) std::log10(_pass) ; + + iptr_type _jlog_freq = + (+5 * std::max(10000, + (iptr_type)std::pow(10, _jlog_tens))) / 2 ; # endif if(++_pass>_args.iter()) break; @@ -951,7 +956,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._node_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -974,7 +979,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._edge_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -998,7 +1003,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._edge_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1021,7 +1026,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._tria_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } /*----------------------------- meshing converged */ @@ -1062,6 +1067,10 @@ if (_pass%_trim_freq == +0 ) { /*--------------- trim null PQ items "on-the-fly" */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + trim_list( _nbpq ) ; trim_eepq( _mesh , _eepq ) ; @@ -1081,13 +1090,30 @@ trim_list( _tscr ) ; trim_list( _bscr ) ; trim_list( _bdat ) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._list_trim += + _tcpu.time_span(_ttic,_ttoc) ; + # endif//__use_timers } + { /*--------------- enqueue nodes for topol. checks */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers - fill_topo( _mesh, _pass, - _etpq, _emrk, - _edat, _eprv, _args) ; + fill_topo( _mesh, _pass, + _etpq, _emrk, + _edat, _eprv, _args) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._topo_init += + _tcpu.time_span(_ttic,_ttoc) ; + # endif//__use_timers + } /*--------------- update restricted triangulation */ @@ -1164,81 +1190,89 @@ _dump.push("\n") ; _dump.push("**TIMING statistics...\n") ; - _dump.push(" MESH-SEED = ") ; + _dump.push(" *mesh-seed = ") ; _dump.push( std::to_string (_tcpu._mesh_seed)); _dump.push("\n") ; - _dump.push(" NODE-INIT = ") ; + _dump.push(" *node-init = ") ; _dump.push( std::to_string (_tcpu._node_init)); _dump.push("\n") ; - _dump.push(" NODE-RULE = ") ; + _dump.push(" *node-rule = ") ; _dump.push( std::to_string (_tcpu._node_rule)); _dump.push("\n") ; - _dump.push(" EDGE-INIT = ") ; + _dump.push(" *edge-init = ") ; _dump.push( std::to_string (_tcpu._edge_init)); _dump.push("\n") ; - _dump.push(" EDGE-RULE = ") ; + _dump.push(" *edge-rule = ") ; _dump.push( std::to_string (_tcpu._edge_rule)); _dump.push("\n") ; - _dump.push(" TRIA-INIT = ") ; + _dump.push(" *tria-init = ") ; _dump.push( std::to_string (_tcpu._tria_init)); _dump.push("\n") ; - _dump.push(" TRIA-RULE = ") ; + _dump.push(" *tria-rule = ") ; _dump.push( std::to_string (_tcpu._tria_rule)); + _dump.push("\n") ; + _dump.push(" *list-init = ") ; + _dump.push( + std::to_string (_tcpu._list_trim)); + _dump.push("\n") ; + _dump.push(" *topo-init = ") ; + _dump.push( + std::to_string (_tcpu._topo_init)); _dump.push("\n\n"); _dump.push("**REFINE statistics...\n") ; - _dump.push(" EDGE-CIRC = ") ; + _dump.push(" *edge-circ = ") ; _dump.push(std::to_string( _enod[rdel_opts::circ_kind])); _dump.push("\n") ; - _dump.push(" EDGE-OFFH = ") ; + _dump.push(" *edge-offH = ") ; _dump.push(std::to_string( _enod[rdel_opts::offH_kind])); _dump.push("\n") ; - _dump.push(" EDGE-OFFT = ") ; + _dump.push(" *edge-offT = ") ; _dump.push(std::to_string( _enod[rdel_opts::offT_kind])); _dump.push("\n") ; - _dump.push(" TRIA-CIRC = ") ; + _dump.push(" *tria-circ = ") ; _dump.push(std::to_string( _tnod[rdel_opts::circ_kind])); _dump.push("\n") ; - _dump.push(" TRIA-SINK = ") ; + _dump.push(" *tria-sink = ") ; _dump.push(std::to_string( _tnod[rdel_opts::sink_kind])); _dump.push("\n") ; - _dump.push(" TRIA-OFFH = ") ; + _dump.push(" *tria-offH = ") ; _dump.push(std::to_string( _tnod[rdel_opts::offH_kind])); _dump.push("\n") ; - _dump.push(" TRIA-OFFC = ") ; + _dump.push(" *tria-offC = ") ; _dump.push(std::to_string( _tnod[rdel_opts::offC_kind])); _dump.push("\n") ; } - if (_args.verb() >= +3 ) + if (_args.verb() >= +2 ) { - /*-------------------- push refinement memory metrics */ + /*-------------------- more refinement scheme metrics */ _dump.push("\n") ; _dump.push("**MEMORY statistics...\n") ; - _dump.push(" DELAUNAY-OBJECT:\n"); + _dump.push(" xDEL-type:\n") ; _dump.push(" *node-byte = ") ; _dump.push(std::to_string( sizeof(typename mesh_type:: tria_type:: node_type)) ) ; _dump.push("\n") ; - _dump.push(" *node-list = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._tria._nset.alloc())) ; _dump.push("\n") ; @@ -1247,18 +1281,22 @@ sizeof(typename mesh_type:: tria_type:: tria_type)) ) ; _dump.push("\n") ; - _dump.push(" *tria-list = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tria._tset.alloc())) ; - _dump.push("\n\n"); + _dump.push("\n") ; + _dump.push(" *pool-byte = ") ; + _dump.push(std::to_string( + _mesh._tria._fpol.bytes())) ; + _dump.push("\n") ; - _dump.push(" RESTRICTED-TRIA:\n"); + _dump.push(" rDEL-type:\n") ; _dump.push(" *ball-byte = ") ; _dump.push(std::to_string( sizeof( typename mesh_type::ball_item)) ) ; _dump.push("\n") ; - _dump.push(" *ball-hash = ") ; + _dump.push(" *bset-size = ") ; _dump.push(std::to_string( _mesh._bset._lptr.alloc())) ; _dump.push("\n") ; @@ -1271,7 +1309,7 @@ sizeof( typename mesh_type::node_item)) ) ; _dump.push("\n") ; - _dump.push(" *node-hash = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._nset._lptr.alloc())) ; _dump.push("\n") ; @@ -1284,7 +1322,7 @@ sizeof( typename mesh_type::edge_item)) ) ; _dump.push("\n") ; - _dump.push(" *edge-hash = ") ; + _dump.push(" *eset-size = ") ; _dump.push(std::to_string( _mesh._eset._lptr.alloc())) ; _dump.push("\n") ; @@ -1297,38 +1335,119 @@ sizeof( typename mesh_type::tria_item)) ) ; _dump.push("\n") ; - _dump.push(" *tria-hash = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tset._lptr.alloc())) ; _dump.push("\n") ; _dump.push(" *pool-byte = ") ; _dump.push( std::to_string(_mesh._tpol.bytes())) ; - _dump.push("\n\n"); + _dump.push("\n") ; - _dump.push(" PRIORITY-QUEUES:\n"); + _dump.push(" xxPQ-type:\n") ; _dump.push(" *bscr-byte = ") ; _dump.push( std::to_string(sizeof(ball_data))); _dump.push("\n") ; - _dump.push(" *bbpq-item = ") ; + _dump.push(" *bset-peak = ") ; _dump.push(std::to_string(_Nbpq)) ; _dump.push("\n") ; _dump.push(" *escr-byte = ") ; _dump.push( std::to_string(sizeof(edge_cost))); _dump.push("\n") ; - _dump.push(" *eepq-item = ") ; + _dump.push(" *eset-peak = ") ; _dump.push(std::to_string(_Nepq)) ; _dump.push("\n") ; _dump.push(" *tscr-byte = ") ; _dump.push( std::to_string(sizeof(tria_cost))); _dump.push("\n") ; - _dump.push(" *ttpq-item = ") ; + _dump.push(" *tset-peak = ") ; _dump.push(std::to_string(_Ntpq)) ; _dump.push("\n") ; + _dump.push("\n") ; + _dump.push("**FPMATH statistics...\n") ; + + _dump.push(" *orient2Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT2D_f])) ; + _dump.push("\n") ; + _dump.push(" *orient2Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT2D_i])) ; + _dump.push("\n") ; + _dump.push(" *orient2De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT2D_e])) ; + _dump.push("\n") ; + + _dump.push(" *bisect2Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2D_f])) ; + _dump.push("\n") ; + _dump.push(" *bisect2Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2D_i])) ; + _dump.push("\n") ; + _dump.push(" *bisect2De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2D_e])) ; + _dump.push("\n") ; + _dump.push(" *bisect2Wf = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2W_f])) ; + _dump.push("\n") ; + _dump.push(" *bisect2Wi = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2W_i])) ; + _dump.push("\n") ; + _dump.push(" *bisect2We = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT2W_e])) ; + _dump.push("\n") ; + + _dump.push(" *inball2Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2D_f])) ; + _dump.push("\n") ; + _dump.push(" *inball2Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2D_i])) ; + _dump.push("\n") ; + _dump.push(" *inball2De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2D_e])) ; + _dump.push("\n") ; + _dump.push(" *inball2Wf = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2W_f])) ; + _dump.push("\n") ; + _dump.push(" *inball2Wi = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2W_i])) ; + _dump.push("\n") ; + _dump.push(" *inball2We = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL2W_e])) ; + _dump.push("\n") ; + } _dump.push("\n") ; diff --git a/src/libcpp/rdel_mesh/rdel_mesh_3.hpp b/src/libcpp/rdel_mesh/rdel_mesh_3.hpp index 9ec1a19..86ae97b 100644 --- a/src/libcpp/rdel_mesh/rdel_mesh_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_mesh_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -182,14 +186,12 @@ typedef typename mesh_type::tria_data tria_data ; + typedef mesh::rdel_timers rdel_stat ; + typedef mesh::mesh_params < real_type, iptr_type > rdel_opts ; - typedef mesh::rdel_timers < - real_type , - iptr_type > rdel_stat ; - typedef containers::array < iptr_type > iptr_list ; @@ -387,8 +389,7 @@ if(!_eepq.empty()) { - iptr_type _dead = +0 ; - iptr_type _okay = +0 ; + iptr_type _dead = +0, _okay = +0 ; for (auto _hpos = _eepq.count() - 1 ; _hpos > +0 ; @@ -448,8 +449,7 @@ if(!_ffpq.empty()) { - iptr_type _dead = +0 ; - iptr_type _okay = +0 ; + iptr_type _dead = +0, _okay = +0 ; for (auto _hpos = _ffpq.count() - 1 ; _hpos > +0 ; @@ -511,8 +511,7 @@ if(!_ttpq.empty()) { - iptr_type _dead = +0 ; - iptr_type _okay = +0 ; + iptr_type _dead = +0, _okay = +0 ; for (auto _hpos = _ttpq.count() - 1 ; _hpos > +0 ; @@ -767,9 +766,6 @@ mesh_type &_mesh ) { - - //return; - iptr_list _nsum; _nsum.set_count( _mesh._tria._nset.count(), @@ -1009,7 +1005,12 @@ # ifdef _DEBUG iptr_type _jlog_freq = +250 ; # else - iptr_type _jlog_freq = +37500 ; + iptr_type _jlog_tens = + (iptr_type) std::log10(_pass) ; + + iptr_type _jlog_freq = + (+5 * std::max(10000, + (iptr_type)std::pow(10, _jlog_tens))) / 2 ; # endif if(++_pass>_args.iter()) break; @@ -1140,9 +1141,9 @@ _mesh, _epro, _fpro, _pass, _mode, _args) ; - */ - //init_dual( _mesh) ; + init_dual( _mesh) ; + */ init_rdel( _geom, _hfun, _mesh, true, @@ -1232,7 +1233,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._node_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1257,7 +1258,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._edge_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1283,7 +1284,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._edge_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1308,7 +1309,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._face_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1334,7 +1335,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._face_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } else @@ -1359,7 +1360,7 @@ # ifdef __use_timers _ttoc = _time.now() ; _tcpu._tria_rule += - _tcpu.time_span(_ttic,_ttoc) ; + _tcpu.nano_span(_ttic,_ttoc) ; # endif//__use_timers } /*----------------------------- meshing converged */ @@ -1407,6 +1408,10 @@ if (_pass%_trim_freq == +0 ) { /*--------------- trim null PQ items "on-the-fly" */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers + trim_list( _nbpq ) ; trim_eepq( _mesh , _eepq ) ; @@ -1432,15 +1437,32 @@ trim_list( _tscr ) ; trim_list( _bdat ) ; trim_list( _bscr ) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._list_trim += + _tcpu.time_span(_ttic,_ttoc) ; + # endif//__use_timers } + { /*--------------- enqueue nodes for topol. checks */ + # ifdef __use_timers + _ttic = _time.now() ; + # endif//__use_timers - fill_topo( _mesh, _pass, - _etpq, _emrk, - _ftpq, _fmrk, - _edat, _eprv, - _fdat, _fprv, _args) ; + fill_topo( _mesh, _pass, + _etpq, _emrk, + _ftpq, _fmrk, + _edat, _eprv, + _fdat, _fprv, _args) ; + + # ifdef __use_timers + _ttoc = _time.now() ; + _tcpu._topo_init += + _tcpu.time_span(_ttic,_ttoc) ; + # endif//__use_timers + } /*--------------- update restricted triangulation */ @@ -1530,109 +1552,117 @@ _dump.push("\n") ; _dump.push("**TIMING statistics...\n") ; - _dump.push(" MESH-SEED = ") ; + _dump.push(" *mesh-seed = ") ; _dump.push( std::to_string (_tcpu._mesh_seed)); _dump.push("\n") ; - _dump.push(" NODE-INIT = ") ; + _dump.push(" *node-init = ") ; _dump.push( std::to_string (_tcpu._node_init)); _dump.push("\n") ; - _dump.push(" NODE-RULE = ") ; + _dump.push(" *node-rule = ") ; _dump.push( std::to_string (_tcpu._node_rule)); _dump.push("\n") ; - _dump.push(" EDGE-INIT = ") ; + _dump.push(" *edge-init = ") ; _dump.push( std::to_string (_tcpu._edge_init)); _dump.push("\n") ; - _dump.push(" EDGE-RULE = ") ; + _dump.push(" *edge-rule = ") ; _dump.push( std::to_string (_tcpu._edge_rule)); _dump.push("\n") ; - _dump.push(" FACE-INIT = ") ; + _dump.push(" *face-init = ") ; _dump.push( std::to_string (_tcpu._face_init)); _dump.push("\n") ; - _dump.push(" FACE-RULE = ") ; + _dump.push(" *face-rule = ") ; _dump.push( std::to_string (_tcpu._face_rule)); _dump.push("\n") ; - _dump.push(" TRIA-INIT = ") ; + _dump.push(" *tria-init = ") ; _dump.push( std::to_string (_tcpu._tria_init)); _dump.push("\n") ; - _dump.push(" TRIA-RULE = ") ; + _dump.push(" *tria-rule = ") ; _dump.push( std::to_string (_tcpu._tria_rule)); + _dump.push("\n") ; + _dump.push(" *list-init = ") ; + _dump.push( + std::to_string (_tcpu._list_trim)); + _dump.push("\n") ; + _dump.push(" *topo-init = ") ; + _dump.push( + std::to_string (_tcpu._topo_init)); _dump.push("\n\n"); _dump.push("**REFINE statistics...\n") ; - _dump.push(" EDGE-CIRC = ") ; + _dump.push(" *edge-circ = ") ; _dump.push(std::to_string( _enod[rdel_opts::circ_kind])); _dump.push("\n") ; - _dump.push(" EDGE-OFFH = ") ; + _dump.push(" *edge-offH = ") ; _dump.push(std::to_string( _enod[rdel_opts::offH_kind])); _dump.push("\n") ; - _dump.push(" EDGE-OFFT = ") ; + _dump.push(" *edge-offT = ") ; _dump.push(std::to_string( _enod[rdel_opts::offT_kind])); _dump.push("\n") ; - _dump.push(" FACE-CIRC = ") ; + _dump.push(" *face-circ = ") ; _dump.push(std::to_string( _fnod[rdel_opts::circ_kind])); _dump.push("\n") ; - _dump.push(" FACE-SINK = ") ; + _dump.push(" *face-sink = ") ; _dump.push(std::to_string( _fnod[rdel_opts::sink_kind])); _dump.push("\n") ; - _dump.push(" FACE-OFFH = ") ; + _dump.push(" *face-offH = ") ; _dump.push(std::to_string( _fnod[rdel_opts::offH_kind])); _dump.push("\n") ; - _dump.push(" FACE-OFFC = ") ; + _dump.push(" *face-offC = ") ; _dump.push(std::to_string( _fnod[rdel_opts::offC_kind])); _dump.push("\n") ; - _dump.push(" FACE-OFFT = ") ; + _dump.push(" *face-offT = ") ; _dump.push(std::to_string( _fnod[rdel_opts::offT_kind])); _dump.push("\n") ; - _dump.push(" TRIA-CIRC = ") ; + _dump.push(" *tria-circ = ") ; _dump.push(std::to_string( _tnod[rdel_opts::circ_kind])); _dump.push("\n") ; - _dump.push(" TRIA-SINK = ") ; + _dump.push(" *tria-sink = ") ; _dump.push(std::to_string( _tnod[rdel_opts::sink_kind])); _dump.push("\n") ; - _dump.push(" TRIA-OFFH = ") ; + _dump.push(" *tria-offH = ") ; _dump.push(std::to_string( _tnod[rdel_opts::offH_kind])); _dump.push("\n") ; - _dump.push(" TRIA-OFFC = ") ; + _dump.push(" *tria-offC = ") ; _dump.push(std::to_string( _tnod[rdel_opts::offC_kind])); _dump.push("\n") ; } - if (_args.verb() >= +3 ) + if (_args.verb() >= +2 ) { - /*-------------------- push refinement memory metrics */ + /*-------------------- more refinement scheme metrics */ _dump.push("\n") ; _dump.push("**MEMORY statistics...\n") ; - _dump.push(" DELAUNAY-OBJECT:\n"); + _dump.push(" xDEL-type:\n") ; _dump.push(" *node-byte = ") ; _dump.push(std::to_string( sizeof(typename mesh_type:: tria_type:: node_type)) ) ; _dump.push("\n") ; - _dump.push(" *node-list = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._tria._nset.alloc())) ; _dump.push("\n") ; @@ -1641,18 +1671,22 @@ sizeof(typename mesh_type:: tria_type:: tria_type)) ) ; _dump.push("\n") ; - _dump.push(" *tria-list = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tria._tset.alloc())) ; - _dump.push("\n\n"); + _dump.push("\n") ; + _dump.push(" *pool-byte = ") ; + _dump.push(std::to_string( + _mesh._tria._fpol.bytes())) ; + _dump.push("\n") ; - _dump.push(" RESTRICTED-TRIA:\n"); + _dump.push(" rDEL-type:\n") ; _dump.push(" *ball-byte = ") ; _dump.push(std::to_string( sizeof( typename mesh_type::ball_item)) ) ; _dump.push("\n") ; - _dump.push(" *ball-hash = ") ; + _dump.push(" *bset-size = ") ; _dump.push(std::to_string( _mesh._bset._lptr.alloc())) ; _dump.push("\n") ; @@ -1665,7 +1699,7 @@ sizeof( typename mesh_type::node_item)) ) ; _dump.push("\n") ; - _dump.push(" *node-hash = ") ; + _dump.push(" *nset-size = ") ; _dump.push(std::to_string( _mesh._nset._lptr.alloc())) ; _dump.push("\n") ; @@ -1678,7 +1712,7 @@ sizeof( typename mesh_type::edge_item)) ) ; _dump.push("\n") ; - _dump.push(" *edge-hash = ") ; + _dump.push(" *eset-size = ") ; _dump.push(std::to_string( _mesh._eset._lptr.alloc())) ; _dump.push("\n") ; @@ -1691,7 +1725,7 @@ sizeof( typename mesh_type::face_item)) ) ; _dump.push("\n") ; - _dump.push(" *face-hash = ") ; + _dump.push(" *fset-size = ") ; _dump.push(std::to_string( _mesh._fset._lptr.alloc())) ; _dump.push("\n") ; @@ -1704,45 +1738,126 @@ sizeof( typename mesh_type::tria_item)) ) ; _dump.push("\n") ; - _dump.push(" *tria-hash = ") ; + _dump.push(" *tset-size = ") ; _dump.push(std::to_string( _mesh._tset._lptr.alloc())) ; _dump.push("\n") ; _dump.push(" *pool-byte = ") ; _dump.push( std::to_string(_mesh._tpol.bytes())) ; - _dump.push("\n\n"); + _dump.push("\n") ; - _dump.push(" PRIORITY-QUEUES:\n"); + _dump.push(" xxPQ-type:\n") ; _dump.push(" *bscr-byte = ") ; _dump.push( std::to_string(sizeof(ball_data))); _dump.push("\n") ; - _dump.push(" *bbpq-item = ") ; + _dump.push(" *bset-peak = ") ; _dump.push(std::to_string(_Nbpq)) ; _dump.push("\n") ; _dump.push(" *escr-byte = ") ; _dump.push( std::to_string(sizeof(edge_cost))); _dump.push("\n") ; - _dump.push(" *eepq-item = ") ; + _dump.push(" *eset-peak = ") ; _dump.push(std::to_string(_Nepq)) ; _dump.push("\n") ; _dump.push(" *fscr-byte = ") ; _dump.push( std::to_string(sizeof(face_cost))); _dump.push("\n") ; - _dump.push(" *ffpq-item = ") ; + _dump.push(" *fset-peak = ") ; _dump.push(std::to_string(_Nfpq)) ; _dump.push("\n") ; _dump.push(" *tscr-byte = ") ; _dump.push( std::to_string(sizeof(tria_cost))); _dump.push("\n") ; - _dump.push(" *ttpq-item = ") ; + _dump.push(" *tset-peak = ") ; _dump.push(std::to_string(_Ntpq)) ; _dump.push("\n") ; + _dump.push("\n") ; + _dump.push("**FPMATH statistics...\n") ; + + _dump.push(" *orient3Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT3D_f])) ; + _dump.push("\n") ; + _dump.push(" *orient3Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT3D_i])) ; + _dump.push("\n") ; + _dump.push(" *orient3De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::ORIENT3D_e])) ; + _dump.push("\n") ; + + _dump.push(" *bisect3Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3D_f])) ; + _dump.push("\n") ; + _dump.push(" *bisect3Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3D_i])) ; + _dump.push("\n") ; + _dump.push(" *bisect3De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3D_e])) ; + _dump.push("\n") ; + _dump.push(" *bisect3Wf = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3W_f])) ; + _dump.push("\n") ; + _dump.push(" *bisect3Wi = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3W_i])) ; + _dump.push("\n") ; + _dump.push(" *bisect3We = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::BISECT3W_e])) ; + _dump.push("\n") ; + + _dump.push(" *inball3Df = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3D_f])) ; + _dump.push("\n") ; + _dump.push(" *inball3Di = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3D_i])) ; + _dump.push("\n") ; + _dump.push(" *inball3De = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3D_e])) ; + _dump.push("\n") ; + _dump.push(" *inball3Wf = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3W_f])) ; + _dump.push("\n") ; + _dump.push(" *inball3Wi = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3W_i])) ; + _dump.push("\n") ; + _dump.push(" *inball3We = ") ; + _dump.push(std::to_string( + geompred::_nn_calls [ + geompred::INBALL3W_e])) ; + _dump.push("\n") ; + } _dump.push("\n") ; diff --git a/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc index c29253b..cf5740f 100644 --- a/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 31 Mar., 2021 + * Last updated: 03 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -66,7 +70,8 @@ _kind = rdel_opts::null_kind; typename hfun_type::hint_type - _hint = _hfun .null_hint() ; + _hint = _hfun .null_hint() , + _HINT = _hfun .null_hint() ; real_type static const _rtol = (real_type)+1.00E-003 ; @@ -75,16 +80,13 @@ _dtol = (real_type)+8.00E-001 ; real_type static const - _lgap = (real_type)+9.00E-001 ; + _lgap = (real_type)+8./9. ; real_type static const - _ugap = (real_type)+1.10E+000 ; + _ugap = (real_type)+9./8. ; __unreferenced(_args) ; - if (_enod[1] < _enod[0]) - std::swap( _enod[0], _enod[1]); - real_type _hsiz [ 4] ; _hsiz[ 0] = _hfun.eval ( &_mesh._tria.node(_enod[0])->pval(0) , @@ -93,13 +95,19 @@ &_mesh._tria.node(_enod[1])->pval(0) , _mesh._tria.node(_enod[1])->idxh()) ; + if (_hsiz[1] < _hsiz[0]) + { + std::swap( _enod[0], _enod[1]); + std::swap( _hsiz[0], _hsiz[1]); + } + real_type _dvec[3] ; real_type _base[2] = { _mesh._tria.node(_enod[0])->pval(0) , _mesh._tria.node(_enod[0])->pval(1) , } ; - _hint = + _hint = _HINT = _mesh._tria.node (_enod[0])->idxh() ; _dvec[ 0] = @@ -140,8 +148,6 @@ (real_type)+.5 * (_base[1]+_ppos[1]) , } ; - typename hfun_type::hint_type - _HINT = _hint ; _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hval = @@ -154,11 +160,11 @@ if (_dist >= _dvec[2] * _lgap && _dist <= _dvec[2] * _ugap ) { // circumball cushion - _dist += _dvec[2] ; - _dist /= (real_type)2.; + _ppos[0]=_sbal[0] ; + _ppos[1]=_sbal[1] ; - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; + return _kind ; } if (_dist >= _dvec[2] * _ugap ) @@ -166,31 +172,28 @@ _ppos[0]=_sbal[0] ; _ppos[1]=_sbal[1] ; - _kind = - rdel_opts::circ_kind ; - + _kind = rdel_opts::circ_kind; return _kind ; } else // adv.-front limiter { - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; } _dist -= _pert * _dist ; iptr_type _dual = -1 ; - cosine_intersect _pred(_base,_dvec); + cosine_intersect _pred(_base,_dvec) ; _ball._rrad = _dist ; if (!_geom.intersect ( _ball, _pred) ) - return rdel_opts::null_kind ; + return rdel_opts::null_kind; if (!_pred. _find ) - return rdel_opts::null_kind ; + return rdel_opts::null_kind; real_type _move = geometry::length_2d( - _ppos,&_pred._proj.pval(0)); + _ppos,&_pred._proj.pval(0)) ; _ppos[ 0] = _pred._proj.pval(0); _ppos[ 1] = _pred._proj.pval(1); @@ -198,15 +201,17 @@ _mesh._tria.find_node ( // test voro. limiter &_ppos[0], _dual, _enod[ 0]) ; + if (_dual != _enod [ +0] ) + { real_type _dlen = geometry::length_2d( _ppos, &_mesh._tria. node(_dual)->pval(0)) ; - if (_dual != _enod [ +0] ) if (_dlen <= _dtol*_hval ) { - return rdel_opts::null_kind ; + return rdel_opts::null_kind; + } } if (_move <= _rtol*_hval ) break ; @@ -239,7 +244,8 @@ _kind = rdel_opts::null_kind; typename hfun_type::hint_type - _hint = _hfun .null_hint() ; + _hint = _hfun .null_hint() , + _HINT = _hfun .null_hint() ; real_type static const _rtol = (real_type)+1.00E-003 ; @@ -251,10 +257,10 @@ _dtol = (real_type)+8.00E-001 ; real_type static const - _lgap = (real_type)+9.00E-001 ; + _lgap = (real_type)+8./9. ; real_type static const - _ugap = (real_type)+1.10E+000 ; + _ugap = (real_type)+9./8. ; __unreferenced(_geom) ; __unreferenced(_args) ; @@ -267,7 +273,7 @@ &_mesh._tria.node(_fnod[1])->pval(0) , _mesh._tria.node(_fnod[1])->idxh()) ; - _hint = + _hint = _HINT = _mesh._tria.node(_fnod[0])->idxh () ; real_type _bias[2] = { @@ -308,8 +314,6 @@ (real_type)+.5 * (_base[1]+_ppos[1]) , } ; - typename hfun_type::hint_type - _HINT = _hint ; _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hmid = @@ -338,28 +342,29 @@ (real_type)std::sqrt(_dsqr) ; } - if (_dist > _alth * _hmid) + if (_dist >= _alth * _hmid) { // adv.-front limiter - _dist = _alth * _hmid ; - _kind = - rdel_opts::offH_kind ; + _dist = _alth * _hmid ; + _kind = rdel_opts::offH_kind; } if (_dist >= _dvec[3]) // off-centre limiter { - _dist = _dvec[3] ; - _kind = - rdel_opts::offC_kind ; + _dist = + 2. * _dist * _dvec[3] + / (_dist + _dvec[3] ) ; + + _kind = rdel_opts::offC_kind; } if (_dist >= _dvec[2] * _lgap && _dist <= _dvec[2] * _ugap ) { // circumball cushion - _dist += _dvec[2] ; - _dist /= (real_type)2.; + _ppos[0]=_tbal[0] ; + _ppos[1]=_tbal[1] ; - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; + return _kind ; } if (_dist >= _dvec[2] * _ugap ) @@ -367,9 +372,7 @@ _ppos[0]=_tbal[0] ; _ppos[1]=_tbal[1] ; - _kind = - rdel_opts::circ_kind ; - + _kind = rdel_opts::circ_kind; return _kind ; } @@ -391,16 +394,18 @@ _mesh._tria.find_node ( // test voro. limiter &_ppos[0], _dual, _fnod[ 0]) ; + if (_dual != _fnod [ +0] && + _dual != _fnod [ +1] ) + { real_type _dlen = geometry::length_2d( _ppos, &_mesh._tria. node(_dual)->pval(0)) ; - if (_dual != _fnod [ +0] && - _dual != _fnod [ +1] ) if (_dlen <= _dtol*_hmid ) { - return rdel_opts::null_kind ; + return rdel_opts::null_kind; + } } if (_move < _rtol * _hmid) break ; diff --git a/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc index ec6a273..9173175 100644 --- a/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 31 Mar., 2021 + * Last updated: 01 Aug., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -66,7 +70,8 @@ _kind = rdel_opts::null_kind; typename hfun_type::hint_type - _hint = _hfun .null_hint() ; + _hint = _hfun .null_hint() , + _HINT = _hfun .null_hint() ; real_type static const _rtol = (real_type)+1.00E-003 ; @@ -75,16 +80,13 @@ _dtol = (real_type)+8.00E-001 ; real_type static const - _lgap = (real_type)+9.00E-001 ; + _lgap = (real_type)+8./9. ; real_type static const - _ugap = (real_type)+1.10E+000 ; + _ugap = (real_type)+9./8. ; __unreferenced(_args) ; - if (_enod[1] < _enod[0]) - std::swap (_enod[0], _enod[1]); - real_type _hsiz [ 4] ; _hsiz[ 0] = _hfun.eval ( &_mesh._tria.node(_enod[0])->pval(0) , @@ -93,6 +95,12 @@ &_mesh._tria.node(_enod[1])->pval(0) , _mesh._tria.node(_enod[1])->idxh()) ; + if (_hsiz[1] < _hsiz[0]) + { + std::swap( _enod[0], _enod[1]); + std::swap( _hsiz[0], _hsiz[1]); + } + real_type _dvec[4] ; real_type _base[3] = { _mesh._tria.node(_enod[0])->pval(0) , @@ -100,7 +108,7 @@ _mesh._tria.node(_enod[0])->pval(2) , } ; - _hint = + _hint = _HINT = _mesh._tria.node (_enod[0])->idxh() ; _dvec[ 0] = @@ -147,8 +155,6 @@ (real_type)+.5 * (_base[2]+_ppos[2]) , } ; - typename hfun_type::hint_type - _HINT = _hint ; _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hval = @@ -161,11 +167,12 @@ if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _dist += _dvec[3] ; - _dist /= (real_type)2.; + _ppos[0]=_sbal[0] ; + _ppos[1]=_sbal[1] ; + _ppos[2]=_sbal[2] ; - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; + return _kind ; } if (_dist >= _dvec[3] * _ugap ) @@ -174,31 +181,28 @@ _ppos[1]=_sbal[1] ; _ppos[2]=_sbal[2] ; - _kind = - rdel_opts::circ_kind ; - + _kind = rdel_opts::circ_kind; return _kind ; } else // adv.-front limiter { - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; } _dist -= _pert * _dist ; iptr_type _dual = -1 ; - cosine_intersect _pred(_base,_dvec); + cosine_intersect _pred(_base,_dvec) ; _ball._rrad = _dist ; if (!_geom.intersect ( _ball, _pred) ) - return rdel_opts::null_kind ; + return rdel_opts::null_kind; if (!_pred. _find ) - return rdel_opts::null_kind ; + return rdel_opts::null_kind; real_type _move = geometry::length_3d( - _ppos,&_pred._proj.pval(0)); + _ppos,&_pred._proj.pval(0)) ; _ppos[ 0] = _pred._proj.pval(0); _ppos[ 1] = _pred._proj.pval(1); @@ -207,15 +211,17 @@ _mesh._tria.find_node ( // test voro. limiter &_ppos[0], _dual, _enod[ 0]) ; + if (_dual != _enod [ +0] ) + { real_type _dlen = geometry::length_3d( _ppos, &_mesh._tria. node(_dual)->pval(0)) ; - if (_dual != _enod [ +0] ) if (_dlen <= _dtol*_hval ) { - return rdel_opts::null_kind ; + return rdel_opts::null_kind; + } } if (_move <= _rtol*_hval ) break ; @@ -248,7 +254,8 @@ _kind = rdel_opts::null_kind; typename hfun_type::hint_type - _hint = _hfun .null_hint() ; + _hint = _hfun .null_hint() , + _HINT = _hfun .null_hint() ; real_type static const _rtol = (real_type)+1.00E-003 ; @@ -260,10 +267,10 @@ _dtol = (real_type)+8.00E-001 ; real_type static const - _lgap = (real_type)+9.00E-001 ; + _lgap = (real_type)+8./9. ; real_type static const - _ugap = (real_type)+1.10E+000 ; + _ugap = (real_type)+9./8. ; __unreferenced(_args) ; @@ -275,7 +282,7 @@ &_mesh._tria.node(_enod[1])->pval(0) , _mesh._tria.node(_enod[1])->idxh()) ; - _hint = + _hint = _HINT = _mesh._tria.node(_enod[0])->idxh () ; real_type _bias[2] = { @@ -340,8 +347,6 @@ (real_type)+.5 * (_base[2]+_ppos[2]) , } ; - typename hfun_type::hint_type - _HINT = _hint ; _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hval = @@ -376,28 +381,30 @@ (real_type)std::sqrt(_dsqr) ; } - if (_dist > _alth * _hval) + if (_dist >= _alth * _hval) { // adv.-front limiter - _dist = _alth * _hval ; - _kind = - rdel_opts::offH_kind ; + _dist = _alth * _hval ; + _kind = rdel_opts::offH_kind; } if (_dist >= _dvec[4]) // off-centre limiter { - _dist = _dvec[4] ; - _kind = - rdel_opts::offC_kind ; + _dist = + 2. * _dist * _dvec[4] + / (_dist + _dvec[4] ) ; + + _kind = rdel_opts::offC_kind; } if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _dist += _dvec[3] ; - _dist /= (real_type)2.; + _ppos[0]=_sbal[0] ; + _ppos[1]=_sbal[1] ; + _ppos[2]=_sbal[2] ; - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; + return _kind ; } if (_dist >= _dvec[3] * _ugap ) @@ -406,27 +413,24 @@ _ppos[1]=_sbal[1] ; _ppos[2]=_sbal[2] ; - _kind = - rdel_opts::circ_kind ; - + _kind = rdel_opts::circ_kind; return _kind ; } _dist -= _pert * _dist ; iptr_type _dual = -1 ; - cosine_intersect _pred(_base,_dvec); + cosine_intersect _pred(_base,_dvec) ; _disc._rrad = _dist ; if (!_geom.intersect ( - _disc, - _sbal, _pred) ) - return rdel_opts::null_kind ; + _disc, _sbal, _pred) ) + return rdel_opts::null_kind; if (!_pred. _find ) - return rdel_opts::null_kind ; + return rdel_opts::null_kind; real_type _move = geometry::length_3d( - _ppos,&_pred._proj.pval(0)); + _ppos,&_pred._proj.pval(0)) ; _ppos[ 0] = _pred._proj.pval(0); _ppos[ 1] = _pred._proj.pval(1); @@ -435,16 +439,18 @@ _mesh._tria.find_node ( // test voro. limiter &_ppos[0], _dual, _enod[ 0]) ; + if (_dual != _enod [ +0] && + _dual != _enod [ +1] ) + { real_type _dlen = geometry::length_3d( _ppos, &_mesh._tria. node(_dual)->pval(0)) ; - if (_dual != _enod [ +0] && - _dual != _enod [ +1] ) if (_dlen <= _dtol*_hmin ) { - return rdel_opts::null_kind ; + return rdel_opts::null_kind; + } } if (_move <= _rtol*_hmin ) break ; @@ -477,7 +483,8 @@ _kind = rdel_opts::null_kind; typename hfun_type::hint_type - _hint = _hfun .null_hint() ; + _hint = _hfun .null_hint() , + _HINT = _hfun .null_hint() ; real_type static const _rtol = (real_type)+1.00E-003 ; @@ -489,10 +496,10 @@ _dtol = (real_type)+8.00E-001 ; real_type static const - _lgap = (real_type)+9.00E-001 ; + _lgap = (real_type)+8./9. ; real_type static const - _ugap = (real_type)+1.10E+000 ; + _ugap = (real_type)+9./8. ; __unreferenced(_geom) ; __unreferenced(_args) ; @@ -536,8 +543,6 @@ (real_type)+.5 * (_fbal[2]+_ppos[2]) , } ; - typename hfun_type::hint_type - _HINT = _hint ; _hsiz[4] = _hfun.eval(_PMID, _HINT) ; real_type _hmid = @@ -567,28 +572,30 @@ (real_type)std::sqrt(_dsqr) ; } - if (_dist > _alth * _hmid) + if (_dist >= _alth * _hmid) { // adv.-front limiter - _dist = _alth * _hmid ; - _kind = - rdel_opts::offH_kind ; + _dist = _alth * _hmid ; + _kind = rdel_opts::offH_kind; } if (_dist >= _dvec[4]) // off-centre limiter { - _dist = _dvec[4]; - _kind = - rdel_opts::offC_kind ; + _dist = + 2. * _dist * _dvec[4] + / (_dist + _dvec[4] ) ; + + _kind = rdel_opts::offC_kind; } if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _dist += _dvec[3] ; - _dist /= (real_type)2.; + _ppos[0]=_tbal[0] ; + _ppos[1]=_tbal[1] ; + _ppos[2]=_tbal[2] ; - _kind = - rdel_opts::offH_kind ; + _kind = rdel_opts::offH_kind; + return _kind ; } if (_dist >= _dvec[3] * _ugap ) @@ -597,9 +604,7 @@ _ppos[1]=_tbal[1] ; _ppos[2]=_tbal[2] ; - _kind = - rdel_opts::circ_kind ; - + _kind = rdel_opts::circ_kind; return _kind ; } @@ -624,17 +629,19 @@ _mesh._tria.find_node ( // test voro. limiter &_ppos[0], _dual, _fnod[ 0]) ; + if (_dual != _fnod [ +0] && + _dual != _fnod [ +1] && + _dual != _fnod [ +2] ) + { real_type _dlen = geometry::length_3d( _ppos, &_mesh._tria. node(_dual)->pval(0)) ; - if (_dual != _fnod [ +0] && - _dual != _fnod [ +1] && - _dual != _fnod [ +2] ) if (_dlen <= _dtol*_hmid ) { - return rdel_opts::null_kind ; + return rdel_opts::null_kind; + } } if (_move < _rtol * _hmid) break ; diff --git a/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp b/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp index cdba1d8..8fc2dd2 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp b/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp index 9031838..ff16623 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp b/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp index 88a7fc1..f05a117 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -207,14 +211,18 @@ __const_ptr(real_type) _ball ) { - uint32_t _rsiz = - sizeof(real_type) * +2 ; - uint32_t _usiz = + uint32_t constexpr _rsiz = + sizeof(float ) * +2 ; + uint32_t constexpr _usiz = sizeof(uint32_t ) * +1 ; + float volatile _fbal[2]; // volatile, gcc-11 bug... + _fbal[0] =(float) _ball [0]; + _fbal[1] =(float) _ball [1]; + uint32_t _hash ; _hash = hash::hashword ( - (uint32_t*)_ball, _rsiz + (uint32_t*)_fbal, _rsiz / _usiz, +13) ; return ( _hash ) ; @@ -450,8 +458,11 @@ _tria.tria(_tpos)->circ(0); _tbal[1] = _mesh. _tria.tria(_tpos)->circ(1); - _tbal[2] = (real_type)+0. ; + + auto _hash = + _mesh._tria._nset.count(); + _tbal[2]+= geometry::lensqr_2d (_tbal, &_mesh._tria.node( @@ -482,7 +493,7 @@ tria(_tpos)->node(_enod[ 1]); _llen[_enum] = - geometry::lensqr_2d ( + (float)geometry::lensqr_2d ( &_mesh._tria. node(_enod[0])->pval(0), &_mesh._tria. @@ -490,8 +501,9 @@ } /*--------------------------------- find min/max edge */ - iptr_type _emin = +0; - iptr_type _emax = +0; + iptr_type _emin = +0, _emax = +0 ; + if (_hash % +2 == +0) // rnd. tie-break + { for(_enum = +3; _enum-- != +1; ) { if (_llen[_emax] < _llen[_enum]) @@ -499,6 +511,17 @@ if (_llen[_emin] > _llen[_enum]) _emin = _enum ; } + } + else + { + for(_enum = +0; _enum++ != +2; ) + { + if (_llen[_emax] < _llen[_enum]) + _emax = _enum ; + if (_llen[_emin] > _llen[_enum]) + _emin = _enum ; + } + } /*-------------------------- ask for "frontal" status */ if(!base_edge(_mesh, _tpos, _emin)) @@ -507,7 +530,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_tbal) % _STEP) + 1; + (_hash % _STEP) + 1 ; _tdat._mark += _push; @@ -600,7 +623,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_tbal) % _STEP) + 1; + (_hash % _STEP) + 1 ; _tdat._mark += _push ; diff --git a/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp b/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp index 1817975..8cea204 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -227,14 +231,19 @@ __const_ptr(real_type) _ball ) { - uint32_t _rsiz = - sizeof(real_type) * +3 ; - uint32_t _usiz = + uint32_t constexpr _rsiz = + sizeof(float ) * +3 ; + uint32_t constexpr _usiz = sizeof(uint32_t ) * +1 ; + float volatile _fbal[3]; // volatile, gcc-11 bug... + _fbal[0] =(float) _ball [0]; + _fbal[1] =(float) _ball [1]; + _fbal[2] =(float) _ball [2]; + uint32_t _hash ; _hash = hash::hashword ( - (uint32_t*)_ball, _rsiz + (uint32_t*)_fbal, _rsiz / _usiz, +13) ; return ( _hash ) ; @@ -603,6 +612,9 @@ return ( _kind ) ; } + auto _hash = + _mesh._tria._nset.count() ; + /*--------------------------------- find edge lengths */ real_type _llen[3] ; iptr_type _enum ; @@ -615,8 +627,8 @@ _enod[ 0] = _fnod[_enod[0]] ; _enod[ 1] = _fnod[_enod[1]] ; - _llen[_enum] = - geometry::lensqr_3d ( + _llen[_enum] = + (float)geometry::lensqr_3d ( &_mesh._tria. node(_enod[0])->pval(0), &_mesh._tria. @@ -624,8 +636,9 @@ } /*--------------------------------- find min/max edge */ - iptr_type _emin = +0; - iptr_type _emax = +0; + iptr_type _emin = +0, _emax = +0 ; + if (_hash % +2 == +0) // rnd. tie-break + { for(_enum = +3; _enum-- != +1; ) { if (_llen[_emax] < _llen[_enum]) @@ -633,6 +646,17 @@ if (_llen[_emin] > _llen[_enum]) _emin = _enum ; } + } + else + { + for(_enum = +0; _enum++ != +2; ) + { + if (_llen[_emax] < _llen[_enum]) + _emax = _enum ; + if (_llen[_emin] > _llen[_enum]) + _emin = _enum ; + } + } /*-------------------------- ask for "frontal" status */ if(!base_edge(_mesh, _fnod, _tadj , @@ -642,7 +666,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_pmax) % _STEP) + 1; + (_hash % _STEP) + 1 ; _fdat._mark += _push; @@ -759,7 +783,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_pmax) % _STEP) + 1; + (_hash % _STEP) + 1 ; _fdat._mark += _push ; @@ -825,23 +849,26 @@ _tria.tria(_tpos)->circ(1); _tbal[2] = _mesh. _tria.tria(_tpos)->circ(2); - _tbal[3] = (real_type)+0. ; + + auto _hash = + _mesh._tria._nset.count(); + _tbal[3]+= geometry::lensqr_3d (_tbal, - &_mesh._tria.node( + &_mesh._tria.node( _tnod[0])->pval( 0)) ; _tbal[3]+= geometry::lensqr_3d (_tbal, - &_mesh._tria.node( + &_mesh._tria.node( _tnod[1])->pval( 0)) ; _tbal[3]+= geometry::lensqr_3d (_tbal, - &_mesh._tria.node( + &_mesh._tria.node( _tnod[2])->pval( 0)) ; _tbal[3]+= geometry::lensqr_3d (_tbal, - &_mesh._tria.node( + &_mesh._tria.node( _tnod[3])->pval( 0)) ; _tbal[3]/= (real_type)+4. ; @@ -861,7 +888,7 @@ tria(_tpos)->node(_enod[ 1]); _llen[_enum] = - geometry::lensqr_3d ( + (float)geometry::lensqr_3d ( &_mesh._tria. node(_enod[0])->pval(0), &_mesh._tria. @@ -869,8 +896,9 @@ } /*--------------------------------- find min/max edge */ - iptr_type _emin = +0; - iptr_type _emax = +0; + iptr_type _emin = +0, _emax = +0 ; + if (_hash % +2 == +0) // rnd. tie-break + { for(_enum = +6; _enum-- != +1; ) { if (_llen[_emax] < _llen[_enum]) @@ -878,6 +906,17 @@ if (_llen[_emin] > _llen[_enum]) _emin = _enum ; } + } + else + { + for(_enum = +0; _enum++ != +5; ) + { + if (_llen[_emax] < _llen[_enum]) + _emax = _enum ; + if (_llen[_emin] > _llen[_enum]) + _emin = _enum ; + } + } /*--------------------------------- find 2-face radii */ real_type _frad[4] ; @@ -904,12 +943,13 @@ &_mesh._tria. node(_fnod[2])->pval(0)) ; - _frad[_fpos] = _fbal[3]; + _frad[_fpos] = (float)_fbal[3] ; } /*--------------------------------- find min/max face */ - iptr_type _fmin = +0; - iptr_type _fmax = +0; + iptr_type _fmin = +0, _fmax = +0 ; + if (_hash % +2 == +0) // rnd. tie-break + { for(_fpos = +4; _fpos-- != +1; ) { if (_frad[_fmax] < _frad[_fpos]) @@ -917,6 +957,17 @@ if (_frad[_fmin] > _frad[_fpos]) _fmin = _fpos ; } + } + else + { + for(_fpos = +0; _fpos++ != +3; ) + { + if (_frad[_fmax] < _frad[_fpos]) + _fmax = _fpos ; + if (_frad[_fmin] > _frad[_fpos]) + _fmin = _fpos ; + } + } /*-------------------------- ask for "frontal" status */ if(!base_face(_mesh, _tpos, _fmin)) @@ -925,7 +976,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_tbal) % _STEP) + 1; + (_hash % _STEP) + 1 ; _tdat._mark += _push; @@ -1039,7 +1090,7 @@ { /*---------------------- reject as "void" element */ uint32_t _push = - (hash_ball(_tbal) % _STEP) + 1; + (_hash % _STEP) + 1 ; _tdat._mark += _push ; diff --git a/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc b/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc index f6a65b5..085b9cb 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc b/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc index 7214f23..5b88ce9 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_refine_base_2.inc b/src/libcpp/rdel_mesh/rdel_refine_base_2.inc index 59764d5..c93e827 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_base_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_base_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -191,6 +195,7 @@ _mesh._tria.node( _node)->fdim() = _tdim ; + /*------------------------- test "new" rDT cavity */ real_type _pnow[2] ; _pnow[0] = _ppos[0] ; _pnow[1] = _ppos[1] ; diff --git a/src/libcpp/rdel_mesh/rdel_refine_base_3.inc b/src/libcpp/rdel_mesh/rdel_refine_base_3.inc index 5e9c50f..4cf557d 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_base_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_base_3.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -205,6 +209,7 @@ _mesh._tria.node( _node)->fdim() = _tdim; + /*------------------------- test "new" rDT cavity */ real_type _pnow[3] ; _pnow[0] = _ppos[0] ; _pnow[1] = _ppos[1] ; diff --git a/src/libcpp/rdel_mesh/rdel_refine_face_2.inc b/src/libcpp/rdel_mesh/rdel_refine_face_2.inc index 0b40b12..97ea5e2 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_face_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_face_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_refine_face_3.inc b/src/libcpp/rdel_mesh/rdel_refine_face_3.inc index c8b06e1..0be4e45 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_face_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_face_3.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc b/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc index e4a2bcc..fdf047a 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc b/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc index 9a31e18..6ed7115 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc index 7ae736f..6404533 100644 --- a/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Jul., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc index 44c8f89..922922f 100644 --- a/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Jul., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc b/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc index 9125a8c..f8a497e 100644 --- a/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc +++ b/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -231,16 +235,11 @@ if (_mode > +0) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * +2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*---------------------------------------- test edges */ for ( auto _epos = _enew.head(); @@ -339,17 +338,13 @@ if (_epro.count() > +0) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * +2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; + /*------------------------- push alloc. for hash obj. */ for ( auto _epos = _enew.head(); _epos != _enew.tend(); ++_epos ) diff --git a/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc b/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc index 34eebb8..eeaac68 100644 --- a/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc +++ b/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -346,16 +350,11 @@ if (_mode > +0) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * +2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*---------------------------------------- test edges */ for ( auto _epos = _enew.head(); @@ -381,7 +380,7 @@ _fbal, _sbal , _feat, _topo , _part ) ) __assert( false && - "_old_bnds: edge-ball" ); + "_OLD-BNDS: edge-ball" ); real_type _blen = geometry::lensqr_3d(_ppos, @@ -433,16 +432,11 @@ if (_mode > +1) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::face_list _fset ( - typename mesh_type::face_hash(), - typename mesh_type::face_pred(), - +.8, _mesh._fset.get_alloc()) ; + _mesh._ftwo.clear(); + _mesh._ftwo. + set_slots(_fnew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _fset.set_slots ( - _fnew.count() * +2 , - containers::tight_alloc) ; + auto& _fset = _mesh. _ftwo; /*---------------------------------------- test faces */ for ( auto _fpos = _fnew.head(); @@ -547,17 +541,13 @@ if (_epro.count() > +0) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * +2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; + /*------------------------- push alloc. for hash obj. */ for ( auto _epos = _enew.head(); _epos != _enew.tend(); ++_epos ) @@ -586,17 +576,13 @@ if (_fpro.count() > +0) { /*------------------------- init. for local hash obj. */ - typename - mesh_type::face_list _fset ( - typename mesh_type::face_hash(), - typename mesh_type::face_pred(), - +.8, _mesh._fset.get_alloc()) ; + _mesh._ftwo.clear(); + _mesh._ftwo. + set_slots(_fnew.count() * +2) ; - /*------------------------- push alloc. for hash obj. */ - _fset.set_slots ( - _fnew.count() * +2 , - containers::tight_alloc) ; + auto& _fset = _mesh. _ftwo; + /*------------------------- push alloc. for hash obj. */ for ( auto _fpos = _fnew.head(); _fpos != _fnew.tend(); ++_fpos ) diff --git a/src/libcpp/rdel_mesh/rdel_timers.hpp b/src/libcpp/rdel_mesh/rdel_timers.hpp index c00d2b0..a7a95fd 100644 --- a/src/libcpp/rdel_mesh/rdel_timers.hpp +++ b/src/libcpp/rdel_mesh/rdel_timers.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 20 Jan., 2022 + * Last updated: 20 Jul., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -54,20 +58,11 @@ -------------------------------------------------------- */ - template < - typename R , - typename I - > class rdel_timers { public : - - typedef R real_type ; - typedef I iptr_type ; - - typedef rdel_timers self_type ; - double _mesh_seed = (double ) +0. ; + double _node_init = (double ) +0. ; double _node_rule = (double ) +0. ; double _edge_init = (double ) +0. ; @@ -77,12 +72,17 @@ double _tria_init = (double ) +0. ; double _tria_rule = (double ) +0. ; + double _list_trim = (double ) +0. ; + + double _topo_init = (double ) +0. ; + public : /*-------------------------------------- elapsed time */ # ifdef __use_timers + __static_call __inline_call double time_span ( typename std:: chrono::high_resolution_clock @@ -98,6 +98,7 @@ (_ttoc-_ttic).count()) / +1.0E+06 ; } + __static_call __inline_call double nano_span ( typename std:: chrono::high_resolution_clock diff --git a/src/libcpp/rdel_mesh/rdel_update_face_2.inc b/src/libcpp/rdel_mesh/rdel_update_face_2.inc index 1347149..96eecd3 100644 --- a/src/libcpp/rdel_mesh/rdel_update_face_2.inc +++ b/src/libcpp/rdel_mesh/rdel_update_face_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 06 July, 2019 + * Last updated: 02 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -56,6 +60,8 @@ iptr_type _tpos ) { + if(_mesh._eset._size == +0) return ; + for(auto _fpos =+3; _fpos-- != +0; ) { /*--------------------------------- get edge indexing */ @@ -93,6 +99,8 @@ iptr_type _tpos ) { + if (_mesh._tset._size == 0) return; + { /*--------------------------------- get tria indexing */ tria_data _tdat; @@ -404,7 +412,7 @@ /*---------------------- calc. ball in floating-point */ real_type _tbal[3] ; - geometry::circ_ball_2d ( + geometry::perp_ball_2d ( _tbal , &_mesh._tria. node(_tnod[0])->pval(0) , @@ -450,7 +458,6 @@ /*------------------------- no. "restricted" subfaces */ iptr_type _nedg = +0 ; iptr_type _ntri = +0 ; - iptr_type _ndup = +0 ; /*------------------------- calc. voronoi-dual points */ @@ -483,12 +490,8 @@ if (_dim0 <= edge_mode && _dim1 >= edge_mode ) { - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc(), - _tnew.count() * +3) ; + _mesh._etwo.clear(); + _mesh._etwo.set_slots(_tnew.count() * +3) ; for( auto _iter = _tnew.head(); _iter != _tnew.tend(); @@ -497,8 +500,8 @@ push_edge(_mesh, _geom , _hfun,*_iter , _edat, _escr , - _eset, _nedg , - _ndup, + _mesh. _etwo , + _nedg, _ndup , _pass, _opts) ; } } @@ -506,18 +509,14 @@ if (_dim0 <= tria_mode && _dim1 >= tria_mode ) { - //typename - // mesh_type::tria_list _tset ( - //typename mesh_type::tria_hash(), - //typename mesh_type::tria_pred(), - // +.8, _mesh._tset.get_alloc(), - // _tnew.count() * +1) ; + // _mesh._ttwo.clear(); + // _mesh._ttwo.set_slots(_tnew.count() * +1) ; bool_type _safe = true ; if (_dim0 > +0) _safe = false ; - //if (_nedg >= +1) _safe = false ; + // if (_nedg >= +1) _safe = false ; if (_ndup >= +1) _safe = false ; for( auto _iter = _tnew.head(); diff --git a/src/libcpp/rdel_mesh/rdel_update_face_3.inc b/src/libcpp/rdel_mesh/rdel_update_face_3.inc index f91316e..ada9622 100644 --- a/src/libcpp/rdel_mesh/rdel_update_face_3.inc +++ b/src/libcpp/rdel_mesh/rdel_update_face_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 06 July, 2019 + * Last updated: 02 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -56,6 +60,8 @@ iptr_type _tpos ) { + if(_mesh._eset._size == +0) return ; + for(auto _fpos =+6; _fpos-- != +0; ) { /*--------------------------------- get edge indexing */ @@ -93,6 +99,8 @@ iptr_type _tpos ) { + if(_mesh._fset._size == +0) return ; + for(auto _fpos =+4; _fpos-- != +0; ) { /*--------------------------------- get face indexing */ @@ -133,6 +141,8 @@ iptr_type _tpos ) { + if (_mesh._tset._size == 0) return; + { /*--------------------------------- get tria indexing */ tria_data _tdat; @@ -633,7 +643,6 @@ iptr_type _nedg = +0 ; iptr_type _nfac = +0 ; iptr_type _ntri = +0 ; - iptr_type _ndup = +0 ; /*------------------------- calc. voronoi-dual points */ @@ -666,12 +675,8 @@ if (_dim0 <= edge_mode && _dim1 >= edge_mode ) { - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc(), - _tnew.count() * +6) ; + _mesh._etwo.clear(); + _mesh._etwo.set_slots(_tnew.count() * +6) ; for( auto _iter = _tnew.head(); _iter != _tnew.tend(); @@ -680,7 +685,8 @@ push_edge(_mesh, _geom , _hfun,*_iter , _edat, _escr , - _eset, _nedg , + _mesh. _etwo , + _nedg, _pass, _opts) ; } } @@ -688,12 +694,8 @@ if (_dim0 <= face_mode && _dim1 >= face_mode ) { - typename - mesh_type::face_list _fset ( - typename mesh_type::face_hash(), - typename mesh_type::face_pred(), - +.8, _mesh._fset.get_alloc(), - _tnew.count() * +4) ; + _mesh._ftwo.clear(); + _mesh._ftwo.set_slots(_tnew.count() * +4) ; for( auto _iter = _tnew.head(); _iter != _tnew.tend(); @@ -702,8 +704,8 @@ push_face(_mesh, _geom , _hfun,*_iter , _fdat, _fscr , - _fset, _nfac , - _ndup, + _mesh. _ftwo , + _nfac, _ndup , _pass, _opts) ; } } @@ -711,18 +713,14 @@ if (_dim0 <= tria_mode && _dim1 >= tria_mode ) { - //typename - // mesh_type::tria_list _tset ( - //typename mesh_type::tria_hash(), - //typename mesh_type::tria_pred(), - // +.8, _mesh._tset.get_alloc(), - // _tnew.count() * +1) ; + // _mesh._ttwo.clear(); + // _mesh._ttwo.set_slots(_tnew.count() * +1) ; bool_type _safe = true ; if (_dim0 > +0) _safe = false ; - //if (_nfac >= +1) _safe = false ; + // if (_nfac >= +1) _safe = false ; if (_ndup >= +1) _safe = false ; for( auto _iter = _tnew.head(); diff --git a/src/libcpp/rdel_mesh/rdel_update_topo_2.inc b/src/libcpp/rdel_mesh/rdel_update_topo_2.inc index 3249d4f..e11f922 100644 --- a/src/libcpp/rdel_mesh/rdel_update_topo_2.inc +++ b/src/libcpp/rdel_mesh/rdel_update_topo_2.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -106,16 +110,11 @@ { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * 2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*------------------------- add "old" absent in "new" */ node_data _ndat ; @@ -135,7 +134,6 @@ item_type *_mptr = nullptr ; if(!_eset.find(*_iter, _mptr)) { - if (_emrk[_iter->_node[0]] == -1) { _emrk[_iter->_node[0]] = +1; @@ -155,23 +153,17 @@ _etpq.push(_ndat) ; } - } } } { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_eold.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _eold.count() * 2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*------------------------- add "new" absent in "old" */ node_data _ndat ; @@ -191,7 +183,6 @@ item_type *_mptr = nullptr ; if(!_eset.find(*_iter, _mptr)) { - if (_emrk[_iter->_node[0]] == -1) { _emrk[_iter->_node[0]] = +1; @@ -211,7 +202,6 @@ _etpq.push(_ndat) ; } - } } } diff --git a/src/libcpp/rdel_mesh/rdel_update_topo_3.inc b/src/libcpp/rdel_mesh/rdel_update_topo_3.inc index a2dc264..51cc41e 100644 --- a/src/libcpp/rdel_mesh/rdel_update_topo_3.inc +++ b/src/libcpp/rdel_mesh/rdel_update_topo_3.inc @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Aug., 2022 * - * Copyright 2013-2019 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -111,16 +115,11 @@ { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_enew.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _enew.count() * 2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*------------------------- add "old" absent in "new" */ node_data _ndat ; @@ -140,7 +139,6 @@ item_type *_mptr = nullptr ; if(!_eset.find(*_iter, _mptr)) { - if (_emrk[_iter->_node[0]] == -1) { _emrk[_iter->_node[0]] = +1; @@ -160,23 +158,17 @@ _etpq.push(_ndat) ; } - } } } { /*------------------------- init. for local hash obj. */ - typename - mesh_type::edge_list _eset ( - typename mesh_type::edge_hash(), - typename mesh_type::edge_pred(), - +.8, _mesh._eset.get_alloc()) ; + _mesh._etwo.clear(); + _mesh._etwo. + set_slots(_eold.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _eset.set_slots ( - _eold.count() * 2 , - containers::tight_alloc) ; + auto& _eset = _mesh. _etwo; /*------------------------- add "new" absent in "old" */ node_data _ndat ; @@ -196,7 +188,6 @@ item_type *_mptr = nullptr ; if(!_eset.find(*_iter, _mptr)) { - if (_emrk[_iter->_node[0]] == -1) { _emrk[_iter->_node[0]] = +1; @@ -216,7 +207,6 @@ _etpq.push(_ndat) ; } - } } } @@ -279,16 +269,11 @@ { /*------------------------- init. for local hash obj. */ - typename - mesh_type::face_list _fset ( - typename mesh_type::face_hash(), - typename mesh_type::face_pred(), - +.8, _mesh._fset.get_alloc()) ; + _mesh._ftwo.clear(); + _mesh._ftwo. + set_slots(_fnew.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _fset.set_slots ( - _fnew.count() * 2 , - containers::tight_alloc) ; + auto& _fset = _mesh. _ftwo; /*------------------------- add "old" absent in "new" */ node_data _ndat ; @@ -308,7 +293,6 @@ item_type *_mptr = nullptr ; if(!_fset.find(*_iter, _mptr)) { - if (_fmrk[_iter->_node[0]] == -1) { _fmrk[_iter->_node[0]] = +1; @@ -338,23 +322,17 @@ _ftpq.push(_ndat) ; } - } } } { /*------------------------- init. for local hash obj. */ - typename - mesh_type::face_list _fset ( - typename mesh_type::face_hash(), - typename mesh_type::face_pred(), - +.8, _mesh._fset.get_alloc()) ; + _mesh._ftwo.clear(); + _mesh._ftwo. + set_slots(_fold.count() * 2) ; - /*------------------------- push alloc. for hash obj. */ - _fset.set_slots ( - _fold.count() * 2 , - containers::tight_alloc) ; + auto& _fset = _mesh. _ftwo; /*------------------------- add "new" absent in "old" */ node_data _ndat ; @@ -374,7 +352,6 @@ item_type *_mptr = nullptr ; if(!_fset.find(*_iter, _mptr)) { - if (_fmrk[_iter->_node[0]] == -1) { _fmrk[_iter->_node[0]] = +1; @@ -404,7 +381,6 @@ _ftpq.push(_ndat) ; } - } } } diff --git a/src/libcpp/rdelmesh.hpp b/src/libcpp/rdelmesh.hpp index ee1a0c3..5cf8f9f 100644 --- a/src/libcpp/rdelmesh.hpp +++ b/src/libcpp/rdelmesh.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/tessellate.hpp b/src/libcpp/tessellate.hpp index f2a2b9d..01ba57a 100644 --- a/src/libcpp/tessellate.hpp +++ b/src/libcpp/tessellate.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/tessellate/delaunay_scan_tria.inc b/src/libcpp/tessellate/delaunay_scan_tria.inc index 23e0b0b..3ed1f8d 100644 --- a/src/libcpp/tessellate/delaunay_scan_tria.inc +++ b/src/libcpp/tessellate/delaunay_scan_tria.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 17 March, 2018 + * Last updated: 17 Mar., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_star_void.inc b/src/libcpp/tessellate/delaunay_star_void.inc index 94765e7..88fa31b 100644 --- a/src/libcpp/tessellate/delaunay_star_void.inc +++ b/src/libcpp/tessellate/delaunay_star_void.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 03 July, 2019 + * Last updated: 03 Jul., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_k.hpp b/src/libcpp/tessellate/delaunay_tri_k.hpp index b0dc5c7..484529b 100644 --- a/src/libcpp/tessellate/delaunay_tri_k.hpp +++ b/src/libcpp/tessellate/delaunay_tri_k.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/tessellate/delaunay_tri_pred_2.hpp b/src/libcpp/tessellate/delaunay_tri_pred_2.hpp index 44c51ad..2af5bb8 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_2.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_2.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 March, 2019 + * Last updated: 01 Mar., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_pred_3.hpp b/src/libcpp/tessellate/delaunay_tri_pred_3.hpp index 7de9aad..497ae8c 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_3.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 March, 2019 + * Last updated: 01 Mar., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_pred_4.hpp b/src/libcpp/tessellate/delaunay_tri_pred_4.hpp index fe5af0a..0dae792 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_4.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_4.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_type_2.hpp b/src/libcpp/tessellate/delaunay_tri_type_2.hpp index b95599e..c85f2bc 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_2.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_2.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 22 February, 2020 + * Last updated: 22 Feb., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_type_3.hpp b/src/libcpp/tessellate/delaunay_tri_type_3.hpp index 3f6a119..8de1250 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_3.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 22 February, 2020 + * Last updated: 22 Feb., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_tri_type_4.hpp b/src/libcpp/tessellate/delaunay_tri_type_4.hpp index 9100065..7cb49ae 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_4.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_4.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/delaunay_walk_mesh.inc b/src/libcpp/tessellate/delaunay_walk_mesh.inc index 8d21e59..7987b50 100644 --- a/src/libcpp/tessellate/delaunay_walk_mesh.inc +++ b/src/libcpp/tessellate/delaunay_walk_mesh.inc @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 18 February, 2019 + * Last updated: 18 Feb., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/libcpp/tessellate/laguerre_tri_pred_2.hpp b/src/libcpp/tessellate/laguerre_tri_pred_2.hpp index 36794d0..34beb12 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_2.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_2.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 March, 2020 + * Last updated: 01 Mar., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/laguerre_tri_pred_3.hpp b/src/libcpp/tessellate/laguerre_tri_pred_3.hpp index 68154bc..8209e5d 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_3.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_3.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 01 March, 2020 + * Last updated: 01 Mar., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/tessellate/laguerre_tri_pred_4.hpp b/src/libcpp/tessellate/laguerre_tri_pred_4.hpp index 51362b3..496a071 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_4.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_4.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 30 April, 2020 + * Last updated: 30 Apr., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/libcpp/textutil.hpp b/src/libcpp/textutil.hpp index c0d2f67..7a55667 100644 --- a/src/libcpp/textutil.hpp +++ b/src/libcpp/textutil.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/libcpp/useropts.hpp b/src/libcpp/useropts.hpp index 2801c2d..4281e67 100644 --- a/src/libcpp/useropts.hpp +++ b/src/libcpp/useropts.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 27 November, 2019 + * Last updated: 27 Nov., 2019 * * Copyright 2013-2019 * Darren Engwirda diff --git a/src/liblib/init_jig_t.hpp b/src/liblib/init_jig_t.hpp index a58c09d..8c1c586 100644 --- a/src/liblib/init_jig_t.hpp +++ b/src/liblib/init_jig_t.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -60,6 +64,15 @@ { /*------------------------------------- MISC keywords */ _jcfg->_verbosity = (indx_t) +0 ; + _jcfg->_numthread = (indx_t) +0 ; + + if (_jcfg->_numthread <= 0 ) + # ifdef __use_openmp + _jcfg->_numthread = + omp_get_num_procs() ; + # else + _jcfg->_numthread = +1 ; + # endif//__use_openmp /*------------------------------------- BNDS keywords */ _jcfg->_bnds_kern = JIGSAW_BNDS_TRIACELL ; @@ -107,13 +120,13 @@ _jcfg->_mesh_siz2 = (real_t) _SIZ2 ; _jcfg->_mesh_siz3 = (real_t) _SIZ3 ; - _jcfg->_mesh_snk2 = (real_t) +1./5.; - _jcfg->_mesh_snk3 = (real_t) +1./3.; + _jcfg->_mesh_snk2 = (real_t) + 1./5. ; + _jcfg->_mesh_snk3 = (real_t) + 1./3. ; - _jcfg->_mesh_eps1 = (real_t) +1./3.; - _jcfg->_mesh_eps2 = (real_t) +1./3.; + _jcfg->_mesh_eps1 = (real_t) + 1./3. ; + _jcfg->_mesh_eps2 = (real_t) + 1./3. ; - _jcfg->_mesh_vol3 = (real_t) +0./1.; + _jcfg->_mesh_vol3 = (real_t) + 0./1. ; /*------------------------------------- OPTM keywords */ _jcfg->_optm_kern = JIGSAW_KERN_ODT_DQDX ; @@ -122,8 +135,11 @@ _jcfg->_optm_cost = JIGSAW_KERN_AREA_LEN ; + _jcfg->_optm_beta = (real_t) +0.4950 ; + _jcfg->_optm_zeta = (real_t) +0.8250 ; + _jcfg->_optm_qtol = (real_t) +1.E-04 ; - _jcfg->_optm_qlim = (real_t) +14./15.; + _jcfg->_optm_qlim = (real_t) +14./15.; // .9333... _jcfg->_optm_tria = (indx_t) +1 ; _jcfg->_optm_dual = (indx_t) +0 ; diff --git a/src/liblib/init_msh_t.hpp b/src/liblib/init_msh_t.hpp index c128a95..02e6f00 100644 --- a/src/liblib/init_msh_t.hpp +++ b/src/liblib/init_msh_t.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/liblib/load_jig_t.hpp b/src/liblib/load_jig_t.hpp index 3997401..b7dac2c 100644 --- a/src/liblib/load_jig_t.hpp +++ b/src/liblib/load_jig_t.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -81,6 +85,13 @@ this-> _jjig->_verbosity = _verb; } + __normal_call void_type push_numthread ( + std::int32_t _nprt + ) + { + this-> + _jjig->_numthread = _nprt; + } /*------------------------------------- GEOM keywords */ __normal_call void_type push_geom_seed ( @@ -297,6 +308,20 @@ this-> _jjig->_optm_cost = _cost; } + __normal_call void_type push_optm_beta ( + double _beta + ) + { + this-> + _jjig->_optm_beta = _beta; + } + __normal_call void_type push_optm_zeta ( + double _zeta + ) + { + this-> + _jjig->_optm_zeta = _zeta; + } __normal_call void_type push_optm_qtol ( double _qtol ) diff --git a/src/liblib/load_msh_t.hpp b/src/liblib/load_msh_t.hpp index 07bd194..16dd760 100644 --- a/src/liblib/load_msh_t.hpp +++ b/src/liblib/load_msh_t.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/liblib/save_jig_t.hpp b/src/liblib/save_jig_t.hpp index 1172285..87db89b 100644 --- a/src/liblib/save_jig_t.hpp +++ b/src/liblib/save_jig_t.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 28 Aug., 2021 + * Last updated: 12 Dec., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -85,6 +89,9 @@ _file << "VERBOSITY = " << _jcfg->_verbosity << "\n" ; + _file << "NUMTHREAD = " << + _jcfg->_numthread << "\n" ; + /*--------------------------------- GEOM keywords */ _file << "GEOM_SEED = " << _jcfg->_geom_seed << "\n" ; @@ -210,6 +217,11 @@ _file << "OPTM_ITER = " << _jcfg->_optm_iter << "\n" ; + _file << "OPTM_BETA = " << + _jcfg->_optm_beta << "\n" ; + _file << "OPTM_ZETA = " << + _jcfg->_optm_zeta << "\n" ; + _file << "OPTM_QTOL = " << _jcfg->_optm_qtol << "\n" ; _file << "OPTM_QLIM = " << diff --git a/src/liblib/save_msh_t.hpp b/src/liblib/save_msh_t.hpp index 11a1470..5ac50d9 100644 --- a/src/liblib/save_msh_t.hpp +++ b/src/liblib/save_msh_t.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 06 June, 2018 + * Last updated: 06 Jun., 2018 * * Copyright 2013-2018 * Darren Engwirda diff --git a/src/marche.hpp b/src/marche.hpp index b3e2f36..32dee12 100644 --- a/src/marche.hpp +++ b/src/marche.hpp @@ -14,7 +14,7 @@ * MARCHE: "fast-marching" eikonal equation solver. -------------------------------------------------------- * - * Last updated: 28 Mar., 2022 + * Last updated: 10 Jun., 2022 * * Copyright 2013 -- 2022 * Darren Engwirda @@ -41,12 +41,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor the National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- */ @@ -362,15 +366,10 @@ /*--------------------------------- setup *.JLOG file */ jlog_text _jlog(_jcfg) ; - _jlog.push(MARCHE:: - asciibanner) ; if(!_jcfg._jcfg_file.empty()) { /*--------------------------------- parse *.JCFG file */ - _jlog.push ( - " Reading CFG. file...\n\n" ) ; - # ifdef __use_timers _ttic = _time.now(); # endif//__use_timers @@ -381,6 +380,11 @@ return _retv ; } + _jlog._verbosity = + _jcfg._verbosity ; + + _jlog.push ( MARCHE::asciibanner ) ; + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/src/msh_copy.hpp b/src/msh_copy.hpp index 016de95..b482aa1 100644 --- a/src/msh_copy.hpp +++ b/src/msh_copy.hpp @@ -22,18 +22,22 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 19 Apr., 2021 + * Last updated: 18 Jul., 2022 * - * Copyright 2013-2021 + * Copyright 2013-2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -46,6 +50,190 @@ # ifndef __MSH_COPY__ # define __MSH_COPY__ + template < + typename iptr_list + > + __normal_call void_type sort_node ( + mesh_data &_mesh , + iptr_list &_perm + ) + { + iptr_type static constexpr SIZE = +96 ; + + if (_mesh._ndim == +2 && + _mesh._kind == + jmsh_kind::euclidean_mesh) + { + /*---------------------------------- sort 2-dim. mesh */ + typedef geom_tree::aabb_item_node_k < + real_type, + iptr_type, 2> tree_item ; + + typedef geom_tree::aabb_tree< + tree_item, 2> tree_type ; + + tree_type _tree ; + + containers::array _item ; + containers::array _itmp ; + + iptr_type _ipos = +0 ; + for (auto _iter = _mesh. + _euclidean_rdel_2d._tria._nset.head() ; + _iter != _mesh. + _euclidean_rdel_2d._tria._nset.tend() ; + ++_iter, ++_ipos) + { + if (_iter->mark() >= +0 && + _iter->fdim() <= +2 ) // is not isolated + { + _item.push_tail(); + _item.tail()->ipos () = _ipos ; + _item.tail()->pval(0) = + _iter->pval(0) ; + _item.tail()->pval(1) = + _iter->pval(1) ; + } + } + + _tree.load(_item.head(), _item.tend() , + SIZE , // pop.=#nodes per leaf + _tree.median_split , + 1.0) ; // set LONG=1, only div. by pop. + + _tree.dcmp(_itmp, _perm) ; + } + else + if (_mesh._ndim == +3 && + _mesh._kind == + jmsh_kind::euclidean_mesh) + { + /*---------------------------------- sort 3-dim. mesh */ + typedef geom_tree::aabb_item_node_k < + real_type, + iptr_type, 3> tree_item ; + + typedef geom_tree::aabb_tree< + tree_item, 3> tree_type ; + + tree_type _tree ; + + containers::array _item ; + containers::array _itmp ; + + iptr_type _ipos = +0 ; + for (auto _iter = _mesh. + _euclidean_rdel_3d._tria._nset.head() ; + _iter != _mesh. + _euclidean_rdel_3d._tria._nset.tend() ; + ++_iter, ++_ipos) + { + if (_iter->mark() >= +0 && + _iter->fdim() <= +3 ) // is not isolated + { + _item.push_tail(); + _item.tail()->ipos () = _ipos ; + _item.tail()->pval(0) = + _iter->pval(0) ; + _item.tail()->pval(1) = + _iter->pval(1) ; + _item.tail()->pval(2) = + _iter->pval(2) ; + } + } + + _tree.load(_item.head(), _item.tend() , + SIZE , // pop.=#nodes per leaf + _tree.median_split , + 1.0) ; // set LONG=1, only div. by pop. + + _tree.dcmp(_itmp, _perm) ; + } + } + + + template < + typename cell_list , + typename iptr_list , + typename cell_perm + > + __normal_call void_type sort_cell ( + cell_list &_cell , + size_t _nsiz , + iptr_list &_nmap , + cell_perm &_perm + ) + { + class sort_pair + { + public : + /*------------------------ tuple for cell re-ordering */ + typename cell_list::item_type * + _cell ; + float _cost ; + + /*------------------------ construct inline from src. */ + __inline_call sort_pair ( + typename cell_list::item_type * + _psrc , + float const&_csrc + ) : + _cell (_psrc), + _cost((float)_csrc) {} + } ; + + class sort_pred + { + public : + /*------------------------ less-than op. for cost-tup */ + __inline_call + bool_type operator () ( + sort_pair const&_idat , + sort_pair const&_jdat + ) const + { return _idat._cost < _jdat._cost ; + } + } ; + + typedef + containers::array sort_list ; + + sort_list _sort ; + for (auto _iter = _cell._lptr.head() ; + _iter != _cell._lptr.tend() ; + ++_iter ) + { + for (auto _item = *_iter ; + _item != nullptr; + _item = _item->_next ) + { + auto _cost = // min. node indx + _nmap[_item->_data._node [0]] ; + for (auto + _inod = _nsiz; _inod-- != 1; ) + { + _cost = std::min(_cost, + _nmap[_item->_data._node[_inod]]) ; + } + + _sort.push_tail( + sort_pair(_item, _cost)); + } + } + + algorithms::qsort( _sort.head() , + _sort.tend() , + sort_pred () ) ; + + for (auto _iter = _sort.head() ; + _iter != _sort.tend() ; + ++_iter ) + { + _perm.push_tail( _iter->_cell ) ; + } + } + + /* -------------------------------------------------------- * COPY-MESH: copy rdel-complex to tria-complex. @@ -71,7 +259,9 @@ jmsh_kind::euclidean_mesh) { /*---------------------------------- copy 2-dim. mesh */ - containers::array _nmap ; + containers::array _nmap, _perm; + + sort_node(_mesh, _perm) ; _nmap.set_count(_mesh. _euclidean_rdel_2d._tria._nset.count(), @@ -80,50 +270,48 @@ _mesh._euclidean_mesh_2d._mesh. clear(containers::tight_alloc) ; - iptr_type _npos = +0 ; - for (auto _iter = _mesh. - _euclidean_rdel_2d._tria._nset.head() ; - _iter != _mesh. - _euclidean_rdel_2d._tria._nset.tend() ; - ++_iter, ++_npos) + for (auto _iter = _perm.head() ; + _iter != _perm.tend() ; + ++_iter ) { - if (_iter->mark() >= +0) - { + auto _nptr = _mesh. + _euclidean_rdel_2d._tria._nset.head() + *_iter ; + typename mesh_data:: euclidean_mesh_2d:: mesh_type::node_type _node ; - _node.pval(0) = _iter->pval(0) ; - _node.pval(1) = _iter->pval(1) ; + _node.pval(0) = _nptr->pval(0) ; + _node.pval(1) = _nptr->pval(1) ; - _node.pval(2) = _iter->pval(2) ; + _node.pval(2) = _nptr->pval(2) ; - _node.hidx () = _iter->idxh () ; + _node.hidx () = _nptr->idxh () ; - _node.itag () = _iter->part () ; - _node.fdim () = _iter->fdim () ; - _node.feat () = _iter->feat () ; + _node.itag () = _nptr->part () ; + _node.fdim () = _nptr->fdim () ; + _node.feat () = _nptr->feat () ; - _nmap[_npos] = + _nmap[ *_iter ] = _mesh._euclidean_mesh_2d. _mesh.push_node (_node, false) ; - } } _mesh._euclidean_rdel_2d._tria. clear(containers::tight_alloc) ; - for (auto _iter = _mesh. - _euclidean_rdel_2d._eset._lptr.head() ; - _iter != _mesh. - _euclidean_rdel_2d._eset._lptr.tend() ; + containers::array< + mesh_data::euclidean_rdel_2d:: + edge_list::item_type*> _eprm ; + + sort_cell(_mesh. + _euclidean_rdel_2d._eset, +2, _nmap, _eprm); + + for (auto _iter = _eprm.head() ; + _iter != _eprm.tend() ; ++_iter ) { - if(*_iter != nullptr) - { - for (auto _item = *_iter ; - _item != nullptr; - _item = _item->_next ) - { + auto _item = *_iter ; + typename mesh_data:: euclidean_mesh_2d:: mesh_type::edge_type _face; @@ -137,25 +325,24 @@ _mesh._euclidean_mesh_2d. _mesh.push_edge (_face, false) ; - } - } } _mesh._euclidean_rdel_2d._eset. clear(containers::tight_alloc) ; - for (auto _iter = _mesh. - _euclidean_rdel_2d._tset._lptr.head() ; - _iter != _mesh. - _euclidean_rdel_2d._tset._lptr.tend() ; + containers::array< + mesh_data::euclidean_rdel_2d:: + tria_list::item_type*> _tprm ; + + sort_cell(_mesh. + _euclidean_rdel_2d._tset, +3, _nmap, _tprm); + + for (auto _iter = _tprm.head() ; + _iter != _tprm.tend() ; ++_iter ) { - if(*_iter != nullptr) - { - for (auto _item = *_iter ; - _item != nullptr; - _item = _item->_next ) - { + auto _item = *_iter ; + typename mesh_data:: euclidean_mesh_2d:: mesh_type::tri3_type _face; @@ -171,8 +358,6 @@ _mesh._euclidean_mesh_2d. _mesh.push_tri3 (_face, false) ; - } - } } _mesh._euclidean_rdel_2d._tset. @@ -191,7 +376,9 @@ jmsh_kind::euclidean_mesh) { /*---------------------------------- copy 3-dim. mesh */ - containers::array _nmap ; + containers::array _nmap, _perm; + + sort_node(_mesh, _perm) ; _nmap.set_count(_mesh. _euclidean_rdel_3d._tria._nset.count(), @@ -200,51 +387,49 @@ _mesh._euclidean_mesh_3d._mesh. clear(containers::tight_alloc) ; - iptr_type _npos = +0 ; - for (auto _iter = _mesh. - _euclidean_rdel_3d._tria._nset.head() ; - _iter != _mesh. - _euclidean_rdel_3d._tria._nset.tend() ; - ++_iter, ++_npos) + for (auto _iter = _perm.head() ; + _iter != _perm.tend() ; + ++_iter ) { - if (_iter->mark() >= +0) - { + auto _nptr = _mesh. + _euclidean_rdel_3d._tria._nset.head() + *_iter ; + typename mesh_data:: euclidean_mesh_3d:: mesh_type::node_type _node ; - _node.pval(0) = _iter->pval(0) ; - _node.pval(1) = _iter->pval(1) ; - _node.pval(2) = _iter->pval(2) ; + _node.pval(0) = _nptr->pval(0) ; + _node.pval(1) = _nptr->pval(1) ; + _node.pval(2) = _nptr->pval(2) ; - _node.pval(3) = _iter->pval(3) ; + _node.pval(3) = _nptr->pval(3) ; - _node.hidx () = _iter->idxh () ; + _node.hidx () = _nptr->idxh () ; - _node.itag () = _iter->part () ; - _node.fdim () = _iter->fdim () ; - _node.feat () = _iter->feat () ; + _node.itag () = _nptr->part () ; + _node.fdim () = _nptr->fdim () ; + _node.feat () = _nptr->feat () ; - _nmap[_npos] = + _nmap[ *_iter ] = _mesh._euclidean_mesh_3d. _mesh.push_node (_node, false) ; - } } _mesh._euclidean_rdel_3d._tria. clear(containers::tight_alloc) ; - for (auto _iter = _mesh. - _euclidean_rdel_3d._eset._lptr.head() ; - _iter != _mesh. - _euclidean_rdel_3d._eset._lptr.tend() ; + containers::array< + mesh_data::euclidean_rdel_3d:: + edge_list::item_type*> _eprm ; + + sort_cell(_mesh. + _euclidean_rdel_3d._eset, +2, _nmap, _eprm); + + for (auto _iter = _eprm.head() ; + _iter != _eprm.tend() ; ++_iter ) { - if(*_iter != nullptr) - { - for (auto _item = *_iter ; - _item != nullptr; - _item = _item->_next ) - { + auto _item = *_iter ; + typename mesh_data:: euclidean_mesh_3d:: mesh_type::edge_type _face; @@ -258,25 +443,24 @@ _mesh._euclidean_mesh_3d. _mesh.push_edge (_face, false) ; - } - } } _mesh._euclidean_rdel_3d._eset. clear(containers::tight_alloc) ; - for (auto _iter = _mesh. - _euclidean_rdel_3d._fset._lptr.head() ; - _iter != _mesh. - _euclidean_rdel_3d._fset._lptr.tend() ; + containers::array< + mesh_data::euclidean_rdel_3d:: + face_list::item_type*> _fprm ; + + sort_cell(_mesh. + _euclidean_rdel_3d._fset, +3, _nmap, _fprm); + + for (auto _iter = _fprm.head() ; + _iter != _fprm.tend() ; ++_iter ) { - if(*_iter != nullptr) - { - for (auto _item = *_iter ; - _item != nullptr; - _item = _item->_next ) - { + auto _item = *_iter ; + typename mesh_data:: euclidean_mesh_3d:: mesh_type::tri3_type _face; @@ -292,25 +476,24 @@ _mesh._euclidean_mesh_3d. _mesh.push_tri3 (_face, false) ; - } - } } _mesh._euclidean_rdel_3d._fset. clear(containers::tight_alloc) ; - for (auto _iter = _mesh. - _euclidean_rdel_3d._tset._lptr.head() ; - _iter != _mesh. - _euclidean_rdel_3d._tset._lptr.tend() ; + containers::array< + mesh_data::euclidean_rdel_3d:: + tria_list::item_type*> _tprm ; + + sort_cell(_mesh. + _euclidean_rdel_3d._tset, +4, _nmap, _tprm); + + for (auto _iter = _tprm.head() ; + _iter != _tprm.tend() ; ++_iter ) { - if(*_iter != nullptr) - { - for (auto _item = *_iter ; - _item != nullptr; - _item = _item->_next ) - { + auto _item = *_iter ; + typename mesh_data:: euclidean_mesh_3d:: mesh_type::tri4_type _face; @@ -328,8 +511,6 @@ _mesh._euclidean_mesh_3d. _mesh.push_tri4 (_face, false) ; - } - } } _mesh._euclidean_rdel_3d._tset. diff --git a/src/msh_init.hpp b/src/msh_init.hpp index 685a4cd..a9002f0 100644 --- a/src/msh_init.hpp +++ b/src/msh_init.hpp @@ -22,16 +22,20 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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: 27 July, 2020 + * Last updated: 27 Jul., 2020 * * Copyright 2013-2020 * Darren Engwirda diff --git a/src/msh_read.hpp b/src/msh_read.hpp index 304e0a7..2c7214e 100644 --- a/src/msh_read.hpp +++ b/src/msh_read.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/msh_save.hpp b/src/msh_save.hpp index bfb1fa7..6784819 100644 --- a/src/msh_save.hpp +++ b/src/msh_save.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/msh_save.inc b/src/msh_save.inc index ba80713..6aff098 100644 --- a/src/msh_save.inc +++ b/src/msh_save.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/netcdf/ncutil.h b/src/netcdf/ncutil.h index f2e4058..b47a2fe 100644 --- a/src/netcdf/ncutil.h +++ b/src/netcdf/ncutil.h @@ -1,4 +1,50 @@ + /* + -------------------------------------------------------- + * NCUTIL: simple interface to the NetCDF library. + -------------------------------------------------------- + * + * 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: 20 May, 2022 + * + * Copyright 2022-- + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * + -------------------------------------------------------- + */ + # include # include # include diff --git a/src/offset.hpp b/src/offset.hpp index 3c6be28..2455a81 100644 --- a/src/offset.hpp +++ b/src/offset.hpp @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * @@ -68,7 +72,7 @@ __unreferenced(_jlog) ; /*--------------------------------- find GEOM offsets */ - real_type _xmid[3] = { +0. } ; + double _xmid[3] = { +0. } ; if (_geom._ndim == +2 && _geom._kind == @@ -134,7 +138,7 @@ __unreferenced(_jlog) ; /*--------------------------------- find GEOM offsets */ - real_type _xmid[3] = { +0. } ; + double _xmid[3] = { +0. } ; if (_hfun._ndim == +2 && _hfun._kind == diff --git a/src/rdt_save.inc b/src/rdt_save.inc index ff28747..a8f69a6 100644 --- a/src/rdt_save.inc +++ b/src/rdt_save.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/tri_save.inc b/src/tri_save.inc index 46ba638..fa015a4 100644 --- a/src/tri_save.inc +++ b/src/tri_save.inc @@ -22,12 +22,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- * diff --git a/src/tripod.hpp b/src/tripod.hpp index f796ad1..6f30776 100644 --- a/src/tripod.hpp +++ b/src/tripod.hpp @@ -14,9 +14,9 @@ * TRIPOD: a "restricted" delaunay tessellator. -------------------------------------------------------- * - * Last updated: 27 Aug., 2021 + * Last updated: 10 Jun., 2022 * - * Copyright 2013 -- 2021 + * Copyright 2013 -- 2022 * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda @@ -41,12 +41,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor the National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * -------------------------------------------------------- */ @@ -655,15 +659,10 @@ /*--------------------------------- setup *.JLOG file */ jlog_text _jlog(_jcfg) ; - _jlog.push(TRIPOD:: - asciibanner) ; if(!_jcfg._jcfg_file.empty()) { /*--------------------------------- parse *.JCFG file */ - _jlog.push ( - " Reading CFG. file...\n\n" ) ; - # ifdef __use_timers _ttic = _time.now(); # endif//__use_timers @@ -674,6 +673,11 @@ return _retv ; } + _jlog._verbosity = + _jcfg._verbosity ; + + _jlog.push ( TRIPOD::asciibanner ) ; + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/version.txt b/version.txt index 66d5bf3..e44fc12 100644 --- a/version.txt +++ b/version.txt @@ -13,6 +13,12 @@ # JIGSAW: an unstructured mesh generation library #------------------------------------------------------------ + * Version 1.0.0: + + - Initial support for thread-parallelism in optim. + phase. + + * Version 0.9.15: -------------- @@ -22,6 +28,10 @@ - New "skewed-cosine" optimisation metric, useful to build "well-centred" primal-dual meshes. + - New "momentum" type optimisation approach, with + the two-parameter quasi-hyperbolic method (QHM) + implemented. + - Support "masked-out" entries in MARCHE solvers. - Fix a point-location bug wrt. unstructured h(x) From 5d00b6ac675cb8f1f00771c2359817d70f3392a1 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Sat, 24 Dec 2022 13:44:16 -0700 Subject: [PATCH 02/25] Update README.md and LICENSE.md --- LICENSE.md | 9 ++++++++- README.md | 25 +++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 37a1b22..84a0e6b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,4 +2,11 @@ This program may be freely redistributed under the condition that the copyright notices (including this entire header) are not removed, and no compensation is received through use of the software. Private, research, and institutional use is free. You may distribute modified versions of this code `UNDER THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR NOTICE IS GIVEN OF THE MODIFICATIONS`. Distribution of this code as part of a commercial system is permissible `ONLY BY DIRECT ARRANGEMENT WITH THE AUTHOR`. (If you are not directly supplying this code to a customer, and you are instead telling them how they can obtain it for free, then you are not required to make any arrangement with me.) -`DISCLAIMER`: Neither I nor: Columbia University, the Massachusetts Institute of Technology, the University of Sydney, nor the National Aeronautics and Space Administration warrant this code in any way whatsoever. This code is provided "as-is" to be used at your own risk. +`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 diff --git a/README.md b/README.md index 7941dd8..7af7e26 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This package provides the underlying `c++` source for `JIGSAW`; defining a basic command-line interface and a `c`-format `API`. Higher-level scripting interfaces, supporting a range of additional facilities for file I/O, mesh visualisation and post-processing operations are also available, including for `MATLAB` / `OCTAVE` here and for `PYTHON` here. -`JIGSAW` has been compiled and tested on various `64-bit` `Linux`, `Windows` and `MacOS` based platforms. +`JIGSAW` is compiled and tested on various `64-bit` `Linux`, `Windows` and `MacOS` platforms using the `g++`, `clang++` and `msvc` compilers. ### `Code Structure` @@ -47,12 +47,12 @@ The full `JIGSAW` src can be found in `../jigsaw/src/`< * Make a new temporary directory BUILD. * cd build * cmake .. -DCMAKE_BUILD_TYPE=BUILD_MODE - * cmake --build . --config BUILD_MODE --target install + * cmake --build . --config BUILD_MODE --target install EXTRAS * Delete the temporary BUILD directory. This process will build a series of executables and shared libraries: `jigsaw` itself - the main command-line meshing utility, `tripod` - `JIGSAW`'s tessellation infrastructure, `marche` - a fast-marching solver designed to optimise mesh-spacing configurations, as well as `libjigsaw` - `JIGSAW`'s shared `API`. -`BUILD_MODE` can be used to select different compiler configurations and should generally either be `Release` or `Debug`. +`BUILD_MODE` can be used to select different compiler configurations and should generally either be `Release` or `Debug`. `EXTRAS` can be used to pass additional compile-time arguments, for example `-- -j 4` will build in parallel on supported architectures. See `example.jig` for documentation on calling the command-line executables, and the headers in `../jigsaw/inc/` for details on the `API`. @@ -94,16 +94,29 @@ The unit-tests can be built using the `cmake` u * Make a new temporary directory BUILD. * cd build * cmake .. -DCMAKE_BUILD_TYPE=BUILD_MODE - * cmake --build . --config BUILD_MODE --target install + * cmake --build . --config BUILD_MODE --target install EXTRAS * Delete the temporary BUILD directory. -This process will build the unit-tests as a series of executables in `../jigsaw/uni/`. `BUILD_MODE` is a compiler configuration flag: either `Release` or `Debug`. +This process will build the unit-tests as a series 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. + +### `Contributors` + +1. [@dengwirda](github.com/dengwirda) is `JIGSAW`'s developer and maintainer --- this work was originally the focus of my PhD at the University of Sydney. +2. [@xylar](github.com/xylar) contributed the original `cmake` build system. +3. [@tunnellm](https://github.com/tunnellm) extended the original sequential optimisation algorithms to support thread-parallelism. ### `License` This program may be freely redistributed under the condition that the copyright notices (including this entire header) are not removed, and no compensation is received through use of the software. Private, research, and institutional use is free. You may distribute modified versions of this code `UNDER THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR NOTICE IS GIVEN OF THE MODIFICATIONS`. Distribution of this code as part of a commercial system is permissible `ONLY BY DIRECT ARRANGEMENT WITH THE AUTHOR`. (If you are not directly supplying this code to a customer, and you are instead telling them how they can obtain it for free, then you are not required to make any arrangement with me.) -`DISCLAIMER`: Neither I nor: Columbia University, the Massachusetts Institute of Technology, the University of Sydney, nor the National Aeronautics and Space Administration warrant this code in any way whatsoever. This code is provided "as-is" to be used at your own risk. +`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 ### `References` From bc1ff937ee960d017ceeab0ca6e26750cf7b0ad7 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Sat, 24 Dec 2022 13:51:06 -0700 Subject: [PATCH 03/25] Update README.md and LICENSE.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7af7e26..aa504f5 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ This process will build the unit-tests as a series of executables in Date: Sat, 24 Dec 2022 21:22:18 -0700 Subject: [PATCH 05/25] Switch CI to GitHub Actions --- .github/workflows/cmake.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e75b103..b571947 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -32,21 +32,21 @@ jobs: } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Print environment + - name: Print environment run: | echo github.event.action: ${{ github.event.action }} echo github.event_name: ${{ github.event_name }} - - name: Install dependencies on win + - name: Install dependencies on win if: startsWith(matrix.config.os, 'windows') run: | choco install ninja cmake ninja --version cmake --version - - name: Install dependencies on unx + - name: Install dependencies on unx if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') run: | sudo apt-get update @@ -55,7 +55,7 @@ jobs: cmake --version g++ --version - - name: Install dependencies on osx + - name: Install dependencies on osx if: startsWith(matrix.config.os, 'macos') run: | brew install ninja cmake @@ -63,14 +63,14 @@ jobs: cmake --version clang++ --version - - name: Configure jigsaw - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + - name: Configure jigsaw + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - name: Build jigsaw - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} install + - name: Build jigsaw + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} install - - name: Configure tests for jigsaw - run: cmake -B ${{github.workspace}}/uni/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + - name: Configure tests for jigsaw + run: cmake -B ${{github.workspace}}/uni/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - name: Build tests for jigsaw - run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} install + - name: Build tests for jigsaw + run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} install From d5986ea5ce5d95d379fabc60a45225efead17a9f Mon Sep 17 00:00:00 2001 From: dengwirda Date: Sat, 24 Dec 2022 21:35:29 -0700 Subject: [PATCH 06/25] Switch CI to GitHub Actions --- .github/workflows/cmake.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b571947..0f401e8 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,6 +1,7 @@ name: CMake Build Matrix on: + workflow_dispatch: pull_request: env: From 4e832a0f7145f7d24ab8f36fd0831c36ce7bca2a Mon Sep 17 00:00:00 2001 From: dengwirda Date: Mon, 26 Dec 2022 06:59:36 -0700 Subject: [PATCH 07/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Code clean-up: int signedness, downgrade std=c++17 features not (yet) well supported... --- README.md | 4 +- src/libcpp/aabb_tree/aabb_tree_k.hpp | 10 ++-- src/libcpp/containers/priorityidx.hpp | 30 ++++++---- .../interpolate/hfun_grid_ellipsoid_3.hpp | 4 +- .../interpolate/hfun_grid_euclidean_2.hpp | 4 +- .../interpolate/hfun_mesh_ellipsoid_3.hpp | 4 +- .../interpolate/hfun_mesh_euclidean_2.hpp | 4 +- .../interpolate/hfun_mesh_euclidean_3.hpp | 4 +- src/libcpp/iter_mesh/_zip_mesh_2.inc | 12 ++-- src/libcpp/iter_mesh/flip_mesh_2.inc | 18 +++--- src/libcpp/iter_mesh/iter_mesh_2.hpp | 36 +++++++----- src/libcpp/iter_mesh/move_mesh_2.inc | 14 +++-- src/libcpp/iter_mesh/part_mesh_2.inc | 57 +++++++++++++++++-- src/msh_copy.hpp | 8 ++- 14 files changed, 139 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index aa504f5..a59cf25 100644 --- a/README.md +++ b/README.md @@ -102,8 +102,8 @@ This process will build the unit-tests as a series of executables in _keys[_kpos] = - _ipos - this->_heap.head() ; + this->_keys[_kpos] = + (iptr_type)( + _ipos - this->_heap.head()) ; } __inline_call void_type push ( // move @@ -473,7 +474,8 @@ /*------------------------- map _item to _data "hole" */ this->_keys[_kpos] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()) ; } /* @@ -518,7 +520,8 @@ /*---------------------- update mapping for tail item */ this->_keys[_ipos->_kidx] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()); } this->_heap._pop_tail(); @@ -563,7 +566,8 @@ /*---------------------- update mapping for tail item */ this->_keys[_ipos->_kidx] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()); } this->_heap._pop_tail(); @@ -600,6 +604,7 @@ /*------------------------ copy position into mapping */ this->_keys[_kpos] = + (iptr_type) _ipos - this->_heap.head() ; } @@ -627,7 +632,8 @@ /*------------------------ copy position into mapping */ this->_keys[_kpos] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()) ; } /* @@ -655,7 +661,8 @@ /*------------------------ copy position into mapping */ this->_keys[_kpos] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()) ; } __inline_call void_type reduce ( // move @@ -677,7 +684,8 @@ /*------------------------ copy position into mapping */ this->_keys[_kpos] = - _ipos - this->_heap.head() ; + (iptr_type)( + _ipos - this->_heap.head()) ; } /* diff --git a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp index 7eb5dce..5451172 100644 --- a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp @@ -428,8 +428,8 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static constexpr - _FTOL = std::pow( + vals_type static _FTOL = + (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; # define ISALIVE(__idx) \ diff --git a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp index aca5467..225e007 100644 --- a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp @@ -180,8 +180,8 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static constexpr - _FTOL = std::pow( + vals_type static _FTOL = + (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; iptr_type IBEG = +0; diff --git a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp index 9b56bac..8b89b53 100644 --- a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp @@ -352,8 +352,8 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static constexpr - _FTOL = std::pow( + vals_type static _FTOL = + (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; # define ISALIVE(__idx) \ diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp index 3d04977..ae612ef 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp @@ -280,8 +280,8 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static constexpr - _FTOL = std::pow( + vals_type static _FTOL = + (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; # define ISALIVE(__idx) \ diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp index 6a9cf02..dfed66b 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp @@ -298,8 +298,8 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static constexpr - _FTOL = std::pow( + vals_type static _FTOL = + (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; # define ISALIVE(__idx) \ diff --git a/src/libcpp/iter_mesh/_zip_mesh_2.inc b/src/libcpp/iter_mesh/_zip_mesh_2.inc index 52c6d96..0e7cac9 100644 --- a/src/libcpp/iter_mesh/_zip_mesh_2.inc +++ b/src/libcpp/iter_mesh/_zip_mesh_2.inc @@ -70,8 +70,8 @@ iter_opts &_opts , // user options real_type _QLIM , // cell quality threshold real_type _DLIM , // dual quality threshold - iptr_type &_nzip , // number of successful zip's - iptr_type &_ndiv , // number of successful div's + size_t &_nzip , // number of successful zip's + size_t &_ndiv , // number of successful div's iter_stat &_tcpu // CPU timers/info ) { @@ -333,8 +333,8 @@ iter_opts &_opts , // user options real_type _QLIM , // cell quality threshold real_type _DLIM , // dual quality threshold - iptr_type &_nzip , // number of successful zip's - iptr_type &_ndiv , // number of successful div's + size_t &_nzip , // number of successful zip's + size_t &_ndiv , // number of successful div's iter_stat &_tcpu // CPU timers/info ) { @@ -586,8 +586,8 @@ iter_opts &_opts , // user options real_type _QLIM , // cell quality threshold real_type _DLIM , // dual quality threshold - iptr_type &_nzip , // number of successful zip's - iptr_type &_ndiv , // number of successful div's + size_t &_nzip , // number of successful zip's + size_t &_ndiv , // number of successful div's iter_stat &_tcpu // CPU timers/info ) { diff --git a/src/libcpp/iter_mesh/flip_mesh_2.inc b/src/libcpp/iter_mesh/flip_mesh_2.inc index e569c08..801a8c6 100644 --- a/src/libcpp/iter_mesh/flip_mesh_2.inc +++ b/src/libcpp/iter_mesh/flip_mesh_2.inc @@ -262,7 +262,7 @@ iptr_list &_nset , // list of nodes active mark_list &_mark , // sets of node/cell flags iptr_type _imrk , // outer iteration marker - iptr_type &_nflp , // number of successful flips + size_t &_nflp , // number of successful flips iter_stat &_tcpu // CPU timers/info ) { @@ -353,7 +353,7 @@ iptr_list &_nset , // list of nodes active mark_list &_mark , // sets of node/cell flags iptr_type _imrk , // outer iteration marker - iptr_type &_nflp , // number of successful flips + size_t &_nflp , // number of successful flips iter_stat &_tcpu // CPU timers/info ) { @@ -440,7 +440,7 @@ hfun_type &_hfun , // spacing object conn_list &_flip , // list of cells to flip mark_list &_mark , // sets of node/cell flags - iptr_type &_nflp , // number of successful flips + size_t &_nflp , // number of successful flips iter_stat &_tcpu // CPU timers/info ) { @@ -496,12 +496,12 @@ quad(_cell->_cell).mark() >= +0) { bool_type _okay = false ; - flip_quad( _geom, _mesh, - _mark. _node, - _cell->_cell, - _okay, _conn, _CONN, - _qold, _qnew, - (flip_kind)laguerre_flip) ; + // flip_quad( _geom, _mesh, + // _mark. _node, + // _cell->_cell, + // _okay, _conn, _CONN, + // _qold, _qnew, + // (flip_kind)laguerre_flip) ; if (_okay) _nflp += +1 ; diff --git a/src/libcpp/iter_mesh/iter_mesh_2.hpp b/src/libcpp/iter_mesh/iter_mesh_2.hpp index 55397dc..2b191a3 100644 --- a/src/libcpp/iter_mesh/iter_mesh_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_2.hpp @@ -348,11 +348,14 @@ shared(_mesh, _opts, _QMIN) { real_type _qmin = (real_type) +1. ; - # pragma omp for nowait schedule(static) - for (auto _cell = _mesh.tri3().head() ; - _cell != _mesh.tri3().tend() ; - ++_cell ) + # pragma omp for nowait schedule(static) + for (auto _cpos = +0u ; + _cpos < _mesh.tri3().count() ; + ++_cpos ) { + auto _cell = + _mesh. tri3().head() + _cpos ; + if (_cell->mark() >= +0 ) { /*--------------------- test initial cell quality */ @@ -373,11 +376,14 @@ } } - # pragma omp for nowait schedule(static) - for (auto _cell = _mesh.quad().head() ; - _cell != _mesh.quad().tend() ; - ++_cell ) + # pragma omp for nowait schedule(static) + for (auto _cpos = +0u ; + _cpos < _mesh.quad().count() ; + ++_cpos ) { + auto _cell = + _mesh. quad().head() + _cpos ; + if (_cell->mark() >= +0 ) { /*--------------------- test initial cell quality */ @@ -497,10 +503,10 @@ _nset.set_count( +0); - iptr_type _nmov = +0 ; - iptr_type _nflp = +0 ; - iptr_type _nzip = +0 ; - iptr_type _ndiv = +0 ; + size_t _nmov = +0 ; + size_t _nflp = +0 ; + size_t _nzip = +0 ; + size_t _ndiv = +0 ; /*------------------------------ scale quality limits */ iptr_type _nsub = _iter +0 ; @@ -572,7 +578,7 @@ _dump.push( "**CALL FLIP-MESH...\n" ) ; - iptr_type _nloc; + size_t _nloc; flip_mesh( _geom, _mesh , _hfun , _conn, _nset, _mark , +3 * _iter - 2 , _nloc , _tcpu); @@ -641,7 +647,7 @@ _dump.push( "**CALL FLIP-MESH...\n" ) ; - iptr_type _nloc; + size_t _nloc; flip_mesh( _geom, _mesh , _hfun , _conn, _nset, _mark , +3 * _iter - 1 , _nloc , _tcpu); @@ -700,7 +706,7 @@ _dump.push( "**CALL FLIP-MESH...\n" ) ; - iptr_type _nloc; + size_t _nloc; flip_mesh( _geom, _mesh , _hfun , _nset, _mark, +3 * _iter - 0 , _nloc , _tcpu); diff --git a/src/libcpp/iter_mesh/move_mesh_2.inc b/src/libcpp/iter_mesh/move_mesh_2.inc index 8c1e119..916359e 100644 --- a/src/libcpp/iter_mesh/move_mesh_2.inc +++ b/src/libcpp/iter_mesh/move_mesh_2.inc @@ -643,7 +643,7 @@ PART_SCAL ; _pful = std::min( _opts. nprt(), _pful + 1) ; - + # ifdef __use_timers _ttoc = _time.now() ; _tcpu._init_node += _tcpu.time_span(_ttic, _ttoc) ; @@ -690,10 +690,12 @@ _ttic = _time.now() ; # endif//__use_timers + auto _pi = std::atan(+1.) * +4. ; + if (_isub == +0) part_mesh(_mesh, _part._full, _pful, _aset, - _isub, _tcpu) ; + _isub, _pi*0,_tcpu) ; _pbnd = _part._full._seqs.count() / BNDS_SCAL ; @@ -703,7 +705,7 @@ if (_isub == +0) part_mesh(_mesh, _part._bnds, _pbnd, _part. _full._seqs, - _isub, _tcpu) ; + _isub, _pi/4,_tcpu) ; # ifdef __use_timers _ttoc = _time.now() ; @@ -1166,10 +1168,12 @@ _ttic = _time.now() ; # endif//__use_timers + auto _pi = std::atan(+1.) * +4. ; + if (_isub == +0) part_mesh(_mesh, _part._full, _pful, _aset, - _isub, _tcpu) ; + _isub, _pi*0,_tcpu) ; _pbnd = _part._full._seqs.count() / BNDS_SCAL ; @@ -1179,7 +1183,7 @@ if (_isub == +0) part_mesh(_mesh, _part._bnds, _pbnd, _part. _full._seqs, - _isub, _tcpu) ; + _isub, _pi/4,_tcpu) ; # ifdef __use_timers _ttoc = _time.now() ; diff --git a/src/libcpp/iter_mesh/part_mesh_2.inc b/src/libcpp/iter_mesh/part_mesh_2.inc index 7690abd..b6642b5 100644 --- a/src/libcpp/iter_mesh/part_mesh_2.inc +++ b/src/libcpp/iter_mesh/part_mesh_2.inc @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 15 Dec., 2022 + * Last updated: 23 Dec., 2022 * * Copyright 2013-2022 * Marc Tunnell, @@ -56,6 +56,7 @@ iptr_type _nprt, // number of partitions to make iptr_list _aset, // list of active nodes iptr_type _isub, // inner iteration marker + real_type _arot, iter_stat &_tcpu // CPU timers/info ) { @@ -122,10 +123,56 @@ _item.push_tail(); _item.tail()->ipos() = *_apos; - for (auto _idim = geom_dims; - _idim-- != 0; ) - _item.tail()->pval(_idim) = - _aptr ->pval(_idim); + if (geom_dims == 2) + { + /*-------------------- rotate to stop realignment */ + real_type _xcos = std::cos (_arot) ; + real_type _xsin = std::sin (_arot) ; + + real_type _xmat[2][2]; // 2d rotation + _xmat[0][0] = +_xcos ; + _xmat[0][1] = -_xsin ; + _xmat[1][0] = +_xsin ; + _xmat[1][1] = +_xcos ; + + _item.tail()->pval(0) = + _xmat[0][0] * _aptr->pval(0) + + _xmat[0][1] * _aptr->pval(1) ; + _item.tail()->pval(1) = + _xmat[1][0] * _aptr->pval(0) + + _xmat[1][1] * _aptr->pval(1) ; + } + else + if (geom_dims == 3) + { + /*-------------------- rotate to stop realignment */ + real_type _xcos = std::cos (_arot) ; + real_type _xsin = std::sin (_arot) ; + + real_type _xmat[3][3]; // 3d rotation + _xmat[0][0] = +1. ; + _xmat[0][1] = +1. - _xcos - _xsin; + _xmat[0][2] = +1. - _xcos + _xsin; + _xmat[1][0] = +1. - _xcos + _xsin; + _xmat[1][1] = +1. ; + _xmat[1][2] = +1. - _xcos - _xsin; + _xmat[2][0] = +1. - _xcos - _xsin; + _xmat[2][1] = +1. - _xcos + _xsin; + _xmat[2][2] = +1. ; + + _item.tail()->pval(0) = + _xmat[0][0] * _aptr->pval(0) + + _xmat[0][1] * _aptr->pval(1) + + _xmat[0][2] * _aptr->pval(2) ; + _item.tail()->pval(1) = + _xmat[1][0] * _aptr->pval(0) + + _xmat[1][1] * _aptr->pval(1) + + _xmat[1][2] * _aptr->pval(2) ; + _item.tail()->pval(2) = + _xmat[2][0] * _aptr->pval(0) + + _xmat[2][1] * _aptr->pval(1) + + _xmat[2][2] * _aptr->pval(2) ; + } } } diff --git a/src/msh_copy.hpp b/src/msh_copy.hpp index b482aa1..52bea10 100644 --- a/src/msh_copy.hpp +++ b/src/msh_copy.hpp @@ -75,7 +75,7 @@ tree_type _tree ; containers::array _item ; - containers::array _itmp ; + containers::array< size_t > _itmp ; iptr_type _ipos = +0 ; for (auto _iter = _mesh. @@ -119,7 +119,7 @@ tree_type _tree ; containers::array _item ; - containers::array _itmp ; + containers::array< size_t > _itmp ; iptr_type _ipos = +0 ; for (auto _iter = _mesh. @@ -216,8 +216,10 @@ _nmap[_item->_data._node[_inod]]) ; } + float _cval = (float)_cost; + _sort.push_tail( - sort_pair(_item, _cost)); + sort_pair(_item, _cval)); } } From 9e58d7dfba7ab4f91f4853d9f4a51db038b082bd Mon Sep 17 00:00:00 2001 From: dengwirda Date: Mon, 26 Dec 2022 08:52:29 -0700 Subject: [PATCH 08/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Code clean-up: check/limit openmp version for msvc compilers. --- src/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29d58be..0eaf80e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ function (cfg_compile_options OPT CFG) add_compile_options ("$<$:${OPT}>") endfunction () +include (CheckCXXCompilerFlag) + set (CMAKE_CXX_STANDARD 17) set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) @@ -19,6 +21,7 @@ endif () if (DEFINED MSVC_LIKE) add_compile_options (/W3) + add_compile_options (/openmp:llvm) cfg_compile_options (/GS- RELEASE) cfg_compile_options (/Ot RELEASE) endif () @@ -45,6 +48,11 @@ endif () find_package (OpenMP) +if (OpenMP_CXX_FOUND AND (OpenMP_CXX_VERSION LESS 3)) + set (OpenMP_CXX_FOUND FALSE) + message (STATUS "Insufficient OpenMP support") +endif () + if (OpenMP_CXX_FOUND) message (STATUS "OpenMP library found") message (STATUS "OpenMP inc. lib: ${OpenMP_CXX_LIB_NAMES}") From 02e82f373f0611570f7336b5707870e286986efa Mon Sep 17 00:00:00 2001 From: dengwirda Date: Tue, 10 Jan 2023 08:04:20 -0700 Subject: [PATCH 09/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Make aabb-tree find routines thread-safe. - Clean-up openmp implementations for msvc. --- example.jig | 20 ++ inc/jigsaw_const.h | 4 +- inc/jigsaw_jig_t.h | 16 +- inc/jigsaw_msh_t.h | 4 +- inc/lib_jigsaw.h | 4 +- src/CMakeLists.txt | 2 +- src/geo_load.hpp | 4 +- src/hfn_init.hpp | 4 +- src/hfn_load.hpp | 4 +- src/hfn_save.inc | 6 +- src/ini_load.hpp | 4 +- src/jig_load.hpp | 6 +- src/jig_read.hpp | 4 +- src/jigsaw.cpp | 6 +- src/jigsaw.hpp | 10 +- src/libcpp/aabb_tree/aabb_mesh_k.hpp | 4 +- src/libcpp/aabb_tree/aabb_pred_k.hpp | 4 +- src/libcpp/aabb_tree/aabb_tree_k.hpp | 118 ++++++------ src/libcpp/aabb_tree/aabb_type_k.hpp | 4 +- src/libcpp/aabbtree.hpp | 4 +- src/libcpp/algorithms.hpp | 4 +- src/libcpp/algorithms/find.hpp | 4 +- src/libcpp/algorithms/sort.hpp | 24 +-- src/libcpp/allocators.hpp | 4 +- src/libcpp/allocators/alloc_base.hpp | 4 +- src/libcpp/allocators/alloc_item.hpp | 4 +- src/libcpp/allocators/alloc_pool.hpp | 4 +- src/libcpp/allocators/alloc_wrap.hpp | 4 +- src/libcpp/basebase.hpp | 4 +- src/libcpp/containers.hpp | 4 +- src/libcpp/containers/array.hpp | 16 +- src/libcpp/containers/array_iter.hpp | 16 +- src/libcpp/containers/arraylist.hpp | 16 +- src/libcpp/containers/basic_stack.hpp | 16 +- src/libcpp/containers/block_array.hpp | 16 +- src/libcpp/containers/block_iter.hpp | 16 +- src/libcpp/containers/double_list.hpp | 16 +- src/libcpp/containers/doubleiter.hpp | 16 +- src/libcpp/containers/fixed_array.hpp | 16 +- src/libcpp/containers/hashtable.hpp | 16 +- src/libcpp/containers/hashtwice.hpp | 16 +- src/libcpp/containers/iter_base.hpp | 86 ++++----- src/libcpp/containers/priorityidx.hpp | 32 ++-- src/libcpp/containers/prioritymap.hpp | 16 +- src/libcpp/containers/priorityset.hpp | 16 +- src/libcpp/containers/single_list.hpp | 16 +- src/libcpp/containers/singleiter.hpp | 16 +- src/libcpp/expansion/dd_float.hpp | 4 +- src/libcpp/expansion/ia_float.hpp | 4 +- src/libcpp/expansion/mp_basic.hpp | 4 +- src/libcpp/expansion/mp_float.hpp | 4 +- src/libcpp/expansion/mp_utils.hpp | 4 +- src/libcpp/geom_base/cell_ball_k.hpp | 4 +- src/libcpp/geom_base/cell_base_k.hpp | 14 +- src/libcpp/geom_base/intersect_k.hpp | 4 +- src/libcpp/geom_base/vect_base_k.hpp | 4 +- src/libcpp/geom_reps/geom_base_2.hpp | 4 +- src/libcpp/geom_reps/geom_base_3.hpp | 4 +- .../geom_reps/geom_mesh_ellipsoid_3.hpp | 6 +- .../geom_reps/geom_mesh_euclidean_2.hpp | 6 +- .../geom_reps/geom_mesh_euclidean_3.hpp | 8 +- src/libcpp/geometry.hpp | 4 +- src/libcpp/geompred.hpp | 4 +- src/libcpp/geomreps.hpp | 4 +- src/libcpp/interpolate.hpp | 4 +- src/libcpp/interpolate/hfun_base_k.hpp | 4 +- src/libcpp/interpolate/hfun_clip_k.hpp | 24 +-- .../interpolate/hfun_constant_value_k.hpp | 4 +- .../interpolate/hfun_grid_ellipsoid_3.hpp | 50 ++--- .../interpolate/hfun_grid_euclidean_2.hpp | 32 ++-- .../interpolate/hfun_grid_euclidean_3.hpp | 6 +- .../interpolate/hfun_mesh_ellipsoid_3.hpp | 32 ++-- .../interpolate/hfun_mesh_euclidean_2.hpp | 30 +-- .../interpolate/hfun_mesh_euclidean_3.hpp | 34 ++-- src/libcpp/iter_mesh/_bfs_mesh_2.inc | 4 +- src/libcpp/iter_mesh/_zip_mesh_2.inc | 22 +-- src/libcpp/iter_mesh/cost_mesh_2.inc | 4 +- src/libcpp/iter_mesh/flip_mesh_2.inc | 12 +- src/libcpp/iter_mesh/iter_divs_2.inc | 14 +- src/libcpp/iter_mesh/iter_divs_3.inc | 4 +- src/libcpp/iter_mesh/iter_dual_2.inc | 6 +- src/libcpp/iter_mesh/iter_dual_3.inc | 4 +- src/libcpp/iter_mesh/iter_flip_2.inc | 6 +- src/libcpp/iter_mesh/iter_flip_3.inc | 4 +- src/libcpp/iter_mesh/iter_mesh_2.hpp | 36 ++-- src/libcpp/iter_mesh/iter_mesh_3.hpp | 4 +- .../iter_mesh/iter_mesh_euclidean_2.hpp | 4 +- .../iter_mesh/iter_mesh_euclidean_3.hpp | 4 +- src/libcpp/iter_mesh/iter_node_1.inc | 4 +- src/libcpp/iter_mesh/iter_node_2.inc | 60 ++++-- src/libcpp/iter_mesh/iter_node_3.inc | 4 +- .../iter_mesh/iter_pred_ellipsoid_3.hpp | 4 +- .../iter_mesh/iter_pred_euclidean_2.hpp | 4 +- src/libcpp/iter_mesh/iter_timers.hpp | 8 +- src/libcpp/iter_mesh/iter_zips_2.inc | 42 ++--- src/libcpp/iter_mesh/iter_zips_3.inc | 4 +- src/libcpp/iter_mesh/move_mesh_2.inc | 166 +++++++++-------- src/libcpp/iter_mesh/part_mesh_2.inc | 97 +++++----- src/libcpp/iter_mesh/sort_mesh_2.inc | 64 ++++--- src/libcpp/itermesh.hpp | 4 +- src/libcpp/mathutil.hpp | 4 +- src/libcpp/mesh_reps/base_complex_k.hpp | 174 ++++++------------ src/libcpp/mesh_reps/hash_complex_k.hpp | 4 +- src/libcpp/mesh_reps/mesh_complex_1.hpp | 4 +- src/libcpp/mesh_reps/mesh_complex_2.hpp | 4 +- src/libcpp/mesh_reps/mesh_complex_3.hpp | 4 +- src/libcpp/mesh_reps/mesh_complex_type_k.hpp | 22 +-- src/libcpp/mesh_reps/tria_complex_1.hpp | 4 +- src/libcpp/mesh_reps/tria_complex_2.hpp | 4 +- src/libcpp/mesh_reps/tria_complex_3.hpp | 4 +- src/libcpp/meshreps.hpp | 4 +- src/libcpp/mpfloats.hpp | 4 +- src/libcpp/parameters/iter_params.hpp | 4 +- src/libcpp/parameters/mesh_params.hpp | 4 +- src/libcpp/predicate/bisect_k.hpp | 4 +- src/libcpp/predicate/inball_k.hpp | 4 +- src/libcpp/predicate/orient_k.hpp | 4 +- src/libcpp/predicate/predicate_k.hpp | 4 +- src/libcpp/rdel_mesh/rdel_base_2.hpp | 45 ++--- src/libcpp/rdel_mesh/rdel_base_3.hpp | 90 ++++----- src/libcpp/rdel_mesh/rdel_complex_2.hpp | 4 +- src/libcpp/rdel_mesh/rdel_complex_3.hpp | 4 +- src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc | 50 ++--- src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc | 86 +++++---- src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc | 61 +++--- src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc | 106 +++++------ src/libcpp/rdel_mesh/rdel_create_init_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_create_init_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_filt_k.hpp | 4 +- src/libcpp/rdel_mesh/rdel_make_2.hpp | 4 +- src/libcpp/rdel_mesh/rdel_make_3.hpp | 4 +- src/libcpp/rdel_mesh/rdel_mesh_2.hpp | 15 +- src/libcpp/rdel_mesh/rdel_mesh_3.hpp | 15 +- src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc | 36 ++-- src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc | 60 +++--- src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp | 4 +- src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp | 4 +- src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp | 6 +- src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp | 10 +- src/libcpp/rdel_mesh/rdel_refine_ball_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_ball_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_base_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_base_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_face_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_face_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_topo_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_refine_topo_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_test_bounds_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_test_bounds_3.inc | 4 +- src/libcpp/rdel_mesh/rdel_timers.hpp | 4 +- src/libcpp/rdel_mesh/rdel_update_face_2.inc | 6 +- src/libcpp/rdel_mesh/rdel_update_face_3.inc | 8 +- src/libcpp/rdel_mesh/rdel_update_topo_2.inc | 4 +- src/libcpp/rdel_mesh/rdel_update_topo_3.inc | 4 +- src/libcpp/rdelmesh.hpp | 4 +- src/libcpp/tessellate.hpp | 4 +- src/libcpp/tessellate/delaunay_scan_tria.inc | 4 +- src/libcpp/tessellate/delaunay_star_void.inc | 4 +- src/libcpp/tessellate/delaunay_tri_k.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_pred_2.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_pred_3.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_pred_4.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_type_2.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_type_3.hpp | 4 +- src/libcpp/tessellate/delaunay_tri_type_4.hpp | 4 +- src/libcpp/tessellate/delaunay_walk_mesh.inc | 4 +- src/libcpp/tessellate/laguerre_tri_pred_2.hpp | 4 +- src/libcpp/tessellate/laguerre_tri_pred_3.hpp | 4 +- src/libcpp/tessellate/laguerre_tri_pred_4.hpp | 4 +- src/libcpp/textutil.hpp | 4 +- src/libcpp/useropts.hpp | 4 +- src/liblib/init_jig_t.hpp | 6 +- src/liblib/init_msh_t.hpp | 4 +- src/liblib/load_jig_t.hpp | 4 +- src/liblib/load_msh_t.hpp | 4 +- src/liblib/save_jig_t.hpp | 4 +- src/liblib/save_msh_t.hpp | 4 +- src/marche.hpp | 8 +- src/msh_copy.hpp | 32 ++-- src/msh_init.hpp | 4 +- src/msh_read.hpp | 4 +- src/msh_save.hpp | 4 +- src/msh_save.inc | 4 +- src/netcdf/ncutil.h | 4 +- src/offset.hpp | 4 +- src/rdt_save.inc | 4 +- src/tri_save.inc | 4 +- src/tripod.hpp | 8 +- uni/test2d_c.c | 4 +- uni/test2s_b.c | 4 +- uni/test3d_c.c | 4 +- 193 files changed, 1367 insertions(+), 1314 deletions(-) diff --git a/example.jig b/example.jig index 229bab2..4ee871a 100644 --- a/example.jig +++ b/example.jig @@ -324,6 +324,26 @@ # OPTM_COST = SKEW-COS +# ---> OPTM_BETA - {default=0.4950} "momentum"-type weight +# for gradient descent updates, such that +# DX' = BETA * DX(K-1) + (1-BETA) * DX(K). +# Momentum typically improves the convergence of mesh +# optimisation. +# + +# OPTM_BETA = 0.3750 + + +# ---> OPTM_ZETA - {default=0.8250} "momentum"-type weight +# for search direction updates, such that +# DX* = ZETA * DX' (K) + (1-ZETA) * DX(K). +# Momentum typically improves the convergence of mesh +# optimisation. +# + +# OPTM_ZETA = 0.7500 + + # ---> OPTM_ITER - {default=16} max. number of mesh optim- # isation iterations. Set ITER=N to see progress after # N iterations. diff --git a/inc/jigsaw_const.h b/inc/jigsaw_const.h index 220a5f8..7a413ad 100644 --- a/inc/jigsaw_const.h +++ b/inc/jigsaw_const.h @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/inc/jigsaw_jig_t.h b/inc/jigsaw_jig_t.h index f1b6e15..4efce4f 100644 --- a/inc/jigsaw_jig_t.h +++ b/inc/jigsaw_jig_t.h @@ -22,8 +22,8 @@ * 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 + * 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: @@ -412,11 +412,11 @@ /* -------------------------------------------------------- - * OPTM_BETA - {default=0.4950} "momentum"-type biases - * for gradient descent updates, such that + * OPTM_BETA - {default=0.4950} "momentum"-type weight + * for gradient descent updates, such that * DX' = BETA * DX(K-1) + (1-BETA) * DX(K). * Momentum typically improves the convergence of mesh - * optimisation. + * optimisation. -------------------------------------------------------- */ @@ -424,11 +424,11 @@ /* -------------------------------------------------------- - * OPTM_ZETA - {default=0.7500} "momentum"-type biases - * for search direction updates, such that + * OPTM_ZETA - {default=0.8250} "momentum"-type weight + * for search direction updates, such that * DX* = ZETA * DX' (K) + (1-ZETA) * DX(K). * Momentum typically improves the convergence of mesh - * optimisation. + * optimisation. -------------------------------------------------------- */ diff --git a/inc/jigsaw_msh_t.h b/inc/jigsaw_msh_t.h index e5ae417..3983de6 100644 --- a/inc/jigsaw_msh_t.h +++ b/inc/jigsaw_msh_t.h @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/inc/lib_jigsaw.h b/inc/lib_jigsaw.h index a6aec2b..2491e2f 100644 --- a/inc/lib_jigsaw.h +++ b/inc/lib_jigsaw.h @@ -41,8 +41,8 @@ * 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 + * 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: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0eaf80e..714e834 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,7 @@ if (DEFINED MSVC_LIKE) endif () if (DEFINED GCXX_LIKE) - add_compile_options (-pedantic -Wall) + add_compile_options (-pedantic -Wall -Wfloat-conversion) endif () if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) diff --git a/src/geo_load.hpp b/src/geo_load.hpp index 1c796e3..23a5986 100644 --- a/src/geo_load.hpp +++ b/src/geo_load.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/hfn_init.hpp b/src/hfn_init.hpp index 2db9670..c6cd93b 100644 --- a/src/hfn_init.hpp +++ b/src/hfn_init.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/hfn_load.hpp b/src/hfn_load.hpp index a45b390..78c543f 100644 --- a/src/hfn_load.hpp +++ b/src/hfn_load.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/hfn_save.inc b/src/hfn_save.inc index 6a7bcdc..678d7ed 100644 --- a/src/hfn_save.inc +++ b/src/hfn_save.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -810,7 +810,7 @@ if (_ffun._ellipsoid_grid_3d. _hmat.count() > +0) { - /*-------------------------- write VALUE data */ + /*-------------------------- write VALUE data */ ncutil::put_var( _jcfg._hfun_file, "value_mat", &_ffun._ellipsoid_grid_3d._hmat [0]) ; diff --git a/src/ini_load.hpp b/src/ini_load.hpp index 5d70d7d..0cb3f2b 100644 --- a/src/ini_load.hpp +++ b/src/ini_load.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/jig_load.hpp b/src/jig_load.hpp index 45cf2d3..bd63937 100644 --- a/src/jig_load.hpp +++ b/src/jig_load.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -525,7 +525,7 @@ if (_jjig._numthread <= 0 ) # ifdef __use_openmp - _jjig._numthread = + _jjig._numthread = omp_get_num_procs(); # else _jjig._numthread = +1 ; diff --git a/src/jig_read.hpp b/src/jig_read.hpp index 501e2c5..aa164d4 100644 --- a/src/jig_read.hpp +++ b/src/jig_read.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/jigsaw.cpp b/src/jigsaw.cpp index 4fed4ce..768eb58 100644 --- a/src/jigsaw.cpp +++ b/src/jigsaw.cpp @@ -70,8 +70,8 @@ * 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 + * 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: @@ -353,7 +353,7 @@ iptr_type _verbosity = 0 ; # ifdef __use_openmp - iptr_type _numthread = + iptr_type _numthread = omp_get_num_procs() ; # else iptr_type _numthread = 1 ; diff --git a/src/jigsaw.hpp b/src/jigsaw.hpp index e6ba8ef..ec541e5 100644 --- a/src/jigsaw.hpp +++ b/src/jigsaw.hpp @@ -41,8 +41,8 @@ * 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 + * 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: @@ -1669,7 +1669,7 @@ /*--------------------------------- setup *.JLOG file */ jlog_text _jlog(_jcfg) ; - + if(!_jcfg._jcfg_file.empty()) { /*--------------------------------- parse *.JCFG file */ @@ -1683,11 +1683,11 @@ return _retv ; } - _jlog._verbosity = + _jlog._verbosity = _jcfg._verbosity ; _jlog.push ( JIGSAW::asciibanner ) ; - + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/src/libcpp/aabb_tree/aabb_mesh_k.hpp b/src/libcpp/aabb_tree/aabb_mesh_k.hpp index 3b3d373..906345a 100644 --- a/src/libcpp/aabb_tree/aabb_mesh_k.hpp +++ b/src/libcpp/aabb_tree/aabb_mesh_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/aabb_tree/aabb_pred_k.hpp b/src/libcpp/aabb_tree/aabb_pred_k.hpp index 2dc557e..3191105 100644 --- a/src/libcpp/aabb_tree/aabb_pred_k.hpp +++ b/src/libcpp/aabb_tree/aabb_pred_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/aabb_tree/aabb_tree_k.hpp b/src/libcpp/aabb_tree/aabb_tree_k.hpp index a1214da..4e7d39a 100644 --- a/src/libcpp/aabb_tree/aabb_tree_k.hpp +++ b/src/libcpp/aabb_tree/aabb_tree_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * ------------------------------------------------------------ * - * Last updated: 18 Dec., 2022 + * Last updated: 30 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -172,7 +172,7 @@ private : /*---------------------- helper - delete a block of nodes */ __inline_call void_type free_node ( - node_data*&_data + __write_ptr(node_data)&_data ) { this-> @@ -184,7 +184,7 @@ /*---------------------- helper - create a block of nodes */ __inline_call void_type make_node ( - node_data*&_data + __write_ptr(node_data)&_data ) { _data = @@ -195,7 +195,7 @@ /*------------------------------- helper - delete an item */ __inline_call void_type free_item ( - item_data *_idat + __write_ptr(item_data) _idat ) { this-> @@ -208,7 +208,7 @@ /*------------------------------- helper - create an item */ __inline_call void_type make_item ( item_type const&_item, - item_data *&_idat + __write_ptr(item_data)&_idat ) { _idat = @@ -220,8 +220,8 @@ /*--------------------- helper - push an item onto a list */ __static_call __inline_call void_type push_item ( - item_data*&_head, - item_data *_item + __write_ptr(item_data)&_head, + __write_ptr(item_data) _item ) { _item->_next = _head ; @@ -231,9 +231,9 @@ /*--------------------- helper - _pop an item from a list */ __static_call __inline_call void_type _pop_item ( - item_data*&_head, - item_data *_item, - item_data *_prev + __write_ptr(item_data)&_head, + __write_ptr(item_data) _item, + __write_ptr(item_data) _prev ) { if (_prev != nullptr ) @@ -272,8 +272,8 @@ // pool'd alloc. takes care of dealloc... __inline_call void_type clear ( - ) - { + ) + { this->_root = nullptr ; this->_size = +0; this->_imax = +0; @@ -384,9 +384,9 @@ { /*------------------------------ find long bbox. axis */ real_type _alen; - _alen = _node->_pmax[_idim] - + _alen = _node->_pmax[_idim] - _node->_pmin[_idim] ; - + _rect[_idim]._alen = _alen ; _rect[_idim]._axis = _idim ; } @@ -403,7 +403,8 @@ _bdim = _rect[_last]._axis ; _blen = this->_long * _rect[_last]._alen ; - return ; + + return ; // exit, no "long" node } /*------------------------------ scan aabb dimensions */ @@ -457,7 +458,7 @@ iter_type _tend , // last of items array to load iptr_type _NPOP = + 32 , // leaf population lim. iptr_type _RULE = window_split , // split scheme - real_type _LONG = +.75 , // "too-long" item lim. + real_type _LONG = +.75 , // "too-long" item lim. real_type _VTOL = +.50 // leaf vol. split lim. ) { @@ -507,7 +508,7 @@ for( ; !this->_work.empty() ; ) { node_type *_pnod = nullptr; - node_data *_ndat = nullptr; + __write_ptr(node_data) _ndat = nullptr; node_type *_rnod = nullptr; node_type *_lnod = nullptr; @@ -518,11 +519,12 @@ iptr_type _lnum = +0 ; iptr_type _rnum = +0 ; - item_data *_next = nullptr; - item_data *_pptr = nullptr; - item_data *_cptr = nullptr; - item_data *_lptr = nullptr; - item_data *_rptr = nullptr; + __write_ptr(item_data) _next = nullptr; + __write_ptr(item_data) _pptr = nullptr; + __write_ptr(item_data) _cptr = nullptr; + __write_ptr(item_data) _lptr = nullptr; + __write_ptr(item_data) _rptr = nullptr; + __write_ptr(item_data) _iptr = nullptr; /*-------------------------- _pop node from stack */ this->_work._pop_tail (_pnod); @@ -541,11 +543,10 @@ { /*---------- split pos. - middle of items in node */ double _SPOS = +0. ; - for(item_data *_iptr = _hptr ; - _iptr != nullptr ; - _iptr = _next ) + for(_iptr = _hptr ; _iptr != nullptr ; + _iptr = _next ) { - _next = _iptr->_next ; + _next = _iptr-> _next ; /*------------------------------- partition items */ if (_iptr->_data .plen (_bdim) > _blen) @@ -572,19 +573,18 @@ // (1+-a)-approx. with probability p // require: 1/a^2 + log(1/p) samples - size_t _nsel = - (size_t) +500 * std::log2(_nnum + 1) + 1 ; + size_t _nsel = + (size_t)(+500 * std::log2(_nnum + 1) + 1) ; size_t _filt = _nnum / _nsel + 1; size_t _njmp = _filt ; size_t _inum = +0; - _sort.clear(); - for(item_data *_iptr = _hptr ; - _iptr != nullptr ; - _iptr = _next , - _inum += +1 ) + _sort.clear(); + for(_iptr = _hptr ; _iptr != nullptr ; + _iptr = _next , + _inum += +1 ) { - _next = _iptr->_next ; + _next = _iptr-> _next ; /*------------------------------- partition items */ if (_iptr->_data .plen (_bdim) > _blen) @@ -610,7 +610,7 @@ if(!_sort.empty()) { algorithms::qsort( - _sort.head(), _sort.tend(), + _sort.head(), _sort.tend(), std::less()) ; _spos = _sort[_sort.count() / 2]; @@ -623,20 +623,19 @@ // (1+-a)-approx. with probability p // require: 1/a^2 + log(1/p) samples - size_t _nsel = - (size_t) +500 * std::log2(_nnum + 1) + 1 ; + size_t _nsel = + (size_t)(+500 * std::log2(_nnum + 1) + 1) ; size_t _filt = _nnum / _nsel + 1; size_t _njmp = _filt ; size_t _inum = +0; double _SPOS = +0. ; - _sort.clear(); - for(item_data *_iptr = _hptr ; - _iptr != nullptr ; - _iptr = _next , - _inum += +1 ) + _sort.clear(); + for(_iptr = _hptr ; _iptr != nullptr ; + _iptr = _next , + _inum += +1 ) { - _next = _iptr->_next ; + _next = _iptr-> _next ; /*------------------------------- partition items */ if (_iptr->_data .plen (_bdim) > _blen) @@ -665,7 +664,7 @@ if(!_sort.empty()) // middle-median blend { algorithms::qsort( - _sort.head(), _sort.tend(), + _sort.head(), _sort.tend(), std::less()) ; _spos = _sort[_sort.count() / 2]; @@ -701,23 +700,24 @@ init_aabb_node (_rnod , _pnod); /*---------- partition list - split on left|right */ - for(item_data *_iptr = _cptr ; - _iptr != nullptr ; - _iptr = _next ) + for(_iptr = _cptr ; _iptr != nullptr ; + _iptr = _next ) { - _next = _iptr->_next ; + _next = _iptr-> _next ; /*------------------------------- partition items */ if (_iptr->_data .pmid (_bdim) > _spos) { push_aabb_node( _rnod, _iptr) ; push_item(_rptr,_iptr); + _rnum += +1 ; } else { push_aabb_node( _lnod, _iptr) ; push_item(_lptr,_iptr); + _lnum += +1 ; } } @@ -923,7 +923,7 @@ /*---------------------------- push items to CCS list */ if (_node->items () != nullptr) { - for (auto + for (auto _item = _node->items() ; _item != nullptr; _item = _item->_next ) @@ -1013,19 +1013,23 @@ { if (this->_root == nullptr) return false ; + containers::array< + node_type* , + allocator> _wset ; + /*----------------- maintain stack of unvisited nodes */ - this->_work.clear() ; + _wset.set_alloc (+64) ; if (_pred(this->_root->_pmin, this->_root->_pmax) ) - this->_work.push_tail(this->_root); + _wset.push_tail (this->_root) ; /*----------------- traverse while _pred remains true */ bool_type _find = false ; - for ( ; !this->_work.empty() ; ) + for ( ; !_wset.empty() ; ) { node_type *_node = nullptr ; - this->_work._pop_tail(_node) ; + _wset._pop_tail(_node) ; if (_node->_hptr!= nullptr ) { @@ -1041,14 +1045,14 @@ _node->lower(0)->_pmin , _node->lower(0)->_pmax ) ) - this->_work.push_tail ( + _wset.push_tail ( _node->lower(0)) ; if (_pred( _node->lower(1)->_pmin , _node->lower(1)->_pmax ) ) - this->_work.push_tail ( + _wset.push_tail ( _node->lower(1)) ; } } diff --git a/src/libcpp/aabb_tree/aabb_type_k.hpp b/src/libcpp/aabb_tree/aabb_type_k.hpp index 11d5ff2..ee52a80 100644 --- a/src/libcpp/aabb_tree/aabb_type_k.hpp +++ b/src/libcpp/aabb_tree/aabb_type_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/aabbtree.hpp b/src/libcpp/aabbtree.hpp index 71b8e84..84af308 100644 --- a/src/libcpp/aabbtree.hpp +++ b/src/libcpp/aabbtree.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/algorithms.hpp b/src/libcpp/algorithms.hpp index f0703f0..cc8aa66 100644 --- a/src/libcpp/algorithms.hpp +++ b/src/libcpp/algorithms.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/algorithms/find.hpp b/src/libcpp/algorithms/find.hpp index bcc573e..1ba8944 100644 --- a/src/libcpp/algorithms/find.hpp +++ b/src/libcpp/algorithms/find.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/algorithms/sort.hpp b/src/libcpp/algorithms/sort.hpp index 68e1b50..5663c97 100644 --- a/src/libcpp/algorithms/sort.hpp +++ b/src/libcpp/algorithms/sort.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -392,7 +392,7 @@ typename pred_type > __normal_call void_type qsort ( // unrolled quick sort - iter_type _head, + iter_type _head, iter_type _tend, // last of sequence to sort pred_type _less // comparison predicate ) @@ -448,7 +448,7 @@ /* find pivot item for current partition */ _mm = pivot(_hh, _tt, _less); - + /* reduce partition around pivot element */ iter_type _ll = _hh + 1; iter_type _rr = _tt - 1; @@ -459,13 +459,13 @@ if (_ll < _rr) { /* swap elements */ - if (_ll == _mm) + if (_ll == _mm) _mm = _rr; else - if (_rr == _mm) + if (_rr == _mm) _mm = _ll; - std::swap(*_ll, + std::swap(*_ll, *_rr) ; } if (_ll <= _rr) @@ -503,7 +503,7 @@ typename pred_type > __normal_call void_type qsift ( // quick select - iter_type _head, + iter_type _head, iter_type _kk, // pos. in sequence to find iter_type _tend, // last of sequence to parition pred_type _less // comparison predicate @@ -515,7 +515,7 @@ do { /* deal with "spec.-case" tiny partition */ - if (_tt - _hh + 1 <= 1) + if (_tt - _hh + 1 <= 1) break ; if (_tt - _hh + 1 == 2) @@ -546,13 +546,13 @@ if (_ll < _rr) { /* swap elements */ - if (_ll == _mm) + if (_ll == _mm) _mm = _rr; else - if (_rr == _mm) + if (_rr == _mm) _mm = _ll; - std::swap(*_ll, + std::swap(*_ll, *_rr) ; } if (_ll <= _rr) diff --git a/src/libcpp/allocators.hpp b/src/libcpp/allocators.hpp index 18e73a2..7f91a32 100644 --- a/src/libcpp/allocators.hpp +++ b/src/libcpp/allocators.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/allocators/alloc_base.hpp b/src/libcpp/allocators/alloc_base.hpp index d6059da..bd78a9b 100644 --- a/src/libcpp/allocators/alloc_base.hpp +++ b/src/libcpp/allocators/alloc_base.hpp @@ -29,8 +29,8 @@ * 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 + * 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: diff --git a/src/libcpp/allocators/alloc_item.hpp b/src/libcpp/allocators/alloc_item.hpp index ab68109..6371849 100644 --- a/src/libcpp/allocators/alloc_item.hpp +++ b/src/libcpp/allocators/alloc_item.hpp @@ -29,8 +29,8 @@ * 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 + * 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: diff --git a/src/libcpp/allocators/alloc_pool.hpp b/src/libcpp/allocators/alloc_pool.hpp index 99dc087..0f03078 100644 --- a/src/libcpp/allocators/alloc_pool.hpp +++ b/src/libcpp/allocators/alloc_pool.hpp @@ -32,8 +32,8 @@ * 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 + * 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: diff --git a/src/libcpp/allocators/alloc_wrap.hpp b/src/libcpp/allocators/alloc_wrap.hpp index c04eeee..81ff04a 100644 --- a/src/libcpp/allocators/alloc_wrap.hpp +++ b/src/libcpp/allocators/alloc_wrap.hpp @@ -30,8 +30,8 @@ * 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 + * 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: diff --git a/src/libcpp/basebase.hpp b/src/libcpp/basebase.hpp index f297273..277b793 100644 --- a/src/libcpp/basebase.hpp +++ b/src/libcpp/basebase.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/containers.hpp b/src/libcpp/containers.hpp index bbe0623..2e2d46f 100644 --- a/src/libcpp/containers.hpp +++ b/src/libcpp/containers.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/containers/array.hpp b/src/libcpp/containers/array.hpp index f916409..904c3f4 100644 --- a/src/libcpp/containers/array.hpp +++ b/src/libcpp/containers/array.hpp @@ -32,12 +32,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/array_iter.hpp b/src/libcpp/containers/array_iter.hpp index cf0cb97..67f1185 100644 --- a/src/libcpp/containers/array_iter.hpp +++ b/src/libcpp/containers/array_iter.hpp @@ -32,12 +32,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/arraylist.hpp b/src/libcpp/containers/arraylist.hpp index 1c8b99b..84e7cfb 100644 --- a/src/libcpp/containers/arraylist.hpp +++ b/src/libcpp/containers/arraylist.hpp @@ -28,12 +28,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/basic_stack.hpp b/src/libcpp/containers/basic_stack.hpp index 6f6d4fb..4d60e89 100644 --- a/src/libcpp/containers/basic_stack.hpp +++ b/src/libcpp/containers/basic_stack.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/block_array.hpp b/src/libcpp/containers/block_array.hpp index 141c8b0..7bff094 100644 --- a/src/libcpp/containers/block_array.hpp +++ b/src/libcpp/containers/block_array.hpp @@ -34,12 +34,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/block_iter.hpp b/src/libcpp/containers/block_iter.hpp index ad8013f..4c4eacf 100644 --- a/src/libcpp/containers/block_iter.hpp +++ b/src/libcpp/containers/block_iter.hpp @@ -34,12 +34,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/double_list.hpp b/src/libcpp/containers/double_list.hpp index 56bf71f..676537c 100644 --- a/src/libcpp/containers/double_list.hpp +++ b/src/libcpp/containers/double_list.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/doubleiter.hpp b/src/libcpp/containers/doubleiter.hpp index 7e3e5c8..a9fef6d 100644 --- a/src/libcpp/containers/doubleiter.hpp +++ b/src/libcpp/containers/doubleiter.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/fixed_array.hpp b/src/libcpp/containers/fixed_array.hpp index 9240f71..2db557d 100644 --- a/src/libcpp/containers/fixed_array.hpp +++ b/src/libcpp/containers/fixed_array.hpp @@ -28,12 +28,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/hashtable.hpp b/src/libcpp/containers/hashtable.hpp index aca9678..a403e1b 100644 --- a/src/libcpp/containers/hashtable.hpp +++ b/src/libcpp/containers/hashtable.hpp @@ -28,12 +28,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/hashtwice.hpp b/src/libcpp/containers/hashtwice.hpp index cb3371a..56d6d8c 100644 --- a/src/libcpp/containers/hashtwice.hpp +++ b/src/libcpp/containers/hashtwice.hpp @@ -31,12 +31,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/iter_base.hpp b/src/libcpp/containers/iter_base.hpp index 6b5f32f..46c0a7a 100644 --- a/src/libcpp/containers/iter_base.hpp +++ b/src/libcpp/containers/iter_base.hpp @@ -1,45 +1,49 @@ - /* - -------------------------------------------------------- - * a bit of template meta-magic on iterator types. - -------------------------------------------------------- - * - * This program may be freely redistributed under the - * condition that the copyright notices (including this - * entire header) are not removed, and no compensation - * is received through use of the software. Private, - * research, and institutional use is free. You may - * distribute modified versions of this code UNDER THE - * CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE - * TO IT IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE - * ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE - * MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR - * NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution - * of this code as part of a commercial system is - * permissible ONLY BY DIRECT ARRANGEMENT WITH THE - * AUTHOR. (If you are not directly supplying this - * code to a customer, and you are instead telling them - * how they can obtain it for free, then you are not - * required to make any arrangement with me.) - * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. - * - -------------------------------------------------------- - * - * Last updated: 03 May, 2017 - * - * Copyright 2013-2017 - * Darren Engwirda - * d.engwirda@gmail.com - * https://github.com/dengwirda/ - * - -------------------------------------------------------- - */ +/* +------------------------------------------------------------ + * a bit of template meta-magic on iterator types. +------------------------------------------------------------ + * + * 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: 03 May, 2017 + * + * Copyright 2013-2017 + * Darren Engwirda + * d.engwirda@gmail.com + * https://github.com/dengwirda/ + * +------------------------------------------------------------ + */ # pragma once diff --git a/src/libcpp/containers/priorityidx.hpp b/src/libcpp/containers/priorityidx.hpp index 6b03666..1948807 100644 --- a/src/libcpp/containers/priorityidx.hpp +++ b/src/libcpp/containers/priorityidx.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * @@ -134,7 +138,7 @@ /*------------- helper - set "null" item marker as maxint */ __static_call __inline_call iptr_type const null ( - ) + ) { return std::numeric_limits::max() ; } @@ -411,11 +415,11 @@ data_type const&_data ) {/*---------------- make room for new item in mapping */ - iptr_type _size = + iptr_type _size = (iptr_type) this->_keys .count() ; if (_size <= _kpos) - this->_keys.set_count( - _kpos + 1 , + this->_keys.set_count( + _kpos + 1 , containers::loose_alloc, null()); if (this->_keys[_kpos] != null()) @@ -437,7 +441,7 @@ __copy(data_type, _data) ; /*------------------------- map _item to _data "hole" */ - this->_keys[_kpos] = + this->_keys[_kpos] = (iptr_type)( _ipos - this->_heap.head()) ; } @@ -447,11 +451,11 @@ data_type && _data ) {/*---------------- make room for new item in mapping */ - iptr_type _size = + iptr_type _size = (iptr_type) this->_keys .count() ; if (_size <= _kpos) - this->_keys.set_count( - _kpos + 1 , + this->_keys.set_count( + _kpos + 1 , containers::loose_alloc, null()); if (this->_keys[_kpos] != null()) diff --git a/src/libcpp/containers/prioritymap.hpp b/src/libcpp/containers/prioritymap.hpp index 27648a2..1ce5e74 100644 --- a/src/libcpp/containers/prioritymap.hpp +++ b/src/libcpp/containers/prioritymap.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/priorityset.hpp b/src/libcpp/containers/priorityset.hpp index b8e4b6b..af5911a 100644 --- a/src/libcpp/containers/priorityset.hpp +++ b/src/libcpp/containers/priorityset.hpp @@ -30,12 +30,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/single_list.hpp b/src/libcpp/containers/single_list.hpp index f4e0649..3fc278e 100644 --- a/src/libcpp/containers/single_list.hpp +++ b/src/libcpp/containers/single_list.hpp @@ -32,12 +32,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/containers/singleiter.hpp b/src/libcpp/containers/singleiter.hpp index 3a681de..39b53fd 100644 --- a/src/libcpp/containers/singleiter.hpp +++ b/src/libcpp/containers/singleiter.hpp @@ -32,12 +32,16 @@ * how they can obtain it for free, then you are not * required to make any arrangement with me.) * - * Disclaimer: Neither I nor: Columbia University, The - * Massachusetts Institute of Technology, The - * University of Sydney, nor The National Aeronautics - * and Space Administration warrant this code in any - * way whatsoever. This code is provided "as-is" to be - * used at your own risk. + * 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 * ------------------------------------------------------------ * diff --git a/src/libcpp/expansion/dd_float.hpp b/src/libcpp/expansion/dd_float.hpp index 5ddba25..c94bd39 100644 --- a/src/libcpp/expansion/dd_float.hpp +++ b/src/libcpp/expansion/dd_float.hpp @@ -37,8 +37,8 @@ * 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 + * 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: diff --git a/src/libcpp/expansion/ia_float.hpp b/src/libcpp/expansion/ia_float.hpp index 0d4b5f8..1d2cc80 100644 --- a/src/libcpp/expansion/ia_float.hpp +++ b/src/libcpp/expansion/ia_float.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/expansion/mp_basic.hpp b/src/libcpp/expansion/mp_basic.hpp index aa15870..66262e5 100644 --- a/src/libcpp/expansion/mp_basic.hpp +++ b/src/libcpp/expansion/mp_basic.hpp @@ -50,8 +50,8 @@ * 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 + * 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: diff --git a/src/libcpp/expansion/mp_float.hpp b/src/libcpp/expansion/mp_float.hpp index ac04050..5610954 100644 --- a/src/libcpp/expansion/mp_float.hpp +++ b/src/libcpp/expansion/mp_float.hpp @@ -46,8 +46,8 @@ * 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 + * 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: diff --git a/src/libcpp/expansion/mp_utils.hpp b/src/libcpp/expansion/mp_utils.hpp index d7d0621..5720a03 100644 --- a/src/libcpp/expansion/mp_utils.hpp +++ b/src/libcpp/expansion/mp_utils.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_base/cell_ball_k.hpp b/src/libcpp/geom_base/cell_ball_k.hpp index cb94df4..3fa289f 100644 --- a/src/libcpp/geom_base/cell_ball_k.hpp +++ b/src/libcpp/geom_base/cell_ball_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_base/cell_base_k.hpp b/src/libcpp/geom_base/cell_base_k.hpp index d6e6c0f..fd4ad37 100644 --- a/src/libcpp/geom_base/cell_base_k.hpp +++ b/src/libcpp/geom_base/cell_base_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -588,14 +588,14 @@ // -ve due to ccw sign of vectors real_type _dd11 = geometry::dot_2d( - _vv31, _vv12) / _ll31 / _ll12 ; + _vv31, _vv12) / _ll31 / _ll12 ; real_type _dd22 = geometry::dot_2d( _vv12, _vv23) / _ll12 / _ll23 ; real_type _dd33 = geometry::dot_2d( _vv23, _vv31) / _ll23 / _ll31 ; - + _dd11 += (real_type)+ 1./2. ; _dd22 += (real_type)+ 1./2. ; _dd33 += (real_type)+ 1./2. ; @@ -646,7 +646,7 @@ real_type _dd33 = geometry::dot_3d( _vv23, _vv31) / _ll23 / _ll31 ; - + _dd11 += (real_type)+ 1./2. ; _dd22 += (real_type)+ 1./2. ; _dd33 += (real_type)+ 1./2. ; @@ -711,7 +711,7 @@ real_type _r3 = _m3[2] ; real_type _rb = // chara.-length - (_r1+_r2+_r3) / (real_type)+3. ; + std::pow( _r1 * _r2 * _r3, 1./3.) ; real_type _qb = _lb / _rb ; @@ -773,7 +773,7 @@ real_type _r3 = _m3[3] ; real_type _rb = // chara.-length - (_r1+_r2+_r3) / (real_type)+3. ; + std::pow( _r1 * _r2 * _r3, 1./3.) ; real_type _qb = _lb / _rb ; diff --git a/src/libcpp/geom_base/intersect_k.hpp b/src/libcpp/geom_base/intersect_k.hpp index bad6ce8..c6b6442 100644 --- a/src/libcpp/geom_base/intersect_k.hpp +++ b/src/libcpp/geom_base/intersect_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_base/vect_base_k.hpp b/src/libcpp/geom_base/vect_base_k.hpp index 495a435..29f5daa 100644 --- a/src/libcpp/geom_base/vect_base_k.hpp +++ b/src/libcpp/geom_base/vect_base_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_reps/geom_base_2.hpp b/src/libcpp/geom_reps/geom_base_2.hpp index b521fb0..364c564 100644 --- a/src/libcpp/geom_reps/geom_base_2.hpp +++ b/src/libcpp/geom_reps/geom_base_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_reps/geom_base_3.hpp b/src/libcpp/geom_reps/geom_base_3.hpp index 95ff03f..116aadc 100644 --- a/src/libcpp/geom_reps/geom_base_3.hpp +++ b/src/libcpp/geom_reps/geom_base_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp b/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp index 778e087..b5b9e2c 100644 --- a/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp +++ b/src/libcpp/geom_reps/geom_mesh_ellipsoid_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -2014,7 +2014,7 @@ float _RRAD = (float) _ball. _rrad; - _RRAD *= (+1. + _RTOL) ; + _RRAD *= (1.f + _RTOL) ; /*------------------ call actual intersection testing */ real_type _rmin[3] = { diff --git a/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp b/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp index 8d2b1e7..ae17fff 100644 --- a/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp +++ b/src/libcpp/geom_reps/geom_mesh_euclidean_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -1472,7 +1472,7 @@ float _RRAD = (float) _ball. _rrad; - _RRAD *= (+1. + _RTOL) ; + _RRAD *= (1.f + _RTOL) ; /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; diff --git a/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp b/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp index 733d971..202dcf3 100644 --- a/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp +++ b/src/libcpp/geom_reps/geom_mesh_euclidean_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -2468,7 +2468,7 @@ float _RRAD = (float) _ball. _rrad; - _RRAD *= (+1. + _RTOL) ; + _RRAD *= (1.f + _RTOL) ; /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; @@ -2524,7 +2524,7 @@ float _RRAD = (float) _disc. _rrad; - _RRAD *= (+1. + _RTOL) ; + _RRAD *= (1.f + _RTOL) ; /*------------------ call actual intersection testing */ tree_pred _pred(_PMID, _RRAD) ; diff --git a/src/libcpp/geometry.hpp b/src/libcpp/geometry.hpp index 4d0bc61..8472480 100644 --- a/src/libcpp/geometry.hpp +++ b/src/libcpp/geometry.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geompred.hpp b/src/libcpp/geompred.hpp index 79a50cd..ca78caf 100644 --- a/src/libcpp/geompred.hpp +++ b/src/libcpp/geompred.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/geomreps.hpp b/src/libcpp/geomreps.hpp index 90a7a6f..b979619 100644 --- a/src/libcpp/geomreps.hpp +++ b/src/libcpp/geomreps.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/interpolate.hpp b/src/libcpp/interpolate.hpp index 6e9d2f6..5a15151 100644 --- a/src/libcpp/interpolate.hpp +++ b/src/libcpp/interpolate.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/interpolate/hfun_base_k.hpp b/src/libcpp/interpolate/hfun_base_k.hpp index 451ec78..c637b18 100644 --- a/src/libcpp/interpolate/hfun_base_k.hpp +++ b/src/libcpp/interpolate/hfun_base_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/interpolate/hfun_clip_k.hpp b/src/libcpp/interpolate/hfun_clip_k.hpp index d9322bd..1772655 100644 --- a/src/libcpp/interpolate/hfun_clip_k.hpp +++ b/src/libcpp/interpolate/hfun_clip_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -584,28 +584,28 @@ if (_h1 >=(vals_type)+0. && _h2 >=(vals_type)+0. ) if (eikonal_edge_2d ( - _p1, _p2, _hb , + _p1, _p2, _hb , _h1, _h2, _g1 , _g2) ) _clip = true ; if (_h2 >=(vals_type)+0. && _h3 >=(vals_type)+0. ) if (eikonal_edge_2d ( - _p2, _p3, _hb , + _p2, _p3, _hb , _h2, _h3, _g2 , _g3) ) _clip = true ; if (_h3 >=(vals_type)+0. && _h4 >=(vals_type)+0. ) if (eikonal_edge_2d ( - _p3, _p4, _hb , + _p3, _p4, _hb , _h3, _h4, _g3 , _g4) ) _clip = true ; if (_h4 >=(vals_type)+0. && _h1 >=(vals_type)+0. ) if (eikonal_edge_2d ( - _p4, _p1, _hb , + _p4, _p1, _hb , _h4, _h1, _g4 , _g1) ) _clip = true ; } @@ -635,7 +635,7 @@ { /*---------------------- limit h-values within GRID-4 */ bool_type _clip = false ; - + if (true) { /*--------------------------------- 1st tria ordering */ @@ -751,28 +751,28 @@ if (_h1 >=(vals_type)+0. && _h2 >=(vals_type)+0. ) if (eikonal_edge_3d ( - _p1, _p2, _hb , + _p1, _p2, _hb , _h1, _h2, _g1 , _g2) ) _clip = true ; if (_h2 >=(vals_type)+0. && _h3 >=(vals_type)+0. ) if (eikonal_edge_3d ( - _p2, _p3, _hb , + _p2, _p3, _hb , _h2, _h3, _g2 , _g3) ) _clip = true ; if (_h3 >=(vals_type)+0. && _h4 >=(vals_type)+0. ) if (eikonal_edge_3d ( - _p3, _p4, _hb , + _p3, _p4, _hb , _h3, _h4, _g3 , _g4) ) _clip = true ; if (_h4 >=(vals_type)+0. && _h1 >=(vals_type)+0. ) if (eikonal_edge_3d ( - _p4, _p1, _hb , + _p4, _p1, _hb , _h4, _h1, _g4 , _g1) ) _clip = true ; } @@ -802,7 +802,7 @@ { /*---------------------- limit h-values within GRID-4 */ bool_type _clip = false ; - + if (true) { /*--------------------------------- 1st tria ordering */ diff --git a/src/libcpp/interpolate/hfun_constant_value_k.hpp b/src/libcpp/interpolate/hfun_constant_value_k.hpp index 362c093..0f557a6 100644 --- a/src/libcpp/interpolate/hfun_constant_value_k.hpp +++ b/src/libcpp/interpolate/hfun_constant_value_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp index 5451172..7b3bd24 100644 --- a/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_grid_ellipsoid_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -325,7 +325,7 @@ } } ; - size_t static constexpr _imax = + size_t static constexpr _imax = std::numeric_limits::max() ; containers::priorityidx < @@ -337,7 +337,7 @@ /*-------------------- check matrix size against type */ if (this->_hmat.count() >= _imax) - throw std::out_of_range( + throw std::out_of_range( "hfun.clip: data size limit exceeded"); /*-------------------- init. values for periodic bc's */ @@ -428,7 +428,7 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static _FTOL = + vals_type static _FTOL = (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; @@ -491,13 +491,13 @@ _lpii, _lpjj, _lnod); /*-------------------- skip cells due to sorted order */ - if (_inod != _base && + if (_inod != _base && !ISALIVE(_inod)) continue ; - if (_jnod != _base && + if (_jnod != _base && !ISALIVE(_jnod)) continue ; - if (_knod != _base && + if (_knod != _base && !ISALIVE(_knod)) continue ; - if (_lnod != _base && + if (_lnod != _base && !ISALIVE(_lnod)) continue ; vals_type _hmax; @@ -589,7 +589,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hmat[_inod] = _inew; @@ -597,7 +597,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hmat[_jnod] = _jnew; @@ -605,7 +605,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hmat[_knod] = _knew; @@ -613,7 +613,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hmat[_lnod] = _lnew; @@ -633,7 +633,7 @@ this->_hmat [_inod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_inod] != _iold) _sort.reduce(_pair , _pair) ; } @@ -648,7 +648,7 @@ this->_hmat [_jnod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_jnod] != _jold) _sort.reduce(_pair , _pair) ; } @@ -663,7 +663,7 @@ this->_hmat [_knod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_knod] != _kold) _sort.reduce(_pair , _pair) ; } @@ -678,7 +678,7 @@ this->_hmat [_lnod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_lnod] != _lold) _sort.reduce(_pair , _pair) ; } @@ -705,7 +705,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hmat[_inod] = _inew; @@ -713,7 +713,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hmat[_jnod] = _jnew; @@ -721,7 +721,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hmat[_knod] = _knew; @@ -729,7 +729,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hmat[_lnod] = _lnew; @@ -749,7 +749,7 @@ this->_hmat [_inod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_inod] != _iold) _sort.reduce(_pair , _pair) ; } @@ -764,7 +764,7 @@ this->_hmat [_jnod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_jnod] != _jold) _sort.reduce(_pair , _pair) ; } @@ -779,7 +779,7 @@ this->_hmat [_knod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_knod] != _kold) _sort.reduce(_pair , _pair) ; } @@ -794,7 +794,7 @@ this->_hmat [_lnod] ; if (_sort. - keys(_pair) != _sort.null()) + keys(_pair) != _sort.null()) if (_hmat[_lnod] != _lold) _sort.reduce(_pair , _pair) ; } diff --git a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp index 225e007..0619b53 100644 --- a/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_grid_euclidean_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -180,9 +180,9 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static _FTOL = + vals_type static _FTOL = (vals_type)std::pow( - std::numeric_limits::epsilon(), .75) ; + std::numeric_limits::epsilon(), .75) ; iptr_type IBEG = +0; iptr_type IEND = @@ -249,13 +249,13 @@ _lpii, _lpjj, _lnod); /*-------------------- skip cells due to sorted order */ - if (_inod != _base && + if (_inod != _base && !ISALIVE(_inod)) continue ; - if (_jnod != _base && + if (_jnod != _base && !ISALIVE(_jnod)) continue ; - if (_knod != _base && + if (_knod != _base && !ISALIVE(_knod)) continue ; - if (_lnod != _base && + if (_lnod != _base && !ISALIVE(_lnod)) continue ; vals_type _hmax; @@ -323,7 +323,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hmat[_inod] = _inew; @@ -331,7 +331,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hmat[_jnod] = _jnew; @@ -339,7 +339,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hmat[_knod] = _knew; @@ -347,7 +347,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hmat[_lnod] = _lnew; @@ -375,7 +375,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hmat[_inod] = _inew; @@ -383,7 +383,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hmat[_jnod] = _jnew; @@ -391,7 +391,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hmat[_knod] = _knew; @@ -399,7 +399,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hmat[_lnod] = _lnew; diff --git a/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp b/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp index a9445a9..c56f854 100644 --- a/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp +++ b/src/libcpp/interpolate/hfun_grid_euclidean_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -298,7 +298,7 @@ auto _ipos = this-> null_hint() ; auto _jpos = this-> null_hint() ; auto _kpos = this-> null_hint() ; - + if (this->_xvar == true) { auto _joff = diff --git a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp index 8b89b53..36c3a5a 100644 --- a/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_ellipsoid_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -352,7 +352,7 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static _FTOL = + vals_type static _FTOL = (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; @@ -390,13 +390,13 @@ _mesh. tri3( _cell).node(2); /*-------------------- skip cells due to sorted order */ - if (_inod != _base && + if (_inod != _base && !ISALIVE(_inod)) continue ; - if (_jnod != _base && + if (_jnod != _base && !ISALIVE(_jnod)) continue ; - if (_knod != _base && + if (_knod != _base && !ISALIVE(_knod)) continue ; - + vals_type _hmax; _hmax = this->_hval[_inod] ; _hmax = std::max( @@ -442,7 +442,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -450,7 +450,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -458,7 +458,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -489,7 +489,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -497,7 +497,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -505,7 +505,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -557,7 +557,7 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ @@ -618,13 +618,13 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ __inline_call float operator () ( typename - tree_type::node_type *_lptr, + tree_type::node_type *_lptr, typename tree_type::item_data *_iptr ) diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp index ae612ef..b7c0e56 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -280,7 +280,7 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static _FTOL = + vals_type static _FTOL = (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; @@ -318,13 +318,13 @@ _mesh. tri3( _cell).node(2); /*-------------------- skip cells due to sorted order */ - if (_inod != _base && + if (_inod != _base && !ISALIVE(_inod)) continue ; - if (_jnod != _base && + if (_jnod != _base && !ISALIVE(_jnod)) continue ; - if (_knod != _base && + if (_knod != _base && !ISALIVE(_knod)) continue ; - + vals_type _hmax; _hmax = this->_hval[_inod] ; _hmax = std::max( @@ -370,7 +370,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -378,7 +378,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -386,7 +386,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -417,7 +417,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -425,7 +425,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -433,7 +433,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -485,7 +485,7 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ @@ -546,7 +546,7 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ diff --git a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp index dfed66b..2b5f3e3 100644 --- a/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp +++ b/src/libcpp/interpolate/hfun_mesh_euclidean_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -298,7 +298,7 @@ } /*-------------------- compute h(x) via fast-marching */ - vals_type static _FTOL = + vals_type static _FTOL = (vals_type)std::pow( std::numeric_limits::epsilon(), .75) ; @@ -338,13 +338,13 @@ _mesh. tri4( _cell).node(3); /*-------------------- skip cells due to sorted order */ - if (_inod != _base && + if (_inod != _base && !ISALIVE(_inod)) continue ; - if (_jnod != _base && + if (_jnod != _base && !ISALIVE(_jnod)) continue ; - if (_knod != _base && + if (_knod != _base && !ISALIVE(_knod)) continue ; - if (_lnod != _base && + if (_lnod != _base && !ISALIVE(_lnod)) continue ; vals_type _hmax; @@ -401,7 +401,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -409,7 +409,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -417,7 +417,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -425,7 +425,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hval[_lnod] = _lnew; @@ -459,7 +459,7 @@ // maintains its sorted order if (_sort. - keys(_inod) != _sort.null()) + keys(_inod) != _sort.null()) if ( UPDATED(_inew, _iold) ) { _hval[_inod] = _inew; @@ -467,7 +467,7 @@ } if (_sort. - keys(_jnod) != _sort.null()) + keys(_jnod) != _sort.null()) if ( UPDATED(_jnew, _jold) ) { _hval[_jnod] = _jnew; @@ -475,7 +475,7 @@ } if (_sort. - keys(_knod) != _sort.null()) + keys(_knod) != _sort.null()) if ( UPDATED(_knew, _kold) ) { _hval[_knod] = _knew; @@ -483,7 +483,7 @@ } if (_sort. - keys(_lnod) != _sort.null()) + keys(_lnod) != _sort.null()) if ( UPDATED(_lnew, _lold) ) { _hval[_lnod] = _lnew; @@ -535,7 +535,7 @@ ) : _ppos(_psrc) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ @@ -596,7 +596,7 @@ ::infinity()) , _mesh(_msrc) , _find(false) , - _tpos( + _tpos( hfun_type::null_hint()) {} /*------------------------ call pred. on tree matches */ diff --git a/src/libcpp/iter_mesh/_bfs_mesh_2.inc b/src/libcpp/iter_mesh/_bfs_mesh_2.inc index 7141940..7e35ec3 100644 --- a/src/libcpp/iter_mesh/_bfs_mesh_2.inc +++ b/src/libcpp/iter_mesh/_bfs_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/_zip_mesh_2.inc b/src/libcpp/iter_mesh/_zip_mesh_2.inc index 0e7cac9..ebaad39 100644 --- a/src/libcpp/iter_mesh/_zip_mesh_2.inc +++ b/src/libcpp/iter_mesh/_zip_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -88,7 +88,7 @@ iptr_type _jsrc , iptr_type _ksrc , float _csrc - ) : _inod(_isrc), _jnod(_jsrc), + ) : _inod(_isrc), _jnod(_jsrc), _knod(_ksrc), _cost(_csrc) {} } ; @@ -143,7 +143,7 @@ sort_list _sort ; conn_list _iadj , _jadj, _kadj ; - conn_list _conn , _cset; + conn_list _conn , _cset; conn_list _iset , _jset, _kset ; real_list _qold , _qnew, _qtmp ; @@ -189,7 +189,7 @@ & _jptr->pval(0) , & _kptr->pval(0) ) ; - auto _ndeg = _iptr->ndeg() + + auto _ndeg = _iptr->ndeg() + _jptr->ndeg() + _kptr->ndeg() ; @@ -300,7 +300,7 @@ _imrk, _tadj, _kern, _move, _nnew, _iset, _jset, _kset, - _iadj, _jadj, _kadj, + _iadj, _jadj, _kadj, _cset, _qold, _qnew, _qtmp, _QLIM, _tcpu) ; @@ -443,7 +443,7 @@ & _iptr->pval(0) , & _jptr->pval(0) ) ; - auto _ndeg = _iptr->ndeg() + + auto _ndeg = _iptr->ndeg() + _jptr->ndeg() ; _lsqr *= (float) _ndeg; @@ -604,14 +604,14 @@ /*--------------------- zip//div topo. cell hierarchy */ _zip_fcel( _geom, _mesh, _hfun, - _kern, _hval, - _nset, _mark, _imrk, + _kern, _hval, + _nset, _mark, _imrk, _opts, _QLIM, _DLIM, _nzip, _ndiv, _tcpu) ; _zip_ecel( _geom, _mesh, _hfun, - _kern, _hval, - _nset, _mark, _imrk, + _kern, _hval, + _nset, _mark, _imrk, _opts, _QLIM, _DLIM, _nzip, _ndiv, _tcpu) ; diff --git a/src/libcpp/iter_mesh/cost_mesh_2.inc b/src/libcpp/iter_mesh/cost_mesh_2.inc index 2266099..6e49f3f 100644 --- a/src/libcpp/iter_mesh/cost_mesh_2.inc +++ b/src/libcpp/iter_mesh/cost_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/flip_mesh_2.inc b/src/libcpp/iter_mesh/flip_mesh_2.inc index 801a8c6..4689e43 100644 --- a/src/libcpp/iter_mesh/flip_mesh_2.inc +++ b/src/libcpp/iter_mesh/flip_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -285,7 +285,7 @@ _nflp = (iptr_type) +0 ; - init_mark(_mesh, + init_mark(_mesh, _mark, std::max(+0 , _imrk - 1) ) ; # ifdef __use_timers @@ -333,7 +333,7 @@ # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._init_flip + _tcpu._init_flip += _tcpu.time_span (_ttic, _ttoc) ; # endif//__use_timers @@ -376,7 +376,7 @@ _nflp = (iptr_type) +0 ; - init_mark(_mesh, + init_mark(_mesh, _mark, std::max(+0 , _imrk - 1) ) ; # ifdef __use_timers @@ -422,7 +422,7 @@ # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._init_flip + _tcpu._init_flip += _tcpu.time_span (_ttic, _ttoc) ; # endif//__use_timers diff --git a/src/libcpp/iter_mesh/iter_divs_2.inc b/src/libcpp/iter_mesh/iter_divs_2.inc index 0e8ca03..f38a6ee 100644 --- a/src/libcpp/iter_mesh/iter_divs_2.inc +++ b/src/libcpp/iter_mesh/iter_divs_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -198,10 +198,10 @@ { // try to reduce large vertex valence via refinement - real_type _qerr = (real_type) -1./16. ; + real_type _qerr = (real_type) -1./16. ; _qerr*= std::max (_ierr, _jerr ) ; _qerr/= std::pow (_iout, +1./2.) ; // stop oscl. - _qinc = std::min (_qinc, + _qinc = std::min (_qinc, _qinc + _qerr) ; } @@ -214,7 +214,7 @@ real_type _qerr = (real_type) -1./16. ; _qerr*= std::max (_ierr, _jerr ) ; _qerr/= std::pow (_iout, +1./2.) ; // stop oscl. - _qinc = std::min (_qinc, + _qinc = std::min (_qinc, _qinc + _qerr) ; } @@ -387,9 +387,9 @@ move_node( _geom, _mesh, _hfun, _hval, - _opts, _nptr, _prev, + _opts, _nptr, _prev, _kern, _move, _cnew, - _qtmp, _qdst, + _qtmp, _qdst, _minC, _QLIM, _tcpu) ; if (_move <= +0 ) break; diff --git a/src/libcpp/iter_mesh/iter_divs_3.inc b/src/libcpp/iter_mesh/iter_divs_3.inc index 5d557d5..1b0d8e7 100644 --- a/src/libcpp/iter_mesh/iter_divs_3.inc +++ b/src/libcpp/iter_mesh/iter_divs_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_dual_2.inc b/src/libcpp/iter_mesh/iter_dual_2.inc index f7da6ce..833eebb 100644 --- a/src/libcpp/iter_mesh/iter_dual_2.inc +++ b/src/libcpp/iter_mesh/iter_dual_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -351,7 +351,7 @@ } } - if (_dmin * + if (_dmin * _dmax <=(real_type) +0. ) // check monotone? _DQDW =(real_type) +0. ; diff --git a/src/libcpp/iter_mesh/iter_dual_3.inc b/src/libcpp/iter_mesh/iter_dual_3.inc index 8f13909..88b5dfb 100644 --- a/src/libcpp/iter_mesh/iter_dual_3.inc +++ b/src/libcpp/iter_mesh/iter_dual_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_flip_2.inc b/src/libcpp/iter_mesh/iter_flip_2.inc index 2008705..4d2fad3 100644 --- a/src/libcpp/iter_mesh/iter_flip_2.inc +++ b/src/libcpp/iter_mesh/iter_flip_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -450,5 +450,5 @@ _mesh.push_tri3(_tdat), TRIA3_tag)) ; } - + diff --git a/src/libcpp/iter_mesh/iter_flip_3.inc b/src/libcpp/iter_mesh/iter_flip_3.inc index 8ad2b57..2440e58 100644 --- a/src/libcpp/iter_mesh/iter_flip_3.inc +++ b/src/libcpp/iter_mesh/iter_flip_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_mesh_2.hpp b/src/libcpp/iter_mesh/iter_mesh_2.hpp index 2b191a3..7766ce8 100644 --- a/src/libcpp/iter_mesh/iter_mesh_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -38,7 +38,7 @@ * Last updated: 12 Dec., 2022 * * Copyright 2013-2022 - * Darren Engwirda, + * Darren Engwirda, * Marc Tunnell * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -223,7 +223,7 @@ #include "flip_mesh_2.inc" - + /* -------------------------------------------------------- * _ZIP-MESH: merge/split operations on cells. @@ -231,7 +231,7 @@ */ #include "_zip_mesh_2.inc" - + /*------------------------------ helper: init. marker */ @@ -353,7 +353,7 @@ _cpos < _mesh.tri3().count() ; ++_cpos ) { - auto _cell = + auto _cell = _mesh. tri3().head() + _cpos ; if (_cell->mark() >= +0 ) @@ -381,7 +381,7 @@ _cpos < _mesh.quad().count() ; ++_cpos ) { - auto _cell = + auto _cell = _mesh. quad().head() + _cpos ; if (_cell->mark() >= +0 ) @@ -410,7 +410,7 @@ auto _nprt = omp_get_num_threads(); # pragma omp for ordered schedule(static,1) - for (auto _rank = 0 ; _rank <_nprt; + for (auto _rank = 0 ; _rank <_nprt; ++_rank ) { # pragma omp ordered @@ -474,7 +474,7 @@ mark_list _mark ; init_mark(_mesh, _mark) ; - init_bnds(_mesh, _mark) ; + init_bnds(_mesh, _mark) ; flip_sign(_mesh); @@ -498,7 +498,7 @@ _iter <= _opts.iter(); ++_iter) { /*------------------------------ set-up current iter. */ - init_mark(_mesh , + init_mark(_mesh , _mark,std::max(_iter - 1, +0)) ; _nset.set_count( +0); @@ -509,7 +509,7 @@ size_t _ndiv = +0 ; /*------------------------------ scale quality limits */ - iptr_type _nsub = _iter +0 ; + iptr_type _nsub = _iter +1 ; _nsub = std::min(ITER_MAX_, _nsub) ; @@ -519,8 +519,8 @@ real_type _DLIM = (real_type)+1.-_opts.qtol() ; - real_type _QLIM = std::min( - _opts.qlim(),_QMIN * + real_type _QLIM = std::min ( + _opts.qlim(),_QMIN * (real_type)(0.90 + 0.05 * (_iter - 1))) ; /*------------------------------ 1. CELL GEOM. PASSES */ @@ -555,7 +555,7 @@ move_node( _geom, _mesh , _conn , _hfun, _kern, _hval , _last , _nset, _aset, _mark , - _part, _iter, _isub , + _part, _iter, _isub , _opts, _QLIM, _DLIM , _tcpu); } @@ -624,7 +624,7 @@ move_dual( _geom, _mesh , _conn , _hfun, _hval, _last , _nset, _aset, _mark , - _part, _iter, _isub , + _part, _iter, _isub , _opts, _QLIM, _DLIM , _tcpu); } @@ -762,7 +762,7 @@ _dump.push("\n"); _dump.push(" *core-node: "); _dump.push( - std::to_string(_tcpu._core_node)) ; + std::to_string(_tcpu._core_node)) ; _dump.push("\n"); _dump.push(" *seqs-node: "); _dump.push( @@ -817,11 +817,11 @@ _dump.push(" TOPO-FLIP: "); _dump.push( std::to_string(_tcpu._topo_flip)) ; - _dump.push("\n"); + _dump.push("\n"); _dump.push(" *init-flip: "); _dump.push( std::to_string(_tcpu._init_flip)) ; - _dump.push("\n"); + _dump.push("\n"); _dump.push(" *core-flip: "); _dump.push( std::to_string(_tcpu._core_flip)) ; diff --git a/src/libcpp/iter_mesh/iter_mesh_3.hpp b/src/libcpp/iter_mesh/iter_mesh_3.hpp index c66eceb..ff77988 100644 --- a/src/libcpp/iter_mesh/iter_mesh_3.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp b/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp index 316ffb5..d70b6f2 100644 --- a/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_euclidean_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp b/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp index a2cfca9..30fd6cf 100644 --- a/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_euclidean_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_node_1.inc b/src/libcpp/iter_mesh/iter_node_1.inc index f4e0203..af3b245 100644 --- a/src/libcpp/iter_mesh/iter_node_1.inc +++ b/src/libcpp/iter_mesh/iter_node_1.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_node_2.inc b/src/libcpp/iter_mesh/iter_node_2.inc index e22a70e..0cb0fcc 100644 --- a/src/libcpp/iter_mesh/iter_node_2.inc +++ b/src/libcpp/iter_mesh/iter_node_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 21 Jan., 2022 + * Last updated: 30 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -128,6 +128,9 @@ EVALHFUN( _jnod , _jptr ) EVALHFUN( _knod , _kptr ) + real_type _hbal = _hfun.eval( + &_ball[0], _node->hidx()) ; + real_type _irho = _hval[_imid] / _hval[_inod] ; real_type _jrho = @@ -135,10 +138,14 @@ real_type _krho = _hval[_imid] / _hval[_knod] ; + real_type _0rho = + _hval[_imid] / _hbal ; + real_type _hrho = - _irho * (real_type)1./3. + - _jrho * (real_type)1./3. + - _krho * (real_type)1./3. ; + _irho * (real_type)2./9. + + _jrho * (real_type)2./9. + + _krho * (real_type)2./9. + + _0rho * (real_type)3./9. ; _hrho = _tmag * std::pow(_hrho, +3) ; @@ -242,6 +249,9 @@ EVALHFUN( _knod , _kptr ) EVALHFUN( _lnod , _lptr ) + real_type _hbal = _hfun.eval( + &_ball[0], _node->hidx()) ; + real_type _irho = _hval[_imid] / _hval[_inod] ; real_type _jrho = @@ -251,11 +261,15 @@ real_type _lrho = _hval[_imid] / _hval[_lnod] ; + real_type _0rho = + _hval[_imid] / _hbal ; + real_type _hrho = - _irho * (real_type)1./4. + - _jrho * (real_type)1./4. + - _krho * (real_type)1./4. + - _lrho * (real_type)1./4. ; + _irho * (real_type)2./12 + + _jrho * (real_type)2./12 + + _krho * (real_type)2./12 + + _lrho * (real_type)2./12 + + _0rho * (real_type)4./12 ; _hrho = _qmag * std::pow(_hrho, +3) ; @@ -460,7 +474,7 @@ real_type _lsqr = std::max( _0bal[_last], (real_type) +0.); - EVALHFUN( _inod , _iptr ) + EVALHFUN( _inod , _iptr ) // eval. at node EVALHFUN( _jnod , _jptr ) EVALHFUN( _knod , _kptr ) @@ -478,6 +492,17 @@ _hval[_inod] * (real_type)1./2. + _hval[_knod] * (real_type)1./2. ; + real_type _0val = _hfun.eval( // eval. on dual + &_0bal[0], _node->hidx()) ; + real_type _1val = _hfun.eval( + &_1bal[0], _node->hidx()) ; + real_type _2val = _hfun.eval( + &_2bal[0], _node->hidx()) ; + + _0rho = +.5 * (_0rho + _0val) ; + _1rho = +.5 * (_1rho + _1val) ; + _2rho = +.5 * (_2rho + _2val) ; + _0rho = std::pow( _hval[_inod] / _0rho, +3) ; _1rho = std::pow( @@ -635,7 +660,7 @@ real_type _lsqr = std::max( _0bal[_last], (real_type) +0.); - EVALHFUN( _inod , _iptr ) + EVALHFUN( _inod , _iptr ) // eval. at node EVALHFUN( _jnod , _jptr ) EVALHFUN( _knod , _kptr ) EVALHFUN( _lnod , _lptr ) @@ -655,6 +680,17 @@ _hval[_inod] * (real_type)1./2. + _hval[_lnod] * (real_type)1./2. ; + real_type _0val = _hfun.eval( // eval. on dual + &_0bal[0], _node->hidx()) ; + real_type _1val = _hfun.eval( + &_1bal[0], _node->hidx()) ; + real_type _2val = _hfun.eval( + &_2bal[0], _node->hidx()) ; + + _0rho = +.5 * (_0rho + _0val) ; + _1rho = +.5 * (_1rho + _1val) ; + _2rho = +.5 * (_2rho + _2val) ; + _0rho = std::pow( _hval[_inod] / _0rho, +3) ; _1rho = std::pow( diff --git a/src/libcpp/iter_mesh/iter_node_3.inc b/src/libcpp/iter_mesh/iter_node_3.inc index c592c2d..b2cd660 100644 --- a/src/libcpp/iter_mesh/iter_node_3.inc +++ b/src/libcpp/iter_mesh/iter_node_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp b/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp index 2c30656..4a1176e 100644 --- a/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp +++ b/src/libcpp/iter_mesh/iter_pred_ellipsoid_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp b/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp index b4ee4c5..c89f223 100644 --- a/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp +++ b/src/libcpp/iter_mesh/iter_pred_euclidean_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/iter_timers.hpp b/src/libcpp/iter_mesh/iter_timers.hpp index f845c96..bc6c9fb 100644 --- a/src/libcpp/iter_mesh/iter_timers.hpp +++ b/src/libcpp/iter_mesh/iter_timers.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -64,11 +64,13 @@ double _iter_full = (double ) +0. ; + double _init_iter = (double ) +0. ; + double _move_node = (double ) +0. ; double _init_node = (double ) +0. ; double _core_node = (double ) +0. ; double _seqs_node = (double ) +0. ; - double _para_node = (double ) +0. ; + double _para_node = (double ) +0. ; double _ldir_node = (double ) +0. ; double _lopt_node = (double ) +0. ; diff --git a/src/libcpp/iter_mesh/iter_zips_2.inc b/src/libcpp/iter_mesh/iter_zips_2.inc index 778fcc4..8c93c20 100644 --- a/src/libcpp/iter_mesh/iter_zips_2.inc +++ b/src/libcpp/iter_mesh/iter_zips_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -290,7 +290,7 @@ &_LPTR->pval(+0), true) ; } - for (auto _idim = _last; + for (auto _idim = _last; _idim-- != +0; ) { _ball[_idim] += _MASS * _BALL[_idim] ; @@ -553,11 +553,11 @@ /*--------------------------------- get adjacent cost */ real_type _amin = loop_cost( - _mesh, + _mesh, _iset, _qsrc, cell_kind()) ; real_type _bmin = loop_cost( - _mesh, + _mesh, _jadj, _qsrc, cell_kind()) ; real_type _qmin = @@ -634,10 +634,10 @@ ) ; move_node( _geom, _mesh, - _hfun, _hval, + _hfun, _hval, _opts, _nptr, _prev, _kern, _move, _cset, - _qtmp, _qdst, + _qtmp, _qdst, _minC, _QLIM, _tcpu) ; if (_move <= +0 ) break; @@ -783,7 +783,7 @@ _mesh .node(_jnod).ndeg(TRIA3_tag) ; auto _kdeg = _mesh .node(_knod).ndeg(TRIA3_tag) ; - + if (_nmrk[_inod] < 0) _ideg = 6 ; if (_nmrk[_jnod] < 0) _jdeg = 6 ; if (_nmrk[_knod] < 0) _kdeg = 6 ; @@ -796,12 +796,12 @@ (iptr_type)(_DEG_TRIA3-_kdeg) ; auto _ndeg = _ideg + _jdeg + _kdeg - 3*3 ; - + auto _nerr = (iptr_type)(_DEG_TRIA3-_ndeg) ; auto _dnew = std::abs(_nerr) ; - auto _dnow = std::abs(_ierr) + + auto _dnow = std::abs(_ierr) + std::abs(_jerr) + std::abs(_kerr) ; @@ -820,7 +820,7 @@ pred_type:: proj_node(_geom, _pbal, _pbal); - real_type _isiz, _jsiz, _ksiz ; + real_type _isiz, _jsiz, _ksiz ; real_type _bsiz; _isiz = _hfun.eval( &_iptr->pval(0), _iptr->hidx()) ; @@ -833,13 +833,13 @@ _bsiz = _hfun.eval(_pbal , _hint) ; - real_type _lsqr = + real_type _lsqr = _pbal[_last] * (real_type)+3. ; real_type _hbar = - _isiz * (real_type)(1./6.) + - _jsiz * (real_type)(1./6.) + - _ksiz * (real_type)(1./6.) + - _bsiz * (real_type)(3./6.) ; + _isiz * (real_type)(2./9.) + + _jsiz * (real_type)(2./9.) + + _ksiz * (real_type)(2./9.) + + _bsiz * (real_type)(3./9.) ; /*--------------------------------- exit if too large */ if (_lsqr >= _hbar * _lmax * @@ -867,15 +867,15 @@ /*--------------------------------- get adjacent cost */ real_type _amin = loop_cost( - _mesh, + _mesh, _iset, _qsrc, cell_kind()) ; real_type _bmin = loop_cost( - _mesh, + _mesh, _jadj, _qsrc, cell_kind()) ; real_type _cmin = loop_cost( - _mesh, + _mesh, _kadj, _qsrc, cell_kind()) ; real_type _qmin = @@ -959,10 +959,10 @@ ) ; move_node( _geom, _mesh, - _hfun, _hval, + _hfun, _hval, _opts, _nptr, _prev, _kern, _move, _cset, - _qtmp, _qdst, + _qtmp, _qdst, _minC, _QLIM, _tcpu) ; if (_move <= +0 ) break; diff --git a/src/libcpp/iter_mesh/iter_zips_3.inc b/src/libcpp/iter_mesh/iter_zips_3.inc index 2b75321..3ccada6 100644 --- a/src/libcpp/iter_mesh/iter_zips_3.inc +++ b/src/libcpp/iter_mesh/iter_zips_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/iter_mesh/move_mesh_2.inc b/src/libcpp/iter_mesh/move_mesh_2.inc index 916359e..dfc4ce6 100644 --- a/src/libcpp/iter_mesh/move_mesh_2.inc +++ b/src/libcpp/iter_mesh/move_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -38,7 +38,7 @@ * Last updated: 11 Dec., 2022 * * Copyright 2013-2022 - * Darren Engwirda, + * Darren Engwirda, * Marc Tunnell * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -68,7 +68,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 kern_kind _kern , // optim. kernel selector iptr_type &_move , // > 0 if move successful conn_list &_conn , // list of adj. cells @@ -236,7 +236,7 @@ /*---------------- push update along search direction */ real_type _scal = _SCAL[_iter]; - real_type _zeta = _opts._zeta * + real_type _zeta = _opts._zeta * std::min ((real_type)1.,_scal) ; real_type _beta = _opts._beta ; @@ -245,10 +245,10 @@ pred_type::geom_dims; _idim-- != +0; ) { /*---------------- momentum-type bias for search dir. */ - _step[_idim] = + _step[_idim] = _last[_idim]*((real_type)0.+_beta) + _line[_idim]*((real_type)1.-_beta) ; - + _proj[_idim] = _save[_idim] + _scal * ( _step[_idim]*((real_type)0.+_zeta) + @@ -266,9 +266,9 @@ } real_type _XTOL = _xtol * _scal; // armijo - real_type _XEPS = _xeps * + real_type _XEPS = _xeps * std::min ((real_type)1.,_scal) ; - + real_type _lmov = pred_type::length_sq(_save, _proj) ; @@ -393,7 +393,7 @@ real_type _weps = // delta_w ~= 0.0 (real_type)+.01*_opts.qtol() ; - real_type _save = + real_type _save = _node->pval( pred_type::real_dims - 1); @@ -403,7 +403,7 @@ (real_type) +0.50, (real_type) +0.25, (real_type) +.125 } ; - + /*---------------- do backtracking line search iter's */ // ifdef __use_timers @@ -415,17 +415,17 @@ { real_type _scal = _SCAL[_iter]; - real_type _zeta = _opts._zeta * - (real_type)3./4. * + real_type _zeta = _opts._zeta * + (real_type)3./4. * std::min((real_type)1.,_scal) ; real_type _beta = _opts._beta ; /*---------------- momentum-type bias for search dir. */ - _step = + _step = _last * ((real_type)0.+_beta) + _line * ((real_type)1.-_beta) ; - + _node->pval(real_dims-1) = _save + _scal * ( _step * ((real_type)0.+_zeta) + @@ -562,7 +562,7 @@ move_node( _geom, _mesh, _hfun, _hval, _opts, _node, - &_last[ _apos][ +0 ], + &_last[ _apos][ +0 ], _kern, _move, _conn, _qold, _qnew, _QMIN, _QLIM, _tcpu) ; @@ -636,11 +636,12 @@ if (_isub == +0) sort_node(_mesh, _CONN, _aset, - _mark._node, + _mark._node, _iout,_isub, _QLIM, _DLIM, _opts) ; - _pful = std::sqrt(_aset.count ()) / - PART_SCAL ; + _pful =(iptr_type)( + std::sqrt(_aset.count ()) / + PART_SCAL ) ; _pful = std::min( _opts. nprt(), _pful + 1) ; @@ -671,7 +672,7 @@ _CONN , _kern, _last, _nset , _mark, _iout , _opts, - _conn , _qold, _qnew, _QLIM, + _conn , _qold, _qnew, _QLIM, _tcpu ) ; } } @@ -684,7 +685,7 @@ } else { - /*-------------------- multiple-part: thread-parallel */ + /*-------------------- multiple-part: thread-parallel */ # ifdef __use_timers _ttic = _time.now() ; @@ -694,11 +695,12 @@ if (_isub == +0) part_mesh(_mesh, _part._full, _pful, - _aset, + _aset, _isub, _pi*0,_tcpu) ; - _pbnd = _part._full._seqs.count() / - BNDS_SCAL ; + _pbnd =(iptr_type)( + _part._full._seqs.count() / + BNDS_SCAL ) ; _pbnd = std::min( _opts. nprt(), _pbnd + 1) ; @@ -711,7 +713,7 @@ _ttoc = _time.now() ; _tcpu._part_node += _tcpu.time_span(_ttic, _ttoc) ; # endif//__use_timers - + /*-------------------- SYMMETRIC GAUSS-SEIDEL on CELL */ if (_opts .tria()) // 1=>GS, 2=>SGS @@ -721,9 +723,9 @@ _ttic = _time.now() ; # endif//__use_timers - for (auto _apos = + for (auto _apos = _part._bnds._seqs.head(); - _apos != + _apos != _part._bnds._seqs.tend(); _apos += +1) { @@ -732,7 +734,7 @@ _CONN , _kern, _last, _nset , _mark, _iout , _opts, - _conn , _qold, _qnew, _QLIM, + _conn , _qold, _qnew, _QLIM, _tcpu ) ; } @@ -764,21 +766,21 @@ real_list _QOLD, _QNEW; iptr_list _NSET; iptr_type _pass = 0u ; - iptr_type _anum; + iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._bnds._lptr.count()-1; ++_rank) { - for (auto _apos = PBEG(_part. _bnds, + for (auto _apos = PBEG(_part. _bnds, _pass, _rank) ; - _apos != PEND(_part. _bnds, + _apos != PEND(_part. _bnds, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._bnds._list [_apos] ; - if (_part._bnds._part[_anum] < 0) + if (_part._bnds._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -786,7 +788,7 @@ _CONN , _kern, _last, _NSET , _mark, _iout , _opts, - _CSET , _QOLD, _QNEW, _QLIM, + _CSET , _QOLD, _QNEW, _QLIM, _tcpu ) ; } } @@ -823,20 +825,20 @@ iptr_list _NSET; iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._full._lptr.count()-1; ++_rank) { for (auto _pass = 0; _pass < 2; ++_pass) - for (auto _apos = PBEG(_part. _full, + for (auto _apos = PBEG(_part. _full, _pass, _rank) ; - _apos != PEND(_part. _full, + _apos != PEND(_part. _full, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._full._list [_apos] ; - if (_part._full._part[_anum] < 0) + if (_part._full._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -844,7 +846,7 @@ _CONN , _kern, _last, _NSET , _mark, _iout , _opts, - _CSET , _QOLD, _QNEW, _QLIM, + _CSET , _QOLD, _QNEW, _QLIM, _tcpu ) ; } } @@ -880,21 +882,21 @@ real_list _QOLD, _QNEW; iptr_list _NSET; iptr_type _pass = 1u ; - iptr_type _anum; + iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._bnds._lptr.count()-1; ++_rank) { - for (auto _apos = PBEG(_part. _bnds, + for (auto _apos = PBEG(_part. _bnds, _pass, _rank) ; - _apos != PEND(_part. _bnds, + _apos != PEND(_part. _bnds, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._bnds._list [_apos] ; - if (_part._bnds._part[_anum] < 0) + if (_part._bnds._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -902,7 +904,7 @@ _CONN , _kern, _last, _NSET , _mark, _iout , _opts, - _CSET , _QOLD, _QNEW, _QLIM, + _CSET , _QOLD, _QNEW, _QLIM, _tcpu ) ; } } @@ -931,9 +933,9 @@ _ttic = _time.now() ; # endif//__use_timers - for (auto _apos = + for (auto _apos = _part._bnds._seqs.tail(); - _apos != + _apos != _part._bnds._seqs.hend(); _apos += -1) { @@ -942,7 +944,7 @@ _CONN , _kern, _last, _nset , _mark, _iout , _opts, - _conn , _qold, _qnew, _QLIM, + _conn , _qold, _qnew, _QLIM, _tcpu ) ; } @@ -953,7 +955,7 @@ # endif//__use_timers } //if opts.tria - + } //if _nptr > 1 # undef MARK @@ -981,7 +983,7 @@ iptr_list &_nset , // list of nodes active iptr_list &_aset , // space for new active list mark_list &_mark , // sets of node/cell flags - part_data &_part , // mesh parallel partition + part_data &_part , // mesh parallel partition iptr_type _iout , // outer iteration marker iptr_type _isub , // inner iteration marker iter_opts &_opts , // user options @@ -1114,11 +1116,12 @@ if (_isub == +0) sort_node(_mesh, _CONN, _aset, - _mark._node, + _mark._node, _iout,_isub, _QLIM, _DLIM, _opts) ; - _pful = std::sqrt(_aset.count ()) / - PART_SCAL ; + _pful =(iptr_type)( + std::sqrt(_aset.count ()) / + PART_SCAL ) ; _pful = std::min( _opts. nprt(), _pful + 1) ; @@ -1149,7 +1152,7 @@ _CONN , _last, _nset , _mark, _iout , _opts, - _conn , _dold, _dnew, _DLIM, + _conn , _dold, _dnew, _DLIM, _tcpu ) ; } } @@ -1162,7 +1165,7 @@ } else { - /*-------------------- multiple-part: thread-parallel */ + /*-------------------- multiple-part: thread-parallel */ # ifdef __use_timers _ttic = _time.now() ; @@ -1172,11 +1175,12 @@ if (_isub == +0) part_mesh(_mesh, _part._full, _pful, - _aset, + _aset, _isub, _pi*0,_tcpu) ; - _pbnd = _part._full._seqs.count() / - BNDS_SCAL ; + _pbnd =(iptr_type)( + _part._full._seqs.count() / + BNDS_SCAL ) ; _pbnd = std::min( _opts. nprt(), _pbnd + 1) ; @@ -1199,9 +1203,9 @@ _ttic = _time.now() ; # endif//__use_timers - for (auto _apos = + for (auto _apos = _part._bnds._seqs.head(); - _apos != + _apos != _part._bnds._seqs.tend(); _apos += +1) { @@ -1210,7 +1214,7 @@ _CONN , _last, _nset , _mark, _iout , _opts, - _conn , _dold, _dnew, _DLIM, + _conn , _dold, _dnew, _DLIM, _tcpu ) ; } @@ -1242,21 +1246,21 @@ real_list _DOLD, _DNEW; iptr_list _NSET; iptr_type _pass = 0u ; - iptr_type _anum; + iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._bnds._lptr.count()-1; ++_rank) { - for (auto _apos = PBEG(_part. _bnds, + for (auto _apos = PBEG(_part. _bnds, _pass, _rank) ; - _apos != PEND(_part. _bnds, + _apos != PEND(_part. _bnds, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._bnds._list [_apos] ; - if (_part._bnds._part[_anum] < 0) + if (_part._bnds._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -1264,7 +1268,7 @@ _CONN , _last, _NSET , _mark, _iout , _opts, - _CSET , _DOLD, _DNEW, _DLIM, + _CSET , _DOLD, _DNEW, _DLIM, _tcpu ) ; } } @@ -1301,20 +1305,20 @@ iptr_list _NSET; iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._full._lptr.count()-1; ++_rank) { for (auto _pass = 0; _pass < 2; ++_pass) - for (auto _apos = PBEG(_part. _full, + for (auto _apos = PBEG(_part. _full, _pass, _rank) ; - _apos != PEND(_part. _full, + _apos != PEND(_part. _full, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._full._list [_apos] ; - if (_part._full._part[_anum] < 0) + if (_part._full._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -1322,7 +1326,7 @@ _CONN , _last, _NSET , _mark, _iout , _opts, - _CSET , _DOLD, _DNEW, _DLIM, + _CSET , _DOLD, _DNEW, _DLIM, _tcpu ) ; } } @@ -1358,21 +1362,21 @@ real_list _DOLD, _DNEW; iptr_list _NSET; iptr_type _pass = 1u ; - iptr_type _anum; + iptr_type _anum; # pragma omp for nowait schedule(static,1) - for (auto _rank = 0u ; + for (auto _rank = 0u ; _rank < _part._bnds._lptr.count()-1; ++_rank) { - for (auto _apos = PBEG(_part. _bnds, + for (auto _apos = PBEG(_part. _bnds, _pass, _rank) ; - _apos != PEND(_part. _bnds, + _apos != PEND(_part. _bnds, _pass, _rank) ; _apos += ITER(_pass) ) { _anum = _part._bnds._list [_apos] ; - if (_part._bnds._part[_anum] < 0) + if (_part._bnds._part[_anum] < 0) continue ; // skip if interface move_task()(_geom, _mesh, _anum, @@ -1380,7 +1384,7 @@ _CONN , _last, _NSET , _mark, _iout , _opts, - _CSET , _DOLD, _DNEW, _DLIM, + _CSET , _DOLD, _DNEW, _DLIM, _tcpu ) ; } } @@ -1409,9 +1413,9 @@ _ttic = _time.now() ; # endif//__use_timers - for (auto _apos = + for (auto _apos = _part._bnds._seqs.tail(); - _apos != + _apos != _part._bnds._seqs.hend(); _apos += -1) { @@ -1420,7 +1424,7 @@ _CONN , _last, _nset , _mark, _iout , _opts, - _conn , _dold, _dnew, _DLIM, + _conn , _dold, _dnew, _DLIM, _tcpu ) ; } diff --git a/src/libcpp/iter_mesh/part_mesh_2.inc b/src/libcpp/iter_mesh/part_mesh_2.inc index b6642b5..7a6ca27 100644 --- a/src/libcpp/iter_mesh/part_mesh_2.inc +++ b/src/libcpp/iter_mesh/part_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -38,7 +38,7 @@ * Last updated: 23 Dec., 2022 * * Copyright 2013-2022 - * Marc Tunnell, + * Marc Tunnell, * Darren Engwirda * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -86,7 +86,7 @@ __unreferenced(_isub) ; - if (_nprt > +1) + if (_nprt > +1) { /*------ define AABB-tree for recursive partition */ # ifdef __use_timers @@ -104,19 +104,19 @@ tree_type _tree; - auto _npop = // no. nodes per part for nprts - (8 * _aset.count()) / _nprt / 3 ; + iptr_type _npop = // no. nodes per partition + (iptr_type)((8 * _aset.count()) / _nprt / 3) ; /*-------------------- populate tree: xyz + index */ - containers::array _item ; + containers::array _item ; for (auto _apos = _aset.tail() ; _apos != _aset.hend() ; --_apos ) // backward maintains sort? { - auto _aptr = + auto _aptr = _mesh.node().head() + *_apos; - if (_aptr->mark() >= 0 && + if (_aptr->mark() >= 0 && (_aptr->ndeg(TRIA3_tag) > 0 || _aptr->ndeg(QUAD4_tag) > 0 )) { @@ -135,11 +135,11 @@ _xmat[1][0] = +_xsin ; _xmat[1][1] = +_xcos ; - _item.tail()->pval(0) = - _xmat[0][0] * _aptr->pval(0) + + _item.tail()->pval(0) = + _xmat[0][0] * _aptr->pval(0) + _xmat[0][1] * _aptr->pval(1) ; - _item.tail()->pval(1) = - _xmat[1][0] * _aptr->pval(0) + + _item.tail()->pval(1) = + _xmat[1][0] * _aptr->pval(0) + _xmat[1][1] * _aptr->pval(1) ; } else @@ -160,16 +160,16 @@ _xmat[2][1] = +1. - _xcos + _xsin; _xmat[2][2] = +1. ; - _item.tail()->pval(0) = - _xmat[0][0] * _aptr->pval(0) + + _item.tail()->pval(0) = + _xmat[0][0] * _aptr->pval(0) + _xmat[0][1] * _aptr->pval(1) + _xmat[0][2] * _aptr->pval(2) ; - _item.tail()->pval(1) = - _xmat[1][0] * _aptr->pval(0) + + _item.tail()->pval(1) = + _xmat[1][0] * _aptr->pval(0) + _xmat[1][1] * _aptr->pval(1) + _xmat[1][2] * _aptr->pval(2) ; - _item.tail()->pval(2) = - _xmat[2][0] * _aptr->pval(0) + + _item.tail()->pval(2) = + _xmat[2][0] * _aptr->pval(0) + _xmat[2][1] * _aptr->pval(1) + _xmat[2][2] * _aptr->pval(2) ; } @@ -186,7 +186,7 @@ /*-------------------- form sparse lists for part */ - // LIST[LPTR[K]:LPTR[K+1]-1]: list of nodes that + // LIST[LPTR[K]:LPTR[K+1]-1]: list of nodes that // comprise the K-th partition _part._lptr.clear() ; @@ -195,12 +195,12 @@ _part._seqs.clear() ; _tree.dcmp(_part._lptr,_part._list) ; - + # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._tree_part += + _tcpu._tree_part += _tcpu.time_span(_ttic, _ttoc) ; - _tcpu._full_part += + _tcpu._full_part += _tcpu.time_span(_ttic, _ttoc) ; # endif//__use_timers @@ -210,19 +210,20 @@ # endif//__use_timers _part._part.set_count( - _mesh.node().count(), + _mesh.node().count(), containers::loose_alloc, -1) ; // PART[J] = K: the partition for J-th mesh node - for (auto + for (auto _lnum = _part._lptr.count() - 1 ; _lnum-- != 0 ; ) { for (auto _iptr = _part._lptr[_lnum+0]; _iptr < _part._lptr[_lnum+1]; ++_iptr ) - _part._part[_part._list[_iptr]] = _lnum ; + _part._part[ + _part._list[_iptr]] = (iptr_type) _lnum ; } // PART[J] =-1: the J-th node is on an interface @@ -240,16 +241,16 @@ _knod = _tria->node( 2); iptr_type _have = 0; - iptr_type _pmin = + iptr_type _pmin = std::numeric_limits::max() ; - iptr_type _pmax = + iptr_type _pmax = std::numeric_limits::min() ; PART_LIMS(_part._part[_inod]); PART_LIMS(_part._part[_jnod]); PART_LIMS(_part._part[_knod]); - if (_have==0 || _pmin == _pmax) + if (_have==0 || _pmin == _pmax) continue ; _part._part[_inod] = PUSH_BNDS ( @@ -276,9 +277,9 @@ _lnod = _quad->node( 3); iptr_type _have = 0; - iptr_type _pmin = + iptr_type _pmin = std::numeric_limits::max() ; - iptr_type _pmax = + iptr_type _pmax = std::numeric_limits::min() ; PART_LIMS(_part._part[_inod]); @@ -286,7 +287,7 @@ PART_LIMS(_part._part[_knod]); PART_LIMS(_part._part[_lnod]); - if (_have==0 || _pmin == _pmax) + if (_have==0 || _pmin == _pmax) continue ; _part._part[_inod] = PUSH_BNDS ( @@ -302,9 +303,9 @@ # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._part_part += + _tcpu._part_part += _tcpu.time_span(_ttic, _ttoc) ; - _tcpu._full_part += + _tcpu._full_part += _tcpu.time_span(_ttic, _ttoc) ; # endif//__use_timers @@ -325,13 +326,13 @@ # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._seqs_part += + _tcpu._seqs_part += _tcpu.time_span(_ttic, _ttoc) ; - _tcpu._full_part += + _tcpu._full_part += _tcpu.time_span(_ttic, _ttoc) ; # endif//__use_timers - } - else + } + else { /*-------------- dummy part lists for single part */ # ifdef __use_timers @@ -341,7 +342,7 @@ _part._lptr.set_count(+2); _part._list.set_alloc(_aset.count()) ; _part._part.set_count( - _mesh.node().count(), + _mesh.node().count(), containers::loose_alloc, +0) ; _part._lptr[0] = +0; @@ -351,9 +352,9 @@ # ifdef __use_timers _ttoc = _time.now() ; - _tcpu._seqs_part += + _tcpu._seqs_part += _tcpu.time_span(_ttic, _ttoc) ; - _tcpu._full_part += + _tcpu._full_part += _tcpu.time_span(_ttic, _ttoc) ; # endif//__use_timers } @@ -364,23 +365,23 @@ _iter != _mesh.node().tend(); ++_iter, ++_ipos) { - // just for debug: output part idx. to node itag + // just for debug: output part idx. to node itag if (_iter->mark() >= 0) { _iter->itag() = _part._part[_ipos]; } } - - iptr_type _pmin = + + iptr_type _pmin = std::numeric_limits::max(); - iptr_type _pmax = + iptr_type _pmax = std::numeric_limits::min(); for (auto _rank = 0u ; _rank<_part._lptr.count()-1; ++_rank) { // just for debug: output min/max sizes of part's - iptr_type _size = - _part._lptr[_rank+1] - + iptr_type _size = + _part._lptr[_rank+1] - _part._lptr[_rank+0] ; _pmin = std::min(_pmin, _size); _pmax = std::max(_pmax, _size); @@ -391,4 +392,4 @@ # undef PART_LIMS # undef PUSH_BNDS } - + diff --git a/src/libcpp/iter_mesh/sort_mesh_2.inc b/src/libcpp/iter_mesh/sort_mesh_2.inc index 76abe5a..599ffbf 100644 --- a/src/libcpp/iter_mesh/sort_mesh_2.inc +++ b/src/libcpp/iter_mesh/sort_mesh_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -38,7 +38,7 @@ * Last updated: 18 Dec., 2022 * * Copyright 2013-2022 - * Darren Engwirda, + * Darren Engwirda, * Marc Tunnell * d.engwirda@gmail.com * https://github.com/dengwirda/ @@ -58,6 +58,8 @@ __static_call __normal_call void_type pull_conn ( mesh_type &_mesh , // mesh object + iptr_list &_aset , // list of nodes active + iptr_list &_amrk , // >= 0 if nodes active conn_sets &_conn // cached node spacing array ) { @@ -71,19 +73,26 @@ _mesh.node().count() + 1, containers::tight_alloc , +0 ) ; + auto _scal = + ((double)_aset.count()) / + _mesh.node().count() ; + _conn._adj1.set_alloc( - _mesh.edge().count() * 2) ; + (size_t)(_scal * ( + _mesh.edge().count() * 2) ) ) ; _conn._adj2.set_alloc( + (size_t)(_scal * ( _mesh.tri3().count() * 3 + - _mesh.quad().count() * 4) ; + _mesh.quad().count() * 4) ) ) ; iptr_type _npos = +0 ; for (auto _node = _mesh.node().head() ; _node != _mesh.node().tend() ; ++_node, ++_npos) { - if (_node->mark() >= + 0) - { + if (_node->mark() >= 0 && + _amrk[_npos ] >= 0) + { /*-------------------- append adj. lists per node */ _mesh.connect_1( _npos, POINT_tag, _conn._adj1) ; @@ -96,16 +105,16 @@ _conn._idx2[_npos+1] = _conn._adj2.count() ; - } - else - { + } + else + { /*-------------------- empty lists for null nodes */ _conn._idx1[_npos+1] = _conn._idx1[ _npos] ; _conn._idx2[_npos+1] = _conn._idx2[ _npos] ; - } + } } } @@ -166,6 +175,7 @@ containers::array cost_list ; real_list _qbar, _qmin, _cost ; + iptr_list _amrk ; cost_list _sset ; __unreferenced ( _DLIM ) ; @@ -179,8 +189,10 @@ _qmin.set_count( _mesh.node().count(), containers::tight_alloc, +1.0) ; - - pull_conn(_mesh, _CONN) ; + + _amrk.set_count( + _mesh.node().count(), + containers::tight_alloc, -1) ; # ifdef __use_openmp omp_set_num_threads(_opts.nprt()) ; @@ -193,17 +205,17 @@ # pragma omp parallel for schedule(static) \ default(none) \ shared(_mesh, _cost) - for (auto _tpos = +0u ; + for (auto _tpos = +0u ; _tpos < _mesh.tri3().count() ; ++_tpos ) { - auto _tria = + auto _tria = _mesh.tri3().head() + _tpos; if (_tria->mark() >= +0) { /*-------------------- calc. min. scores at cells */ - _cost[_tpos] = + _cost[_tpos] = pred_type::tri3_cost ( &_mesh .node( _tria->node(0)).pval(0), @@ -244,17 +256,17 @@ # pragma omp parallel for schedule(static) \ default(none) \ shared(_mesh, _cost) - for (auto _qpos = +0u ; + for (auto _qpos = +0u ; _qpos < _mesh.quad().count() ; ++_qpos ) { - auto _quad = + auto _quad = _mesh.quad().head() + _qpos; if (_quad->mark() >= +0) { /*-------------------- calc. min. scores at cells */ - _cost[_qpos] = + _cost[_qpos] = pred_type::quad_cost ( &_mesh .node( _quad->node(0)).pval(0), @@ -310,13 +322,13 @@ _nmrk[_ipos]) >= _FLAG || // recent _qmin[_ipos] <= _QLIM ) // skewed { - auto _nadj = + auto _nadj = _node->ndeg(TRIA3_tag) + _node->ndeg(QUAD4_tag) ; - + _nadj = std::max(1, _nadj) ; - float _cval = + float _cval = (float)_qbar[_ipos]/_nadj - (float)_qmin[_ipos] ; @@ -335,9 +347,15 @@ ++_iter ) { /*------------------------ push sorted wrt. min.-cost */ - _aset.push_tail(_iter->_node) ; + auto _spos = _iter->_node ; + _amrk[_spos] = _isub ; + _aset.push_tail(_spos) ; } + /*------------------------ cache adj. for active node */ + pull_conn( + _mesh, _aset, _amrk, _CONN) ; + # undef PUSHCOST } diff --git a/src/libcpp/itermesh.hpp b/src/libcpp/itermesh.hpp index d96f6df..c9eed90 100644 --- a/src/libcpp/itermesh.hpp +++ b/src/libcpp/itermesh.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mathutil.hpp b/src/libcpp/mathutil.hpp index dd2633b..4e717dc 100644 --- a/src/libcpp/mathutil.hpp +++ b/src/libcpp/mathutil.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/base_complex_k.hpp b/src/libcpp/mesh_reps/base_complex_k.hpp index 06fa7f8..a14be4a 100644 --- a/src/libcpp/mesh_reps/base_complex_k.hpp +++ b/src/libcpp/mesh_reps/base_complex_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -1493,7 +1493,7 @@ __unreferenced(_kind); // maybe, per TOPODIM if (_mesh. - _llN1[_npos].mark() < +0 ) + _llN1[_npos].mark() < +0 ) return ; // is already removed if (_itop != -1) @@ -1567,7 +1567,7 @@ __unreferenced(_kind); // maybe, per TOPODIM if (_mesh. - _llE2[_epos].mark() < +0 ) + _llE2[_epos].mark() < +0 ) return ; // is already removed if (_itop == -1) @@ -1664,7 +1664,7 @@ __unreferenced(_kind); // maybe, per TOPODIM if (_mesh. - _llT3[_tpos].mark() < +0 ) + _llT3[_tpos].mark() < +0 ) return ; // is already removed if (_itop == -1) @@ -1775,7 +1775,7 @@ __unreferenced(_kind); // maybe, per TOPODIM if (_mesh. - _llQ4[_qpos].mark() < +0 ) + _llQ4[_qpos].mark() < +0 ) return ; // is already removed if (_itop == -1) @@ -1890,7 +1890,7 @@ __unreferenced(_kind); // maybe, per TOPODIM if (_mesh. - _llT4[_tpos].mark() < +0 ) + _llT4[_tpos].mark() < +0 ) return ; // is already removed if (_itop == -1) @@ -2612,8 +2612,6 @@ { _mesh._tmp1.set_count( +0 ) ; - auto _ioff = _conn.count () ; - switch ( _kind ) { /*-------------------------- init. "source" adj. list */ @@ -2637,28 +2635,20 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _conn.push_tail (*_iadj) ; - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } /*-------------------------- flip d-face marker lists */ - for (auto _iter = _conn.head()+_ioff ; - _iter != _conn.tend() ; - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } + // done! } template < @@ -2675,8 +2665,6 @@ { _mesh._tmp1.set_count( +0 ) ; - auto _ioff = _conn.count () ; - switch ( _kind ) { /*-------------------------- init. "source" adj. list */ @@ -2700,28 +2688,20 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _conn.push_tail (*_iadj) ; - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } /*-------------------------- flip d-face marker lists */ - for (auto _iter = _conn.head()+_ioff ; - _iter != _conn.tend() ; - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } + // done! } /* @@ -2821,15 +2801,16 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _mesh. _tmp2.push_tail (*_iadj); - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } @@ -2867,17 +2848,6 @@ _iter->_cell].mark() = 0 ; } } - - for (auto _iter = _mesh._tmp2.head(); - _iter != _mesh._tmp2.tend(); - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } } template < @@ -2927,15 +2897,16 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _mesh. _tmp2.push_tail (*_iadj); - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } @@ -2988,17 +2959,6 @@ _iter->_cell].mark() = 0 ; } } - - for (auto _iter = _mesh._tmp2.head(); - _iter != _mesh._tmp2.tend(); - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } } /* @@ -3106,15 +3066,16 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _mesh. _tmp2.push_tail (*_iadj); - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } @@ -3187,17 +3148,6 @@ _iter->_cell].mark() = 0 ; } } - - for (auto _iter = _mesh._tmp2.head(); - _iter != _mesh._tmp2.tend(); - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } } template < @@ -3256,15 +3206,16 @@ _mesh._aaN1.tend(_iter->_cell); ++_iadj ) { - if(_iadj->_kind == EDGE2_tag && - _mesh. _llE2[ - _iadj->_cell].mark() == 0) - { + // 1-adj. list is disjoint, guaranteed + // if(_iadj->_kind == EDGE2_tag && + // _mesh. _llE2[ + // _iadj->_cell].mark() == 0) + // { _mesh. _tmp2.push_tail (*_iadj); - _mesh. _llE2[ - _iadj->_cell].mark() += 1; - } + // _mesh. _llE2[ + // _iadj->_cell].mark() += 1; + // } } } @@ -3424,17 +3375,6 @@ _iter->_cell].mark() = 0 ; } } - - for (auto _iter = _mesh._tmp2.head(); - _iter != _mesh._tmp2.tend(); - ++_iter ) - { - if(_iter->_kind == EDGE2_tag) - { - _mesh. _llE2[ - _iter->_cell].mark() = 0 ; - } - } } # undef TOPO_DIMS diff --git a/src/libcpp/mesh_reps/hash_complex_k.hpp b/src/libcpp/mesh_reps/hash_complex_k.hpp index f78b48b..1c70d07 100644 --- a/src/libcpp/mesh_reps/hash_complex_k.hpp +++ b/src/libcpp/mesh_reps/hash_complex_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/mesh_complex_1.hpp b/src/libcpp/mesh_reps/mesh_complex_1.hpp index 022c02b..c769db6 100644 --- a/src/libcpp/mesh_reps/mesh_complex_1.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_1.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/mesh_complex_2.hpp b/src/libcpp/mesh_reps/mesh_complex_2.hpp index 40b2c8b..c6e50fc 100644 --- a/src/libcpp/mesh_reps/mesh_complex_2.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/mesh_complex_3.hpp b/src/libcpp/mesh_reps/mesh_complex_3.hpp index e79ea14..0e41833 100644 --- a/src/libcpp/mesh_reps/mesh_complex_3.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/mesh_complex_type_k.hpp b/src/libcpp/mesh_reps/mesh_complex_type_k.hpp index d911c63..47dece0 100644 --- a/src/libcpp/mesh_reps/mesh_complex_type_k.hpp +++ b/src/libcpp/mesh_reps/mesh_complex_type_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -135,7 +135,7 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } @@ -164,7 +164,7 @@ ) const { size_t _ntot = 0; - for (auto _ipos = 8; _ipos-- != 0 ; ) + for (auto _ipos = 8; _ipos-- != 0 ; ) _ntot += this->_ndeg [_ipos ] ; return _ntot ; @@ -173,7 +173,7 @@ __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } @@ -247,7 +247,7 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } @@ -276,7 +276,7 @@ ) const { size_t _ntot = 0; - for (auto _ipos = 8; _ipos-- != 0 ; ) + for (auto _ipos = 8; _ipos-- != 0 ; ) _ntot += this->_ndeg [_ipos ] ; return _ntot ; @@ -285,7 +285,7 @@ __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } @@ -359,7 +359,7 @@ __inline_call ndeg_type & ndeg ( iptr_type _cell ) - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } @@ -388,7 +388,7 @@ ) const { size_t _ntot = 0; - for (auto _ipos = 8; _ipos-- != 0 ; ) + for (auto _ipos = 8; _ipos-- != 0 ; ) _ntot += this->_ndeg [_ipos ] ; return _ntot ; @@ -397,7 +397,7 @@ __inline_call ndeg_type const& ndeg ( iptr_type _cell ) const - { return + { return this->_ndeg[_tag_to_ndeg (_cell)] ; } diff --git a/src/libcpp/mesh_reps/tria_complex_1.hpp b/src/libcpp/mesh_reps/tria_complex_1.hpp index 7da0279..c05ee19 100644 --- a/src/libcpp/mesh_reps/tria_complex_1.hpp +++ b/src/libcpp/mesh_reps/tria_complex_1.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/tria_complex_2.hpp b/src/libcpp/mesh_reps/tria_complex_2.hpp index 10a7b75..64edff3 100644 --- a/src/libcpp/mesh_reps/tria_complex_2.hpp +++ b/src/libcpp/mesh_reps/tria_complex_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mesh_reps/tria_complex_3.hpp b/src/libcpp/mesh_reps/tria_complex_3.hpp index e9f8a1a..bb98415 100644 --- a/src/libcpp/mesh_reps/tria_complex_3.hpp +++ b/src/libcpp/mesh_reps/tria_complex_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/meshreps.hpp b/src/libcpp/meshreps.hpp index a130ca0..7ca2505 100644 --- a/src/libcpp/meshreps.hpp +++ b/src/libcpp/meshreps.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/mpfloats.hpp b/src/libcpp/mpfloats.hpp index 2d9ce03..367ef28 100644 --- a/src/libcpp/mpfloats.hpp +++ b/src/libcpp/mpfloats.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/parameters/iter_params.hpp b/src/libcpp/parameters/iter_params.hpp index 1aebee7..65bffab 100644 --- a/src/libcpp/parameters/iter_params.hpp +++ b/src/libcpp/parameters/iter_params.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/parameters/mesh_params.hpp b/src/libcpp/parameters/mesh_params.hpp index afbddb4..a1ffa5e 100644 --- a/src/libcpp/parameters/mesh_params.hpp +++ b/src/libcpp/parameters/mesh_params.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/predicate/bisect_k.hpp b/src/libcpp/predicate/bisect_k.hpp index d235613..bb3a730 100644 --- a/src/libcpp/predicate/bisect_k.hpp +++ b/src/libcpp/predicate/bisect_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/predicate/inball_k.hpp b/src/libcpp/predicate/inball_k.hpp index 2306473..fbc7dfe 100644 --- a/src/libcpp/predicate/inball_k.hpp +++ b/src/libcpp/predicate/inball_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/predicate/orient_k.hpp b/src/libcpp/predicate/orient_k.hpp index e82b8d4..fe6505d 100644 --- a/src/libcpp/predicate/orient_k.hpp +++ b/src/libcpp/predicate/orient_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/predicate/predicate_k.hpp b/src/libcpp/predicate/predicate_k.hpp index 19d013f..dfb2b05 100644 --- a/src/libcpp/predicate/predicate_k.hpp +++ b/src/libcpp/predicate/predicate_k.hpp @@ -47,8 +47,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_base_2.hpp b/src/libcpp/rdel_mesh/rdel_base_2.hpp index 1e2e4ca..bc38cb3 100644 --- a/src/libcpp/rdel_mesh/rdel_base_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_base_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -383,27 +383,22 @@ /*--------------------------- test loc. intersections */ auto _iful = _pred._list.tend() ; - auto _imin = _pred._list.tend() ; + auto _imax = _pred._list.tend() ; real_type _RTOL = _rEPS*_radj; - real_type _dmin = - +std::numeric_limits - ::infinity() ; + real_type _dmax = + -std::numeric_limits::infinity() ; real_type _dful = - -std::numeric_limits - ::infinity() ; + -std::numeric_limits::infinity() ; bool_type _safe ; - for (auto _iter = - _pred._list.head() ; - _iter != - _pred._list.tend() ; + for (auto _iter = _pred._list.head() ; + _iter != _pred._list.tend() ; ++_iter ) { - if (clip_dual( _mesh, _hset , - &_iter->pval( 0), - _safe, _RTOL) ) + if (clip_dual( _mesh, _hset, + &_iter->pval(0), _safe, _RTOL) ) { /*--------------------------- prune near-degeneracies */ if(!_safe) @@ -434,10 +429,10 @@ &_iter->pval( 0)) ; /*--------------------------- keep furthest from ball */ - if (_dsqr < _dmin ) + if (_dsqr > _dmax ) { - _dmin = _dsqr ; - _imin = _iter ; + _dmax = _dsqr ; + _imax = _iter ; } if (_dsqr > _dful && @@ -477,17 +472,17 @@ return ( true ) ; } else - if (_imin != _pred._list.tend() ) + if (_imax != _pred._list.tend() ) { /*--------------------------- keep best intersections */ - _sbal[ 0] = _imin->pval(0); - _sbal[ 1] = _imin->pval(1); + _sbal[ 0] = _imax->pval(0); + _sbal[ 1] = _imax->pval(1); - _part = _imin->itag (); - _feat = _imin->feat (); + _part = _imax->itag (); + _feat = _imax->feat (); - _topo[ 0] = _imin->topo(0); - _topo[ 1] = _imin->topo(1); + _topo[ 0] = _imax->topo(0); + _topo[ 1] = _imax->topo(1); /*--------------------------- eval. surf. ball radius */ _sbal[ 2]+= diff --git a/src/libcpp/rdel_mesh/rdel_base_3.hpp b/src/libcpp/rdel_mesh/rdel_base_3.hpp index bd8b7d4..06799d6 100644 --- a/src/libcpp/rdel_mesh/rdel_base_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_base_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -502,27 +502,22 @@ /*--------------------------- test loc. intersections */ auto _iful = _pred._list.tend() ; - auto _imin = _pred._list.tend() ; + auto _imax = _pred._list.tend() ; real_type _RTOL = _rEPS*_radj; - real_type _dmin = - +std::numeric_limits - ::infinity() ; + real_type _dmax = + -std::numeric_limits::infinity() ; real_type _dful = - -std::numeric_limits - ::infinity() ; + -std::numeric_limits::infinity() ; bool_type _safe ; - for (auto _iter = - _pred._list.head() ; - _iter != - _pred._list.tend() ; + for (auto _iter = _pred._list.head() ; + _iter != _pred._list.tend() ; ++_iter ) { - if (clip_dual( _mesh, _hset , - &_iter->pval( 0), - _safe, _RTOL) ) + if (clip_dual( _mesh, _hset, + &_iter->pval(0), _safe, _RTOL) ) { /*--------------------------- prune near-degeneracies */ if(!_safe) @@ -559,10 +554,10 @@ &_iter->pval( 0)) ; /*--------------------------- keep furthest from ball */ - if (_dsqr < _dmin ) + if (_dsqr > _dmax ) { - _dmin = _dsqr ; - _imin = _iter ; + _dmax = _dsqr ; + _imax = _iter ; } if (_dsqr > _dful && @@ -603,18 +598,18 @@ return ( true ) ; } else - if(_imin != _pred._list.tend() ) + if(_imax != _pred._list.tend() ) { /*--------------------------- keep best intersections */ - _sbal[ 0] = _imin->pval(0); - _sbal[ 1] = _imin->pval(1); - _sbal[ 2] = _imin->pval(2); + _sbal[ 0] = _imax->pval(0); + _sbal[ 1] = _imax->pval(1); + _sbal[ 2] = _imax->pval(2); - _part = _imin->itag (); - _feat = _imin->feat (); + _part = _imax->itag (); + _feat = _imax->feat (); - _topo[ 0] = _imin->topo(0); - _topo[ 1] = _imin->topo(1); + _topo[ 0] = _imax->topo(0); + _topo[ 1] = _imax->topo(1); /*--------------------------- eval. surf. ball radius */ _sbal[ 3]+= @@ -846,27 +841,22 @@ /*--------------------------- test loc. intersections */ auto _iful = _pred._list.tend() ; - auto _imin = _pred._list.tend() ; + auto _imax = _pred._list.tend() ; real_type _RTOL = _rEPS*_radj; - real_type _dmin = - +std::numeric_limits - ::infinity() ; + real_type _dmax = + -std::numeric_limits::infinity() ; real_type _dful = - -std::numeric_limits - ::infinity() ; + -std::numeric_limits::infinity() ; bool_type _safe ; - for (auto _iter = - _pred._list.head() ; - _iter != - _pred._list.tend() ; + for (auto _iter = _pred._list.head() ; + _iter != _pred._list.tend() ; ++_iter ) { - if (clip_dual( _mesh, _hset , - &_iter->pval( 0), - _safe, _RTOL) ) + if (clip_dual( _mesh, _hset, + &_iter->pval(0), _safe, _RTOL) ) { /*--------------------------- prune near-degeneracies */ if(!_safe) @@ -898,10 +888,10 @@ &_iter->pval( 0)) ; /*--------------------------- keep furthest from ball */ - if (_dsqr < _dmin ) + if (_dsqr > _dmax ) { - _dmin = _dsqr ; - _imin = _iter ; + _dmax = _dsqr ; + _imax = _iter ; } if (_dsqr > _dful && @@ -946,18 +936,18 @@ return ( true ) ; } else - if(_imin != _pred._list.tend() ) + if(_imax != _pred._list.tend() ) { /*--------------------------- keep best intersections */ - _sbal[ 0] = _imin->pval(0); - _sbal[ 1] = _imin->pval(1); - _sbal[ 2] = _imin->pval(2); + _sbal[ 0] = _imax->pval(0); + _sbal[ 1] = _imax->pval(1); + _sbal[ 2] = _imax->pval(2); - _part = _imin->itag (); - _feat = _imin->feat (); + _part = _imax->itag (); + _feat = _imax->feat (); - _topo[ 0] = _imin->topo(0); - _topo[ 1] = _imin->topo(1); + _topo[ 0] = _imax->topo(0); + _topo[ 1] = _imax->topo(1); /*--------------------------- eval. surf. ball radius */ _sbal[ 3]+= diff --git a/src/libcpp/rdel_mesh/rdel_complex_2.hpp b/src/libcpp/rdel_mesh/rdel_complex_2.hpp index 2bbdac7..f93a07b 100644 --- a/src/libcpp/rdel_mesh/rdel_complex_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_complex_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_complex_3.hpp b/src/libcpp/rdel_mesh/rdel_complex_3.hpp index 13bcfb2..0f5b8d7 100644 --- a/src/libcpp/rdel_mesh/rdel_complex_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_complex_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc b/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc index ca6eb9f..49e3be9 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delaunay_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 01 Aug., 2022 + * Last updated: 29 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -73,7 +73,7 @@ { _kind = mesh::null_item ; - _edat._mark = (iptr_type) +0; + _edat._mark = (iptr_type)+0; if (_args.dims() < +1) return; @@ -94,18 +94,22 @@ /*--------------------------------- is not restricted */ return ; + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_2d(_ebal, _pmax) ; + /*------------------------- calc. refinement priority */ - _edat._cost = - (float)(_pmax[2] + _ebal[2]) ; + _edat._cost = (float) ( + (float)_pmax[2] * (_srat + 1.f ) ) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0. ; - _esiz += (real_type)1./3.*_hfun.eval( + real_type _esiz = (real_type)+0.; + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)1./3.*_hfun.eval( + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -114,23 +118,19 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)1./3. * + _esiz += (real_type)2./4. * _hfun.eval( _pmax, _hint) ; + _srat /= (float)(_esiz * _esiz) ; + real_type _eave =_pmax [ +2] ; _eave /= _esiz * _esiz ; _eave *= (real_type)4./1. ; - /*------------------------- eval. surface-disc.-error */ - real_type _srat = - geometry::lensqr_2d( - _ebal, _pmax)/(_esiz * _esiz) ; - /*------------------------- refinement classification */ // flag cells "trapped" between boundaries -- having - // all nodes on lower dimensional facets and with at - // least one boundary face. + // all nodes on lower dimensional facets... bool_type _trap = _mesh._tria.node(_enod[0])->fdim() < 1 && @@ -171,7 +171,7 @@ { _kind = mesh::null_item ; - _tdat._mark = (iptr_type) +0 ; + _tdat._mark = (iptr_type)+0 ; if (_args.dims() < +2) return ; @@ -261,11 +261,11 @@ # endif /*------------------------- eval. radius--edge ratios */ - real_type _erat = _tbal[ 2] / - _llen[_emin] ; + float _erat = (float) ( + (float)_tbal [2] / _llen [_emin] ) ; /*------------------------- calc. refinement priority */ - _tdat._cost = (float) _erat; + _tdat._cost = (float) _erat; /*------------------------- refinement classification */ @@ -296,17 +296,17 @@ /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. @@ -315,7 +315,7 @@ auto _hint = _mesh._tria.node(_tnod[ 2])->idxh() ; - _tsiz += (real_type)1./4. * + _tsiz += (real_type)3./9. * _hfun.eval( _tbal, _hint) ; real_type _eave = _tbal[ +2] ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc b/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc index 3a4d665..10c2042 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delaunay_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 01 Aug., 2022 + * Last updated: 29 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -73,7 +73,7 @@ { _kind = mesh::null_item ; - _edat._mark = (iptr_type) +0; + _edat._mark = (iptr_type)+0; if (_args.dims() < +1) return; @@ -94,18 +94,22 @@ /*--------------------------------- is not restricted */ return ; + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_3d(_ebal, _pmax) ; + /*------------------------- calc. refinement priority */ - _edat._cost = - (float)(_pmax[3] + _ebal[3]) ; + _edat._cost = (float) ( + (float)_pmax[3] * (_srat + 1.f ) ) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0. ; - _esiz += (real_type)1./3.*_hfun.eval( + real_type _esiz = (real_type)+0.; + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)1./3.*_hfun.eval( + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -114,23 +118,19 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)1./3. * + _esiz += (real_type)2./4. * _hfun.eval( _pmax, _hint) ; + _srat /= (float)(_esiz * _esiz) ; + real_type _eave =_pmax [ +3] ; _eave /= _esiz * _esiz ; _eave *= (real_type)4./1. ; - /*------------------------- eval. surface-disc.-error */ - real_type _srat = - geometry::lensqr_3d( - _ebal, _pmax)/(_esiz * _esiz) ; - /*------------------------- refinement classification */ // flag cells "trapped" between boundaries -- having - // all nodes on lower dimensional facets and with at - // least one boundary face. + // all nodes on lower dimensional facets... bool_type _trap = _mesh._tria.node(_enod[0])->fdim() < 1 && @@ -176,7 +176,7 @@ { _kind = mesh::null_item ; - _fdat._mark = (iptr_type) +0; + _fdat._mark = (iptr_type)+0; if (_args.dims() < +2) return; @@ -262,18 +262,17 @@ } # endif - /*------------------------- eval. radius--edge ratios */ - real_type _prat = _pmax[ 3] / - _llen[_emin] ; - - real_type _erat = _tbal[ 3] / - _llen[_emin] ; + /*------------------------- eval. surface-disc.-error */ + float _srat = (float) + geometry::lensqr_3d(_tbal, _pmax) ; - __unreferenced(_prat); - __unreferenced(_erat); + /*------------------------- eval. radius--edge ratios */ + float _prat = (float) ( + (float)_pmax[3] / _llen[_emin] ) ; /*------------------------- calc. refinement priority */ - _fdat._cost = (float) _prat; + _fdat._cost = (float) ( + (float)_prat * (+1.f + _srat) ) ; /*------------------------- refinement classification */ @@ -304,17 +303,17 @@ /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[0])->pval(0) , _mesh._tria. node(_fnod[0])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[1])->pval(0) , _mesh._tria. node(_fnod[1])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[2])->pval(0) , _mesh._tria. @@ -323,18 +322,15 @@ auto _hint = _mesh._tria.node(_fnod[ 2])->idxh() ; - _tsiz += (real_type)1./4. * + _tsiz += (real_type)3./9. * _hfun.eval( _pmax, _hint) ; + _srat /= (float)(_tsiz * _tsiz) ; + real_type _eave =_pmax [ +3] ; _eave /= _tsiz * _tsiz; _eave *= (real_type)3./1. ; - /*------------------------- eval. surface-disc/-error */ - real_type _srat = - geometry::lensqr_3d( - _tbal, _pmax)/(_tsiz * _tsiz) ; - /*------------------------- refinement classification */ _scal += (real_type)(_trap * 0.100) ; @@ -371,7 +367,7 @@ { _kind = mesh::null_item ; - _tdat._mark = (iptr_type) +0; + _tdat._mark = (iptr_type)+0; if (_args.dims() < +3) return; @@ -504,11 +500,11 @@ # endif /*------------------------- eval. radius--edge ratios */ - real_type _erat = _tbal[ 3] / - _llen[_emin] ; + float _erat = (float) ( + (float)_tbal [3] / _llen [_emin] ) ; /*------------------------- calc. refinement priority */ - _tdat._cost = (float) _erat; + _tdat._cost = (float) _erat; /*------------------------- refinement classification */ @@ -541,22 +537,22 @@ /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. node(_tnod[2])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[3])->pval(0) , _mesh._tria. @@ -565,7 +561,7 @@ auto _hint = _mesh._tria.node(_tnod[ 3])->idxh() ; - _tsiz += (real_type)1./5. * + _tsiz += (real_type)4./16 * _hfun.eval( _tbal, _hint) ; real_type _eave = _tbal[ +3] ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc index b574c7b..2cdd16a 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delfront_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 01 Aug., 2022 + * Last updated: 29 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -73,7 +73,7 @@ { _kind = mesh::null_item ; - _edat._mark = (iptr_type) +0; + _edat._mark = (iptr_type)+0; if (_args.dims() < +1) return; @@ -96,25 +96,20 @@ /*------------------------- eval. surface-disc.-error */ float _srat = (float) - geometry::lensqr_2d(_ebal, _pmax); + geometry::lensqr_2d(_ebal, _pmax) ; /*------------------------- calc. refinement priority */ - _edat._mark += _mesh._tria. - node(_enod[0])->fdim() - 1 ; - _edat._mark += _mesh._tria. - node(_enod[1])->fdim() - 1 ; - - _edat._cost = - (float) _pmax[2] * (_srat + 1.f ); + _edat._cost = (float) ( + (float)_pmax[2] * (_srat + 1.f ) ) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0. ; - _esiz += (real_type)1./3.*_hfun.eval( + real_type _esiz = (real_type)+0.; + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)1./3.*_hfun.eval( + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -123,10 +118,10 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)1./3. * + _esiz += (real_type)2./4. * _hfun.eval( _pmax, _hint) ; - _srat /= _esiz * _esiz ; + _srat /= (float)(_esiz * _esiz) ; real_type _eave =_pmax [ +2] ; _eave /= _esiz * _esiz ; @@ -176,7 +171,7 @@ { _kind = mesh::null_item ; - _tdat._mark = (iptr_type) +0 ; + _tdat._mark = (iptr_type)+0; if (_args.dims() < +2) return ; @@ -261,30 +256,28 @@ } # endif + if ((hash_ball(_tbal) % 3 == +0) && + _nbnd == +0 ) // add quasi-random re-order + _tdat._mark += +1 ; + /*------------------------- eval. radius--edge ratios */ - float _erat = - (float) _tbal[2] / _llen[_emin] ; + float _erat = (float) ( + (float)_tbal [2] / _llen [_emin] ) ; /*------------------------- calc. refinement priority */ - _tdat._cost = - (float)(_tbal[2] * _erat) ; + _tdat._cost = (float) ( + (float)_tbal [2] * _erat ) ; /*------------------------- refinement classification */ // add a scaling with "age" to help prioritise older // cells on the front. - _tdat._cost/= + _tdat._cost/= _mesh._tria._nset.count() + 1 ; - _tdat._cost/= + _tdat._cost/= _mesh._tria._nset.count() + 1 ; - // add a quasi-random scaling to help "break-up" any - // aligned "seam" features. - - _tdat._cost/= - (hash_ball (_tbal) % +3 ) + 1 ; - // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. @@ -312,17 +305,17 @@ /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. @@ -331,7 +324,7 @@ auto _hint = _mesh._tria.node(_tnod[ 2])->idxh() ; - _tsiz += (real_type)1./4. * + _tsiz += (real_type)3./9. * _hfun.eval( _tbal, _hint) ; real_type _eave = _tbal[ +2] ; diff --git a/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc index e699e87..db3c8a4 100644 --- a/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_cost_delfront_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 01 Aug., 2022 + * Last updated: 29 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -73,7 +73,7 @@ { _kind = mesh::null_item ; - _edat._mark = (iptr_type) +0; + _edat._mark = (iptr_type)+0; if (_args.dims() < +1) return; @@ -96,25 +96,20 @@ /*------------------------- eval. surface-disc.-error */ float _srat = (float) - geometry::lensqr_3d(_ebal, _pmax); + geometry::lensqr_3d(_ebal, _pmax) ; /*------------------------- calc. refinement priority */ - _edat._mark += _mesh._tria. - node(_enod[0])->fdim() - 1 ; - _edat._mark += _mesh._tria. - node(_enod[1])->fdim() - 1 ; - - _edat._cost = - (float) _pmax[3] * (_srat + 1.f ); + _edat._cost = (float) ( + (float)_pmax[3] * (_srat + 1.f ) ) ; /*------------------------- eval. size func. at _tbal */ - real_type _esiz = (real_type)+0. ; - _esiz += (real_type)1./3.*_hfun.eval( + real_type _esiz = (real_type)+0.; + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[0])->pval(0) , _mesh._tria. node(_enod[0])->idxh()) ; - _esiz += (real_type)1./3.*_hfun.eval( + _esiz += (real_type)1./4.*_hfun.eval( &_mesh._tria. node(_enod[1])->pval(0) , _mesh._tria. @@ -123,10 +118,10 @@ auto _hint = _mesh._tria.node(_enod[ 1])->idxh() ; - _esiz += (real_type)1./3. * + _esiz += (real_type)2./4. * _hfun.eval( _pmax, _hint) ; - _srat /= _esiz * _esiz ; + _srat /= (float)(_esiz * _esiz) ; real_type _eave =_pmax [ +3] ; _eave /= _esiz * _esiz ; @@ -181,7 +176,7 @@ { _kind = mesh::null_item ; - _fdat._mark = (iptr_type) +0; + _fdat._mark = (iptr_type)+0; if (_args.dims() < +2) return; @@ -267,34 +262,33 @@ } # endif + if ((hash_ball(_pmax) % 3 == +0) && + _nbnd == +0 ) // add quasi-random re-order + _fdat._mark += +1 ; + /*------------------------- eval. surface-disc.-error */ float _srat = (float) - geometry::lensqr_3d(_tbal, _pmax); + geometry::lensqr_3d(_tbal, _pmax) ; /*------------------------- eval. radius--edge ratios */ - float _prat = (float) - _pmax[3] / _llen[_emin] ; + float _prat = (float) ( + (float)_pmax[3] / _llen[_emin] ) ; /*------------------------- calc. refinement priority */ - _fdat._cost = (float) - _pmax[3] * _prat * (1.f + _srat); + _fdat._cost = (float) ( + (float)_pmax[3] * _prat + * (+1.0f + _srat) ) ; /*------------------------- refinement classification */ // add a scaling with "age" to help prioritise older // cells on the front. - _fdat._cost/= + _fdat._cost/= _mesh._tria._nset.count() + 1 ; - _fdat._cost/= + _fdat._cost/= _mesh._tria._nset.count() + 1 ; - // add a quasi-random scaling to help "break-up" any - // aligned "seam" features. - - _fdat._cost/= - (hash_ball (_pmax) % +3 ) + 1 ; - // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. @@ -322,17 +316,17 @@ /*------------------------- eval. size func. at _fbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[0])->pval(0) , _mesh._tria. node(_fnod[0])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[1])->pval(0) , _mesh._tria. node(_fnod[1])->idxh()) ; - _tsiz += (real_type)1./4.*_hfun.eval( + _tsiz += (real_type)2./9.*_hfun.eval( &_mesh._tria. node(_fnod[2])->pval(0) , _mesh._tria. @@ -341,10 +335,10 @@ auto _hint = _mesh._tria.node(_fnod[ 2])->idxh() ; - _tsiz += (real_type)1./4. * + _tsiz += (real_type)3./9. * _hfun.eval( _pmax, _hint) ; - _srat /= _tsiz * _tsiz ; + _srat /= (float)(_tsiz * _tsiz) ; real_type _eave =_pmax [ +3] ; _eave /= _tsiz * _tsiz; @@ -386,7 +380,7 @@ { _kind = mesh::null_item ; - _tdat._mark = (iptr_type) +0 ; + _tdat._mark = (iptr_type)+0; if (_args.dims() < +3) return ; @@ -518,35 +512,33 @@ } # endif + if ((hash_ball(_tbal) % 3 == +0) && + _nbnd == +0 ) // add quasi-random re-order + _tdat._mark += +1 ; + /*------------------------- eval. radius--edge ratios */ - float _erat = - (float) _tbal[3] / _llen[_emin] ; + float _erat = (float) ( + (float)_tbal [3] / _llen [_emin] ) ; - float _frat = - (float) _tbal[3] / _frad[_fmin] ; + float _frat = (float) ( + (float)_tbal [3] / _frad [_fmin] ) ; - float _trat = _erat * _frat; + float _trat = _erat *_frat; /*------------------------- calc. refinement priority */ - _tdat._cost = - (float)(_tbal[3] * _trat) ; + _tdat._cost = (float) ( + (float)_tbal [3] * _trat ) ; /*------------------------- refinement classification */ // add a scaling with "age" to help prioritise older // cells on the front. - _tdat._cost/= + _tdat._cost/= _mesh._tria._nset.count() + 1 ; - _tdat._cost/= + _tdat._cost/= _mesh._tria._nset.count() + 1 ; - // add a quasi-random scaling to help "break-up" any - // aligned "seam" features. - - _tdat._cost/= - (hash_ball (_tbal) % +3 ) + 1 ; - // flag cells "trapped" between boundaries -- having // all nodes on lower dimensional facets and with at // least one boundary face. @@ -576,22 +568,22 @@ /*------------------------- eval. size func. at _tbal */ real_type _tsiz = (real_type)+0.; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[0])->pval(0) , _mesh._tria. node(_tnod[0])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[1])->pval(0) , _mesh._tria. node(_tnod[1])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[2])->pval(0) , _mesh._tria. node(_tnod[2])->idxh()) ; - _tsiz += (real_type)1./5.*_hfun.eval( + _tsiz += (real_type)3./16*_hfun.eval( &_mesh._tria. node(_tnod[3])->pval(0) , _mesh._tria. @@ -600,7 +592,7 @@ auto _hint = _mesh._tria.node(_tnod[ 3])->idxh() ; - _tsiz += (real_type)1./5. * + _tsiz += (real_type)4./16 * _hfun.eval( _tbal, _hint) ; real_type _eave = _tbal [+3] ; diff --git a/src/libcpp/rdel_mesh/rdel_create_init_2.inc b/src/libcpp/rdel_mesh/rdel_create_init_2.inc index 496852d..4695294 100644 --- a/src/libcpp/rdel_mesh/rdel_create_init_2.inc +++ b/src/libcpp/rdel_mesh/rdel_create_init_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_create_init_3.inc b/src/libcpp/rdel_mesh/rdel_create_init_3.inc index f0e7738..367f1f4 100644 --- a/src/libcpp/rdel_mesh/rdel_create_init_3.inc +++ b/src/libcpp/rdel_mesh/rdel_create_init_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_filt_k.hpp b/src/libcpp/rdel_mesh/rdel_filt_k.hpp index 86e9387..0b79f8d 100644 --- a/src/libcpp/rdel_mesh/rdel_filt_k.hpp +++ b/src/libcpp/rdel_mesh/rdel_filt_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_make_2.hpp b/src/libcpp/rdel_mesh/rdel_make_2.hpp index 1eb46fe..1bba337 100644 --- a/src/libcpp/rdel_mesh/rdel_make_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_make_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_make_3.hpp b/src/libcpp/rdel_mesh/rdel_make_3.hpp index 5777dbb..9f5fe4e 100644 --- a/src/libcpp/rdel_mesh/rdel_make_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_make_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_mesh_2.hpp b/src/libcpp/rdel_mesh/rdel_mesh_2.hpp index e0db9ac..f7e5831 100644 --- a/src/libcpp/rdel_mesh/rdel_mesh_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_mesh_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -788,12 +788,13 @@ # ifdef _DEBUG iptr_type _jlog_freq = +250 ; # else - iptr_type _jlog_tens = + iptr_type _jlog_tens = (iptr_type) std::log10(_pass) ; - iptr_type _jlog_freq = - (+5 * std::max(10000, - (iptr_type)std::pow(10, _jlog_tens))) / 2 ; + iptr_type _jlog_freq = // logarithmic updates + (+1 * std::max(10000, + (+5 * std::max(1000, + (iptr_type)std::pow(10, _jlog_tens))) / 2)) ; # endif if(++_pass>_args.iter()) break; @@ -1369,7 +1370,7 @@ _dump.push("\n") ; _dump.push("**FPMATH statistics...\n") ; - + _dump.push(" *orient2Df = ") ; _dump.push(std::to_string( geompred::_nn_calls [ diff --git a/src/libcpp/rdel_mesh/rdel_mesh_3.hpp b/src/libcpp/rdel_mesh/rdel_mesh_3.hpp index 86ae97b..bfb2bd2 100644 --- a/src/libcpp/rdel_mesh/rdel_mesh_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_mesh_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -1005,12 +1005,13 @@ # ifdef _DEBUG iptr_type _jlog_freq = +250 ; # else - iptr_type _jlog_tens = + iptr_type _jlog_tens = (iptr_type) std::log10(_pass) ; - iptr_type _jlog_freq = - (+5 * std::max(10000, - (iptr_type)std::pow(10, _jlog_tens))) / 2 ; + iptr_type _jlog_freq = // logarithmic updates + (+1 * std::max(10000, + (+5 * std::max(1000, + (iptr_type)std::pow(10, _jlog_tens))) / 2)) ; # endif if(++_pass>_args.iter()) break; @@ -1779,7 +1780,7 @@ _dump.push("\n") ; _dump.push("**FPMATH statistics...\n") ; - + _dump.push(" *orient3Df = ") ; _dump.push(std::to_string( geompred::_nn_calls [ diff --git a/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc index cf5740f..37ffab6 100644 --- a/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_offh_delfront_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 03 Aug., 2022 + * Last updated: 28 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -77,7 +77,7 @@ _rtol = (real_type)+1.00E-003 ; real_type static const - _dtol = (real_type)+8.00E-001 ; + _dtol = (real_type)+8.33E-001 ; real_type static const _lgap = (real_type)+8./9. ; @@ -107,7 +107,7 @@ _mesh._tria.node(_enod[0])->pval(1) , } ; - _hint = _HINT = + _hint = _HINT = _mesh._tria.node (_enod[0])->idxh() ; _dvec[ 0] = @@ -160,11 +160,10 @@ if (_dist >= _dvec[2] * _lgap && _dist <= _dvec[2] * _ugap ) { // circumball cushion - _ppos[0]=_sbal[0] ; - _ppos[1]=_sbal[1] ; + _dist = + .5 *(_dist + _dvec[2] ) ; _kind = rdel_opts::offH_kind; - return _kind ; } if (_dist >= _dvec[2] * _ugap ) @@ -254,7 +253,7 @@ (real_type)std::sqrt(3.)/2. ; real_type static const - _dtol = (real_type)+8.00E-001 ; + _dtol = (real_type)+8.33E-001 ; real_type static const _lgap = (real_type)+8./9. ; @@ -273,7 +272,7 @@ &_mesh._tria.node(_fnod[1])->pval(0) , _mesh._tria.node(_fnod[1])->idxh()) ; - _hint = _HINT = + _hint = _HINT = _mesh._tria.node(_fnod[0])->idxh () ; real_type _bias[2] = { @@ -317,10 +316,10 @@ _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hmid = - _hsiz[0] * (real_type)1./6. + - _hsiz[1] * (real_type)1./6. + - _hsiz[2] * (real_type)1./6. + - _hsiz[3] * (real_type)3./6. ; + _hsiz[0] * (real_type)2./9. + + _hsiz[1] * (real_type)2./9. + + _hsiz[2] * (real_type)2./9. + + _hsiz[3] * (real_type)3./9. ; _kind = rdel_opts::offH_kind ; @@ -350,8 +349,8 @@ if (_dist >= _dvec[3]) // off-centre limiter { - _dist = - 2. * _dist * _dvec[3] + _dist = + 2. * _dist * _dvec[3] / (_dist + _dvec[3] ) ; _kind = rdel_opts::offC_kind; @@ -360,11 +359,10 @@ if (_dist >= _dvec[2] * _lgap && _dist <= _dvec[2] * _ugap ) { // circumball cushion - _ppos[0]=_tbal[0] ; - _ppos[1]=_tbal[1] ; + _dist = + .5 *(_dist + _dvec[2] ) ; _kind = rdel_opts::offH_kind; - return _kind ; } if (_dist >= _dvec[2] * _ugap ) diff --git a/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc index 9173175..99072a4 100644 --- a/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_offh_delfront_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -35,7 +35,7 @@ * -------------------------------------------------------- * - * Last updated: 01 Aug., 2022 + * Last updated: 28 Dec., 2022 * * Copyright 2013-2022 * Darren Engwirda @@ -77,7 +77,7 @@ _rtol = (real_type)+1.00E-003 ; real_type static const - _dtol = (real_type)+8.00E-001 ; + _dtol = (real_type)+8.33E-001 ; real_type static const _lgap = (real_type)+8./9. ; @@ -108,7 +108,7 @@ _mesh._tria.node(_enod[0])->pval(2) , } ; - _hint = _HINT = + _hint = _HINT = _mesh._tria.node (_enod[0])->idxh() ; _dvec[ 0] = @@ -167,12 +167,10 @@ if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _ppos[0]=_sbal[0] ; - _ppos[1]=_sbal[1] ; - _ppos[2]=_sbal[2] ; + _dist = + .5 *(_dist + _dvec[3] ) ; _kind = rdel_opts::offH_kind; - return _kind ; } if (_dist >= _dvec[3] * _ugap ) @@ -264,7 +262,7 @@ (real_type)std::sqrt(3.)/2. ; real_type static const - _dtol = (real_type)+8.00E-001 ; + _dtol = (real_type)+8.33E-001 ; real_type static const _lgap = (real_type)+8./9. ; @@ -282,7 +280,7 @@ &_mesh._tria.node(_enod[1])->pval(0) , _mesh._tria.node(_enod[1])->idxh()) ; - _hint = _HINT = + _hint = _HINT = _mesh._tria.node(_enod[0])->idxh () ; real_type _bias[2] = { @@ -350,10 +348,10 @@ _hsiz[3] = _hfun.eval(_PMID, _HINT) ; real_type _hval = - _hsiz[0] * (real_type)1./6. + - _hsiz[1] * (real_type)1./6. + - _hsiz[2] * (real_type)1./6. + - _hsiz[3] * (real_type)3./6. ; + _hsiz[0] * (real_type)2./9. + + _hsiz[1] * (real_type)2./9. + + _hsiz[2] * (real_type)2./9. + + _hsiz[3] * (real_type)3./9. ; real_type _hmin ; _hmin = std::min (_hval , _epsh); @@ -389,8 +387,8 @@ if (_dist >= _dvec[4]) // off-centre limiter { - _dist = - 2. * _dist * _dvec[4] + _dist = + 2. * _dist * _dvec[4] / (_dist + _dvec[4] ) ; _kind = rdel_opts::offC_kind; @@ -399,12 +397,10 @@ if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _ppos[0]=_sbal[0] ; - _ppos[1]=_sbal[1] ; - _ppos[2]=_sbal[2] ; + _dist = + .5 *(_dist + _dvec[3] ) ; _kind = rdel_opts::offH_kind; - return _kind ; } if (_dist >= _dvec[3] * _ugap ) @@ -493,7 +489,7 @@ (real_type)std::sqrt(6.)/3. ; real_type static const - _dtol = (real_type)+8.00E-001 ; + _dtol = (real_type)+8.33E-001 ; real_type static const _lgap = (real_type)+8./9. ; @@ -546,11 +542,11 @@ _hsiz[4] = _hfun.eval(_PMID, _HINT) ; real_type _hmid = - _hsiz[0] * (real_type)1./8. + - _hsiz[1] * (real_type)1./8. + - _hsiz[2] * (real_type)1./8. + - _hsiz[3] * (real_type)1./8. + - _hsiz[4] * (real_type)4./8. ; + _hsiz[0] * (real_type)3./16 + + _hsiz[1] * (real_type)3./16 + + _hsiz[2] * (real_type)3./16 + + _hsiz[3] * (real_type)3./16 + + _hsiz[4] * (real_type)4./16 ; _kind = rdel_opts::offH_kind ; @@ -580,8 +576,8 @@ if (_dist >= _dvec[4]) // off-centre limiter { - _dist = - 2. * _dist * _dvec[4] + _dist = + 2. * _dist * _dvec[4] / (_dist + _dvec[4] ) ; _kind = rdel_opts::offC_kind; @@ -590,12 +586,10 @@ if (_dist >= _dvec[3] * _lgap && _dist <= _dvec[3] * _ugap ) { // circumball cushion - _ppos[0]=_tbal[0] ; - _ppos[1]=_tbal[1] ; - _ppos[2]=_tbal[2] ; + _dist = + .5 *(_dist + _dvec[3] ) ; _kind = rdel_opts::offH_kind; - return _kind ; } if (_dist >= _dvec[3] * _ugap ) diff --git a/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp b/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp index 8fc2dd2..c5c4bd6 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delaunay_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp b/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp index ff16623..392251e 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delaunay_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp b/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp index f05a117..5fea2e6 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delfront_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -460,7 +460,7 @@ _tria.tria(_tpos)->circ(1); _tbal[2] = (real_type)+0. ; - auto _hash = + auto _hash = _mesh._tria._nset.count(); _tbal[2]+= diff --git a/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp b/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp index 8cea204..ed14380 100644 --- a/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp +++ b/src/libcpp/rdel_mesh/rdel_pred_delfront_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -612,7 +612,7 @@ return ( _kind ) ; } - auto _hash = + auto _hash = _mesh._tria._nset.count() ; /*--------------------------------- find edge lengths */ @@ -627,7 +627,7 @@ _enod[ 0] = _fnod[_enod[0]] ; _enod[ 1] = _fnod[_enod[1]] ; - _llen[_enum] = + _llen[_enum] = (float)geometry::lensqr_3d ( &_mesh._tria. node(_enod[0])->pval(0), @@ -851,7 +851,7 @@ _tria.tria(_tpos)->circ(2); _tbal[3] = (real_type)+0. ; - auto _hash = + auto _hash = _mesh._tria._nset.count(); _tbal[3]+= diff --git a/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc b/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc index 085b9cb..a420c1d 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_ball_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc b/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc index 5b88ce9..7bd61d0 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_ball_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_base_2.inc b/src/libcpp/rdel_mesh/rdel_refine_base_2.inc index c93e827..b2a4768 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_base_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_base_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_base_3.inc b/src/libcpp/rdel_mesh/rdel_refine_base_3.inc index 4cf557d..2c3f743 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_base_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_base_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_face_2.inc b/src/libcpp/rdel_mesh/rdel_refine_face_2.inc index 97ea5e2..8fb39f3 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_face_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_face_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_face_3.inc b/src/libcpp/rdel_mesh/rdel_refine_face_3.inc index 0be4e45..d4676d1 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_face_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_face_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc b/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc index fdf047a..2ee2b59 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_topo_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc b/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc index 6ed7115..69dcba4 100644 --- a/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc +++ b/src/libcpp/rdel_mesh/rdel_refine_topo_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc b/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc index 6404533..b387e94 100644 --- a/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc +++ b/src/libcpp/rdel_mesh/rdel_sink_delfront_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc b/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc index 922922f..c144982 100644 --- a/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc +++ b/src/libcpp/rdel_mesh/rdel_sink_delfront_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc b/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc index f8a497e..cec0044 100644 --- a/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc +++ b/src/libcpp/rdel_mesh/rdel_test_bounds_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc b/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc index eeaac68..59b3c63 100644 --- a/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc +++ b/src/libcpp/rdel_mesh/rdel_test_bounds_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_timers.hpp b/src/libcpp/rdel_mesh/rdel_timers.hpp index a7a95fd..e2a3928 100644 --- a/src/libcpp/rdel_mesh/rdel_timers.hpp +++ b/src/libcpp/rdel_mesh/rdel_timers.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_update_face_2.inc b/src/libcpp/rdel_mesh/rdel_update_face_2.inc index 96eecd3..767c3c0 100644 --- a/src/libcpp/rdel_mesh/rdel_update_face_2.inc +++ b/src/libcpp/rdel_mesh/rdel_update_face_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -500,7 +500,7 @@ push_edge(_mesh, _geom , _hfun,*_iter , _edat, _escr , - _mesh. _etwo , + _mesh. _etwo , _nedg, _ndup , _pass, _opts) ; } diff --git a/src/libcpp/rdel_mesh/rdel_update_face_3.inc b/src/libcpp/rdel_mesh/rdel_update_face_3.inc index ada9622..766598f 100644 --- a/src/libcpp/rdel_mesh/rdel_update_face_3.inc +++ b/src/libcpp/rdel_mesh/rdel_update_face_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: @@ -685,7 +685,7 @@ push_edge(_mesh, _geom , _hfun,*_iter , _edat, _escr , - _mesh. _etwo , + _mesh. _etwo , _nedg, _pass, _opts) ; } @@ -704,7 +704,7 @@ push_face(_mesh, _geom , _hfun,*_iter , _fdat, _fscr , - _mesh. _ftwo , + _mesh. _ftwo , _nfac, _ndup , _pass, _opts) ; } diff --git a/src/libcpp/rdel_mesh/rdel_update_topo_2.inc b/src/libcpp/rdel_mesh/rdel_update_topo_2.inc index e11f922..557d71b 100644 --- a/src/libcpp/rdel_mesh/rdel_update_topo_2.inc +++ b/src/libcpp/rdel_mesh/rdel_update_topo_2.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdel_mesh/rdel_update_topo_3.inc b/src/libcpp/rdel_mesh/rdel_update_topo_3.inc index 51cc41e..0ac030e 100644 --- a/src/libcpp/rdel_mesh/rdel_update_topo_3.inc +++ b/src/libcpp/rdel_mesh/rdel_update_topo_3.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/rdelmesh.hpp b/src/libcpp/rdelmesh.hpp index 5cf8f9f..aec8dd0 100644 --- a/src/libcpp/rdelmesh.hpp +++ b/src/libcpp/rdelmesh.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate.hpp b/src/libcpp/tessellate.hpp index 01ba57a..fdffbcc 100644 --- a/src/libcpp/tessellate.hpp +++ b/src/libcpp/tessellate.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_scan_tria.inc b/src/libcpp/tessellate/delaunay_scan_tria.inc index 3ed1f8d..fdaa6cf 100644 --- a/src/libcpp/tessellate/delaunay_scan_tria.inc +++ b/src/libcpp/tessellate/delaunay_scan_tria.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_star_void.inc b/src/libcpp/tessellate/delaunay_star_void.inc index 88fa31b..02a7c1f 100644 --- a/src/libcpp/tessellate/delaunay_star_void.inc +++ b/src/libcpp/tessellate/delaunay_star_void.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_k.hpp b/src/libcpp/tessellate/delaunay_tri_k.hpp index 484529b..fb498a5 100644 --- a/src/libcpp/tessellate/delaunay_tri_k.hpp +++ b/src/libcpp/tessellate/delaunay_tri_k.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_pred_2.hpp b/src/libcpp/tessellate/delaunay_tri_pred_2.hpp index 2af5bb8..69eca19 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_2.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_pred_3.hpp b/src/libcpp/tessellate/delaunay_tri_pred_3.hpp index 497ae8c..f6c7b16 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_3.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_pred_4.hpp b/src/libcpp/tessellate/delaunay_tri_pred_4.hpp index 0dae792..38c0db4 100644 --- a/src/libcpp/tessellate/delaunay_tri_pred_4.hpp +++ b/src/libcpp/tessellate/delaunay_tri_pred_4.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_type_2.hpp b/src/libcpp/tessellate/delaunay_tri_type_2.hpp index c85f2bc..a783fb1 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_2.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_type_3.hpp b/src/libcpp/tessellate/delaunay_tri_type_3.hpp index 8de1250..a882ef1 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_3.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_tri_type_4.hpp b/src/libcpp/tessellate/delaunay_tri_type_4.hpp index 7cb49ae..8ad4f02 100644 --- a/src/libcpp/tessellate/delaunay_tri_type_4.hpp +++ b/src/libcpp/tessellate/delaunay_tri_type_4.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/delaunay_walk_mesh.inc b/src/libcpp/tessellate/delaunay_walk_mesh.inc index 7987b50..0841c49 100644 --- a/src/libcpp/tessellate/delaunay_walk_mesh.inc +++ b/src/libcpp/tessellate/delaunay_walk_mesh.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/laguerre_tri_pred_2.hpp b/src/libcpp/tessellate/laguerre_tri_pred_2.hpp index 34beb12..4b084e4 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_2.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_2.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/laguerre_tri_pred_3.hpp b/src/libcpp/tessellate/laguerre_tri_pred_3.hpp index 8209e5d..d0446ca 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_3.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_3.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/tessellate/laguerre_tri_pred_4.hpp b/src/libcpp/tessellate/laguerre_tri_pred_4.hpp index 496a071..0409365 100644 --- a/src/libcpp/tessellate/laguerre_tri_pred_4.hpp +++ b/src/libcpp/tessellate/laguerre_tri_pred_4.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/textutil.hpp b/src/libcpp/textutil.hpp index 7a55667..eb1e1c2 100644 --- a/src/libcpp/textutil.hpp +++ b/src/libcpp/textutil.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/libcpp/useropts.hpp b/src/libcpp/useropts.hpp index 4281e67..fad9956 100644 --- a/src/libcpp/useropts.hpp +++ b/src/libcpp/useropts.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/liblib/init_jig_t.hpp b/src/liblib/init_jig_t.hpp index 8c1c586..0337732 100644 --- a/src/liblib/init_jig_t.hpp +++ b/src/liblib/init_jig_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -68,7 +68,7 @@ if (_jcfg->_numthread <= 0 ) # ifdef __use_openmp - _jcfg->_numthread = + _jcfg->_numthread = omp_get_num_procs() ; # else _jcfg->_numthread = +1 ; diff --git a/src/liblib/init_msh_t.hpp b/src/liblib/init_msh_t.hpp index 02e6f00..acbda4c 100644 --- a/src/liblib/init_msh_t.hpp +++ b/src/liblib/init_msh_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/liblib/load_jig_t.hpp b/src/liblib/load_jig_t.hpp index b7dac2c..5f60912 100644 --- a/src/liblib/load_jig_t.hpp +++ b/src/liblib/load_jig_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/liblib/load_msh_t.hpp b/src/liblib/load_msh_t.hpp index 16dd760..027d7f8 100644 --- a/src/liblib/load_msh_t.hpp +++ b/src/liblib/load_msh_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/liblib/save_jig_t.hpp b/src/liblib/save_jig_t.hpp index 87db89b..7e6ab55 100644 --- a/src/liblib/save_jig_t.hpp +++ b/src/liblib/save_jig_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/liblib/save_msh_t.hpp b/src/liblib/save_msh_t.hpp index 5ac50d9..656c90b 100644 --- a/src/liblib/save_msh_t.hpp +++ b/src/liblib/save_msh_t.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/marche.hpp b/src/marche.hpp index 32dee12..9110168 100644 --- a/src/marche.hpp +++ b/src/marche.hpp @@ -41,8 +41,8 @@ * 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 + * 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: @@ -380,11 +380,11 @@ return _retv ; } - _jlog._verbosity = + _jlog._verbosity = _jcfg._verbosity ; _jlog.push ( MARCHE::asciibanner ) ; - + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/src/msh_copy.hpp b/src/msh_copy.hpp index 52bea10..5eeee1f 100644 --- a/src/msh_copy.hpp +++ b/src/msh_copy.hpp @@ -22,8 +22,8 @@ * 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 + * 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: @@ -66,7 +66,7 @@ { /*---------------------------------- sort 2-dim. mesh */ typedef geom_tree::aabb_item_node_k < - real_type, + real_type, iptr_type, 2> tree_item ; typedef geom_tree::aabb_tree< @@ -89,14 +89,14 @@ { _item.push_tail(); _item.tail()->ipos () = _ipos ; - _item.tail()->pval(0) = + _item.tail()->pval(0) = _iter->pval(0) ; - _item.tail()->pval(1) = + _item.tail()->pval(1) = _iter->pval(1) ; } } - _tree.load(_item.head(), _item.tend() , + _tree.load(_item.head(), _item.tend() , SIZE , // pop.=#nodes per leaf _tree.median_split , 1.0) ; // set LONG=1, only div. by pop. @@ -110,7 +110,7 @@ { /*---------------------------------- sort 3-dim. mesh */ typedef geom_tree::aabb_item_node_k < - real_type, + real_type, iptr_type, 3> tree_item ; typedef geom_tree::aabb_tree< @@ -133,20 +133,20 @@ { _item.push_tail(); _item.tail()->ipos () = _ipos ; - _item.tail()->pval(0) = + _item.tail()->pval(0) = _iter->pval(0) ; - _item.tail()->pval(1) = + _item.tail()->pval(1) = _iter->pval(1) ; - _item.tail()->pval(2) = + _item.tail()->pval(2) = _iter->pval(2) ; } } - _tree.load(_item.head(), _item.tend() , + _tree.load(_item.head(), _item.tend() , SIZE , // pop.=#nodes per leaf _tree.median_split , - 1.0) ; // set LONG=1, only div. by pop. - + 1.0) ; // set LONG=1, only div. by pop. + _tree.dcmp(_itmp, _perm) ; } } @@ -209,10 +209,10 @@ { auto _cost = // min. node indx _nmap[_item->_data._node [0]] ; - for (auto + for (auto _inod = _nsiz; _inod-- != 1; ) { - _cost = std::min(_cost, + _cost = std::min(_cost, _nmap[_item->_data._node[_inod]]) ; } @@ -227,7 +227,7 @@ _sort.tend() , sort_pred () ) ; - for (auto _iter = _sort.head() ; + for (auto _iter = _sort.head() ; _iter != _sort.tend() ; ++_iter ) { diff --git a/src/msh_init.hpp b/src/msh_init.hpp index a9002f0..bdfb17c 100644 --- a/src/msh_init.hpp +++ b/src/msh_init.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/msh_read.hpp b/src/msh_read.hpp index 2c7214e..b475efb 100644 --- a/src/msh_read.hpp +++ b/src/msh_read.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/msh_save.hpp b/src/msh_save.hpp index 6784819..51a4b0f 100644 --- a/src/msh_save.hpp +++ b/src/msh_save.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/msh_save.inc b/src/msh_save.inc index 6aff098..f879dd8 100644 --- a/src/msh_save.inc +++ b/src/msh_save.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/netcdf/ncutil.h b/src/netcdf/ncutil.h index b47a2fe..2749f96 100644 --- a/src/netcdf/ncutil.h +++ b/src/netcdf/ncutil.h @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/offset.hpp b/src/offset.hpp index 2455a81..49a6646 100644 --- a/src/offset.hpp +++ b/src/offset.hpp @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/rdt_save.inc b/src/rdt_save.inc index a8f69a6..32e4f24 100644 --- a/src/rdt_save.inc +++ b/src/rdt_save.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/tri_save.inc b/src/tri_save.inc index fa015a4..0f6a81b 100644 --- a/src/tri_save.inc +++ b/src/tri_save.inc @@ -22,8 +22,8 @@ * 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 + * 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: diff --git a/src/tripod.hpp b/src/tripod.hpp index 6f30776..608bc9a 100644 --- a/src/tripod.hpp +++ b/src/tripod.hpp @@ -41,8 +41,8 @@ * 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 + * 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: @@ -673,11 +673,11 @@ return _retv ; } - _jlog._verbosity = + _jlog._verbosity = _jcfg._verbosity ; _jlog.push ( TRIPOD::asciibanner ) ; - + if ((_retv = test_jcfg ( _jcfg, _jlog)) != __no_error) { diff --git a/uni/test2d_c.c b/uni/test2d_c.c index 463e050..cebeca0 100644 --- a/uni/test2d_c.c +++ b/uni/test2d_c.c @@ -136,9 +136,9 @@ _jjig._mesh_kern = // non-default opts JIGSAW_KERN_DELAUNAY; - _jjig._optm_kern = + _jjig._optm_kern = JIGSAW_KERN_CVT_DQDX; - _jjig._optm_cost = + _jjig._optm_cost = JIGSAW_KERN_SKEW_COS; _retv = jigsaw ( diff --git a/uni/test2s_b.c b/uni/test2s_b.c index a7e2849..012f996 100644 --- a/uni/test2s_b.c +++ b/uni/test2s_b.c @@ -99,9 +99,9 @@ _jjig._mesh_kern = // non-default opts JIGSAW_KERN_DELAUNAY; - _jjig._optm_kern = + _jjig._optm_kern = JIGSAW_KERN_CVT_DQDX; - _jjig._optm_cost = + _jjig._optm_cost = JIGSAW_KERN_SKEW_COS; _retv = jigsaw ( diff --git a/uni/test3d_c.c b/uni/test3d_c.c index e70be6e..dadefca 100644 --- a/uni/test3d_c.c +++ b/uni/test3d_c.c @@ -125,9 +125,9 @@ _jjig._mesh_kern = // non-default opts JIGSAW_KERN_DELAUNAY; - _jjig._optm_kern = + _jjig._optm_kern = JIGSAW_KERN_CVT_DQDX; - _jjig._optm_cost = + _jjig._optm_cost = JIGSAW_KERN_SKEW_COS; _retv = jigsaw ( From 28e3dd0c3523677ed8dc3f50a05b7b6efe8fe2bd Mon Sep 17 00:00:00 2001 From: dengwirda Date: Tue, 10 Jan 2023 11:15:46 -0700 Subject: [PATCH 10/25] Switch CI to GitHub Actions - Call CI on push as well... --- .github/workflows/cmake.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0f401e8..f5aac1e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -3,6 +3,7 @@ name: CMake Build Matrix on: workflow_dispatch: pull_request: + push: env: BUILD_TYPE: Debug From 74f54ba905a0e8702bb26d9c065e2c3776810bb1 Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Tue, 10 Jan 2023 12:25:11 -0700 Subject: [PATCH 11/25] Switch CI to GitHub Actions --- .github/workflows/cmake.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f5aac1e..8556e5b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -69,10 +69,10 @@ jobs: run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build jigsaw - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} install + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install - name: Configure tests for jigsaw run: cmake -B ${{github.workspace}}/uni/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build tests for jigsaw - run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} install + run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} --target install From cb657bfd8b65b107a3d56fa9b7acde459196ca0e Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Tue, 10 Jan 2023 13:41:58 -0700 Subject: [PATCH 12/25] Switch CI to GitHub Actions - Add openmp support for osx. - Clean-up cmake build directories. --- .github/workflows/cmake.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8556e5b..926cc74 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -49,7 +49,7 @@ jobs: cmake --version - name: Install dependencies on unx - if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') + if: startsWith(matrix.config.name, 'ubuntu') run: | sudo apt-get update sudo apt-get install ninja-build cmake @@ -60,7 +60,7 @@ jobs: - name: Install dependencies on osx if: startsWith(matrix.config.os, 'macos') run: | - brew install ninja cmake + brew install ninja cmake llvm libomp ninja --version cmake --version clang++ --version @@ -70,9 +70,15 @@ jobs: - name: Build jigsaw run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install + + - name: Clean jigsaw + run: rm -r ${{github.workspace}}/build - name: Configure tests for jigsaw run: cmake -B ${{github.workspace}}/uni/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build tests for jigsaw run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} --target install + + - name: Clean tests for jigsaw + run: rm -r ${{github.workspace}}/uni/build From 89861a2c24b0b297e538046552a5b69e1bb1d4f1 Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Tue, 10 Jan 2023 14:47:23 -0700 Subject: [PATCH 13/25] Switch CI to GitHub Actions --- .github/workflows/cmake.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 926cc74..6d1d53a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -66,19 +66,27 @@ jobs: clang++ --version - name: Configure jigsaw - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: | + cd ${{github.workspace}}/build + cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build jigsaw - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install + run: | + cd ${{github.workspace}}/build + cmake --build . --config ${{env.BUILD_TYPE}} --target install - name: Clean jigsaw run: rm -r ${{github.workspace}}/build - name: Configure tests for jigsaw - run: cmake -B ${{github.workspace}}/uni/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: | + cd ${{github.workspace}}/uni/build + cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build tests for jigsaw - run: cmake --build ${{github.workspace}}/uni/build --config ${{env.BUILD_TYPE}} --target install + run: | + cd ${{github.workspace}}/uni/build + cmake --build . --config ${{env.BUILD_TYPE}} --target install - name: Clean tests for jigsaw run: rm -r ${{github.workspace}}/uni/build From 50c1f342e2bb5ac24a52dcff00ef3561d65c444b Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Tue, 10 Jan 2023 14:54:25 -0700 Subject: [PATCH 14/25] Switch CI to GitHub Actions --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6d1d53a..9e28c94 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -67,6 +67,7 @@ jobs: - name: Configure jigsaw run: | + mkdir ${{github.workspace}}/build cd ${{github.workspace}}/build cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} @@ -80,6 +81,7 @@ jobs: - name: Configure tests for jigsaw run: | + mkdir ${{github.workspace}}/uni/build cd ${{github.workspace}}/uni/build cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} From 07b572a9aac17197292153938edf6791927d28f8 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Tue, 10 Jan 2023 20:43:45 -0700 Subject: [PATCH 15/25] Update unit tests for CI --- .github/workflows/cmake.yml | 11 ++++ uni/CMakeLists.txt | 5 ++ uni/print.h | 7 ++- uni/test2d_a.c | 11 +++- uni/test2d_b.c | 11 +++- uni/test2d_c.c | 11 +++- uni/test2d_d.c | 21 ++++--- uni/test2d_e.c | 21 ++++--- uni/test2d_f.c | 19 ++++--- uni/test2d_g.c | 19 ++++--- uni/test2d_h.c | 17 ++++-- uni/test2d_i.c | 17 ++++-- uni/test2s_a.c | 11 +++- uni/test2s_b.c | 11 +++- uni/test2s_c.c | 11 +++- uni/test2s_e.c | 21 ++++--- uni/test2s_f.c | 19 ++++--- uni/test2s_g.c | 19 ++++--- uni/test2s_h.c | 17 ++++-- uni/test2s_i.c | 17 ++++-- uni/test3d_a.c | 11 +++- uni/test3d_b.c | 11 +++- uni/test3d_c.c | 11 +++- uni/test3d_d.c | 11 +++- uni/test3d_e.c | 11 +++- uni/test3d_f.c | 19 ++++--- uni/test3d_g.c | 19 ++++--- uni/test_all.c | 108 ++++++++++++++++++++++++++++++++++++ 28 files changed, 377 insertions(+), 120 deletions(-) create mode 100644 uni/test_all.c diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9e28c94..d9915d5 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -90,5 +90,16 @@ jobs: cd ${{github.workspace}}/uni/build cmake --build . --config ${{env.BUILD_TYPE}} --target install + - name: Prep. tests for jigsaw + if: startsWith(matrix.config.os, 'windows') + run: | + cd ${{github.workspace}}/uni + cp ../lib/jigsaw.dll . + + - name: Eval. tests for jigsaw + run: | + cd ${{github.workspace}}/uni + ./test_all + - name: Clean tests for jigsaw run: rm -r ${{github.workspace}}/uni/build diff --git a/uni/CMakeLists.txt b/uni/CMakeLists.txt index 2a35872..01f2a1b 100644 --- a/uni/CMakeLists.txt +++ b/uni/CMakeLists.txt @@ -16,6 +16,11 @@ endif () message (">> LIBJIGSAW LOCATION: ${LIBJIGSAW}") +add_executable (test_all test_all.c) +target_link_libraries (test_all ${LIBJIGSAW}) +set_target_properties(test_all PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +install (TARGETS test_all DESTINATION "${PROJECT_SOURCE_DIR}") + add_executable (test2d_a test2d_a.c) target_link_libraries (test2d_a ${LIBJIGSAW}) set_target_properties(test2d_a PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) diff --git a/uni/print.h b/uni/print.h index 2038f10..b144901 100644 --- a/uni/print.h +++ b/uni/print.h @@ -1,5 +1,8 @@ -# include "../inc/lib_jigsaw.h" +# pragma once + +# ifndef __JIGSAW_PRINT__ +# define __JIGSAW_PRINT__ # include "stdio.h" @@ -140,5 +143,7 @@ } } +# endif //__JIGSAW_PRINT__ + diff --git a/uni/test2d_a.c b/uni/test2d_a.c index 6757907..4ab02c4 100644 --- a/uni/test2d_a.c +++ b/uni/test2d_a.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_a (int _verb) { int _retv = 0; @@ -69,7 +69,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 0.25 ; _jjig._hfun_scal = @@ -86,16 +86,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_2(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2d_a] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_a(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_b.c b/uni/test2d_b.c index 5941a02..4bb2860 100644 --- a/uni/test2d_b.c +++ b/uni/test2d_b.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_b (int _verb) { int _retv = 0; @@ -117,7 +117,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -139,16 +139,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_2(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2d_b] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_b(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_c.c b/uni/test2d_c.c index cebeca0..d825b8e 100644 --- a/uni/test2d_c.c +++ b/uni/test2d_c.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_c (int _verb) { int _retv = 0; @@ -121,7 +121,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -150,16 +150,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_2(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2d_c] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_c(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_d.c b/uni/test2d_d.c index 8bba80b..fb8872a 100644 --- a/uni/test2d_d.c +++ b/uni/test2d_d.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_d (int _verb) { int _retv = 0; @@ -98,7 +98,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 0.25 ; _jjig._hfun_scal = @@ -107,24 +107,29 @@ _jjig._mesh_dims = +2 ; _retv = jigsaw ( - &_jjig , // the config. opts - &_geom , // geom. data - NULL , // empty init. data - NULL , // empty hfun. data - &_mesh ) ; + & _jjig , // the config. opts + & _geom , // geom. data + NULL , // empty init. data + NULL , // empty hfun. data + & _mesh ) ; /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_2(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2d_d] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_d(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_e.c b/uni/test2d_e.c index 36a7dd2..5055250 100644 --- a/uni/test2d_e.c +++ b/uni/test2d_e.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_e (int _verb) { int _retv = 0; @@ -95,7 +95,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 1./3.; _jjig._hfun_scal = @@ -106,24 +106,29 @@ _jjig._mesh_top1 = +1 ; _retv = jigsaw ( - &_jjig , // the config. opts - &_geom , // geom. data - &_init , // init. data - NULL , // empty hfun. data - &_mesh ) ; + & _jjig , // the config. opts + & _geom , // geom. data + & _init , // init. data + NULL , // empty hfun. data + & _mesh ) ; /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_2(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2d_e] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_e(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_f.c b/uni/test2d_f.c index 93a1211..7c4d8f7 100644 --- a/uni/test2d_f.c +++ b/uni/test2d_f.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_f (int _verb) { int _retv = 0; @@ -95,28 +95,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +2 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - &_geom , // geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + & _geom , // geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_2(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[2d_f] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_f(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_g.c b/uni/test2d_g.c index def5919..b4634b0 100644 --- a/uni/test2d_g.c +++ b/uni/test2d_g.c @@ -11,7 +11,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_g (int _verb) { int _retv = 0; @@ -47,28 +47,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +2 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - NULL , // empty geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + NULL , // empty geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_2(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[2d_g] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_g(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_h.c b/uni/test2d_h.c index 4928cac..efff8f2 100644 --- a/uni/test2d_h.c +++ b/uni/test2d_h.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_h (int _verb) { int _retv = 0; @@ -79,14 +79,16 @@ /*-------------------------------- build MARCHE hfun. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _retv = marche ( - &_jjig , // the config. opts - &_hfun ) ; // the spacing h(x) + & _jjig , // the config. opts + & _hfun ) ; // the spacing h(x) /*-------------------------------- print MARCHE hfun. */ + if (_verb > 0 ) + { printf("\n VALUE: \n\n") ; for (size_t _ipos = +0; @@ -97,13 +99,18 @@ _hfun._value._data[_ipos] ) ; } + } printf ( - "MARCHE returned code : %d \n",_retv); + "[2d_h] MARCHE returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_h(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2d_i.c b/uni/test2d_i.c index 3fe8970..fad73b9 100644 --- a/uni/test2d_i.c +++ b/uni/test2d_i.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2d_i (int _verb) { int _retv = 0; @@ -82,14 +82,16 @@ /*-------------------------------- build MARCHE hfun. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _retv = marche ( - &_jjig , // the config. opts - &_hfun ) ; // the spacing h(x) + & _jjig , // the config. opts + & _hfun ) ; // the spacing h(x) /*-------------------------------- print MARCHE hfun. */ + if (_verb > 0 ) + { printf("\n VALUE: \n\n") ; for (size_t _ipos = +0; @@ -100,13 +102,18 @@ _hfun._value._data[_ipos] ) ; } + } printf ( - "MARCHE returned code : %d \n",_retv); + "[2d_i] MARCHE returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2d_i(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_a.c b/uni/test2s_a.c index 6765aa6..9df3b39 100644 --- a/uni/test2s_a.c +++ b/uni/test2s_a.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_a (int _verb) { int _retv = 0; @@ -37,7 +37,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 0.80 ; _jjig._hfun_scal = @@ -54,16 +54,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2s_a] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_a(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_b.c b/uni/test2s_b.c index 012f996..0e0446e 100644 --- a/uni/test2s_b.c +++ b/uni/test2s_b.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_b (int _verb) { int _retv = 0; @@ -87,7 +87,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -113,16 +113,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2s_b] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_b(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_c.c b/uni/test2s_c.c index dc56dec..46b5753 100644 --- a/uni/test2s_c.c +++ b/uni/test2s_c.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_c (int _verb) { int _retv = 0; @@ -84,7 +84,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -106,16 +106,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2s_c] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_c(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_e.c b/uni/test2s_e.c index aa12f65..3907110 100644 --- a/uni/test2s_e.c +++ b/uni/test2s_e.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_e (int _verb) { int _retv = 0; @@ -71,7 +71,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 1./3.; _jjig._hfun_scal = @@ -80,24 +80,29 @@ _jjig._mesh_dims = +2 ; _retv = jigsaw ( - &_jjig , // the config. opts - &_geom , // geom. data - &_init , // init. data - NULL , // empty hfun. data - &_mesh ) ; + & _jjig , // the config. opts + & _geom , // geom. data + & _init , // init. data + NULL , // empty hfun. data + & _mesh ) ; /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[2s_e] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_e(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_f.c b/uni/test2s_f.c index b468e9b..1215547 100644 --- a/uni/test2s_f.c +++ b/uni/test2s_f.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_f (int _verb) { int _retv = 0; @@ -78,28 +78,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +2 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - &_geom , // geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + & _geom , // geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_3(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[2s_f] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_f(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_g.c b/uni/test2s_g.c index 8d9d81b..f374848 100644 --- a/uni/test2s_g.c +++ b/uni/test2s_g.c @@ -11,7 +11,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_g (int _verb) { int _retv = 0; @@ -70,28 +70,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +2 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - &_geom , // geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + & _geom , // geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_3(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[2s_g] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_g(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_h.c b/uni/test2s_h.c index 91697c7..04cd9a4 100644 --- a/uni/test2s_h.c +++ b/uni/test2s_h.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_h (int _verb) { int _retv = 0; @@ -69,14 +69,16 @@ /*-------------------------------- build MARCHE hfun. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _retv = marche ( - &_jjig , // the config. opts - &_hfun ) ; // the spacing h(x) + & _jjig , // the config. opts + & _hfun ) ; // the spacing h(x) /*-------------------------------- print MARCHE hfun. */ + if (_verb > 0 ) + { printf("\n VALUE: \n\n") ; for (size_t _ipos = +0; @@ -87,13 +89,18 @@ _hfun._value._data[_ipos] ) ; } + } printf ( - "MARCHE returned code : %d \n",_retv); + "[2s_h] MARCHE returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_h(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test2s_i.c b/uni/test2s_i.c index c34d0a9..3fd6921 100644 --- a/uni/test2s_i.c +++ b/uni/test2s_i.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test2s_i (int _verb) { int _retv = 0; @@ -78,14 +78,16 @@ /*-------------------------------- build MARCHE hfun. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _retv = marche ( - &_jjig , // the config. opts - &_hfun ) ; // the spacing h(x) + & _jjig , // the config. opts + & _hfun ) ; // the spacing h(x) /*-------------------------------- print MARCHE hfun. */ + if (_verb > 0 ) + { printf("\n VALUE: \n\n") ; for (size_t _ipos = +0; @@ -96,13 +98,18 @@ _hfun._value._data[_ipos] ) ; } + } printf ( - "MARCHE returned code : %d \n",_retv); + "[2s_i] MARCHE returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test2s_i(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_a.c b/uni/test3d_a.c index 7009443..74c9858 100644 --- a/uni/test3d_a.c +++ b/uni/test3d_a.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_a (int _verb) { int _retv = 0; @@ -63,7 +63,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +2 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = .675 ; // uniform spacing _jjig._hfun_scal = @@ -83,16 +83,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[3d_a] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_a(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_b.c b/uni/test3d_b.c index b7635e1..5778858 100644 --- a/uni/test3d_b.c +++ b/uni/test3d_b.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_b (int _verb) { int _retv = 0; @@ -100,7 +100,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -122,16 +122,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[3d_b] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_b(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_c.c b/uni/test3d_c.c index dadefca..df498b8 100644 --- a/uni/test3d_c.c +++ b/uni/test3d_c.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_c (int _verb) { int _retv = 0; @@ -110,7 +110,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_scal = JIGSAW_HFUN_ABSOLUTE; @@ -139,16 +139,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[3d_c] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_c(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_d.c b/uni/test3d_d.c index f4295f7..d60a87d 100644 --- a/uni/test3d_d.c +++ b/uni/test3d_d.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_d (int _verb) { int _retv = 0; @@ -128,7 +128,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +2 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 3./3.; _jjig._hfun_scal = @@ -154,16 +154,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[3d_d] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_d(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_e.c b/uni/test3d_e.c index f82d341..9581b57 100644 --- a/uni/test3d_e.c +++ b/uni/test3d_e.c @@ -10,7 +10,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_e (int _verb) { int _retv = 0; @@ -86,7 +86,7 @@ /*-------------------------------- build JIGSAW tria. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._hfun_hmax = 1./1.; _jjig._hfun_scal = @@ -109,16 +109,21 @@ /*-------------------------------- print JIGSAW tria. */ + if (_verb > 0 ) output_msh_data_3(&_mesh); jigsaw_free_msh_t(&_mesh); printf ( - "JIGSAW returned code : %d \n",_retv); + "[3d_e] JIGSAW returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_e(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_f.c b/uni/test3d_f.c index 351a025..ed44b6f 100644 --- a/uni/test3d_f.c +++ b/uni/test3d_f.c @@ -13,7 +13,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_f (int _verb) { int _retv = 0; @@ -89,28 +89,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +1 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +3 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - &_geom , // geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + & _geom , // geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_3(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[3d_f] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_f(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test3d_g.c b/uni/test3d_g.c index 06caa52..559ce54 100644 --- a/uni/test3d_g.c +++ b/uni/test3d_g.c @@ -11,7 +11,7 @@ # include "print.h" # include "stdio.h" - int main () + int test3d_g (int _verb) { int _retv = 0; @@ -47,28 +47,33 @@ /*-------------------------------- build TRIPOD r-DT. */ - _jjig._verbosity = +2 ; + _jjig._verbosity = _verb; _jjig._mesh_dims = +3 ; _retv = tripod ( - &_jjig , // the config. opts - &_init , // init. data - NULL , // empty geom. data - &_tria ) ; + & _jjig , // the config. opts + & _init , // init. data + NULL , // empty geom. data + & _tria ) ; /*-------------------------------- print TRIPOD r-DT. */ + if (_verb > 0 ) output_msh_data_3(&_tria); jigsaw_free_msh_t(&_tria); printf ( - "TRIPOD returned code : %d \n",_retv); + "[3d_g] TRIPOD returned code : %d \n", _retv) ; return _retv ; } +# ifndef __SKIP_MAIN__ + int main () { return test3d_g(1) ; } +# endif//__SKIP_MAIN__ + diff --git a/uni/test_all.c b/uni/test_all.c new file mode 100644 index 0000000..fbbce67 --- /dev/null +++ b/uni/test_all.c @@ -0,0 +1,108 @@ + +// gcc -Wall -Wextra test_all.c -Xlinker -rpath=../lib +// -L ../lib -ljigsaw -o test_all + +// Call all unit tests and bail-out on any failed runs + +# define __SKIP_MAIN__ + +# include "test2d_a.c" +# include "test2d_b.c" +# include "test2d_c.c" +# include "test2d_d.c" +# include "test2d_e.c" +# include "test2d_f.c" +# include "test2d_g.c" +# include "test2d_h.c" +# include "test2d_i.c" + +# include "test2s_a.c" +# include "test2s_b.c" +# include "test2s_c.c" +// include "test2s_d.c" +# include "test2s_e.c" +# include "test2s_f.c" +# include "test2s_g.c" +# include "test2s_h.c" +# include "test2s_i.c" + +# include "test3d_a.c" +# include "test3d_b.c" +# include "test3d_c.c" +# include "test3d_d.c" +# include "test3d_e.c" +# include "test3d_f.c" +# include "test3d_g.c" +// include "test3d_h.c" +// include "test3d_i.c" + + int main () + { + int _retv = 0; + int _verb =-1; // verbosity + + /*---------------------------------- run all 2d tests */ + if ((_retv = test2d_a(_verb)) != 0) + return _retv ; + if ((_retv = test2d_b(_verb)) != 0) + return _retv ; + if ((_retv = test2d_c(_verb)) != 0) + return _retv ; + if ((_retv = test2d_d(_verb)) != 0) + return _retv ; + if ((_retv = test2d_e(_verb)) != 0) + return _retv ; + if ((_retv = test2d_f(_verb)) != 0) + return _retv ; + if ((_retv = test2d_g(_verb)) != 0) + return _retv ; + if ((_retv = test2d_h(_verb)) != 0) + return _retv ; + if ((_retv = test2d_i(_verb)) != 0) + return _retv ; + + /*---------------------------------- run all 2s tests */ + if ((_retv = test2s_a(_verb)) != 0) + return _retv ; + if ((_retv = test2s_b(_verb)) != 0) + return _retv ; + if ((_retv = test2s_c(_verb)) != 0) + return _retv ; + // if ((_retv = test2s_d(_verb)) != 0) + // return _retv ; + if ((_retv = test2s_e(_verb)) != 0) + return _retv ; + if ((_retv = test2s_f(_verb)) != 0) + return _retv ; + if ((_retv = test2s_g(_verb)) != 0) + return _retv ; + if ((_retv = test2s_h(_verb)) != 0) + return _retv ; + if ((_retv = test2s_i(_verb)) != 0) + return _retv ; + + /*---------------------------------- run all 3d tests */ + if ((_retv = test3d_a(_verb)) != 0) + return _retv ; + if ((_retv = test3d_b(_verb)) != 0) + return _retv ; + if ((_retv = test3d_c(_verb)) != 0) + return _retv ; + if ((_retv = test3d_d(_verb)) != 0) + return _retv ; + if ((_retv = test3d_e(_verb)) != 0) + return _retv ; + if ((_retv = test3d_f(_verb)) != 0) + return _retv ; + if ((_retv = test3d_g(_verb)) != 0) + return _retv ; + // if ((_retv = test3d_h(_verb)) != 0) + // return _retv ; + // if ((_retv = test3d_i(_verb)) != 0) + // return _retv ; + + return _retv ; + } + + + From 4045319ad160928ec80313a8d7063e456dad81c7 Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Tue, 10 Jan 2023 21:11:54 -0700 Subject: [PATCH 16/25] Update unit tests for CI --- .github/workflows/cmake.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d9915d5..51b4a1b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -100,6 +100,16 @@ jobs: run: | cd ${{github.workspace}}/uni ./test_all + + - name: Extra tests for jigsaw + run: | + cd ${{github.workspace}} + ./bin/jigsaw example.jig + ./bin/jigsaw geo/airfoil.jig + ./bin/jigsaw geo/bunny.jig + ./bin/jigsaw geo/parts.jig + ./bin/jigsaw geo/earth.jig + ./bin/jigsaw geo/lakes.jig - name: Clean tests for jigsaw run: rm -r ${{github.workspace}}/uni/build From 152a2c611eda2f7674c077cd96db273a83c08908 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Wed, 11 Jan 2023 08:28:56 -0700 Subject: [PATCH 17/25] Update unit tests for CI --- geo/airfoil.jig | 2 +- geo/bunny.jig | 2 +- geo/earth.jig | 4 ++-- geo/lakes.jig | 1 + geo/parts.jig | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/geo/airfoil.jig b/geo/airfoil.jig index a6cc541..b3fc055 100644 --- a/geo/airfoil.jig +++ b/geo/airfoil.jig @@ -20,7 +20,7 @@ GEOM_FEAT = TRUE MESH_TOP1 = TRUE MESH_DIMS = 2 - HFUN_HMAX = 0.01 + HFUN_HMAX = 0.02 diff --git a/geo/bunny.jig b/geo/bunny.jig index 5b2dbc3..7b08709 100644 --- a/geo/bunny.jig +++ b/geo/bunny.jig @@ -18,7 +18,7 @@ MESH_FILE = out/bunny.msh VERBOSITY = 1 MESH_DIMS = 2 - HFUN_HMAX = 0.0125 + HFUN_HMAX = 0.05 diff --git a/geo/earth.jig b/geo/earth.jig index b1a88a6..84fec7f 100644 --- a/geo/earth.jig +++ b/geo/earth.jig @@ -18,8 +18,8 @@ MESH_FILE = out/earth.msh VERBOSITY = 1 MESH_DIMS = 1 - GEOM_SEED = 256 - HFUN_HMAX = 0.005 + GEOM_SEED = 160 + HFUN_HMAX = 0.01 diff --git a/geo/lakes.jig b/geo/lakes.jig index 1acfff6..3a2b0b2 100644 --- a/geo/lakes.jig +++ b/geo/lakes.jig @@ -20,6 +20,7 @@ GEOM_FEAT = TRUE MESH_TOP1 = TRUE MESH_DIMS = 2 + HFUN_HMAX = 0.05 diff --git a/geo/parts.jig b/geo/parts.jig index 4c5ce1e..21be3c1 100644 --- a/geo/parts.jig +++ b/geo/parts.jig @@ -20,6 +20,7 @@ GEOM_FEAT = TRUE MESH_TOP1 = TRUE MESH_DIMS = 2 + HFUN_HMAX = 0.05 From da1abfe0a3ec84b5a1d996eb03d81a3231e3ce47 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Wed, 11 Jan 2023 08:30:07 -0700 Subject: [PATCH 18/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Fix aabb-tree partition builder for empty trees. --- src/libcpp/aabb_tree/aabb_tree_k.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcpp/aabb_tree/aabb_tree_k.hpp b/src/libcpp/aabb_tree/aabb_tree_k.hpp index 4e7d39a..38c36a9 100644 --- a/src/libcpp/aabb_tree/aabb_tree_k.hpp +++ b/src/libcpp/aabb_tree/aabb_tree_k.hpp @@ -908,13 +908,13 @@ iptr_list &_iset // unrolled list of item index ) { + _lptr.push_tail(_iset.count()) ; + if (this->_root == nullptr) return; this->_work.clear() ; this->_work.push_tail(this->_root); - _lptr.push_tail(_iset.count () ) ; - for ( ; !this->_work.empty() ; ) { node_type *_node = nullptr ; From 96e32fe42fc38bca6efd72e2d2db50b6d51f7fb6 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Wed, 11 Jan 2023 08:34:38 -0700 Subject: [PATCH 19/25] Update unit tests for CI --- example.jig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example.jig b/example.jig index 4ee871a..2507603 100644 --- a/example.jig +++ b/example.jig @@ -142,7 +142,7 @@ # value. Interpreted based on SCAL setting. # -# HFUN_HMAX = 0.03 + HFUN_HMAX = 0.05 # ---> HFUN_HMIN - {default=0.00} min. mesh-size function From a60b98e1553473ade3d0892ba4e3228dcdf91337 Mon Sep 17 00:00:00 2001 From: Darren Engwirda Date: Wed, 11 Jan 2023 08:59:28 -0700 Subject: [PATCH 20/25] Update unit tests for CI --- .github/workflows/cmake.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 51b4a1b..92293f1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -19,8 +19,7 @@ jobs: - { name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", os: windows-latest, - cc: "cl", cxx: "cl", - environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + cc: "cl", cxx: "cl" } - { name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", From 9a7018257a0c0c22a0093809406e9a4f19e8aca4 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Wed, 11 Jan 2023 12:16:28 -0700 Subject: [PATCH 21/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Clean up compiler warnings on clang. --- src/geo_load.hpp | 6 ------ src/jigsaw.cpp | 5 +++++ src/libcpp/iter_mesh/move_mesh_2.inc | 12 ++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/geo_load.hpp b/src/geo_load.hpp index 23a5986..3adba32 100644 --- a/src/geo_load.hpp +++ b/src/geo_load.hpp @@ -893,7 +893,6 @@ std::numeric_limits::min () ; iptr_type _nnPT = +0 ; - iptr_type _nnE2 = +0 ; iptr_type _nnT3 = +0 ; for (auto _iter = _geom. @@ -924,8 +923,6 @@ _imax = std::max( _imax, _iter->node(1)) ; - _nnE2 += +1 ; - if (_imin < +0 || _imax >= _nnPT) { @@ -1063,7 +1060,6 @@ std::numeric_limits::min () ; iptr_type _nnPT = +0 ; - iptr_type _nnE2 = +0 ; for (auto _iter = _geom. _ellipsoid_mesh_3d._mesh.node().head() ; @@ -1121,8 +1117,6 @@ _imax = std::max( _imax, _iter->node(1)) ; - _nnE2 += +1 ; - if (_imin < +0 || _imax >= _nnPT) { diff --git a/src/jigsaw.cpp b/src/jigsaw.cpp index 768eb58..8d94db6 100644 --- a/src/jigsaw.cpp +++ b/src/jigsaw.cpp @@ -266,6 +266,11 @@ /*---------------------------------- JIGSAW's backend */ +# ifdef __clang__ + // bug w function-local classes? +# pragma clang diagnostic ignored "-Wunused-local-typedef" +# endif + extern "C" { # include "../inc/lib_jigsaw.h" diff --git a/src/libcpp/iter_mesh/move_mesh_2.inc b/src/libcpp/iter_mesh/move_mesh_2.inc index dfc4ce6..9e85822 100644 --- a/src/libcpp/iter_mesh/move_mesh_2.inc +++ b/src/libcpp/iter_mesh/move_mesh_2.inc @@ -751,7 +751,7 @@ # ifdef __use_openmp omp_set_num_threads( - _part._bnds._lptr.count()-1 ) ; + (int)_part._bnds._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ @@ -809,7 +809,7 @@ /*--------------------------------- parallel on inner */ # ifdef __use_openmp omp_set_num_threads( - _part._full._lptr.count()-1 ) ; + (int)_part._full._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ @@ -867,7 +867,7 @@ /*--------------------------------- parallel on outer */ # ifdef __use_openmp omp_set_num_threads( - _part._bnds._lptr.count()-1 ) ; + (int)_part._bnds._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ @@ -1231,7 +1231,7 @@ # ifdef __use_openmp omp_set_num_threads( - _part._bnds._lptr.count()-1 ) ; + (int)_part._bnds._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ @@ -1289,7 +1289,7 @@ /*--------------------------------- parallel on inner */ # ifdef __use_openmp omp_set_num_threads( - _part._full._lptr.count()-1 ) ; + (int)_part._full._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ @@ -1347,7 +1347,7 @@ /*--------------------------------- parallel on outer */ # ifdef __use_openmp omp_set_num_threads( - _part._bnds._lptr.count()-1 ) ; + (int)_part._bnds._lptr.count()-1) ; # endif//__use_openmp # pragma omp parallel default(none) \ From a3d6d77023612b59477cddf5ee213798a5124233 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Wed, 11 Jan 2023 15:43:55 -0700 Subject: [PATCH 22/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index e44fc12..7934a70 100644 --- a/version.txt +++ b/version.txt @@ -39,7 +39,7 @@ - Modify refinement rules to "defer" insertion of points that encroach on boundaries. (Typically) - leads to slightly sparser tessellatons. + leads to slightly sparser tessellations. - Support ellipsoidal-type initial conditions. From 0407f71d2dd644ae28a3f65ec25a6fdd4e3039aa Mon Sep 17 00:00:00 2001 From: dengwirda Date: Mon, 16 Jan 2023 05:59:54 -0700 Subject: [PATCH 23/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Add two-level convergence threshold in optim. routines to prevent isolated non-convergence occasionally reported in problems employing discontinuous h(x) inputs. --- src/libcpp/iter_mesh/iter_divs_2.inc | 3 +- src/libcpp/iter_mesh/iter_mesh_2.hpp | 32 ++++++++-- src/libcpp/iter_mesh/iter_node_2.inc | 16 ++--- src/libcpp/iter_mesh/iter_zips_2.inc | 6 +- src/libcpp/iter_mesh/move_mesh_2.inc | 88 ++++++++++++++++------------ src/libcpp/iter_mesh/sort_mesh_2.inc | 4 ++ 6 files changed, 98 insertions(+), 51 deletions(-) diff --git a/src/libcpp/iter_mesh/iter_divs_2.inc b/src/libcpp/iter_mesh/iter_divs_2.inc index f38a6ee..843aa1c 100644 --- a/src/libcpp/iter_mesh/iter_divs_2.inc +++ b/src/libcpp/iter_mesh/iter_divs_2.inc @@ -390,7 +390,8 @@ _opts, _nptr, _prev, _kern, _move, _cnew, _qtmp, _qdst, - _minC, _QLIM, _tcpu) ; + _minC, _QLIM, _QLIM, + _tcpu) ; if (_move <= +0 ) break; } diff --git a/src/libcpp/iter_mesh/iter_mesh_2.hpp b/src/libcpp/iter_mesh/iter_mesh_2.hpp index 7766ce8..268af63 100644 --- a/src/libcpp/iter_mesh/iter_mesh_2.hpp +++ b/src/libcpp/iter_mesh/iter_mesh_2.hpp @@ -488,6 +488,8 @@ static constexpr ITER_MAX_ = max_subit ; real_type _QMIN = init_cost (_mesh, _opts) ; + real_type _QMOV = +0. ; + real_type _DMOV = +0. ; real_list _hval ; // cache h(x) node val. _hval.set_count( @@ -516,12 +518,22 @@ _nsub = std::max(ITER_MIN_, _nsub) ; + real_type _RMIN = _QMIN * + (real_type)(0.90 + 1./20 * (_iter - 1)) ; + real_type _RMAX = _QMIN * + (real_type)(0.90 + 1./30 * (_iter - 1)) ; + real_type _DLIM = (real_type)+1.-_opts.qtol() ; + _DMOV = std::max(_DMOV, _DLIM) ; + _DMOV = std::min(_DMOV, _RMAX) ; + real_type _QLIM = std::min ( - _opts.qlim(),_QMIN * - (real_type)(0.90 + 0.05 * (_iter - 1))) ; + _opts.qlim(),_RMIN) ; + + _QMOV = std::max(_QMOV, _QLIM) ; + _QMOV = std::min(_QMOV, _RMAX) ; /*------------------------------ 1. CELL GEOM. PASSES */ @@ -556,7 +568,9 @@ _hfun, _kern, _hval , _last , _nset, _aset, _mark , _part, _iter, _isub , - _opts, _QLIM, _DLIM , _tcpu); + _opts, + _QLIM, _QMOV, _DLIM , _DMOV , + _tcpu) ; } _nmov = _nset.count() ; @@ -625,7 +639,9 @@ _hfun, _hval, _last , _nset, _aset, _mark , _part, _iter, _isub , - _opts, _QLIM, _DLIM , _tcpu); + _opts, + _QLIM, _QMOV, _DLIM , _DMOV , + _tcpu) ; } _nmov = _nset.count() ; @@ -735,6 +751,14 @@ } /*------------------------------ has iter. converged? */ + _QMOV = std::max(_QLIM, 1. - + ((real_type) _nmov) / + _mesh.node().count()) ; + + _DMOV = std::max(_DLIM, 1. - + ((real_type) _nmov) / + _mesh.node().count()) ; + // if (_nset.count() == 0) break ; if (_nmov == +0 && _nzip == +0 && diff --git a/src/libcpp/iter_mesh/iter_node_2.inc b/src/libcpp/iter_mesh/iter_node_2.inc index 0cb0fcc..3d44a8b 100644 --- a/src/libcpp/iter_mesh/iter_node_2.inc +++ b/src/libcpp/iter_mesh/iter_node_2.inc @@ -79,8 +79,8 @@ &_NPTR->pval(0), _NPTR->hidx()) ; # define LOOPDIMS( _ITER ) \ - for ( auto _idim = \ - pred_type::geom_dims; _idim-- != 0; ) + for ( auto _ITER = \ + pred_type::geom_dims; _ITER-- != 0; ) __unreferenced(_node) ; @@ -194,8 +194,8 @@ &_NPTR->pval(0), _NPTR->hidx()) ; # define LOOPDIMS( _ITER ) \ - for ( auto _idim = \ - pred_type::geom_dims; _idim-- != 0; ) + for ( auto _ITER = \ + pred_type::geom_dims; _ITER-- != 0; ) __unreferenced(_node) ; @@ -397,8 +397,8 @@ &_NPTR->pval(0), _NPTR->hidx()) ; # define LOOPDIMS( _ITER ) \ - for ( auto _idim = \ - pred_type::geom_dims; _idim-- != 0; ) + for ( auto _ITER = \ + pred_type::geom_dims; _ITER-- != 0; ) /*------------------------------------- cell indexing */ auto _tptr = @@ -569,8 +569,8 @@ &_NPTR->pval(0), _NPTR->hidx()) ; # define LOOPDIMS( _ITER ) \ - for ( auto _idim = \ - pred_type::geom_dims; _idim-- != 0; ) + for ( auto _ITER = \ + pred_type::geom_dims; _ITER-- != 0; ) /*------------------------------------- cell indexing */ auto _qptr = diff --git a/src/libcpp/iter_mesh/iter_zips_2.inc b/src/libcpp/iter_mesh/iter_zips_2.inc index 8c93c20..2c494fd 100644 --- a/src/libcpp/iter_mesh/iter_zips_2.inc +++ b/src/libcpp/iter_mesh/iter_zips_2.inc @@ -638,7 +638,8 @@ _opts, _nptr, _prev, _kern, _move, _cset, _qtmp, _qdst, - _minC, _QLIM, _tcpu) ; + _minC, _QLIM, _QLIM, + _tcpu) ; if (_move <= +0 ) break; } @@ -963,7 +964,8 @@ _opts, _nptr, _prev, _kern, _move, _cset, _qtmp, _qdst, - _minC, _QLIM, _tcpu) ; + _minC, _QLIM, _QLIM, + _tcpu) ; if (_move <= +0 ) break; } diff --git a/src/libcpp/iter_mesh/move_mesh_2.inc b/src/libcpp/iter_mesh/move_mesh_2.inc index 9e85822..97f1289 100644 --- a/src/libcpp/iter_mesh/move_mesh_2.inc +++ b/src/libcpp/iter_mesh/move_mesh_2.inc @@ -76,6 +76,7 @@ real_list &_qnew , // list of new adj. costs real_type _QMIN , // minimum adj. old costs real_type _QLIM , // cell quality threshold + real_type _QMOV , iter_stat &_tcpu // CPU timers/info ) { @@ -84,7 +85,7 @@ _hval, _opts, _node, _last, _kern, _move, _conn, _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; // variational + _QMIN, _QLIM, _QMOV, _tcpu) ; // variational if (_move >= +0 ) return ; @@ -93,7 +94,7 @@ dqdx_optimise, _move, _conn, _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; // local dQ/dx + _QMIN, _QLIM, _QMOV, _tcpu) ; // local dQ/dx if (_move >= +0 ) return ; } @@ -117,6 +118,7 @@ real_list &_qnew , // list of new adj. costs real_type _QMIN , // minimum adj. old costs real_type _QLIM , // cell quality threshold + real_type _QMOV , iter_stat &_tcpu // CPU timers/info ) { @@ -198,12 +200,6 @@ real_type _xtol = // delta_x reltol +std::sqrt(_opts.qtol()) / +10.0 ; - if (_kern == dqdx_optimise) // test cost-only - { - _QLIM = - +std::numeric_limits::infinity() ; - } - auto _ppos = &_node->pval(0) ; real_type _lsqr ; @@ -224,6 +220,12 @@ // _ttic = _time.now() ; // endif//__use_timers + if (_kern == dqdx_optimise) // test cost-only + { + _QMOV = + +std::numeric_limits::infinity() ; + } + for (auto _idim = pred_type::geom_dims; _idim-- != +0; ) { @@ -283,7 +285,7 @@ cell_kind ()) ; move_okay( _qnew, _qold, _move, - _QLIM, _opts.qtol(), + _QMOV, _opts.qtol(), _lmov, _XTOL* _lsqr) ; if (_move >= +0) break ; @@ -343,6 +345,7 @@ real_list &_dnew , // list of new adj. costs real_type _DMIN , // minimum adj. old costs real_type _DLIM , // dual quality threshold + real_type _DMOV , iter_stat &_tcpu // CPU timers/info ) { @@ -410,6 +413,9 @@ // _ttic = _time.now() ; // endif//__use_timers + _DMOV = + +std::numeric_limits::infinity() ; + for (auto _iter = +0 ; _iter != _ITER; ++_iter ) { @@ -455,7 +461,7 @@ dual_kind ()) ; move_okay( _dnew, _dold, _move , - _DLIM, _opts.qtol()) ; + _DMOV, _opts.qtol()) ; if (_move >= +0) break ; } @@ -502,7 +508,9 @@ iptr_type _isub , // inner iteration marker iter_opts &_opts , // user options real_type _QLIM , // cell quality threshold + real_type _QMOV , real_type _DLIM , // dual quality threshold + real_type _DMOV , iter_stat &_tcpu // CPU timers/info ) { @@ -528,6 +536,7 @@ real_list &_qold , // space for adj. costs real_list &_qnew , // space for adj. costs real_type _QLIM , // cell quality threshold + real_type _QMOV , iter_stat &_tcpu // CPU timers/info ) const { @@ -565,7 +574,8 @@ &_last[ _apos][ +0 ], _kern, _move, _conn, _qold, _qnew, - _QMIN, _QLIM, _tcpu) ; + _QMIN, _QLIM, _QMOV, + _tcpu) ; } if (_move > +0 ) @@ -635,9 +645,10 @@ # endif//__use_timers if (_isub == +0) - sort_node(_mesh, _CONN, _aset, - _mark._node, - _iout,_isub, _QLIM, _DLIM, _opts) ; + sort_node( _mesh, _CONN, _aset, + _mark. _node, + _iout, _isub, _QLIM, _QMOV, _DLIM, _DMOV, + _opts) ; _pful =(iptr_type)( std::sqrt(_aset.count ()) / @@ -673,7 +684,7 @@ _nset , _mark, _iout , _opts, _conn , _qold, _qnew, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } } @@ -735,7 +746,7 @@ _nset , _mark, _iout , _opts, _conn , _qold, _qnew, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } # ifdef __use_timers @@ -760,7 +771,7 @@ _CONN, _kern, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _QLIM, _QMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _QOLD, _QNEW; @@ -789,7 +800,7 @@ _NSET , _mark, _iout , _opts, _CSET , _QOLD, _QNEW, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } } @@ -818,7 +829,7 @@ _CONN, _kern, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _QLIM, _QMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _QOLD, _QNEW; @@ -847,7 +858,7 @@ _NSET , _mark, _iout , _opts, _CSET , _QOLD, _QNEW, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } } @@ -876,7 +887,7 @@ _CONN, _kern, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _QLIM, _QMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _QOLD, _QNEW; @@ -905,7 +916,7 @@ _NSET , _mark, _iout , _opts, _CSET , _QOLD, _QNEW, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } } @@ -945,7 +956,7 @@ _nset , _mark, _iout , _opts, _conn , _qold, _qnew, _QLIM, - _tcpu ) ; + _QMOV , _tcpu) ; } # ifdef __use_timers @@ -988,7 +999,9 @@ iptr_type _isub , // inner iteration marker iter_opts &_opts , // user options real_type _QLIM , // cell quality threshold + real_type _QMOV , real_type _DLIM , // dual quality threshold + real_type _DMOV , iter_stat &_tcpu // CPU timers/info ) { @@ -1013,6 +1026,7 @@ real_list &_dold , // space for adj. costs real_list &_dnew , // space for adj. costs real_type _DLIM , // dual quality threshold + real_type _DMOV , iter_stat &_tcpu // CPU timers/info ) const { @@ -1048,7 +1062,8 @@ _last[ _apos] , _move, _conn, _dold, _dnew, - _DMIN, _DLIM, _tcpu) ; + _DMIN, _DLIM, _DMOV, + _tcpu) ; } if (_move > +0 ) @@ -1115,9 +1130,10 @@ # endif//__use_timers if (_isub == +0) - sort_node(_mesh, _CONN, _aset, - _mark._node, - _iout,_isub, _QLIM, _DLIM, _opts) ; + sort_node( _mesh, _CONN, _aset, + _mark. _node, + _iout, _isub, _QLIM, _QMOV, _DLIM, _DMOV, + _opts) ; _pful =(iptr_type)( std::sqrt(_aset.count ()) / @@ -1153,7 +1169,7 @@ _nset , _mark, _iout , _opts, _conn , _dold, _dnew, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } } @@ -1215,7 +1231,7 @@ _nset , _mark, _iout , _opts, _conn , _dold, _dnew, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } # ifdef __use_timers @@ -1240,7 +1256,7 @@ _CONN, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _DLIM, _DMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _DOLD, _DNEW; @@ -1269,7 +1285,7 @@ _NSET , _mark, _iout , _opts, _CSET , _DOLD, _DNEW, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } } @@ -1298,7 +1314,7 @@ _CONN, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _DLIM, _DMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _DOLD, _DNEW; @@ -1327,7 +1343,7 @@ _NSET , _mark, _iout , _opts, _CSET , _DOLD, _DNEW, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } } @@ -1356,7 +1372,7 @@ _CONN, _last, \ _nset, _mark, \ _iout, _isub, _opts, \ - _QLIM, _DLIM, _tcpu) + _DLIM, _DMOV, _tcpu) { conn_list _CSET; // thread-local arrays real_list _DOLD, _DNEW; @@ -1385,7 +1401,7 @@ _NSET , _mark, _iout , _opts, _CSET , _DOLD, _DNEW, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } } @@ -1425,7 +1441,7 @@ _nset , _mark, _iout , _opts, _conn , _dold, _dnew, _DLIM, - _tcpu ) ; + _DMOV , _tcpu) ; } # ifdef __use_timers diff --git a/src/libcpp/iter_mesh/sort_mesh_2.inc b/src/libcpp/iter_mesh/sort_mesh_2.inc index 599ffbf..7286b29 100644 --- a/src/libcpp/iter_mesh/sort_mesh_2.inc +++ b/src/libcpp/iter_mesh/sort_mesh_2.inc @@ -133,7 +133,9 @@ iptr_type _iout , // outer iteration marker iptr_type _isub , // inner iteration marker real_type _QLIM , // cell quality threshold + real_type _QMOV , real_type _DLIM , // dual quality threshold + real_type _DMOV , iter_opts &_opts // user options ) { @@ -178,6 +180,8 @@ iptr_list _amrk ; cost_list _sset ; + __unreferenced ( _QMOV ) ; + __unreferenced ( _DMOV ) ; __unreferenced ( _DLIM ) ; __unreferenced ( _opts ) ; __unreferenced ( _isub ) ; From 595ff4bc094e09d815d04104e719d8353fb766e1 Mon Sep 17 00:00:00 2001 From: dengwirda Date: Mon, 16 Jan 2023 13:23:14 -0700 Subject: [PATCH 24/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Initial cmake support for icpc. Note fp-model=precise needed to preserve adapt-fp predictates. - Add extra fp optimisation flags across the board, which seem to (marginally) improve performance without introducing unsafe fp reordering a'la -ffast-math and friends... --- src/CMakeLists.txt | 29 ++++++++++++++++++++++++---- src/libcpp/aabb_tree/aabb_tree_k.hpp | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 714e834..80208f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,20 +14,37 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR message (STATUS "GCXX-like compiler detected") endif () +if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set (ICPC_LIKE TRUE) + message (STATUS "ICPC-like compiler detected") +endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set (MSVC_LIKE TRUE) message (STATUS "MSVC-like compiler detected") endif () +if (DEFINED ICPC_LIKE) + add_compile_options (-pedantic -Wall -Wextra -Wshadow -Wfloat-conversion) + add_compile_options (-fp-model=precise) # needed for adapt-fp + add_compile_options (-fno-math-errno) # no errno checks + add_compile_options (-fno-trapping-math) # no fp exceptions + add_compile_options (-ffinite-math-only) # no explicit nans, etc +endif () + if (DEFINED MSVC_LIKE) add_compile_options (/W3) - add_compile_options (/openmp:llvm) - cfg_compile_options (/GS- RELEASE) - cfg_compile_options (/Ot RELEASE) + add_compile_options (/openmp:llvm) # needed for openmp > 2.0 + add_compile_options (/fp:precise) # needed for adapt-fp + cfg_compile_options (/GS- RELEASE) # disable buffer checks + cfg_compile_options (/Ot RELEASE) # favour "fast" code endif () if (DEFINED GCXX_LIKE) - add_compile_options (-pedantic -Wall -Wfloat-conversion) + add_compile_options (-pedantic -Wall -Wextra -Wshadow -Wfloat-conversion) + add_compile_options (-fno-math-errno) # no errno checks + add_compile_options (-fno-trapping-math) # no fp exceptions + add_compile_options (-ffinite-math-only) # no explicit nans, etc endif () if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -37,6 +54,8 @@ else () message (STATUS "Installing to ${CMAKE_INSTALL_PREFIX}") endif () +# try to find netcdf support + find_library (NETCDF_LIBRARY NAMES netcdf) if (NETCDF_LIBRARY) @@ -46,6 +65,8 @@ else () message (STATUS "NetCDF library not found") endif () +# try to find openmp support + find_package (OpenMP) if (OpenMP_CXX_FOUND AND (OpenMP_CXX_VERSION LESS 3)) diff --git a/src/libcpp/aabb_tree/aabb_tree_k.hpp b/src/libcpp/aabb_tree/aabb_tree_k.hpp index 38c36a9..a7ece7a 100644 --- a/src/libcpp/aabb_tree/aabb_tree_k.hpp +++ b/src/libcpp/aabb_tree/aabb_tree_k.hpp @@ -479,9 +479,9 @@ this->_root->_hptr = nullptr; /*------------------------------ push items onto root */ + { item_data *_hptr = nullptr; item_data *_idat = nullptr; - { for(; _head != _tend; ++_head) { /*------------------------------ alloc. and push item */ From d589b1bfa7ef86c7342c0932f1b5e774e556776f Mon Sep 17 00:00:00 2001 From: dengwirda Date: Thu, 19 Jan 2023 03:28:36 -0700 Subject: [PATCH 25/25] 1.0.0 updates: "spars(er)" refinement, thread-parallelism, etc - Add additional error checks at start-up. --- src/geo_load.hpp | 7 +++++++ src/hfn_load.hpp | 7 +++++++ src/ini_load.hpp | 7 +++++++ src/jigsaw.hpp | 7 ++++++- src/marche.hpp | 7 ++++++- src/tripod.hpp | 7 ++++++- 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/geo_load.hpp b/src/geo_load.hpp index 3adba32..9e34aaa 100644 --- a/src/geo_load.hpp +++ b/src/geo_load.hpp @@ -1132,7 +1132,14 @@ return _errv ; } } + else + { + _jlog. push ( + "**input error: couldn't determine format of GEOM.\n") ; + return __invalid_argument ; + } + return ( _errv ) ; } diff --git a/src/hfn_load.hpp b/src/hfn_load.hpp index 78c543f..1c66f33 100644 --- a/src/hfn_load.hpp +++ b/src/hfn_load.hpp @@ -1931,6 +1931,13 @@ _errv = __invalid_argument ; } } + else + { + _jlog. push ( + "**input error: couldn't determine format of HFUN.\n") ; + + return __invalid_argument ; + } return ( _errv ) ; } diff --git a/src/ini_load.hpp b/src/ini_load.hpp index 0cb3f2b..f6a107a 100644 --- a/src/ini_load.hpp +++ b/src/ini_load.hpp @@ -1158,6 +1158,13 @@ _errv = __invalid_indexing ; } } + else + { + _jlog. push ( + "**input error: couldn't determine format of INIT.\n") ; + + return __invalid_argument ; + } return ( _errv ) ; } diff --git a/src/jigsaw.hpp b/src/jigsaw.hpp index ec541e5..57a4435 100644 --- a/src/jigsaw.hpp +++ b/src/jigsaw.hpp @@ -1629,7 +1629,7 @@ _retv = -2 ; std::cout << - "run jigsaw jigname.jig"; + "Usage: jigsaw user-opts.jig" ; std::cout << std::endl ; break ; @@ -1665,6 +1665,11 @@ break ; } } + if (_retv == -1) + { + std::cout << + "**parse error: *.jig file not found!" << std::endl; + } if (_retv != +0) return ( _retv ) ; /*--------------------------------- setup *.JLOG file */ diff --git a/src/marche.hpp b/src/marche.hpp index 9110168..fb5c048 100644 --- a/src/marche.hpp +++ b/src/marche.hpp @@ -326,7 +326,7 @@ _retv = -2 ; std::cout << - "run marche jigname.jig"; + "Usage: marche user-opts.jig" ; std::cout << std::endl ; break ; @@ -362,6 +362,11 @@ break ; } } + if (_retv == -1) + { + std::cout << + "**parse error: *.jig file not found!" << std::endl; + } if (_retv != +0) return ( _retv ) ; /*--------------------------------- setup *.JLOG file */ diff --git a/src/tripod.hpp b/src/tripod.hpp index 608bc9a..63faed2 100644 --- a/src/tripod.hpp +++ b/src/tripod.hpp @@ -619,7 +619,7 @@ _retv = -2 ; std::cout << - "run tripod jigname.jig"; + "Usage: tripod user-opts.jig" ; std::cout << std::endl ; break ; @@ -655,6 +655,11 @@ break ; } } + if (_retv == -1) + { + std::cout << + "**parse error: *.jig file not found!" << std::endl; + } if (_retv != +0) return ( _retv ) ; /*--------------------------------- setup *.JLOG file */