From c98bc166e322731fe2ee2f9d1f0640ff1454facf Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Wed, 3 Jun 2026 12:43:22 -0600 Subject: [PATCH 01/14] Add a new singularity-utils library. This is the cmakelists file --- singularity-utils/CMakeLists.txt | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 singularity-utils/CMakeLists.txt diff --git a/singularity-utils/CMakeLists.txt b/singularity-utils/CMakeLists.txt new file mode 100644 index 00000000000..bb9ba532998 --- /dev/null +++ b/singularity-utils/CMakeLists.txt @@ -0,0 +1,95 @@ +#------------------------------------------------------------------------------ +# © 2021-2025. Triad National Security, LLC. All rights reserved. This +# program was produced under U.S. Government contract 89233218CNA000001 +# for Los Alamos National Laboratory (LANL), which is operated by Triad +# National Security, LLC for the U.S. Department of Energy/National +# Nuclear Security Administration. All rights in the program are +# reserved by Triad National Security, LLC, and the U.S. Department of +# Energy/National Nuclear Security Administration. The Government is +# granted for itself and others acting on its behalf a nonexclusive, +# paid-up, irrevocable worldwide license in this material to reproduce, +# prepare derivative works, distribute copies to the public, perform +# publicly and display publicly, and to permit others to do so. +#------------------------------------------------------------------------------ + +cmake_minimum_required(VERSION 3.19) + +project(singularity-utils + VERSION 1.0.0 + LANGUAGES CXX) + +# Create interface library (header-only) +add_library(singularity-utils INTERFACE) +add_library(singularity-utils::singularity-utils ALIAS singularity-utils) + +# Set include directories +target_include_directories(singularity-utils + INTERFACE + $ + $ +) + +# singularity-utils depends on ports-of-call and spiner +# These should already be found by the parent singularity-eos project +target_link_libraries(singularity-utils + INTERFACE + ports-of-call::ports-of-call + spiner::spiner +) + +# Propagate HDF5 usage definitions +# These must match the settings used by singularity-eos +if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_USE_SPINER_WITH_HDF5> + ) +endif() + +# Propagate compile definitions for FastMath configuration +# These must match the settings used by singularity-eos +if (DEFINED SINGULARITY_USE_TRUE_LOG_GRIDDING) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_USE_TRUE_LOG_GRIDDING> + ) +endif() + +if (DEFINED SINGULARITY_USE_SINGLE_LOGS) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_USE_SINGLE_LOGS> + ) +endif() + +if (DEFINED SINGULARITY_NQT_PORTABLE) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_NQT_PORTABLE> + ) +endif() + +if (DEFINED SINGULARITY_NQT_ORDER_1) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_NQT_ORDER_1> + ) +endif() + +# Version information +target_compile_definitions(singularity-utils + INTERFACE + SPINER_FORMAT_VERSION="${PROJECT_VERSION}" + SPINER_FORMAT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + SPINER_FORMAT_VERSION_MINOR=${PROJECT_VERSION_MINOR} + SPINER_FORMAT_VERSION_PATCH=${PROJECT_VERSION_PATCH} +) + +# Installation rules +# singularity-utils is always built as part of singularity-eos via add_subdirectory, +# so we don't need the full package config machinery. Just install the headers. +if(NOT SINGULARITY_SUBMODULE_MODE) + install(DIRECTORY singularity-utils/ + DESTINATION include/singularity-utils + ) +endif() From 55d08b63c3f51e715bad6b16bbc22bde1c240ea4 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 12:30:47 -0600 Subject: [PATCH 02/14] Move some shared headers to a new shard library. Update the includes for those --- CMakeLists.txt | 9 +- example/benchmark_spiner_cpu.cpp | 4 +- example/benchmark_spiner_kokkos.cpp | 2 +- example/eos_grid.cpp | 2 +- example/get_sound_speed_press.cpp | 2 +- example/map_pt_space.cpp | 4 +- example/plugin/dust/dust.hpp | 2 +- example/plugin/dust/dust_variant.hpp | 2 +- example/pte_2mat.cpp | 4 +- python/module.hpp | 2 +- sesame2spiner/generate_files.cpp | 4 +- sesame2spiner/io_eospac.hpp | 6 +- sesame2spiner/main.cpp | 2 +- singularity-eos/base/constants.hpp | 2 +- singularity-eos/base/spiner_table_utils.hpp | 255 +-------------- .../kinetic_phasetransition_methods.hpp | 4 +- .../kinetic_phasetransition_models.hpp | 4 +- .../closure/kinetic_phasetransition_utils.hpp | 4 +- singularity-eos/closure/mixed_cell_models.hpp | 8 +- singularity-eos/eos/default_variant.hpp | 2 +- singularity-eos/eos/eos_base.hpp | 6 +- singularity-eos/eos/eos_builder.hpp | 2 +- singularity-eos/eos/eos_carnahan_starling.hpp | 6 +- singularity-eos/eos/eos_davis.hpp | 6 +- singularity-eos/eos/eos_electrons.hpp | 4 +- singularity-eos/eos/eos_eospac.hpp | 2 +- singularity-eos/eos/eos_gruneisen.hpp | 8 +- singularity-eos/eos/eos_helmholtz.hpp | 10 +- singularity-eos/eos/eos_ideal.hpp | 2 +- singularity-eos/eos/eos_jwl.hpp | 2 +- singularity-eos/eos/eos_mgusup.hpp | 4 +- singularity-eos/eos/eos_noble_abel.hpp | 2 +- singularity-eos/eos/eos_powermg.hpp | 4 +- singularity-eos/eos/eos_sap_polynomial.hpp | 2 +- singularity-eos/eos/eos_spiner_common.hpp | 4 +- singularity-eos/eos/eos_spiner_rho_sie.hpp | 12 +- singularity-eos/eos/eos_spiner_rho_temp.hpp | 10 +- singularity-eos/eos/eos_stellar_collapse.hpp | 12 +- singularity-eos/eos/eos_stiff.hpp | 2 +- singularity-eos/eos/eos_type_lists.hpp | 2 +- singularity-eos/eos/eos_variant.hpp | 2 +- singularity-eos/eos/eos_vinet.hpp | 8 +- singularity-eos/eos/get_sg_eos_functors.hpp | 2 +- singularity-eos/eos/modifiers/ramps_eos.hpp | 4 +- .../eos/modifiers/relativistic_eos.hpp | 2 +- singularity-eos/eos/modifiers/zsplit_eos.hpp | 6 +- .../singularity-utils/bounds.hpp | 291 ++++++++++++++++++ .../singularity-utils/constants.hpp | 27 ++ .../singularity-utils}/error_utils.hpp | 8 +- .../singularity-utils}/fast-math/logs.hpp | 8 +- .../singularity-utils}/generic_indexer.hpp | 8 +- .../singularity-utils}/hermite.hpp | 10 +- .../singularity-utils}/indexable_types.hpp | 10 +- .../singularity-utils}/math_utils.hpp | 8 +- .../singularity-utils}/robust_utils.hpp | 6 +- .../root-finding-1d/root_finding.hpp | 6 +- .../sp5/singularity_eos_sp5.hpp | 6 +- .../singularity-utils}/variadic_utils.hpp | 8 +- test/compare_to_eospac.cpp | 2 +- test/eos_unit_test_helpers.hpp | 2 +- test/profile_stellar_collapse.cpp | 2 +- test/pte_test_3mat_analytic.hpp | 2 +- test/test_bounds.cpp | 2 +- test/test_closure_pte.cpp | 4 +- test/test_eos_carnahan_starling.cpp | 2 +- test/test_eos_davis.cpp | 2 +- test/test_eos_ideal.cpp | 2 +- test/test_eos_modifiers.cpp | 6 +- test/test_eos_modifiers_minimal.cpp | 4 +- test/test_eos_tabulated.cpp | 4 +- test/test_eos_zsplit.cpp | 2 +- test/test_generic_indxer.cpp | 2 +- test/test_indexable_types.cpp | 2 +- test/test_math_utils.cpp | 4 +- test/test_modifier_floored_energy.cpp | 2 +- test/test_pte.cpp | 2 +- test/test_pte_ideal.cpp | 2 +- test/test_robust_utils.cpp | 2 +- test/test_solver_utils.cpp | 2 +- test/test_spiner_transform.cpp | 2 +- test/test_variadic_utils.cpp | 2 +- 81 files changed, 487 insertions(+), 417 deletions(-) create mode 100644 singularity-utils/singularity-utils/bounds.hpp create mode 100644 singularity-utils/singularity-utils/constants.hpp rename {singularity-eos/base => singularity-utils/singularity-utils}/error_utils.hpp (94%) rename {singularity-eos/base => singularity-utils/singularity-utils}/fast-math/logs.hpp (97%) rename {singularity-eos/base => singularity-utils/singularity-utils}/generic_indexer.hpp (90%) rename {singularity-eos/base => singularity-utils/singularity-utils}/hermite.hpp (94%) rename {singularity-eos/base => singularity-utils/singularity-utils}/indexable_types.hpp (98%) rename {singularity-eos/base => singularity-utils/singularity-utils}/math_utils.hpp (90%) rename {singularity-eos/base => singularity-utils/singularity-utils}/robust_utils.hpp (94%) rename {singularity-eos/base => singularity-utils/singularity-utils}/root-finding-1d/root_finding.hpp (99%) rename {singularity-eos/base => singularity-utils/singularity-utils}/sp5/singularity_eos_sp5.hpp (94%) rename {singularity-eos/base => singularity-utils/singularity-utils}/variadic_utils.hpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5af39066376..3839e68796f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,9 @@ if (SINGULAIRTY_ON_ARM) endif() # ------------------------------------------------------------------------------# +include(singularity-eos/spiner) +include(singularity-eos/ports-of-call) +add_subdirectory(singularity-utils) # singularity-eos Library # ------------------------------------------------------------------------------# @@ -178,8 +181,6 @@ include(singularity-eos/Eigen3) include(singularity-eos/eospac) include(singularity-eos/hdf5) include(singularity-eos/kokkos) -include(singularity-eos/spiner) -include(singularity-eos/ports-of-call) add_library(singularity-eos INTERFACE) add_library(singularity-eos::singularity-eos ALIAS singularity-eos) @@ -190,7 +191,7 @@ add_library(singularity-eos::singularity-eos_Common ALIAS singularity-eos_Common add_library(singularity-eos_Interface INTERFACE) add_library(singularity-eos::singularity-eos_Interface ALIAS singularity-eos_Interface) -target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common) +target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common singularity-utils::singularity-utils) target_link_libraries(singularity-eos INTERFACE singularity-eos_Interface) # ld has problems with Clang's libomp.so, use ldd instead @@ -589,6 +590,8 @@ target_compile_options( # `-Wclass-memaccess now default with -Wall but we explicitly # manage this ourselves in our serialization routines. $<$,$>:-Wno-class-memaccess> + # Disable finite-math-only in Debug builds to allow NaN/Inf checks (Intel compilers) + $<$,$,$>>:-fno-finite-math-only> ) if (SINGULARITY_STRICT_WARNINGS) target_compile_options(singularity-eos_Interface INTERFACE diff --git a/example/benchmark_spiner_cpu.cpp b/example/benchmark_spiner_cpu.cpp index 35783e84591..195435fd378 100644 --- a/example/benchmark_spiner_cpu.cpp +++ b/example/benchmark_spiner_cpu.cpp @@ -48,7 +48,7 @@ // Spiner headers #include -#include +#include #include #include #include @@ -448,4 +448,4 @@ int main(int argc, char *argv[]) { std::cout << "Benchmark complete for material " << std::to_string(matid) << "\n"; } return 0; -} \ No newline at end of file +} diff --git a/example/benchmark_spiner_kokkos.cpp b/example/benchmark_spiner_kokkos.cpp index 9f9b2cc102f..4f7b49faa0b 100644 --- a/example/benchmark_spiner_kokkos.cpp +++ b/example/benchmark_spiner_kokkos.cpp @@ -37,7 +37,7 @@ // Spiner headers #include -#include +#include #include #include #include diff --git a/example/eos_grid.cpp b/example/eos_grid.cpp index e89ab6a1176..271df371992 100644 --- a/example/eos_grid.cpp +++ b/example/eos_grid.cpp @@ -28,7 +28,7 @@ #include // This contains useful tools for preventing things like divide by zero -#include +#include // Needed to import the eos models #include diff --git a/example/get_sound_speed_press.cpp b/example/get_sound_speed_press.cpp index 7114f1ad0f0..ab793268cf0 100644 --- a/example/get_sound_speed_press.cpp +++ b/example/get_sound_speed_press.cpp @@ -17,7 +17,7 @@ #include // This contains useful tools for preventing things like divide by zero -#include +#include // Needed to import the eos models #include // One way of initializing models with modifiers diff --git a/example/map_pt_space.cpp b/example/map_pt_space.cpp index 7fbeefd715d..79f67a31d45 100644 --- a/example/map_pt_space.cpp +++ b/example/map_pt_space.cpp @@ -41,9 +41,9 @@ #include // This contains useful tools for preventing things like divide by zero -#include +#include // 1D root finding -#include +#include // Needed to import the eos models #include diff --git a/example/plugin/dust/dust.hpp b/example/plugin/dust/dust.hpp index 03c737d4ec2..123711756ea 100644 --- a/example/plugin/dust/dust.hpp +++ b/example/plugin/dust/dust.hpp @@ -21,8 +21,8 @@ // Base stuff #include #include -#include #include +#include namespace singularity { diff --git a/example/plugin/dust/dust_variant.hpp b/example/plugin/dust/dust_variant.hpp index cba779a5374..88d257f2760 100644 --- a/example/plugin/dust/dust_variant.hpp +++ b/example/plugin/dust/dust_variant.hpp @@ -30,7 +30,7 @@ // Base stuff #include #include -#include +#include // EOS models #include diff --git a/example/pte_2mat.cpp b/example/pte_2mat.cpp index d51af00c548..8ae66778710 100644 --- a/example/pte_2mat.cpp +++ b/example/pte_2mat.cpp @@ -62,9 +62,9 @@ #include // This contains logic for indexers -#include +#include // This contains useful tools for preventing things like divide by zero -#include +#include // The PTE closures #include // Needed to import the eos models diff --git a/python/module.hpp b/python/module.hpp index 00309d763ea..834292f13e9 100644 --- a/python/module.hpp +++ b/python/module.hpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include namespace py = pybind11; diff --git a/sesame2spiner/generate_files.cpp b/sesame2spiner/generate_files.cpp index e5453f94c00..ded57ee82b3 100644 --- a/sesame2spiner/generate_files.cpp +++ b/sesame2spiner/generate_files.cpp @@ -31,8 +31,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/sesame2spiner/io_eospac.hpp b/sesame2spiner/io_eospac.hpp index 2a2c166da2d..d6eeb0a7c5e 100644 --- a/sesame2spiner/io_eospac.hpp +++ b/sesame2spiner/io_eospac.hpp @@ -27,9 +27,9 @@ #endif #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/sesame2spiner/main.cpp b/sesame2spiner/main.cpp index a7308b0edc2..cb279aa77f7 100644 --- a/sesame2spiner/main.cpp +++ b/sesame2spiner/main.cpp @@ -30,7 +30,7 @@ #endif #include -#include +#include #include #include "generate_files.hpp" diff --git a/singularity-eos/base/constants.hpp b/singularity-eos/base/constants.hpp index 2f0af656c55..b7edc9b3d9a 100644 --- a/singularity-eos/base/constants.hpp +++ b/singularity-eos/base/constants.hpp @@ -16,6 +16,7 @@ #define SINGULARITY_EOS_BASE_CONSTANTS_HPP_ #include +#include // TableSplit namespace singularity { @@ -37,7 +38,6 @@ constexpr unsigned long all_values = (1 << 10) - 1; constexpr size_t MAX_NUM_LAMBDAS = 3; enum class DataStatus { Deallocated = 0, OnDevice = 1, OnHost = 2, UnManaged = 3 }; enum class TableStatus { OnTable = 0, OffBottom = 1, OffTop = 2 }; -enum class TableSplit { Total = 0, ElectronOnly = 1, IonCold = 2 }; constexpr Real ROOM_TEMPERATURE = 293; // K constexpr Real ATMOSPHERIC_PRESSURE = 1e6; diff --git a/singularity-eos/base/spiner_table_utils.hpp b/singularity-eos/base/spiner_table_utils.hpp index 52f5a2c0209..b2409e4be06 100644 --- a/singularity-eos/base/spiner_table_utils.hpp +++ b/singularity-eos/base/spiner_table_utils.hpp @@ -24,264 +24,13 @@ #include #include -#include -#include -#include +#include +#include // Bounds #include -#include namespace singularity { namespace table_utils { -// For logarithmic interpolation, quantities may be negative. -// If they are, use offset to ensure negative values make sense. -template -class Bounds { - public: - using RegularGrid1D = Spiner::RegularGrid1D; - using Grid_t = Spiner::PiecewiseGrid1D; - // for tag dispatch in constructors - using OneGrid = std::integral_constant; - using TwoGrids = std::integral_constant; - using ThreeGrids = std::integral_constant; - - Bounds() : offset(0), piecewise(false), linmin_(0), linmax_(0) {} - - Bounds(const Real min, const Real max, const int N, const Real offset) - : grid(Grid_t(std::vector{RegularGrid1D(min, max, N)})), - offset(offset), piecewise(false), linmin_(min), linmax_(max) {} - Bounds(OneGrid, const Real min, const Real max, const int N, const Real offset) - : Bounds(min, max, N, offset) {} - - Bounds(Real min, Real max, int N, const bool convertToLog = false, - const Real shrinkRange = 0, - Real anchor_point = std::numeric_limits::signaling_NaN()) - : offset(0), piecewise(true), linmin_(min), linmax_(max) { - if (convertToLog) { - convertBoundsToLog_(min, max, shrinkRange); - if (!(std::isnan(anchor_point))) { - anchor_point = singularity::FastMath::log10(std::abs(anchor_point)); - } - } - if (!(std::isnan(anchor_point))) { - adjustForAnchor_(min, max, N, anchor_point); - } - grid = Grid_t(std::vector{RegularGrid1D(min, max, N)}); - } - Bounds(OneGrid, Real min, Real max, int N, const bool convertToLog = false, - const Real shrinkRange = 0, - Real anchor_point = std::numeric_limits::signaling_NaN()) - : Bounds(min, max, N, convertToLog, shrinkRange, anchor_point) {} - - Bounds(TwoGrids, Real global_min, Real global_max, Real anchor_point, Real splitPoint, - const Real ppd_fine, const Real ppd_factor, const bool convertToLog, - const Real shrinkRange = 0) - : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { - const Real ppd_coarse = (ppd_factor > 0) ? ppd_fine / ppd_factor : ppd_fine; - - if (convertToLog) { - convertBoundsToLog_(global_min, global_max, shrinkRange); - anchor_point = toLog_(anchor_point, offset); - splitPoint = toLog_(splitPoint, offset); - } - - checkInterval_(splitPoint, global_min, global_max, "Split point"); - checkInterval_(anchor_point, global_min, splitPoint, "Anchor point"); - - // add a point just to make sure we have enough points after adjusting for anchor - int N_fine = getNumPointsFromDensity(global_min, splitPoint, ppd_fine) + 1; - adjustForAnchor_(global_min, splitPoint, N_fine, anchor_point); - RegularGrid1D grid_lower(global_min, splitPoint, N_fine); - - const int N_upper = getNumPointsFromDensity(splitPoint, global_max, ppd_coarse); - RegularGrid1D grid_upper(splitPoint, global_max, N_upper); - - grid = Grid_t(std::vector{grid_lower, grid_upper}); - } - - Bounds(ThreeGrids, Real global_min, Real global_max, Real anchor_point, Real fine_min, - Real fine_max, const Real ppd_fine, const Real ppd_factor_lo, - const Real ppd_factor_hi, const bool convertToLog, const Real shrinkRange = 0) - : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { - - if (convertToLog) { - convertBoundsToLog_(global_min, global_max, shrinkRange); - anchor_point = toLog_(anchor_point, offset); - fine_min = toLog_(fine_min, offset); - fine_max = toLog_(fine_max, offset); - } - checkInterval_(anchor_point, global_min, global_max, "Anchor point"); - - grid = gridFromIntervals_(ThreeGrids(), global_min, global_max, anchor_point, - fine_min, fine_max, ppd_fine, ppd_factor_lo, ppd_factor_hi); - } - - Bounds(ThreeGrids, Real global_min, Real global_max, Real anchor_point, - Real log_fine_diameter, const Real ppd_fine, const Real ppd_factor_lo, - const Real ppd_factor_hi, const bool convertToLog, const Real shrinkRange = 0) - : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { - - if (convertToLog) { - convertBoundsToLog_(global_min, global_max, shrinkRange); - anchor_point = toLog_(anchor_point, offset); - } - - checkInterval_(anchor_point, global_min, global_max, "Anchor point"); - Real mid_min = anchor_point - 0.5 * log_fine_diameter; - Real mid_max = anchor_point + 0.5 * log_fine_diameter; - - grid = gridFromIntervals_(ThreeGrids(), global_min, global_max, anchor_point, mid_min, - mid_max, ppd_fine, ppd_factor_lo, ppd_factor_hi); - } - - inline Real log2lin(const Real xl) const { - // JMM: Need to guard this with the linear bounds passed in. The - // reason is that our fast math routines, while completely - // invertible at the level of machine epsilon, do introduce error - // at machine epsilon, which can bring us out of the interpolation - // range of eospac. - return std::min(linmax_, - std::max(linmin_, singularity::FastMath::pow10(xl) - offset)); - } - inline Real i2lin(const int i) const { return log2lin(grid.x(i)); } - - friend std::ostream &operator<<(std::ostream &os, const Bounds &b) { - os << "Bounds: [" << b.grid.min() << ", " << b.grid.max() << "]" - << " + " << b.offset << "\n" - << "\tN = " << b.grid.nPoints() << "\n"; - for (int ig = 0; ig < b.grid.nGrids(); ++ig) { - os << "\t[ig,dx] = [" << ig << ", " << b.grid.dx(ig) << "]" - << "\n"; - } - return os; - } - - // This uses real logs - template - static int getNumPointsFromPPD(Real min, Real max, const T ppd) { - constexpr Real epsilon = std::numeric_limits::epsilon(); - const Real min_offset = 10 * std::abs(epsilon); - // 1.1 so that the y-intercept isn't identically zero - // when min < 0. - // min_offset to handle the case where min=0 - Real offset = 0; - if (min <= 0) offset = 1.1 * std::abs(min) + min_offset; - min += offset; - max += offset; - - Real lmin = std::log10(min); - Real lmax = std::log10(max); - int N = getNumPointsFromDensity(lmin, lmax, ppd); - return N; - } - template - static int getNumPointsFromDensity(const Real min, const Real max, const T density) { - Real delta = max - min; - int N = std::max(2, static_cast(std::ceil(density * delta))); - return N; - } - - private: - Real toLog_(Real val, const Real offset) { - val += offset; - return singularity::FastMath::log10(std::abs(val)); - } - - void convertBoundsToLog_(Real &min, Real &max, const Real shrinkRange = 0) { - // Log scales can't handle negative numbers or exactly zero. To - // deal with that, we offset. - constexpr Real epsilon = std::numeric_limits::epsilon(); - const Real min_offset = 10 * std::abs(epsilon); - // 1.1 so that the y-intercept isn't identically zero - // when min < 0. - // min_offset to handle the case where min=0 - if (min <= 0) offset = 1.1 * std::abs(min) + min_offset; - - min = toLog_(min, offset); - max = toLog_(max, offset); - - Real delta = max - min; - min += 0.5 * shrinkRange * delta; - max -= 0.5 * shrinkRange * delta; - } - - static void adjustForAnchor_(const Real min, Real &max, int &N, - const Real anchor_point) { - if (min < anchor_point && anchor_point < max) { - Real Nfrac = (anchor_point - min) / (max - min); - PORTABLE_REQUIRE((0 < Nfrac && Nfrac < 1), "anchor in bounds"); - - int Nanchor = static_cast(std::ceil(N * Nfrac)); - if ((Nanchor < 2) || (Nanchor >= N)) return; // not possible to shift this safely - - Real dx = (anchor_point - min) / static_cast(Nanchor - 1); - int Nmax_new = static_cast((max - min) / dx); - Real max_new = dx * (Nmax_new - 1) + min; - PORTABLE_REQUIRE(max_new <= max, "must not exceed table bounds"); - - N = Nmax_new; - max = max_new; - } else { - PORTABLE_ALWAYS_WARN("Anchor point out of bounds. Ignoring it."); - } - } - - static void checkInterval_(Real &p, const Real min, const Real max, - const std::string &name) { - if (p <= min) { - PORTABLE_ALWAYS_WARN(name + " less than minimum. Adjusting."); - Real eps = 0.1 * std::abs(min); - p = min + eps; - } - if (p >= max) { - PORTABLE_ALWAYS_WARN(name + " greater than maximum. Adjusting."); - Real eps = 0.1 * std::abs(max); - p = max - eps; - } - } - - static Grid_t gridFromIntervals_(ThreeGrids, Real global_min, Real global_max, - Real anchor_point, Real mid_min, Real mid_max, - const Real ppd_fine, const Real ppd_factor_lo, - const Real ppd_factor_hi) { - const Real ppd_lo = (ppd_factor_lo > 0) ? ppd_fine / ppd_factor_lo : ppd_fine; - const Real ppd_hi = (ppd_factor_hi > 0) ? ppd_fine / ppd_factor_hi : ppd_fine; - - if (mid_min <= global_min) { - PORTABLE_ALWAYS_WARN( - "Table bounds refined minimum lower than global minimum. Adjusting."); - Real delta = std::abs(anchor_point - global_min); - mid_min = anchor_point - 0.9 * delta; - } - if (mid_max >= global_max) { - PORTABLE_ALWAYS_WARN( - "Table bounds refined maximum greater than global maximum. Adjusting."); - Real delta = std::abs(global_max - anchor_point); - mid_max = anchor_point + 0.9 * delta; - } - - // add a point just to make sure we have enough points after adjusting for anchor - int N_fine = getNumPointsFromDensity(mid_min, mid_max, ppd_fine) + 1; - adjustForAnchor_(mid_min, mid_max, N_fine, anchor_point); - RegularGrid1D grid_middle(mid_min, mid_max, N_fine); - - const int N_lower = getNumPointsFromDensity(global_min, mid_min, ppd_lo); - RegularGrid1D grid_lower(global_min, mid_min, N_lower); - - const int N_upper = getNumPointsFromDensity(mid_max, global_max, ppd_hi); - RegularGrid1D grid_upper(mid_max, global_max, N_upper); - - return Grid_t(std::vector{grid_lower, grid_middle, grid_upper}); - } - - public: - Grid_t grid; - Real offset = 0; - bool piecewise = false; - - private: - Real linmin_, linmax_; -}; // JMM: Making this a struct with static methods, rather than a // namespace, saves a few "friend" declarations. Broadly these methods diff --git a/singularity-eos/closure/kinetic_phasetransition_methods.hpp b/singularity-eos/closure/kinetic_phasetransition_methods.hpp index 184a84de58c..89a9ba9d0a1 100644 --- a/singularity-eos/closure/kinetic_phasetransition_methods.hpp +++ b/singularity-eos/closure/kinetic_phasetransition_methods.hpp @@ -18,10 +18,10 @@ #include #include -#include -#include #include #include +#include +#include #include diff --git a/singularity-eos/closure/kinetic_phasetransition_models.hpp b/singularity-eos/closure/kinetic_phasetransition_models.hpp index 0c9892f101a..8aacf94889e 100644 --- a/singularity-eos/closure/kinetic_phasetransition_models.hpp +++ b/singularity-eos/closure/kinetic_phasetransition_models.hpp @@ -19,10 +19,10 @@ #include #include -#include -#include #include #include +#include +#include #include diff --git a/singularity-eos/closure/kinetic_phasetransition_utils.hpp b/singularity-eos/closure/kinetic_phasetransition_utils.hpp index 0dccf5eb19c..3d3a716e8c6 100644 --- a/singularity-eos/closure/kinetic_phasetransition_utils.hpp +++ b/singularity-eos/closure/kinetic_phasetransition_utils.hpp @@ -19,9 +19,9 @@ #include #include -#include -#include #include +#include +#include #include diff --git a/singularity-eos/closure/mixed_cell_models.hpp b/singularity-eos/closure/mixed_cell_models.hpp index 54bd884d858..bf0b1ffd9e7 100644 --- a/singularity-eos/closure/mixed_cell_models.hpp +++ b/singularity-eos/closure/mixed_cell_models.hpp @@ -17,11 +17,11 @@ #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include diff --git a/singularity-eos/eos/default_variant.hpp b/singularity-eos/eos/default_variant.hpp index 556c32bb8ee..431e9e939c7 100644 --- a/singularity-eos/eos/default_variant.hpp +++ b/singularity-eos/eos/default_variant.hpp @@ -30,7 +30,7 @@ // Base stuff #include #include -#include +#include // EOS models #include diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index f4d47d6e465..60823b3f0e1 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -23,9 +23,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include // This file was generated in part with the assistance of generative AI diff --git a/singularity-eos/eos/eos_builder.hpp b/singularity-eos/eos/eos_builder.hpp index fce5e8650b1..fef096d2d37 100644 --- a/singularity-eos/eos/eos_builder.hpp +++ b/singularity-eos/eos/eos_builder.hpp @@ -19,8 +19,8 @@ #include -#include #include +#include namespace singularity { namespace EOSBuilder { diff --git a/singularity-eos/eos/eos_carnahan_starling.hpp b/singularity-eos/eos/eos_carnahan_starling.hpp index 2a0bfd0d01c..87024e1c4ac 100644 --- a/singularity-eos/eos/eos_carnahan_starling.hpp +++ b/singularity-eos/eos/eos_carnahan_starling.hpp @@ -26,10 +26,10 @@ // Base stuff #include #include -#include -#include -#include #include +#include +#include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index 8323766763e..34a23fb35cf 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -20,10 +20,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include /* Implements the equation of state from Wescott, Stewart, and Davis, 2005 diff --git a/singularity-eos/eos/eos_electrons.hpp b/singularity-eos/eos/eos_electrons.hpp index 7ac3f61842d..0fb2d22629d 100644 --- a/singularity-eos/eos/eos_electrons.hpp +++ b/singularity-eos/eos/eos_electrons.hpp @@ -23,9 +23,9 @@ // Base stuff #include -#include -#include #include +#include +#include namespace singularity { using namespace eos_base; diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index a2940d605e3..6ada2f49055 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -31,8 +31,8 @@ #include #include -#include #include +#include // This file was made in part with generative AI diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index 8b79e79978a..5155ee60c40 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -21,10 +21,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include namespace singularity { @@ -292,7 +292,7 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::ComputeRhoMax(const Real s1, const Real maxbound = std::min(min_extremum, maxbound); } } // s3 > 0 ; else - } // discriminant >= 0 + } // discriminant >= 0 if (poly(minbound) * poly(maxbound) < 0.) { // Root is appropriately bounded using RootFinding1D::regula_falsi; diff --git a/singularity-eos/eos/eos_helmholtz.hpp b/singularity-eos/eos/eos_helmholtz.hpp index 665bf5925ed..69d472410f6 100644 --- a/singularity-eos/eos/eos_helmholtz.hpp +++ b/singularity-eos/eos/eos_helmholtz.hpp @@ -42,13 +42,13 @@ // singularity-eos #include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include // spiner #include diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index 0885ae4658e..aa2590ea4bf 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -26,8 +26,8 @@ // Base stuff #include #include -#include #include +#include #define MYMAX(a, b) a > b ? a : b diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index cb5106fc26c..50a0d7a3ae5 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -27,8 +27,8 @@ // Base stuff #include #include -#include #include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_mgusup.hpp b/singularity-eos/eos/eos_mgusup.hpp index 2ebba2009e8..ba6dc20d36e 100644 --- a/singularity-eos/eos/eos_mgusup.hpp +++ b/singularity-eos/eos/eos_mgusup.hpp @@ -22,9 +22,9 @@ #include #include -#include -#include #include +#include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_noble_abel.hpp b/singularity-eos/eos/eos_noble_abel.hpp index b54af11e31c..09eaeb6c6db 100644 --- a/singularity-eos/eos/eos_noble_abel.hpp +++ b/singularity-eos/eos/eos_noble_abel.hpp @@ -26,8 +26,8 @@ // Base stuff #include #include -#include #include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_powermg.hpp b/singularity-eos/eos/eos_powermg.hpp index 21191ce0f6a..e6a9a69905f 100644 --- a/singularity-eos/eos/eos_powermg.hpp +++ b/singularity-eos/eos/eos_powermg.hpp @@ -22,9 +22,9 @@ #include #include -#include -#include #include +#include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_sap_polynomial.hpp b/singularity-eos/eos/eos_sap_polynomial.hpp index 29320ea89c4..e36cbe8b837 100644 --- a/singularity-eos/eos/eos_sap_polynomial.hpp +++ b/singularity-eos/eos/eos_sap_polynomial.hpp @@ -26,8 +26,8 @@ // Base stuff #include #include -#include #include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_spiner_common.hpp b/singularity-eos/eos/eos_spiner_common.hpp index adec55d5164..b92c63bcc3b 100644 --- a/singularity-eos/eos/eos_spiner_common.hpp +++ b/singularity-eos/eos/eos_spiner_common.hpp @@ -36,8 +36,8 @@ // singularity-eos #include -#include -#include +#include +#include #define SPINER_EOS_VERBOSE (0) #define SP_ROOT_FINDER (RootFinding1D::regula_falsi) diff --git a/singularity-eos/eos/eos_spiner_rho_sie.hpp b/singularity-eos/eos/eos_spiner_rho_sie.hpp index 617ca8ea732..7b5f7d3c7df 100644 --- a/singularity-eos/eos/eos_spiner_rho_sie.hpp +++ b/singularity-eos/eos/eos_spiner_rho_sie.hpp @@ -38,16 +38,16 @@ // base #include #include -#include -#include -#include -#include -#include #include -#include #include #include #include +#include +#include +#include +#include +#include +#include // spiner #include diff --git a/singularity-eos/eos/eos_spiner_rho_temp.hpp b/singularity-eos/eos/eos_spiner_rho_temp.hpp index 0f8b49e75a0..6fb210e9e2b 100644 --- a/singularity-eos/eos/eos_spiner_rho_temp.hpp +++ b/singularity-eos/eos/eos_spiner_rho_temp.hpp @@ -38,14 +38,14 @@ // base #include #include -#include -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include +#include // spiner #include diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 311e565dea5..b7c2e846483 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -34,15 +34,15 @@ // singularity-eos #include -#include -#include -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include +#include +#include // spiner #include diff --git a/singularity-eos/eos/eos_stiff.hpp b/singularity-eos/eos/eos_stiff.hpp index a336504b99b..7e01f7aa84d 100644 --- a/singularity-eos/eos/eos_stiff.hpp +++ b/singularity-eos/eos/eos_stiff.hpp @@ -26,8 +26,8 @@ // Base stuff #include #include -#include #include +#include namespace singularity { diff --git a/singularity-eos/eos/eos_type_lists.hpp b/singularity-eos/eos/eos_type_lists.hpp index 30aaced18fa..f3f483fa8b9 100644 --- a/singularity-eos/eos/eos_type_lists.hpp +++ b/singularity-eos/eos/eos_type_lists.hpp @@ -30,7 +30,7 @@ // Base stuff #include #include -#include +#include // EOS models #include diff --git a/singularity-eos/eos/eos_variant.hpp b/singularity-eos/eos/eos_variant.hpp index 10fa5aabc8a..f966dc4d92d 100644 --- a/singularity-eos/eos/eos_variant.hpp +++ b/singularity-eos/eos/eos_variant.hpp @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include using Real = double; diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 14b182c1340..56164fb144f 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -22,9 +22,9 @@ #include #include -#include -#include #include +#include +#include namespace singularity { @@ -222,7 +222,7 @@ inline void Vinet::InitializeVinet(const Real *d2tod40input) { for (int ind = VinetInternalParametersSize - 2; ind >= 2; ind--) { // _VIP[42]=d40=f40 given,first calculated is _VIP[41]=f39 _VIP[ind] = _VIP[ind] - (ind) / _VIP[1] * _VIP[ind + 1]; // prefactors f40 to f0 - } // _VIP[n+2]=fn, ind=n+2 + } // _VIP[n+2]=fn, ind=n+2 } PORTABLE_INLINE_FUNCTION void Vinet::Vinet_F_DT_func(const Real rho, const Real T, @@ -241,7 +241,7 @@ PORTABLE_INLINE_FUNCTION void Vinet::Vinet_F_DT_func(const Real rho, const Real sumP = _d2tod40[pref0vp + ind] + onemx * sumP; //_d2tod40[38]=d40 sumB = _d2tod40[pref0vp + ind] * ind + onemx * sumB; //_d2tod40[-2+40]=d40 sumE = _VIP[pref0vip + ind] + onemx * sumE; //_VIP[42]=f40 - } //_VIP[2]=f0 + } //_VIP[2]=f0 #pragma unroll for (int ind = 1; ind >= 0; ind--) { sumE = _VIP[pref0vip + ind] + onemx * sumE; diff --git a/singularity-eos/eos/get_sg_eos_functors.hpp b/singularity-eos/eos/get_sg_eos_functors.hpp index 1cd3b7c0f40..084b6a840b9 100644 --- a/singularity-eos/eos/get_sg_eos_functors.hpp +++ b/singularity-eos/eos/get_sg_eos_functors.hpp @@ -16,8 +16,8 @@ #define _SINGULARITY_EOS_EOS_GET_SG_EOS_LAMBDAS_HPP_ #include -#include #include +#include #include diff --git a/singularity-eos/eos/modifiers/ramps_eos.hpp b/singularity-eos/eos/modifiers/ramps_eos.hpp index 5e4d07f278b..78c0648a2e3 100644 --- a/singularity-eos/eos/modifiers/ramps_eos.hpp +++ b/singularity-eos/eos/modifiers/ramps_eos.hpp @@ -29,10 +29,10 @@ #include #include #include -#include -#include #include #include +#include +#include namespace singularity { diff --git a/singularity-eos/eos/modifiers/relativistic_eos.hpp b/singularity-eos/eos/modifiers/relativistic_eos.hpp index 00771536148..329162c9029 100644 --- a/singularity-eos/eos/modifiers/relativistic_eos.hpp +++ b/singularity-eos/eos/modifiers/relativistic_eos.hpp @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include namespace singularity { diff --git a/singularity-eos/eos/modifiers/zsplit_eos.hpp b/singularity-eos/eos/modifiers/zsplit_eos.hpp index 8602b2742ad..827f3d9145f 100644 --- a/singularity-eos/eos/modifiers/zsplit_eos.hpp +++ b/singularity-eos/eos/modifiers/zsplit_eos.hpp @@ -22,10 +22,10 @@ #include #include #include -#include -#include -#include #include +#include +#include +#include namespace singularity { diff --git a/singularity-utils/singularity-utils/bounds.hpp b/singularity-utils/singularity-utils/bounds.hpp new file mode 100644 index 00000000000..75e6c4bc4e4 --- /dev/null +++ b/singularity-utils/singularity-utils/bounds.hpp @@ -0,0 +1,291 @@ +//------------------------------------------------------------------------------ +// Grid bounds management for SP5 file format +// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_UTILS_BOUNDS_HPP_ +#define SINGULARITY_UTILS_BOUNDS_HPP_ +#ifdef SINGULARITY_USE_SPINER + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +namespace singularity { +namespace table_utils { + +// For logarithmic interpolation, quantities may be negative. +// If they are, use offset to ensure negative values make sense. +template +class Bounds { + public: + using RegularGrid1D = Spiner::RegularGrid1D; + using Grid_t = Spiner::PiecewiseGrid1D; + // for tag dispatch in constructors + using OneGrid = std::integral_constant; + using TwoGrids = std::integral_constant; + using ThreeGrids = std::integral_constant; + + Bounds() : offset(0), piecewise(false), linmin_(0), linmax_(0) {} + + Bounds(const Real min, const Real max, const int N, const Real offset) + : grid(Grid_t(std::vector{RegularGrid1D(min, max, N)})), + offset(offset), piecewise(false), linmin_(min), linmax_(max) {} + Bounds(OneGrid, const Real min, const Real max, const int N, const Real offset) + : Bounds(min, max, N, offset) {} + + Bounds(Real min, Real max, int N, const bool convertToLog = false, + const Real shrinkRange = 0, + Real anchor_point = std::numeric_limits::signaling_NaN()) + : offset(0), piecewise(true), linmin_(min), linmax_(max) { + if (convertToLog) { + convertBoundsToLog_(min, max, shrinkRange); + if (!(std::isnan(anchor_point))) { + anchor_point = singularity::FastMath::log10(std::abs(anchor_point)); + } + } + if (!(std::isnan(anchor_point))) { + adjustForAnchor_(min, max, N, anchor_point); + } + grid = Grid_t(std::vector{RegularGrid1D(min, max, N)}); + } + Bounds(OneGrid, Real min, Real max, int N, const bool convertToLog = false, + const Real shrinkRange = 0, + Real anchor_point = std::numeric_limits::signaling_NaN()) + : Bounds(min, max, N, convertToLog, shrinkRange, anchor_point) {} + + Bounds(TwoGrids, Real global_min, Real global_max, Real anchor_point, Real splitPoint, + const Real ppd_fine, const Real ppd_factor, const bool convertToLog, + const Real shrinkRange = 0) + : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { + const Real ppd_coarse = (ppd_factor > 0) ? ppd_fine / ppd_factor : ppd_fine; + + if (convertToLog) { + convertBoundsToLog_(global_min, global_max, shrinkRange); + anchor_point = toLog_(anchor_point, offset); + splitPoint = toLog_(splitPoint, offset); + } + + checkInterval_(splitPoint, global_min, global_max, "Split point"); + checkInterval_(anchor_point, global_min, splitPoint, "Anchor point"); + + // add a point just to make sure we have enough points after adjusting for anchor + int N_fine = getNumPointsFromDensity(global_min, splitPoint, ppd_fine) + 1; + adjustForAnchor_(global_min, splitPoint, N_fine, anchor_point); + RegularGrid1D grid_lower(global_min, splitPoint, N_fine); + + const int N_upper = getNumPointsFromDensity(splitPoint, global_max, ppd_coarse); + RegularGrid1D grid_upper(splitPoint, global_max, N_upper); + + grid = Grid_t(std::vector{grid_lower, grid_upper}); + } + + Bounds(ThreeGrids, Real global_min, Real global_max, Real anchor_point, Real fine_min, + Real fine_max, const Real ppd_fine, const Real ppd_factor_lo, + const Real ppd_factor_hi, const bool convertToLog, const Real shrinkRange = 0) + : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { + + if (convertToLog) { + convertBoundsToLog_(global_min, global_max, shrinkRange); + anchor_point = toLog_(anchor_point, offset); + fine_min = toLog_(fine_min, offset); + fine_max = toLog_(fine_max, offset); + } + checkInterval_(anchor_point, global_min, global_max, "Anchor point"); + + grid = gridFromIntervals_(ThreeGrids(), global_min, global_max, anchor_point, + fine_min, fine_max, ppd_fine, ppd_factor_lo, ppd_factor_hi); + } + + Bounds(ThreeGrids, Real global_min, Real global_max, Real anchor_point, + Real log_fine_diameter, const Real ppd_fine, const Real ppd_factor_lo, + const Real ppd_factor_hi, const bool convertToLog, const Real shrinkRange = 0) + : offset(0), piecewise(true), linmin_(global_min), linmax_(global_max) { + + if (convertToLog) { + convertBoundsToLog_(global_min, global_max, shrinkRange); + anchor_point = toLog_(anchor_point, offset); + } + + checkInterval_(anchor_point, global_min, global_max, "Anchor point"); + Real mid_min = anchor_point - 0.5 * log_fine_diameter; + Real mid_max = anchor_point + 0.5 * log_fine_diameter; + + grid = gridFromIntervals_(ThreeGrids(), global_min, global_max, anchor_point, mid_min, + mid_max, ppd_fine, ppd_factor_lo, ppd_factor_hi); + } + + inline Real log2lin(const Real xl) const { + // JMM: Need to guard this with the linear bounds passed in. The + // reason is that our fast math routines, while completely + // invertible at the level of machine epsilon, do introduce error + // at machine epsilon, which can bring us out of the interpolation + // range of eospac. + return std::min(linmax_, + std::max(linmin_, singularity::FastMath::pow10(xl) - offset)); + } + inline Real i2lin(const int i) const { return log2lin(grid.x(i)); } + + friend std::ostream &operator<<(std::ostream &os, const Bounds &b) { + os << "Bounds: [" << b.grid.min() << ", " << b.grid.max() << "]" + << " + " << b.offset << "\n" + << "\tN = " << b.grid.nPoints() << "\n"; + for (int ig = 0; ig < b.grid.nGrids(); ++ig) { + os << "\t[ig,dx] = [" << ig << ", " << b.grid.dx(ig) << "]" + << "\n"; + } + return os; + } + + // This uses real logs + template + static int getNumPointsFromPPD(Real min, Real max, const T ppd) { + constexpr Real epsilon = std::numeric_limits::epsilon(); + const Real min_offset = 10 * std::abs(epsilon); + // 1.1 so that the y-intercept isn't identically zero + // when min < 0. + // min_offset to handle the case where min=0 + Real offset = 0; + if (min <= 0) offset = 1.1 * std::abs(min) + min_offset; + min += offset; + max += offset; + + Real lmin = std::log10(min); + Real lmax = std::log10(max); + int N = getNumPointsFromDensity(lmin, lmax, ppd); + return N; + } + template + static int getNumPointsFromDensity(const Real min, const Real max, const T density) { + Real delta = max - min; + int N = std::max(2, static_cast(std::ceil(density * delta))); + return N; + } + + private: + Real toLog_(Real val, const Real offset) { + val += offset; + return singularity::FastMath::log10(std::abs(val)); + } + + void convertBoundsToLog_(Real &min, Real &max, const Real shrinkRange = 0) { + // Log scales can't handle negative numbers or exactly zero. To + // deal with that, we offset. + constexpr Real epsilon = std::numeric_limits::epsilon(); + const Real min_offset = 10 * std::abs(epsilon); + // 1.1 so that the y-intercept isn't identically zero + // when min < 0. + // min_offset to handle the case where min=0 + if (min <= 0) offset = 1.1 * std::abs(min) + min_offset; + + min = toLog_(min, offset); + max = toLog_(max, offset); + + Real delta = max - min; + min += 0.5 * shrinkRange * delta; + max -= 0.5 * shrinkRange * delta; + } + + static void adjustForAnchor_(const Real min, Real &max, int &N, + const Real anchor_point) { + if (min < anchor_point && anchor_point < max) { + Real Nfrac = (anchor_point - min) / (max - min); + PORTABLE_REQUIRE((0 < Nfrac && Nfrac < 1), "anchor in bounds"); + + int Nanchor = static_cast(std::ceil(N * Nfrac)); + if ((Nanchor < 2) || (Nanchor >= N)) return; // not possible to shift this safely + + Real dx = (anchor_point - min) / static_cast(Nanchor - 1); + int Nmax_new = static_cast((max - min) / dx); + Real max_new = dx * (Nmax_new - 1) + min; + PORTABLE_REQUIRE(max_new <= max, "must not exceed table bounds"); + + N = Nmax_new; + max = max_new; + } else { + PORTABLE_ALWAYS_WARN("Anchor point out of bounds. Ignoring it."); + } + } + + static void checkInterval_(Real &p, const Real min, const Real max, + const std::string &name) { + if (p <= min) { + PORTABLE_ALWAYS_WARN(name + " less than minimum. Adjusting."); + Real eps = 0.1 * std::abs(min); + p = min + eps; + } + if (p >= max) { + PORTABLE_ALWAYS_WARN(name + " greater than maximum. Adjusting."); + Real eps = 0.1 * std::abs(max); + p = max - eps; + } + } + + static Grid_t gridFromIntervals_(ThreeGrids, Real global_min, Real global_max, + Real anchor_point, Real mid_min, Real mid_max, + const Real ppd_fine, const Real ppd_factor_lo, + const Real ppd_factor_hi) { + const Real ppd_lo = (ppd_factor_lo > 0) ? ppd_fine / ppd_factor_lo : ppd_fine; + const Real ppd_hi = (ppd_factor_hi > 0) ? ppd_fine / ppd_factor_hi : ppd_fine; + + if (mid_min <= global_min) { + PORTABLE_ALWAYS_WARN( + "Table bounds refined minimum lower than global minimum. Adjusting."); + Real delta = std::abs(anchor_point - global_min); + mid_min = anchor_point - 0.9 * delta; + } + if (mid_max >= global_max) { + PORTABLE_ALWAYS_WARN( + "Table bounds refined maximum greater than global maximum. Adjusting."); + Real delta = std::abs(global_max - anchor_point); + mid_max = anchor_point + 0.9 * delta; + } + + // add a point just to make sure we have enough points after adjusting for anchor + int N_fine = getNumPointsFromDensity(mid_min, mid_max, ppd_fine) + 1; + adjustForAnchor_(mid_min, mid_max, N_fine, anchor_point); + RegularGrid1D grid_middle(mid_min, mid_max, N_fine); + + const int N_lower = getNumPointsFromDensity(global_min, mid_min, ppd_lo); + RegularGrid1D grid_lower(global_min, mid_min, N_lower); + + const int N_upper = getNumPointsFromDensity(mid_max, global_max, ppd_hi); + RegularGrid1D grid_upper(mid_max, global_max, N_upper); + + return Grid_t(std::vector{grid_lower, grid_middle, grid_upper}); + } + + public: + Grid_t grid; + Real offset = 0; + bool piecewise = false; + + private: + Real linmin_, linmax_; +}; + +} // namespace table_utils +} // namespace singularity + +#endif // SINGULARITY_USE_SPINER +#endif // SINGULARITY_UTILS_BOUNDS_HPP_ diff --git a/singularity-utils/singularity-utils/constants.hpp b/singularity-utils/singularity-utils/constants.hpp new file mode 100644 index 00000000000..b1989cd10f5 --- /dev/null +++ b/singularity-utils/singularity-utils/constants.hpp @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_UTILS_CONSTANTS_HPP_ +#define SINGULARITY_UTILS_CONSTANTS_HPP_ + +namespace singularity { + +// Enum for table splitting modes +// Used when converting EOSPAC tables that can be split into +// electron-only and ion-cold contributions +enum class TableSplit { Total = 0, ElectronOnly = 1, IonCold = 2 }; + +} // namespace singularity + +#endif // SINGULARITY_UTILS_CONSTANTS_HPP_ diff --git a/singularity-eos/base/error_utils.hpp b/singularity-utils/singularity-utils/error_utils.hpp similarity index 94% rename from singularity-eos/base/error_utils.hpp rename to singularity-utils/singularity-utils/error_utils.hpp index 4e0527f60f3..fcf306ec3c2 100644 --- a/singularity-eos/base/error_utils.hpp +++ b/singularity-utils/singularity-utils/error_utils.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ -#define SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ +#ifndef SINGULARITY_UTILS_ERROR_UTILS_HPP_ +#define SINGULARITY_UTILS_ERROR_UTILS_HPP_ #include #include @@ -85,4 +85,4 @@ PORTABLE_FORCEINLINE_FUNCTION bool negative_value(valT &&value, nameT &&var_name } // namespace error_utils } // namespace singularity -#endif // #ifndef SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ +#endif // #ifndef SINGULARITY_UTILS_ERROR_UTILS_HPP_ diff --git a/singularity-eos/base/fast-math/logs.hpp b/singularity-utils/singularity-utils/fast-math/logs.hpp similarity index 97% rename from singularity-eos/base/fast-math/logs.hpp rename to singularity-utils/singularity-utils/fast-math/logs.hpp index a986d8a1c25..609c2d3b495 100644 --- a/singularity-eos/base/fast-math/logs.hpp +++ b/singularity-utils/singularity-utils/fast-math/logs.hpp @@ -1,5 +1,5 @@ //====================================================================== -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //====================================================================== -#ifndef _SINGULARITY_EOS_UTILS_FAST_MATH_LOGS_ -#define _SINGULARITY_EOS_UTILS_FAST_MATH_LOGS_ +#ifndef _SINGULARITY_UTILS_FAST_MATH_LOGS_ +#define _SINGULARITY_UTILS_FAST_MATH_LOGS_ #include #include #include @@ -294,4 +294,4 @@ double pow10(const double x) { } // namespace FastMath } // namespace singularity -#endif // _SINGULARITY_EOS_UTILS_FAST_MATH_LOGS_ +#endif // _SINGULARITY_UTILS_FAST_MATH_LOGS_ diff --git a/singularity-eos/base/generic_indexer.hpp b/singularity-utils/singularity-utils/generic_indexer.hpp similarity index 90% rename from singularity-eos/base/generic_indexer.hpp rename to singularity-utils/singularity-utils/generic_indexer.hpp index 70c35a2ea79..d4d94e91154 100644 --- a/singularity-eos/base/generic_indexer.hpp +++ b/singularity-utils/singularity-utils/generic_indexer.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ -#define SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ +#ifndef SINGULARITY_UTILS_GENERIC_INDEXER_HPP_ +#define SINGULARITY_UTILS_GENERIC_INDEXER_HPP_ #include @@ -59,4 +59,4 @@ GenericIndexer(ArrT_ &&, MapT_ &&) -> GenericIndexer; } // namespace singularity -#endif // #ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ +#endif // #ifndef SINGULARITY_UTILS_GENERIC_INDEXER_HPP_ diff --git a/singularity-eos/base/hermite.hpp b/singularity-utils/singularity-utils/hermite.hpp similarity index 94% rename from singularity-eos/base/hermite.hpp rename to singularity-utils/singularity-utils/hermite.hpp index ebee68258fa..fdcd1a2fc72 100644 --- a/singularity-eos/base/hermite.hpp +++ b/singularity-utils/singularity-utils/hermite.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2023. Triad National Security, LLC. All rights reserved. This +// © 2023–2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,11 +12,11 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_HERMITE_HPP_ -#define SINGULARITY_EOS_BASE_HERMITE_HPP_ +#ifndef SINGULARITY_UTILS_HERMITE_HPP_ +#define SINGULARITY_UTILS_HERMITE_HPP_ #include -#include +#include namespace singularity { namespace hermite { @@ -96,4 +96,4 @@ PORTABLE_INLINE_FUNCTION Real h3(Real fi[16], Real w0t, Real w1t, Real w0mt, Rea } // namespace hermite } // namespace singularity -#endif // SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ +#endif // SINGULARITY_UTILS_MATH_UTILS_HPP_ diff --git a/singularity-eos/base/indexable_types.hpp b/singularity-utils/singularity-utils/indexable_types.hpp similarity index 98% rename from singularity-eos/base/indexable_types.hpp rename to singularity-utils/singularity-utils/indexable_types.hpp index c950832f797..95b004720e4 100644 --- a/singularity-eos/base/indexable_types.hpp +++ b/singularity-utils/singularity-utils/indexable_types.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2025. Triad National Security, LLC. All rights reserved. This +// © 2025-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ -#define SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ +#ifndef SINGULARITY_UTILS_INDEXABLE_TYPES_ +#define SINGULARITY_UTILS_INDEXABLE_TYPES_ #include #include @@ -21,7 +21,7 @@ #include #include -#include +#include namespace singularity { namespace IndexerUtils { @@ -352,4 +352,4 @@ struct MassFractions { }; } // namespace IndexableTypes } // namespace singularity -#endif // SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ +#endif // SINGULARITY_UTILS_INDEXABLE_TYPES_ diff --git a/singularity-eos/base/math_utils.hpp b/singularity-utils/singularity-utils/math_utils.hpp similarity index 90% rename from singularity-eos/base/math_utils.hpp rename to singularity-utils/singularity-utils/math_utils.hpp index f24fe4dbe81..6f423f4be5d 100644 --- a/singularity-eos/base/math_utils.hpp +++ b/singularity-utils/singularity-utils/math_utils.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2022. Triad National Security, LLC. All rights reserved. This +// © 2022-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ -#define SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ +#ifndef SINGULARITY_UTILS_MATH_UTILS_HPP_ +#define SINGULARITY_UTILS_MATH_UTILS_HPP_ #include @@ -61,4 +61,4 @@ PORTABLE_FORCEINLINE_FUNCTION auto pow10(const Real x) { } // namespace math_utils } // namespace singularity -#endif // SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ +#endif // SINGULARITY_UTILS_MATH_UTILS_HPP_ diff --git a/singularity-eos/base/robust_utils.hpp b/singularity-utils/singularity-utils/robust_utils.hpp similarity index 94% rename from singularity-eos/base/robust_utils.hpp rename to singularity-utils/singularity-utils/robust_utils.hpp index 6c51d89abbd..6af6ce83023 100644 --- a/singularity-eos/base/robust_utils.hpp +++ b/singularity-utils/singularity-utils/robust_utils.hpp @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ -#define SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ +#ifndef SINGULARITY_UTILS_ROBUST_UTILS_HPP_ +#define SINGULARITY_UTILS_ROBUST_UTILS_HPP_ #include #include @@ -77,4 +77,4 @@ PORTABLE_FORCEINLINE_FUNCTION T safe_arg_exp(const T &x) { } // namespace robust } // namespace singularity -#endif // SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ +#endif // SINGULARITY_UTILS_ROBUST_UTILS_HPP_ diff --git a/singularity-eos/base/root-finding-1d/root_finding.hpp b/singularity-utils/singularity-utils/root-finding-1d/root_finding.hpp similarity index 99% rename from singularity-eos/base/root-finding-1d/root_finding.hpp rename to singularity-utils/singularity-utils/root-finding-1d/root_finding.hpp index ceb289e5af5..1e052e102fb 100644 --- a/singularity-eos/base/root-finding-1d/root_finding.hpp +++ b/singularity-utils/singularity-utils/root-finding-1d/root_finding.hpp @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef _SINGULARITY_EOS_UTILS_ROOT_FINDING_HPP_ -#define _SINGULARITY_EOS_UTILS_ROOT_FINDING_HPP_ +#ifndef _SINGULARITY_UTILS_ROOT_FINDING_1D_ROOT_FINDING_HPP_ +#define _SINGULARITY_UTILS_ROOT_FINDING_1D_ROOT_FINDING_HPP_ // Implementation based on gsl root finder API // Code originally taken from nubhlight, LA-UR-19-20336 @@ -608,4 +608,4 @@ PORTABLE_INLINE_FUNCTION Status bisect(const T &f, const Real ytarget, const Rea #undef SINGULARITY_ROOT_VERBOSE #undef SINGULARITY_MY_SIGN -#endif // _SINGULARITY_EOS_UTILS_ROOT_FINDING_HPP_ +#endif // _SINGULARITY_UTILS_ROOT_FINDING_1D_ROOT_FINDING_HPP_ diff --git a/singularity-eos/base/sp5/singularity_eos_sp5.hpp b/singularity-utils/singularity-utils/sp5/singularity_eos_sp5.hpp similarity index 94% rename from singularity-eos/base/sp5/singularity_eos_sp5.hpp rename to singularity-utils/singularity-utils/sp5/singularity_eos_sp5.hpp index 67eedf64da9..2e9082e1088 100644 --- a/singularity-eos/base/sp5/singularity_eos_sp5.hpp +++ b/singularity-utils/singularity-utils/sp5/singularity_eos_sp5.hpp @@ -14,8 +14,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef _SINGULARITY_EOS_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ -#define _SINGULARITY_EOS_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ +#ifndef _SINGULARITY_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ +#define _SINGULARITY_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ namespace SP5 { @@ -74,4 +74,4 @@ constexpr char massFrac[] = "mass fractions"; } // namespace SP5 -#endif // _SINGULARITY_EOS_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ +#endif // _SINGULARITY_UTILS_SP5_SINGULARITY_EOS_SP5_HPP_ diff --git a/singularity-eos/base/variadic_utils.hpp b/singularity-utils/singularity-utils/variadic_utils.hpp similarity index 97% rename from singularity-eos/base/variadic_utils.hpp rename to singularity-utils/singularity-utils/variadic_utils.hpp index 8b30c0cb5b2..5780673e978 100644 --- a/singularity-eos/base/variadic_utils.hpp +++ b/singularity-utils/singularity-utils/variadic_utils.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2021-2024. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -12,8 +12,8 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#ifndef SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ -#define SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ +#ifndef SINGULARITY_UTILS_VARIADIC_UTILS_HPP_ +#define SINGULARITY_UTILS_VARIADIC_UTILS_HPP_ #include #include @@ -261,4 +261,4 @@ constexpr auto pack_size(type_list) { } // namespace variadic_utils } // namespace singularity -#endif // SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ +#endif // SINGULARITY_UTILS_VARIADIC_UTILS_HPP_ diff --git a/test/compare_to_eospac.cpp b/test/compare_to_eospac.cpp index 024da2d3756..bfe3cbc3063 100644 --- a/test/compare_to_eospac.cpp +++ b/test/compare_to_eospac.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/eos_unit_test_helpers.hpp b/test/eos_unit_test_helpers.hpp index e11e6a7c72e..a0ab6469c2d 100644 --- a/test/eos_unit_test_helpers.hpp +++ b/test/eos_unit_test_helpers.hpp @@ -35,7 +35,7 @@ #include #include -#include +#include inline std::string demangle(const char *name) { diff --git a/test/profile_stellar_collapse.cpp b/test/profile_stellar_collapse.cpp index 21200075806..7a5c3bf10fb 100644 --- a/test/profile_stellar_collapse.cpp +++ b/test/profile_stellar_collapse.cpp @@ -31,7 +31,7 @@ // #include "hdf5_hl.h" #include -#include +#include #include #include #include diff --git a/test/pte_test_3mat_analytic.hpp b/test/pte_test_3mat_analytic.hpp index f1437370f7f..3f01876058f 100644 --- a/test/pte_test_3mat_analytic.hpp +++ b/test/pte_test_3mat_analytic.hpp @@ -21,9 +21,9 @@ #include #include -#include #include #include +#include constexpr int NMAT = 3; constexpr int NTRIAL = 100; diff --git a/test/test_bounds.cpp b/test/test_bounds.cpp index 0e35bb0fb88..c4b494e21f1 100644 --- a/test/test_bounds.cpp +++ b/test/test_bounds.cpp @@ -18,8 +18,8 @@ #include #include -#include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_closure_pte.cpp b/test/test_closure_pte.cpp index dd1cc262683..5790a25c7f0 100644 --- a/test/test_closure_pte.cpp +++ b/test/test_closure_pte.cpp @@ -25,10 +25,10 @@ #endif #include -#include -#include #include #include +#include +#include #include #ifdef SINGULARITY_TEST_SESAME diff --git a/test/test_eos_carnahan_starling.cpp b/test/test_eos_carnahan_starling.cpp index 986671591af..51db0d080b8 100644 --- a/test/test_eos_carnahan_starling.cpp +++ b/test/test_eos_carnahan_starling.cpp @@ -23,8 +23,8 @@ #endif #include -#include #include +#include #include using singularity::CarnahanStarling; diff --git a/test/test_eos_davis.cpp b/test/test_eos_davis.cpp index f5b459a214a..275e951ae87 100644 --- a/test/test_eos_davis.cpp +++ b/test/test_eos_davis.cpp @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_eos_ideal.cpp b/test/test_eos_ideal.cpp index 2faf1f6b33a..61bd6cda217 100644 --- a/test/test_eos_ideal.cpp +++ b/test/test_eos_ideal.cpp @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_eos_modifiers.cpp b/test/test_eos_modifiers.cpp index dc00b4c0238..c4e99d06ccb 100644 --- a/test/test_eos_modifiers.cpp +++ b/test/test_eos_modifiers.cpp @@ -19,12 +19,12 @@ #include #include #include -#include -#include -#include #include #include #include +#include +#include +#include #ifdef SINGULARITY_BUILD_CLOSURE #include diff --git a/test/test_eos_modifiers_minimal.cpp b/test/test_eos_modifiers_minimal.cpp index ace79a7406b..636bcbdf2d2 100644 --- a/test/test_eos_modifiers_minimal.cpp +++ b/test/test_eos_modifiers_minimal.cpp @@ -16,11 +16,11 @@ #include #include #include -#include -#include #include #include #include +#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_eos_tabulated.cpp b/test/test_eos_tabulated.cpp index e61fb6b8185..352aaff16d9 100644 --- a/test/test_eos_tabulated.cpp +++ b/test/test_eos_tabulated.cpp @@ -23,9 +23,9 @@ #include #include #include -#include -#include #include +#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_eos_zsplit.cpp b/test/test_eos_zsplit.cpp index c52ff9a05b4..81b50ae832a 100644 --- a/test/test_eos_zsplit.cpp +++ b/test/test_eos_zsplit.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_generic_indxer.cpp b/test/test_generic_indxer.cpp index a5fd7882b3e..fad820b62a3 100644 --- a/test/test_generic_indxer.cpp +++ b/test/test_generic_indxer.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_indexable_types.cpp b/test/test_indexable_types.cpp index 9b83e251688..390a9e22726 100644 --- a/test/test_indexable_types.cpp +++ b/test/test_indexable_types.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_math_utils.cpp b/test/test_math_utils.cpp index 1dee262ef6a..1127fe7a90c 100644 --- a/test/test_math_utils.cpp +++ b/test/test_math_utils.cpp @@ -17,9 +17,9 @@ #include #include #include -#include -#include #include +#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_modifier_floored_energy.cpp b/test/test_modifier_floored_energy.cpp index 073ffddbcef..df84eacd14f 100644 --- a/test/test_modifier_floored_energy.cpp +++ b/test/test_modifier_floored_energy.cpp @@ -24,9 +24,9 @@ #include #include -#include #include #include +#include #include using singularity::DavisReactants; diff --git a/test/test_pte.cpp b/test/test_pte.cpp index 9dcfedf8da7..eb603afb26b 100644 --- a/test/test_pte.cpp +++ b/test/test_pte.cpp @@ -23,8 +23,8 @@ #include #include -#include #include +#include #include #include diff --git a/test/test_pte_ideal.cpp b/test/test_pte_ideal.cpp index ee97f2ac054..5aa411c05b3 100644 --- a/test/test_pte_ideal.cpp +++ b/test/test_pte_ideal.cpp @@ -22,7 +22,7 @@ // #include #include #include -#include +#include #include diff --git a/test/test_robust_utils.cpp b/test/test_robust_utils.cpp index 90ca6b8d3a0..cc7392676d7 100644 --- a/test/test_robust_utils.cpp +++ b/test/test_robust_utils.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_solver_utils.cpp b/test/test_solver_utils.cpp index c669b66785c..81daa4efabf 100644 --- a/test/test_solver_utils.cpp +++ b/test/test_solver_utils.cpp @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE diff --git a/test/test_spiner_transform.cpp b/test/test_spiner_transform.cpp index add2f78811f..397ad01c56d 100644 --- a/test/test_spiner_transform.cpp +++ b/test/test_spiner_transform.cpp @@ -26,9 +26,9 @@ #ifdef SINGULARITY_USE_SPINER #include -#include #include #include +#include #include #include diff --git a/test/test_variadic_utils.cpp b/test/test_variadic_utils.cpp index 0ef520dba06..b8f0a51615e 100644 --- a/test/test_variadic_utils.cpp +++ b/test/test_variadic_utils.cpp @@ -12,10 +12,10 @@ // publicly and display publicly, and to permit others to do so. //------------------------------------------------------------------------------ -#include #include #include #include +#include #ifndef CATCH_CONFIG_FAST_COMPILE #define CATCH_CONFIG_FAST_COMPILE From 63646a38b9f14b5e6d7a15dd6106fd4d1189e396 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 14:08:00 -0600 Subject: [PATCH 03/14] Move sesame2spiner files into a library and executable src/ directories. Modify cmake so that we build a library. --- sesame2spiner/CMakeLists.txt | 95 ++++++++++++++++--- .../{ => sesame2spiner}/generate_files.cpp | 3 +- .../{ => sesame2spiner}/generate_files.hpp | 0 .../{ => sesame2spiner}/io_eospac.cpp | 0 .../{ => sesame2spiner}/io_eospac.hpp | 10 +- sesame2spiner/{ => sesame2spiner}/parser.cpp | 4 +- sesame2spiner/{ => sesame2spiner}/parser.hpp | 42 ++++++++ sesame2spiner/{ => src}/main.cpp | 4 +- sesame2spiner/{ => src}/parse_cli.cpp | 3 +- sesame2spiner/{ => src}/parse_cli.hpp | 43 +-------- sesame2spiner/{ => test}/test.cpp | 0 11 files changed, 140 insertions(+), 64 deletions(-) rename sesame2spiner/{ => sesame2spiner}/generate_files.cpp (99%) rename sesame2spiner/{ => sesame2spiner}/generate_files.hpp (100%) rename sesame2spiner/{ => sesame2spiner}/io_eospac.cpp (100%) rename sesame2spiner/{ => sesame2spiner}/io_eospac.hpp (95%) rename sesame2spiner/{ => sesame2spiner}/parser.cpp (99%) rename sesame2spiner/{ => sesame2spiner}/parser.hpp (72%) rename sesame2spiner/{ => src}/main.cpp (96%) rename sesame2spiner/{ => src}/parse_cli.cpp (97%) rename sesame2spiner/{ => src}/parse_cli.hpp (64%) rename sesame2spiner/{ => test}/test.cpp (100%) diff --git a/sesame2spiner/CMakeLists.txt b/sesame2spiner/CMakeLists.txt index 5d622d92be5..a15aadcd41f 100644 --- a/sesame2spiner/CMakeLists.txt +++ b/sesame2spiner/CMakeLists.txt @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# © 2021-2023. Triad National Security, LLC. All rights reserved. This +# © 2021-2026. Triad National Security, LLC. All rights reserved. This # program was produced under U.S. Government contract 89233218CNA000001 # for Los Alamos National Laboratory (LANL), which is operated by Triad # National Security, LLC for the U.S. Department of Energy/National @@ -12,30 +12,97 @@ # publicly and display publicly, and to permit others to do so. #------------------------------------------------------------------------------ + +# sesame2spiner library +add_library(sesame2spiner-lib + sesame2spiner/io_eospac.cpp + sesame2spiner/io_eospac.hpp + sesame2spiner/generate_files.cpp + sesame2spiner/generate_files.hpp + sesame2spiner/parser.cpp + sesame2spiner/parser.hpp + +) + +set_target_properties(sesame2spiner-lib PROPERTIES OUTPUT_NAME sesame2spiner) + +target_include_directories(sesame2spiner-lib + PUBLIC + $ + $ +) + +target_link_libraries(sesame2spiner-lib + PUBLIC + singularity-utils::singularity-utils + eospac-wrapper + singularity-eos::singularity-eos_Common # For HDF5 +) + +target_compile_definitions(sesame2spiner-lib + PUBLIC + SESAME2SPINER_VERSION=\"${PROJECT_VERSION}\" +) + +# Propate SPINER defines +if (DEFINED SINGULARITY_USE_SPINER) + target_compile_definitions(sesame2spiner-lib + PUBLIC + $<$:SINGULARITY_USE_SPINER> + ) +endif() + +# Propagate HDF5 usage definitions +# These must match the settings used by singularity-eos +if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) + target_compile_definitions(sesame2spiner-lib + PUBLIC + $<$:SINGULARITY_USE_SPINER_WITH_HDF5> + ) +endif() + + +add_library(sesame2spiner::sesame2spiner ALIAS sesame2spiner-lib) + +# sesame2spiner executable add_executable(sesame2spiner - io_eospac.cpp - io_eospac.hpp - generate_files.cpp - generate_files.hpp - parse_cli.cpp - parse_cli.hpp - parser.cpp - parser.hpp - main.cpp + src/parse_cli.cpp + src/parse_cli.hpp + src/main.cpp ) target_include_directories(sesame2spiner - PUBLIC - $ - $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src ) target_link_libraries(sesame2spiner PUBLIC - singularity-eos::singularity-eos + sesame2spiner-lib ) +# install + install(TARGETS sesame2spiner DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS sesame2spiner-lib + EXPORT sesame2spiner-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION include +) + +install(DIRECTORY sesame2spiner/ + DESTINATION include/sesame2spiner +) + +if(NOT SINGULARITY_SUBMODULE_MODE) + install(EXPORT sesame2spiner-targets + FILE sesame2spiner-targets.cmake + NAMESPACE sesame2spiner:: + DESTINATION lib/cmake/sesame2spiner + ) +endif() + # TODO: Add tests for sesame2spiner here. diff --git a/sesame2spiner/generate_files.cpp b/sesame2spiner/sesame2spiner/generate_files.cpp similarity index 99% rename from sesame2spiner/generate_files.cpp rename to sesame2spiner/sesame2spiner/generate_files.cpp index ded57ee82b3..621ad0df778 100644 --- a/sesame2spiner/generate_files.cpp +++ b/sesame2spiner/sesame2spiner/generate_files.cpp @@ -39,7 +39,6 @@ #include "generate_files.hpp" #include "io_eospac.hpp" -#include "parse_cli.hpp" #include "parser.hpp" using namespace EospacWrapper; @@ -184,7 +183,7 @@ herr_t saveAllMaterials(const std::string &savename, file = H5Fcreate(savename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); // singularity version - H5LTset_attribute_string(file, "/", "singularity_version", SINGULARITY_VERSION); + H5LTset_attribute_string(file, "/", "singularity_version", SESAME2SPINER_VERSION); // log type. 0 for true, 1 for NQT1, 2 for NQT2, -1 for single precision true int log_type = singularity::FastMath::Settings::log_type; H5LTset_attribute_int(file, "/", SP5::logType, &log_type, 1); diff --git a/sesame2spiner/generate_files.hpp b/sesame2spiner/sesame2spiner/generate_files.hpp similarity index 100% rename from sesame2spiner/generate_files.hpp rename to sesame2spiner/sesame2spiner/generate_files.hpp diff --git a/sesame2spiner/io_eospac.cpp b/sesame2spiner/sesame2spiner/io_eospac.cpp similarity index 100% rename from sesame2spiner/io_eospac.cpp rename to sesame2spiner/sesame2spiner/io_eospac.cpp diff --git a/sesame2spiner/io_eospac.hpp b/sesame2spiner/sesame2spiner/io_eospac.hpp similarity index 95% rename from sesame2spiner/io_eospac.hpp rename to sesame2spiner/sesame2spiner/io_eospac.hpp index d6eeb0a7c5e..4ddff7a5f54 100644 --- a/sesame2spiner/io_eospac.hpp +++ b/sesame2spiner/sesame2spiner/io_eospac.hpp @@ -17,6 +17,14 @@ #ifndef _SESAME2SPINER_IO_EOSPAC_HPP_ #define _SESAME2SPINER_IO_EOSPAC_HPP_ +#ifdef SINGULARITY_USE_SPINER +#warning "SINGULARITY USE SPINER" +#endif + +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 +#warning "SINGULARITY USE SPINER WITH HDF5" +#endif + #include #include @@ -27,9 +35,9 @@ #endif #include +#include #include #include -#include #include #include diff --git a/sesame2spiner/parser.cpp b/sesame2spiner/sesame2spiner/parser.cpp similarity index 99% rename from sesame2spiner/parser.cpp rename to sesame2spiner/sesame2spiner/parser.cpp index 7e8b0568b24..2558dc5e1b6 100644 --- a/sesame2spiner/parser.cpp +++ b/sesame2spiner/sesame2spiner/parser.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include #include -#include "parse_cli.hpp" #include "parser.hpp" Params::Params(const std::string &input_file) { @@ -158,4 +158,4 @@ void AddMaterials(std::vector ¶ms, std::vector &matids, } else { throw std::runtime_error("Couldn't open config file " + input_file + "\n"); } -} \ No newline at end of file +} diff --git a/sesame2spiner/parser.hpp b/sesame2spiner/sesame2spiner/parser.hpp similarity index 72% rename from sesame2spiner/parser.hpp rename to sesame2spiner/sesame2spiner/parser.hpp index 10b9a1e1d2f..dd254ce4447 100644 --- a/sesame2spiner/parser.hpp +++ b/sesame2spiner/sesame2spiner/parser.hpp @@ -21,6 +21,48 @@ #include #include +const std::string EXAMPLESTRING = R"( +# air.dat +# These are comments. +# The "#" character must be at the beginning of a line. +# only matid is required. All others override defaults. +matid = 5030 +name = air +# rho is in g/cm^3 +rhomin = 1e-2 +rhomax = 10 +numrho = 64 +# T is in Kelvin +Tmin = 252 +Tmax = 1e4 +numT = 32 +# sie is in erg/g +siemin = 1e12 +siemax = 1e16 +numsie = 32 + + +# titanium.dat +matid = 2961 +name = titanium +# These set the number of grid poitns per decade +# for each variable. The default is 50 points. +numrho/decade = 30 +numT/decade = 25 +numSie/decade = 15 + + +# steel.dat +matid=4272 +rhomin = 1e-2 +Tmin = 1 +# These shrink lograithm of bounds +# by a fraction of the total interval <= 1 +shrinklRhoBounds = 0.15 +shrinklTBounds = 0.15 +shrinkleBounds = 0.5 +)"; + // Parse a simple parameter file with // "#" denoting comments. class Params { diff --git a/sesame2spiner/main.cpp b/sesame2spiner/src/main.cpp similarity index 96% rename from sesame2spiner/main.cpp rename to sesame2spiner/src/main.cpp index cb279aa77f7..4349acedd03 100644 --- a/sesame2spiner/main.cpp +++ b/sesame2spiner/src/main.cpp @@ -33,8 +33,8 @@ #include #include -#include "generate_files.hpp" -#include "io_eospac.hpp" +#include +#include #include "parse_cli.hpp" int main(int argc, char *argv[]) { diff --git a/sesame2spiner/parse_cli.cpp b/sesame2spiner/src/parse_cli.cpp similarity index 97% rename from sesame2spiner/parse_cli.cpp rename to sesame2spiner/src/parse_cli.cpp index bf4f9171e82..40e16f725fe 100644 --- a/sesame2spiner/parse_cli.cpp +++ b/sesame2spiner/src/parse_cli.cpp @@ -22,7 +22,8 @@ #include #include -#include "io_eospac.hpp" +#include +#include #include "parse_cli.hpp" void parseCLI(int argc, char *argv[], std::string &savename, diff --git a/sesame2spiner/parse_cli.hpp b/sesame2spiner/src/parse_cli.hpp similarity index 64% rename from sesame2spiner/parse_cli.hpp rename to sesame2spiner/src/parse_cli.hpp index 7c4c35da60b..5a939bed0ff 100644 --- a/sesame2spiner/parse_cli.hpp +++ b/sesame2spiner/src/parse_cli.hpp @@ -17,52 +17,11 @@ #ifndef _SESAME2SPINER_PARSER_HPP_ #define _SESAME2SPINER_PARSER_HPP_ -#include "io_eospac.hpp" +#include #include #include const std::string DEFAULT_SAVENAME = "materials.sp5"; -const std::string EXAMPLESTRING = R"( -# air.dat -# These are comments. -# The "#" character must be at the beginning of a line. -# only matid is required. All others override defaults. -matid = 5030 -name = air -# rho is in g/cm^3 -rhomin = 1e-2 -rhomax = 10 -numrho = 64 -# T is in Kelvin -Tmin = 252 -Tmax = 1e4 -numT = 32 -# sie is in erg/g -siemin = 1e12 -siemax = 1e16 -numsie = 32 - - -# titanium.dat -matid = 2961 -name = titanium -# These set the number of grid poitns per decade -# for each variable. The default is 50 points. -numrho/decade = 30 -numT/decade = 25 -numSie/decade = 15 - - -# steel.dat -matid=4272 -rhomin = 1e-2 -Tmin = 1 -# These shrink lograithm of bounds -# by a fraction of the total interval <= 1 -shrinklRhoBounds = 0.15 -shrinklTBounds = 0.15 -shrinkleBounds = 0.5 -)"; void parseCLI(int argc, char *argv[], std::string &savename, std::vector &filenames, bool &printMetadata, diff --git a/sesame2spiner/test.cpp b/sesame2spiner/test/test.cpp similarity index 100% rename from sesame2spiner/test.cpp rename to sesame2spiner/test/test.cpp From 37f59e520c38a5c667d2fe1427ab0e35af183453 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 14:08:36 -0600 Subject: [PATCH 04/14] Modify cmake and fix some include paths to get everything to compile --- CMakeLists.txt | 6 ++++++ eospac-wrapper/CMakeLists.txt | 2 +- singularity-eos/CMakeLists.txt | 9 --------- singularity-eos/base/spiner_table_utils.hpp | 2 +- singularity-eos/eos/eos_spiner_rho_temp.hpp | 2 +- singularity-utils/CMakeLists.txt | 9 +++++++++ singularity-utils/singularity-utils/bounds.hpp | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3839e68796f..ae4d1039b4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,10 +170,14 @@ if (SINGULAIRTY_ON_ARM) endif() endif() +# ------------------------------------------------------------------------------# +# singularity-utils Library # ------------------------------------------------------------------------------# include(singularity-eos/spiner) include(singularity-eos/ports-of-call) add_subdirectory(singularity-utils) + +# ------------------------------------------------------------------------------# # singularity-eos Library # ------------------------------------------------------------------------------# @@ -308,6 +312,8 @@ endif() if(SINGULARITY_BUILD_SESAME2SPINER) add_subdirectory(sesame2spiner) + target_link_libraries(singularity-eos_Interface INTERFACE sesame2spiner-lib) + target_compile_definitions(singularity-eos_Interface INTERFACE SINGULARITY_USE_SESAME2SPINER) endif() if(SINGULARITY_BUILD_STELLARCOLLAPSE2SPINER) diff --git a/eospac-wrapper/CMakeLists.txt b/eospac-wrapper/CMakeLists.txt index f2e0b1bf9cc..8285191c567 100644 --- a/eospac-wrapper/CMakeLists.txt +++ b/eospac-wrapper/CMakeLists.txt @@ -29,7 +29,7 @@ endif() target_include_directories(eospac-wrapper PUBLIC - $ + $ $ ) diff --git a/singularity-eos/CMakeLists.txt b/singularity-eos/CMakeLists.txt index 22b8d484f92..30a1fdea759 100644 --- a/singularity-eos/CMakeLists.txt +++ b/singularity-eos/CMakeLists.txt @@ -24,20 +24,11 @@ register_headers( eos/eos.hpp.in # Normal files - base/fast-math/logs.hpp - base/indexable_types.hpp - base/robust_utils.hpp - base/root-finding-1d/root_finding.hpp base/serialization_utils.hpp base/spiner_table_utils.hpp - base/variadic_utils.hpp - base/math_utils.hpp base/constants.hpp base/eos_error.hpp - base/error_utils.hpp - base/sp5/singularity_eos_sp5.hpp eos/default_variant.hpp - base/hermite.hpp eos/eos_variant.hpp eos/eos_stellar_collapse.hpp eos/eos_ideal.hpp diff --git a/singularity-eos/base/spiner_table_utils.hpp b/singularity-eos/base/spiner_table_utils.hpp index b2409e4be06..dfeb6a63f44 100644 --- a/singularity-eos/base/spiner_table_utils.hpp +++ b/singularity-eos/base/spiner_table_utils.hpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include // Bounds #include diff --git a/singularity-eos/eos/eos_spiner_rho_temp.hpp b/singularity-eos/eos/eos_spiner_rho_temp.hpp index 6fb210e9e2b..7e1b91ecf9f 100644 --- a/singularity-eos/eos/eos_spiner_rho_temp.hpp +++ b/singularity-eos/eos/eos_spiner_rho_temp.hpp @@ -37,10 +37,10 @@ // base #include -#include #include #include #include +#include #include #include #include diff --git a/singularity-utils/CMakeLists.txt b/singularity-utils/CMakeLists.txt index bb9ba532998..f9f8123d4f8 100644 --- a/singularity-utils/CMakeLists.txt +++ b/singularity-utils/CMakeLists.txt @@ -37,6 +37,14 @@ target_link_libraries(singularity-utils spiner::spiner ) +# Propate SPINER defines +if (DEFINED SINGULARITY_USE_SPINER) + target_compile_definitions(singularity-utils + INTERFACE + $<$:SINGULARITY_USE_SPINER> + ) +endif() + # Propagate HDF5 usage definitions # These must match the settings used by singularity-eos if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) @@ -46,6 +54,7 @@ if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) ) endif() + # Propagate compile definitions for FastMath configuration # These must match the settings used by singularity-eos if (DEFINED SINGULARITY_USE_TRUE_LOG_GRIDDING) diff --git a/singularity-utils/singularity-utils/bounds.hpp b/singularity-utils/singularity-utils/bounds.hpp index 75e6c4bc4e4..1581ff6d75e 100644 --- a/singularity-utils/singularity-utils/bounds.hpp +++ b/singularity-utils/singularity-utils/bounds.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include From 5f041fd6dcf54285450bda6168b6f945235b38a9 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 14:18:17 -0600 Subject: [PATCH 05/14] Add sesame2spiner namespace --- sesame2spiner/sesame2spiner/generate_files.cpp | 9 ++++++--- sesame2spiner/sesame2spiner/generate_files.hpp | 5 ++++- sesame2spiner/sesame2spiner/io_eospac.cpp | 4 +++- sesame2spiner/sesame2spiner/io_eospac.hpp | 12 +++--------- sesame2spiner/sesame2spiner/parser.cpp | 5 ++++- sesame2spiner/sesame2spiner/parser.hpp | 4 +++- sesame2spiner/src/main.cpp | 8 +++++--- sesame2spiner/src/parse_cli.cpp | 4 ++-- sesame2spiner/src/parse_cli.hpp | 1 + 9 files changed, 31 insertions(+), 21 deletions(-) diff --git a/sesame2spiner/sesame2spiner/generate_files.cpp b/sesame2spiner/sesame2spiner/generate_files.cpp index 621ad0df778..cc8ac3cbccc 100644 --- a/sesame2spiner/sesame2spiner/generate_files.cpp +++ b/sesame2spiner/sesame2spiner/generate_files.cpp @@ -1,7 +1,7 @@ //====================================================================== // sesame2spiner tool for converting eospac to spiner // Author: Jonah Miller (jonahm@lanl.gov) -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -22,10 +22,10 @@ #include #include +#ifdef SPINER_USE_HDF #include #include - -#ifndef SPINER_USE_HDF +#else #error "HDF5 must be enabled" #endif // SPINER_USE_HDF @@ -43,6 +43,8 @@ using namespace EospacWrapper; +namespace sesame2spiner { + herr_t saveMaterial(hid_t loc, const SesameMetadata &metadata, const Bounds &lRhoBounds, const Bounds &lTBounds, const Bounds &leBounds, const std::string &name, const bool addSubtables, @@ -454,3 +456,4 @@ bool checkValInMatBounds(int matid, const std::string &name, Real val, Real vmin } return true; } +} // namespace sesame2spiner diff --git a/sesame2spiner/sesame2spiner/generate_files.hpp b/sesame2spiner/sesame2spiner/generate_files.hpp index 543a60fb7f5..f84e4250b4c 100644 --- a/sesame2spiner/sesame2spiner/generate_files.hpp +++ b/sesame2spiner/sesame2spiner/generate_files.hpp @@ -1,7 +1,7 @@ //====================================================================== // sesame2spiner tool for converting eospac to spiner // Author: Jonah Miller (jonahm@lanl.gov) -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -30,6 +30,8 @@ using namespace EospacWrapper; +namespace sesame2spiner { + constexpr int PPD_DEFAULT_RHO = 350; constexpr int PPD_DEFAULT_T = 100; constexpr Real STRICTLY_POS_MIN_RHO = 1e-8; @@ -68,5 +70,6 @@ bool checkValInMatBounds(int matid, const std::string &name, Real val, Real vmin Real vmax); int getNumPointsFromPPD(Real min, Real max, int ppd); +} // namespace sesame2spiner #endif // _SESAME2SPINER_GENERATE_FILES_HPP_ diff --git a/sesame2spiner/sesame2spiner/io_eospac.cpp b/sesame2spiner/sesame2spiner/io_eospac.cpp index 23290727f5b..7fcd15abef9 100644 --- a/sesame2spiner/sesame2spiner/io_eospac.cpp +++ b/sesame2spiner/sesame2spiner/io_eospac.cpp @@ -1,7 +1,7 @@ //====================================================================== // sesame2spiner tool for converting eospac to spiner // Author: Jonah Miller (jonahm@lanl.gov) -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -23,6 +23,7 @@ #include "io_eospac.hpp" +namespace sesame2spiner { // TODO: more error checking of bounds? void eosDataOfRhoSie(int matid, const TableSplit split, const Bounds &lRhoBounds, const Bounds &leBounds, DataBox &Ps, DataBox &Ts, DataBox &bMods, @@ -422,3 +423,4 @@ void modifyNames(TableSplit split, std::vector &names) { } } } // namespace impl +} // namespace sesame2spiner diff --git a/sesame2spiner/sesame2spiner/io_eospac.hpp b/sesame2spiner/sesame2spiner/io_eospac.hpp index 4ddff7a5f54..e93022d00a0 100644 --- a/sesame2spiner/sesame2spiner/io_eospac.hpp +++ b/sesame2spiner/sesame2spiner/io_eospac.hpp @@ -1,7 +1,7 @@ //====================================================================== // sesame2spiner tool for converting eospac to spiner // Author: Jonah Miller (jonahm@lanl.gov) -// © 2021-2025. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -17,14 +17,6 @@ #ifndef _SESAME2SPINER_IO_EOSPAC_HPP_ #define _SESAME2SPINER_IO_EOSPAC_HPP_ -#ifdef SINGULARITY_USE_SPINER -#warning "SINGULARITY USE SPINER" -#endif - -#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 -#warning "SINGULARITY USE SPINER WITH HDF5" -#endif - #include #include @@ -42,6 +34,7 @@ #include +namespace sesame2spiner { using EospacWrapper::Verbosity; constexpr int NGRIDS = 3; using singularity::TableSplit; @@ -101,5 +94,6 @@ T select(TableSplit split, T a, T b, T c) { } void modifyNames(TableSplit split, std::vector &names); } // namespace impl +} // namespace sesame2spiner #endif // _SESAME2SPINER_IO_EOSPAC_HPP_ diff --git a/sesame2spiner/sesame2spiner/parser.cpp b/sesame2spiner/sesame2spiner/parser.cpp index 2558dc5e1b6..23e6cd63fe1 100644 --- a/sesame2spiner/sesame2spiner/parser.cpp +++ b/sesame2spiner/sesame2spiner/parser.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2021-2023. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -24,6 +24,8 @@ #include "parser.hpp" +namespace sesame2spiner { + Params::Params(const std::string &input_file) { std::ifstream config_file(input_file); if (config_file.is_open()) { @@ -159,3 +161,4 @@ void AddMaterials(std::vector ¶ms, std::vector &matids, throw std::runtime_error("Couldn't open config file " + input_file + "\n"); } } +} // namespace sesame2spiner diff --git a/sesame2spiner/sesame2spiner/parser.hpp b/sesame2spiner/sesame2spiner/parser.hpp index dd254ce4447..9b79ca8b13b 100644 --- a/sesame2spiner/sesame2spiner/parser.hpp +++ b/sesame2spiner/sesame2spiner/parser.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// © 2021-2023. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -21,6 +21,7 @@ #include #include +namespace sesame2spiner { const std::string EXAMPLESTRING = R"( # air.dat # These are comments. @@ -91,4 +92,5 @@ class Params { void AddMaterials(std::vector ¶ms, std::vector &matids, const std::string &input_file); +} // namespace sesame2spiner #endif // SESAME2SPINER_PARSER_HPP_ diff --git a/sesame2spiner/src/main.cpp b/sesame2spiner/src/main.cpp index 4349acedd03..f9eadd5d684 100644 --- a/sesame2spiner/src/main.cpp +++ b/sesame2spiner/src/main.cpp @@ -1,7 +1,7 @@ //====================================================================== // sesame2spiner tool for converting eospac to spiner // Author: Jonah Miller (jonahm@lanl.gov) -// © 2021-2023. Triad National Security, LLC. All rights reserved. This +// © 2021-2026. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract 89233218CNA000001 // for Los Alamos National Laboratory (LANL), which is operated by Triad // National Security, LLC for the U.S. Department of Energy/National @@ -33,10 +33,11 @@ #include #include +#include "parse_cli.hpp" #include #include -#include "parse_cli.hpp" +using EospacWrapper::Verbosity; int main(int argc, char *argv[]) { std::vector filenames; std::string savename, helpMessage; @@ -52,7 +53,8 @@ int main(int argc, char *argv[]) { << "-----------------------------------------\n" << std::endl; - status = saveAllMaterials(savename, filenames, printMetadata, eospacWarn); + status = + sesame2spiner::saveAllMaterials(savename, filenames, printMetadata, eospacWarn); std::cout << "Done." << std::endl; diff --git a/sesame2spiner/src/parse_cli.cpp b/sesame2spiner/src/parse_cli.cpp index 40e16f725fe..a9104bbfc07 100644 --- a/sesame2spiner/src/parse_cli.cpp +++ b/sesame2spiner/src/parse_cli.cpp @@ -22,9 +22,9 @@ #include #include +#include "parse_cli.hpp" #include #include -#include "parse_cli.hpp" void parseCLI(int argc, char *argv[], std::string &savename, std::vector &filenames, bool &printMetadata, @@ -47,7 +47,7 @@ void parseCLI(int argc, char *argv[], std::string &savename, << "\t-h: print this message\n" << "\n" << "Several example input files:\n" - << EXAMPLESTRING << "\n" + << sesame2spiner::EXAMPLESTRING << "\n" << std::endl; helpMessage = helpStream.str(); diff --git a/sesame2spiner/src/parse_cli.hpp b/sesame2spiner/src/parse_cli.hpp index 5a939bed0ff..582b5759917 100644 --- a/sesame2spiner/src/parse_cli.hpp +++ b/sesame2spiner/src/parse_cli.hpp @@ -23,6 +23,7 @@ const std::string DEFAULT_SAVENAME = "materials.sp5"; +using EospacWrapper::Verbosity; void parseCLI(int argc, char *argv[], std::string &savename, std::vector &filenames, bool &printMetadata, Verbosity &eospacWarn, std::string &helpMessage); From 9c90094159237650c2fe063451f764e0d6ec970a Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 14:33:54 -0600 Subject: [PATCH 06/14] Fix comment --- singularity-utils/singularity-utils/hermite.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-utils/singularity-utils/hermite.hpp b/singularity-utils/singularity-utils/hermite.hpp index fdcd1a2fc72..4f071e6dd0b 100644 --- a/singularity-utils/singularity-utils/hermite.hpp +++ b/singularity-utils/singularity-utils/hermite.hpp @@ -96,4 +96,4 @@ PORTABLE_INLINE_FUNCTION Real h3(Real fi[16], Real w0t, Real w1t, Real w0mt, Rea } // namespace hermite } // namespace singularity -#endif // SINGULARITY_UTILS_MATH_UTILS_HPP_ +#endif // SINGULARITY_UTILS_HERMITE_HPP_ From ee628b572294d915f00437d329ff26a738f3b52f Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Thu, 4 Jun 2026 14:37:02 -0600 Subject: [PATCH 07/14] Add back forwarding headers for the ones we lost --- singularity-eos/CMakeLists.txt | 9 ++++++++ singularity-eos/base/error_utils.hpp | 20 +++++++++++++++++ singularity-eos/base/fast-math/logs.hpp | 20 +++++++++++++++++ singularity-eos/base/generic_indexer.hpp | 20 +++++++++++++++++ singularity-eos/base/hermite.hpp | 20 +++++++++++++++++ singularity-eos/base/indexable_types.hpp | 20 +++++++++++++++++ singularity-eos/base/math_utils.hpp | 20 +++++++++++++++++ singularity-eos/base/robust_utils.hpp | 20 +++++++++++++++++ .../base/root-finding-1d/root_finding.hpp | 20 +++++++++++++++++ .../base/sp5/singularity_eos_sp5.hpp | 22 +++++++++++++++++++ singularity-eos/base/variadic_utils.hpp | 20 +++++++++++++++++ 11 files changed, 211 insertions(+) create mode 100644 singularity-eos/base/error_utils.hpp create mode 100644 singularity-eos/base/fast-math/logs.hpp create mode 100644 singularity-eos/base/generic_indexer.hpp create mode 100644 singularity-eos/base/hermite.hpp create mode 100644 singularity-eos/base/indexable_types.hpp create mode 100644 singularity-eos/base/math_utils.hpp create mode 100644 singularity-eos/base/robust_utils.hpp create mode 100644 singularity-eos/base/root-finding-1d/root_finding.hpp create mode 100644 singularity-eos/base/sp5/singularity_eos_sp5.hpp create mode 100644 singularity-eos/base/variadic_utils.hpp diff --git a/singularity-eos/CMakeLists.txt b/singularity-eos/CMakeLists.txt index 30a1fdea759..22b8d484f92 100644 --- a/singularity-eos/CMakeLists.txt +++ b/singularity-eos/CMakeLists.txt @@ -24,11 +24,20 @@ register_headers( eos/eos.hpp.in # Normal files + base/fast-math/logs.hpp + base/indexable_types.hpp + base/robust_utils.hpp + base/root-finding-1d/root_finding.hpp base/serialization_utils.hpp base/spiner_table_utils.hpp + base/variadic_utils.hpp + base/math_utils.hpp base/constants.hpp base/eos_error.hpp + base/error_utils.hpp + base/sp5/singularity_eos_sp5.hpp eos/default_variant.hpp + base/hermite.hpp eos/eos_variant.hpp eos/eos_stellar_collapse.hpp eos/eos_ideal.hpp diff --git a/singularity-eos/base/error_utils.hpp b/singularity-eos/base/error_utils.hpp new file mode 100644 index 00000000000..3153ce21560 --- /dev/null +++ b/singularity-eos/base/error_utils.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ +#define SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ + +#include + +#endif // #ifndef SINGULARITY_EOS_BASE_ERROR_UTILS_HPP_ diff --git a/singularity-eos/base/fast-math/logs.hpp b/singularity-eos/base/fast-math/logs.hpp new file mode 100644 index 00000000000..b11e6107103 --- /dev/null +++ b/singularity-eos/base/fast-math/logs.hpp @@ -0,0 +1,20 @@ +//====================================================================== +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//====================================================================== + +#ifndef _SINGULARITY_EOS_BASE_FAST_MATH_LOGS_ +#define _SINGULARITY_EOS_BASE_FAST_MATH_LOGS_ + +#include + +#endif // _SINGULARITY_EOS_BASE_FAST_MATH_LOGS_ diff --git a/singularity-eos/base/generic_indexer.hpp b/singularity-eos/base/generic_indexer.hpp new file mode 100644 index 00000000000..82dbe3d8ca7 --- /dev/null +++ b/singularity-eos/base/generic_indexer.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ +#define SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ + +#include + +#endif // #ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_ diff --git a/singularity-eos/base/hermite.hpp b/singularity-eos/base/hermite.hpp new file mode 100644 index 00000000000..5727a516daf --- /dev/null +++ b/singularity-eos/base/hermite.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_HERMITE_HPP_ +#define SINGULARITY_EOS_BASE_HERMITE_HPP_ + +#include + +#endif // SINGULARITY_EOS_BASE_HERMITE_HPP_ diff --git a/singularity-eos/base/indexable_types.hpp b/singularity-eos/base/indexable_types.hpp new file mode 100644 index 00000000000..c62ea08e9f0 --- /dev/null +++ b/singularity-eos/base/indexable_types.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ +#define SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ + +#include + +#endif // SINGULARITY_EOS_BASE_INDEXABLE_TYPES_ diff --git a/singularity-eos/base/math_utils.hpp b/singularity-eos/base/math_utils.hpp new file mode 100644 index 00000000000..ddd61e14d55 --- /dev/null +++ b/singularity-eos/base/math_utils.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ +#define SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ + +#include + +#endif // SINGULARITY_EOS_BASE_MATH_UTILS_HPP_ diff --git a/singularity-eos/base/robust_utils.hpp b/singularity-eos/base/robust_utils.hpp new file mode 100644 index 00000000000..c33776e5fc9 --- /dev/null +++ b/singularity-eos/base/robust_utils.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ +#define SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ + +#include + +#endif // SINGULARITY_EOS_BASE_ROBUST_UTILS_HPP_ diff --git a/singularity-eos/base/root-finding-1d/root_finding.hpp b/singularity-eos/base/root-finding-1d/root_finding.hpp new file mode 100644 index 00000000000..f0469bca7ed --- /dev/null +++ b/singularity-eos/base/root-finding-1d/root_finding.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef _SINGULARITY_EOS_BASE_ROOT_FINDING_1D_ROOT_FINDING_HPP_ +#define _SINGULARITY_EOS_BASE_ROOT_FINDING_1D_ROOT_FINDING_HPP_ + +#include + +#endif // _SINGULARITY_EOS_BASE_ROOT_FINDING_1D_ROOT_FINDING_HPP_ diff --git a/singularity-eos/base/sp5/singularity_eos_sp5.hpp b/singularity-eos/base/sp5/singularity_eos_sp5.hpp new file mode 100644 index 00000000000..c3f25d9393c --- /dev/null +++ b/singularity-eos/base/sp5/singularity_eos_sp5.hpp @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// Extra definitions to the SP5 file format required for singularity-eos +// Author: Jonah Miller (jonahm@lanl.gov) +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef _SINGULARITY_EOS_BASE_SP5_SINGULARITY_EOS_SP5_HPP_ +#define _SINGULARITY_EOS_BASE_SP5_SINGULARITY_EOS_SP5_HPP_ + +#include + +#endif // _SINGULARITY_EOS_BASE_SP5_SINGULARITY_EOS_SP5_HPP_ diff --git a/singularity-eos/base/variadic_utils.hpp b/singularity-eos/base/variadic_utils.hpp new file mode 100644 index 00000000000..b6c8698c971 --- /dev/null +++ b/singularity-eos/base/variadic_utils.hpp @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// © 2026. Triad National Security, LLC. All rights reserved. This +// program was produced under U.S. Government contract 89233218CNA000001 +// for Los Alamos National Laboratory (LANL), which is operated by Triad +// National Security, LLC for the U.S. Department of Energy/National +// Nuclear Security Administration. All rights in the program are +// reserved by Triad National Security, LLC, and the U.S. Department of +// Energy/National Nuclear Security Administration. The Government is +// granted for itself and others acting on its behalf a nonexclusive, +// paid-up, irrevocable worldwide license in this material to reproduce, +// prepare derivative works, distribute copies to the public, perform +// publicly and display publicly, and to permit others to do so. +//------------------------------------------------------------------------------ + +#ifndef SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ +#define SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ + +#include + +#endif // SINGULARITY_EOS_BASE_VARIADIC_UTILS_HPP_ From a5c40a00143448249d6927ee09691314559fd7b4 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Fri, 5 Jun 2026 17:23:30 -0600 Subject: [PATCH 08/14] Updates for non submodule mode --- CMakeLists.txt | 194 ++++++++++++++++++------------- cmake/singularity-eos/hdf5.cmake | 4 +- singularity-utils/CMakeLists.txt | 4 +- 3 files changed, 119 insertions(+), 83 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15afb83e54d..75171c61a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------# -# © 2021-2025. Triad National Security, LLC. All rights reserved. This program +# © 2021-2026. Triad National Security, LLC. All rights reserved. This program # was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC # for the U.S. Department of Energy/National Nuclear Security Administration. @@ -11,6 +11,8 @@ # publicly and display publicly, and to permit others to do so. # ------------------------------------------------------------------------------# +# This file was made in part with generative AI + cmake_minimum_required(VERSION 3.19) # Disable "in-source" builds @@ -170,22 +172,84 @@ if (SINGULAIRTY_ON_ARM) endif() endif() +# checks if this is our build, or we've been imported via `add_subdirectory` NB: +# this should make the `option(SINGULARITY_SUBMODULE_MODE ...)` unnecessary +# This must happen before finding dependencies +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set(CMAKE_CXX_EXTENSIONS OFF) +else() + message( + STATUS + "Detected that `singularity-eos` is a subproject, will configure build in submodule mode" + ) + set(SINGULARITY_SUBMODULE_MODE ON) +endif() + +if(SINGULARITY_FORCE_SUBMODULE_MODE) + message(STATUS "Building as though project was a submodule.") + set(SINGULARITY_SUBMODULE_MODE ON) +endif() + +include(singularity-eos/Eigen3) +include(singularity-eos/eospac) +include(singularity-eos/hdf5) +include(singularity-eos/kokkos) +include(singularity-eos/ports-of-call) +include(singularity-eos/spiner) + # ------------------------------------------------------------------------------# -# singularity-utils Library +# Import/Find External Dependencies # ------------------------------------------------------------------------------# -include(singularity-eos/spiner) -include(singularity-eos/ports-of-call) +# Must happen before building singularity-utils (which needs ports-of-call and spiner) +# Dependency order: Kokkos -> ports-of-call -> spiner -> singularity-utils + +if(SINGULARITY_SUBMODULE_MODE) + # add all submodules + message(STATUS "singularity-eos configuring in submodule mode.") + + # Kokkos first (ports-of-call may depend on it if PORTABILITY_STRATEGY_KOKKOS is set) + if(SINGULARITY_USE_KOKKOS) + singularity_import_kokkos() + if(SINGULARITY_USE_KOKKOSKERNELS) + singularity_import_kokkoskernels() + endif() + endif() + + # Then ports-of-call + singularity_import_ports_of_call() + + # Then spiner (depends on ports-of-call) + if(SINGULARITY_USE_SPINER) + singularity_import_spiner() + endif() +else() + # use system packages + + # Kokkos first + if(SINGULARITY_USE_KOKKOS) + singularity_find_kokkos() + if(SINGULARITY_USE_KOKKOSKERNELS) + singularity_find_kokkoskernels() + endif() + endif() + + # Then ports-of-call + singularity_find_ports_of_call() + + # Then spiner + if(SINGULARITY_USE_SPINER) + singularity_find_spiner() + endif() +endif() + +# Build singularity-utils first - it's a dependency for both +# singularity-eos and sesame2spiner add_subdirectory(singularity-utils) # ------------------------------------------------------------------------------# # singularity-eos Library # ------------------------------------------------------------------------------# -include(singularity-eos/Eigen3) -include(singularity-eos/eospac) -include(singularity-eos/hdf5) -include(singularity-eos/kokkos) - add_library(singularity-eos INTERFACE) add_library(singularity-eos::singularity-eos ALIAS singularity-eos) @@ -230,6 +294,16 @@ if(SINGULARITY_BUILD_PYTHON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +# Enable HDF5 and EOSPAC now that languages and dependencies are set up +if(SINGULARITY_USE_SPINER_WITH_HDF5) + singularity_enable_hdf5(singularity-eos_Common) +endif() + +if(SINGULARITY_USE_EOSPAC) + # NB This will add the `eospac-wrapper` directory. + singularity_enable_eospac(singularity-eos_Common) +endif() + # require at least C++17, but allow newer versions to become a client requirement if # explicitly set at build time (needed for building with newer Kokkos) if(CMAKE_CXX_STANDARD) @@ -238,22 +312,6 @@ else() target_compile_features(singularity-eos_Interface INTERFACE cxx_std_17) endif() -# checks if this is our build, or we've been imported via `add_subdirectory` NB: -# this should make the `option(SINGULARITY_SUBMODULE_MODE ...)` unnecessary -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - set(CMAKE_CXX_EXTENSIONS OFF) -else() - message( - STATUS - "Detected that `singularity-eos` is a subproject, will configure build in submodule mode" - ) - set(SINGULARITY_SUBMODULE_MODE ON) -endif() - -if(SINGULARITY_FORCE_SUBMODULE_MODE) - message(STATUS "Building as though project was a submodule.") - set(SINGULARITY_SUBMODULE_MODE ON) -endif() # Use to determine if Eigen is used or not set(SINGULARITY_USE_EIGEN @@ -305,13 +363,41 @@ if(SINGULARITY_BUILD_EXAMPLES) add_subdirectory(example) endif() -# add subdirs +# ------------------------------------------------------------------------------# +# Import/Find Additional Dependencies (Eigen only) +# ------------------------------------------------------------------------------# +# Kokkos, ports-of-call, and spiner were already imported/found before singularity-utils + +if(SINGULARITY_SUBMODULE_MODE) + if(SINGULARITY_USE_EIGEN) + singularity_import_eigen() + endif() +else() + if(SINGULARITY_USE_EIGEN) + singularity_find_eigen() + endif() +endif() + +# Enable dependencies for singularity-eos_Interface +singularity_enable_ports_of_call(singularity-eos_Interface) + +if(SINGULARITY_USE_SPINER) + singularity_enable_spiner(singularity-eos_Interface) + # if(SINGULARITY_USE_SPINER_WITH_HDF5) + # singularity_enable_hdf5(singularity-eos_Interface) endif() +endif() + +# ------------------------------------------------------------------------------# +# Add subdirectories +# ------------------------------------------------------------------------------# + if(SINGULARITY_BUILD_PYTHON) add_subdirectory(python) endif() if(SINGULARITY_BUILD_SESAME2SPINER) add_subdirectory(sesame2spiner) + # Link sesame2spiner library into singularity-eos target_link_libraries(singularity-eos_Interface INTERFACE sesame2spiner-lib) target_compile_definitions(singularity-eos_Interface INTERFACE SINGULARITY_USE_SESAME2SPINER) endif() @@ -386,59 +472,6 @@ endif() # building are not located outside of the source directory, except for explicit # cases. -if(SINGULARITY_USE_SPINER_WITH_HDF5) - singularity_enable_hdf5(singularity-eos_Common) -endif() - -if(SINGULARITY_USE_EOSPAC) - # NB This will add the `eospac-wrapper` directory. - singularity_enable_eospac(singularity-eos_Common) -endif() - -if(SINGULARITY_SUBMODULE_MODE) - # add all submodules - message(STATUS "singularity-eos configuring in submodule mode.") - singularity_import_ports_of_call() - if(SINGULARITY_USE_SPINER) - singularity_import_spiner() - endif() - if(SINGULARITY_USE_KOKKOS) - singularity_import_kokkos() - if(SINGULARITY_USE_KOKKOSKERNELS) - singularity_import_kokkoskernels() - endif() - endif() - - if(SINGULARITY_USE_EIGEN) - singularity_import_eigen() - endif() -else() - # use system packages - singularity_find_ports_of_call() - if(SINGULARITY_USE_SPINER) - singularity_find_spiner() - endif() - - if(SINGULARITY_USE_KOKKOS) - singularity_find_kokkos() - if(SINGULARITY_USE_KOKKOSKERNELS) - singularity_find_kokkoskernels() - endif() - endif() - if(SINGULARITY_USE_EIGEN) - singularity_find_eigen() - endif() - -endif() - -singularity_enable_ports_of_call(singularity-eos_Interface) - -if(SINGULARITY_USE_SPINER) - singularity_enable_spiner(singularity-eos_Interface) - # if(SINGULARITY_USE_SPINER_WITH_HDF5) - # singularity_enable_hdf5(singularity-eos_Interface) endif() -endif() - # Both the interface (headers) and the library (compiled) need to link to Kokkos # see get_sg_eos.cpp if(SINGULARITY_USE_KOKKOS) @@ -596,8 +629,7 @@ target_compile_options( # `-Wclass-memaccess now default with -Wall but we explicitly # manage this ourselves in our serialization routines. $<$,$>:-Wno-class-memaccess> - # Intel compilers enable -ffast-math even in Debug builds. This disables finite-math-only in - # Debug builds to allow NaN/Inf checks without pages of warnings + # Disable finite-math-only in Debug builds to allow NaN/Inf checks (Intel compilers) $<$,$,$>>:-fno-finite-math-only> ) if (SINGULARITY_STRICT_WARNINGS) diff --git a/cmake/singularity-eos/hdf5.cmake b/cmake/singularity-eos/hdf5.cmake index 323536f9f99..9d4ca0411ab 100644 --- a/cmake/singularity-eos/hdf5.cmake +++ b/cmake/singularity-eos/hdf5.cmake @@ -40,7 +40,9 @@ macro(singularity_enable_hdf5 target) # If we're doing an in-tree cray build, skip all this stuff. Fixes # in-tree builds on Roci + Chicoma This is if (NOT (IN_TREE AND # CRAY_THING)), but no composite expressions in cmake - if(NOT HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE OR NOT SINGULARITY_FORCE_SUBMODULE_MODE) + # Check both HDF5_C_COMPILER_NO_INTERROGATE and HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE + # as the variable name may differ across CMake/HDF5 versions + if(NOT ((HDF5_C_COMPILER_NO_INTERROGATE OR HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE) AND SINGULARITY_FORCE_SUBMODULE_MODE)) # I'm bailing out here if these arn't filled in. I don't know if this is # correct for every downstream use, but right now we need to enforce some kind diff --git a/singularity-utils/CMakeLists.txt b/singularity-utils/CMakeLists.txt index f9f8123d4f8..018fe340113 100644 --- a/singularity-utils/CMakeLists.txt +++ b/singularity-utils/CMakeLists.txt @@ -34,11 +34,13 @@ target_include_directories(singularity-utils target_link_libraries(singularity-utils INTERFACE ports-of-call::ports-of-call - spiner::spiner ) # Propate SPINER defines if (DEFINED SINGULARITY_USE_SPINER) + target_link_libraries(singularity-utils INTERFACE + spiner::spiner + ) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_USE_SPINER> From 64cb3344d44b00650382e121e828abb5f9ff4afe Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Fri, 5 Jun 2026 17:32:13 -0600 Subject: [PATCH 09/14] Use correct if checks --- singularity-utils/CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/singularity-utils/CMakeLists.txt b/singularity-utils/CMakeLists.txt index 018fe340113..56a8ce785d8 100644 --- a/singularity-utils/CMakeLists.txt +++ b/singularity-utils/CMakeLists.txt @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# © 2021-2025. Triad National Security, LLC. All rights reserved. This +# © 2026. Triad National Security, LLC. All rights reserved. This # program was produced under U.S. Government contract 89233218CNA000001 # for Los Alamos National Laboratory (LANL), which is operated by Triad # National Security, LLC for the U.S. Department of Energy/National @@ -12,6 +12,8 @@ # publicly and display publicly, and to permit others to do so. #------------------------------------------------------------------------------ +# This file was made in part with generative AI + cmake_minimum_required(VERSION 3.19) project(singularity-utils @@ -37,7 +39,7 @@ target_link_libraries(singularity-utils ) # Propate SPINER defines -if (DEFINED SINGULARITY_USE_SPINER) +if (SINGULARITY_USE_SPINER) target_link_libraries(singularity-utils INTERFACE spiner::spiner ) @@ -49,7 +51,7 @@ endif() # Propagate HDF5 usage definitions # These must match the settings used by singularity-eos -if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) +if (SINGULARITY_USE_SPINER_WITH_HDF5) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_USE_SPINER_WITH_HDF5> @@ -59,28 +61,28 @@ endif() # Propagate compile definitions for FastMath configuration # These must match the settings used by singularity-eos -if (DEFINED SINGULARITY_USE_TRUE_LOG_GRIDDING) +if (SINGULARITY_USE_TRUE_LOG_GRIDDING) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_USE_TRUE_LOG_GRIDDING> ) endif() -if (DEFINED SINGULARITY_USE_SINGLE_LOGS) +if (SINGULARITY_USE_SINGLE_LOGS) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_USE_SINGLE_LOGS> ) endif() -if (DEFINED SINGULARITY_NQT_PORTABLE) +if (SINGULARITY_NQT_PORTABLE) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_NQT_PORTABLE> ) endif() -if (DEFINED SINGULARITY_NQT_ORDER_1) +if (SINGULARITY_NQT_ORDER_1) target_compile_definitions(singularity-utils INTERFACE $<$:SINGULARITY_NQT_ORDER_1> From d17b2926196ae113e065ee72175bb6a0dd3a54e5 Mon Sep 17 00:00:00 2001 From: "Adam M. Dempsey" Date: Fri, 5 Jun 2026 17:49:24 -0600 Subject: [PATCH 10/14] ancient formatting Co-authored-by: Adam M. Dempsey --- singularity-eos/eos/eos_gruneisen.hpp | 2 +- singularity-eos/eos/eos_vinet.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index 5155ee60c40..050b3151225 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -292,7 +292,7 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::ComputeRhoMax(const Real s1, const Real maxbound = std::min(min_extremum, maxbound); } } // s3 > 0 ; else - } // discriminant >= 0 + } // discriminant >= 0 if (poly(minbound) * poly(maxbound) < 0.) { // Root is appropriately bounded using RootFinding1D::regula_falsi; diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 56164fb144f..ecda94839cd 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -222,7 +222,7 @@ inline void Vinet::InitializeVinet(const Real *d2tod40input) { for (int ind = VinetInternalParametersSize - 2; ind >= 2; ind--) { // _VIP[42]=d40=f40 given,first calculated is _VIP[41]=f39 _VIP[ind] = _VIP[ind] - (ind) / _VIP[1] * _VIP[ind + 1]; // prefactors f40 to f0 - } // _VIP[n+2]=fn, ind=n+2 + } // _VIP[n+2]=fn, ind=n+2 } PORTABLE_INLINE_FUNCTION void Vinet::Vinet_F_DT_func(const Real rho, const Real T, @@ -241,7 +241,7 @@ PORTABLE_INLINE_FUNCTION void Vinet::Vinet_F_DT_func(const Real rho, const Real sumP = _d2tod40[pref0vp + ind] + onemx * sumP; //_d2tod40[38]=d40 sumB = _d2tod40[pref0vp + ind] * ind + onemx * sumB; //_d2tod40[-2+40]=d40 sumE = _VIP[pref0vip + ind] + onemx * sumE; //_VIP[42]=f40 - } //_VIP[2]=f0 + } //_VIP[2]=f0 #pragma unroll for (int ind = 1; ind >= 0; ind--) { sumE = _VIP[pref0vip + ind] + onemx * sumE; From 062f35dd67b0ef2e5ac610cbca1c0901657ffb58 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Tue, 9 Jun 2026 14:43:09 -0600 Subject: [PATCH 11/14] Try this out --- singularity-utils/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/singularity-utils/CMakeLists.txt b/singularity-utils/CMakeLists.txt index 56a8ce785d8..5e22457d7b1 100644 --- a/singularity-utils/CMakeLists.txt +++ b/singularity-utils/CMakeLists.txt @@ -14,11 +14,6 @@ # This file was made in part with generative AI -cmake_minimum_required(VERSION 3.19) - -project(singularity-utils - VERSION 1.0.0 - LANGUAGES CXX) # Create interface library (header-only) add_library(singularity-utils INTERFACE) From 02e42e2ae35ebd6b187f514dd66d5f1345c36cc8 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Tue, 9 Jun 2026 17:31:30 -0600 Subject: [PATCH 12/14] Another attempt --- CMakeLists.txt | 145 +++++++++++++++++------------------ cmake/install.cmake | 12 +++ sesame2spiner/CMakeLists.txt | 50 ++++++------ 3 files changed, 107 insertions(+), 100 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75171c61a45..3ab4dfffed6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,12 +172,40 @@ if (SINGULAIRTY_ON_ARM) endif() endif() -# checks if this is our build, or we've been imported via `add_subdirectory` NB: -# this should make the `option(SINGULARITY_SUBMODULE_MODE ...)` unnecessary +# ------------------------------------------------------------------------------# +# singularity-eos Library +# ------------------------------------------------------------------------------# + +# Load CMake modules for finding dependencies +include(singularity-eos/Eigen3) +include(singularity-eos/eospac) +include(singularity-eos/hdf5) +include(singularity-eos/kokkos) +include(singularity-eos/spiner) +include(singularity-eos/ports-of-call) + +add_library(singularity-eos INTERFACE) +add_library(singularity-eos::singularity-eos ALIAS singularity-eos) + +# interface target to collect runtime libraries +add_library(singularity-eos_Common INTERFACE) +add_library(singularity-eos::singularity-eos_Common ALIAS singularity-eos_Common) + +add_library(singularity-eos_Interface INTERFACE) +add_library(singularity-eos::singularity-eos_Interface ALIAS singularity-eos_Interface) +target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common singularity-utils::singularity-utils) +target_link_libraries(singularity-eos INTERFACE singularity-eos_Interface) + +# ld has problems with Clang's libomp.so, use ldd instead +target_link_options(singularity-eos_Interface INTERFACE $<$:-fuse-ld=lld>) + +# ------------------------------------------------------------------------------# +# Determine if we're in submodule mode +# ------------------------------------------------------------------------------# # This must happen before finding dependencies -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - set(CMAKE_CXX_EXTENSIONS OFF) -else() + +# checks if this is our build, or we've been imported via `add_subdirectory` +if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) message( STATUS "Detected that `singularity-eos` is a subproject, will configure build in submodule mode" @@ -190,12 +218,34 @@ if(SINGULARITY_FORCE_SUBMODULE_MODE) set(SINGULARITY_SUBMODULE_MODE ON) endif() -include(singularity-eos/Eigen3) -include(singularity-eos/eospac) -include(singularity-eos/hdf5) -include(singularity-eos/kokkos) -include(singularity-eos/ports-of-call) -include(singularity-eos/spiner) +# ------------------------------------------------------------------------------# +# Compiler & language setup +# ------------------------------------------------------------------------------# + +enable_language(CXX) +include(CMakeDetermineCXXCompiler) +enable_language(C) +include(CMakeDetermineCCompiler) +if(SINGULARITY_USE_FORTRAN) + enable_language(Fortran) + include(CMakeDetermineFortranCompiler) +endif() + +# Big endianness +include(TestBigEndian) +TEST_BIG_ENDIAN(IS_BIG_ENDIAN) +if (BIG_ENDIAN) + message(WARNING "Big endian detected! " + "Integer aliasing as currently implemented will not function. " + "Please set -DSINGULARITY_NQT_PORTABLE=ON.") +endif() + +include(GNUInstallDirs) + +if(SINGULARITY_BUILD_PYTHON) + # need position independent code for Python shared library + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() # ------------------------------------------------------------------------------# # Import/Find External Dependencies @@ -222,6 +272,11 @@ if(SINGULARITY_SUBMODULE_MODE) if(SINGULARITY_USE_SPINER) singularity_import_spiner() endif() + + # Eigen (if needed) + if(SINGULARITY_USE_EIGEN) + singularity_import_eigen() + endif() else() # use system packages @@ -240,60 +295,17 @@ else() if(SINGULARITY_USE_SPINER) singularity_find_spiner() endif() + + # Eigen (if needed) + if(SINGULARITY_USE_EIGEN) + singularity_find_eigen() + endif() endif() # Build singularity-utils first - it's a dependency for both # singularity-eos and sesame2spiner add_subdirectory(singularity-utils) -# ------------------------------------------------------------------------------# -# singularity-eos Library -# ------------------------------------------------------------------------------# - -add_library(singularity-eos INTERFACE) -add_library(singularity-eos::singularity-eos ALIAS singularity-eos) - -# interface target to collect runtime libraries -add_library(singularity-eos_Common INTERFACE) -add_library(singularity-eos::singularity-eos_Common ALIAS singularity-eos_Common) - -add_library(singularity-eos_Interface INTERFACE) -add_library(singularity-eos::singularity-eos_Interface ALIAS singularity-eos_Interface) -target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common singularity-utils::singularity-utils) -target_link_libraries(singularity-eos INTERFACE singularity-eos_Interface) - -# ld has problems with Clang's libomp.so, use ldd instead -target_link_options(singularity-eos_Interface INTERFACE $<$:-fuse-ld=lld>) - -# ------------------------------------------------------------------------------# -# Compiler & language setup -# ------------------------------------------------------------------------------# - -enable_language(CXX) -include(CMakeDetermineCXXCompiler) -enable_language(C) -include(CMakeDetermineCCompiler) -if(SINGULARITY_USE_FORTRAN) - enable_language(Fortran) - include(CMakeDetermineFortranCompiler) -endif() - -# Big endianness -include(TestBigEndian) -TEST_BIG_ENDIAN(IS_BIG_ENDIAN) -if (BIG_ENDIAN) - message(WARNING "Big endian detected! " - "Integer aliasing as currently implemented will not function. " - "Please set -DSINGULARITY_NQT_PORTABLE=ON.") -endif() - -include(GNUInstallDirs) - -if(SINGULARITY_BUILD_PYTHON) - # need position independent code for Python shared library - set(CMAKE_POSITION_INDEPENDENT_CODE ON) -endif() - # Enable HDF5 and EOSPAC now that languages and dependencies are set up if(SINGULARITY_USE_SPINER_WITH_HDF5) singularity_enable_hdf5(singularity-eos_Common) @@ -363,21 +375,6 @@ if(SINGULARITY_BUILD_EXAMPLES) add_subdirectory(example) endif() -# ------------------------------------------------------------------------------# -# Import/Find Additional Dependencies (Eigen only) -# ------------------------------------------------------------------------------# -# Kokkos, ports-of-call, and spiner were already imported/found before singularity-utils - -if(SINGULARITY_SUBMODULE_MODE) - if(SINGULARITY_USE_EIGEN) - singularity_import_eigen() - endif() -else() - if(SINGULARITY_USE_EIGEN) - singularity_find_eigen() - endif() -endif() - # Enable dependencies for singularity-eos_Interface singularity_enable_ports_of_call(singularity-eos_Interface) diff --git a/cmake/install.cmake b/cmake/install.cmake index dcc19a4948f..2924e424418 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -65,6 +65,12 @@ install( NAMESPACE "singularity-eos::" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/singularity-eos) +# Install singularity-utils (required by singularity-eos_Interface) +install( + TARGETS singularity-utils + EXPORT singularity-eos_Interface + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install( TARGETS singularity-eos_Interface EXPORT singularity-eos_Interface @@ -123,6 +129,12 @@ export( FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-eos_Common.cmake NAMESPACE singularity-eos::) +# Export singularity-utils with singularity-eos_Interface +export( + TARGETS singularity-utils + FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-utils.cmake + NAMESPACE singularity-utils::) + export( EXPORT singularity-eos_Interface FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-eos_Interface.cmake diff --git a/sesame2spiner/CMakeLists.txt b/sesame2spiner/CMakeLists.txt index a15aadcd41f..7f42e373d36 100644 --- a/sesame2spiner/CMakeLists.txt +++ b/sesame2spiner/CMakeLists.txt @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# © 2021-2026. Triad National Security, LLC. All rights reserved. This +# © 2021-2025. Triad National Security, LLC. All rights reserved. This # program was produced under U.S. Government contract 89233218CNA000001 # for Los Alamos National Laboratory (LANL), which is operated by Triad # National Security, LLC for the U.S. Department of Energy/National @@ -13,7 +13,10 @@ #------------------------------------------------------------------------------ -# sesame2spiner library +# ------------------------------------------------------------------------------ +# sesame2spiner Library +# ------------------------------------------------------------------------------ + add_library(sesame2spiner-lib sesame2spiner/io_eospac.cpp sesame2spiner/io_eospac.hpp @@ -21,17 +24,19 @@ add_library(sesame2spiner-lib sesame2spiner/generate_files.hpp sesame2spiner/parser.cpp sesame2spiner/parser.hpp - ) +# Set library output name (without -lib suffix) set_target_properties(sesame2spiner-lib PROPERTIES OUTPUT_NAME sesame2spiner) target_include_directories(sesame2spiner-lib PUBLIC $ + $ $ ) +# sesame2spiner library depends on singularity-utils (not full singularity-eos) target_link_libraries(sesame2spiner-lib PUBLIC singularity-utils::singularity-utils @@ -39,32 +44,19 @@ target_link_libraries(sesame2spiner-lib singularity-eos::singularity-eos_Common # For HDF5 ) +# Version information for library target_compile_definitions(sesame2spiner-lib PUBLIC SESAME2SPINER_VERSION=\"${PROJECT_VERSION}\" ) -# Propate SPINER defines -if (DEFINED SINGULARITY_USE_SPINER) - target_compile_definitions(sesame2spiner-lib - PUBLIC - $<$:SINGULARITY_USE_SPINER> - ) -endif() - -# Propagate HDF5 usage definitions -# These must match the settings used by singularity-eos -if (DEFINED SINGULARITY_USE_SPINER_WITH_HDF5) - target_compile_definitions(sesame2spiner-lib - PUBLIC - $<$:SINGULARITY_USE_SPINER_WITH_HDF5> - ) -endif() - - +# Create alias for consistency add_library(sesame2spiner::sesame2spiner ALIAS sesame2spiner-lib) -# sesame2spiner executable +# ------------------------------------------------------------------------------ +# sesame2spiner Executable +# ------------------------------------------------------------------------------ + add_executable(sesame2spiner src/parse_cli.cpp src/parse_cli.hpp @@ -77,14 +69,22 @@ target_include_directories(sesame2spiner ) target_link_libraries(sesame2spiner - PUBLIC + PRIVATE sesame2spiner-lib ) -# install +# ------------------------------------------------------------------------------ +# Installation +# ------------------------------------------------------------------------------ install(TARGETS sesame2spiner DESTINATION ${CMAKE_INSTALL_BINDIR}) +# Install singularity-utils (required by sesame2spiner-lib) +install(TARGETS singularity-utils + EXPORT sesame2spiner-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + install(TARGETS sesame2spiner-lib EXPORT sesame2spiner-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -104,5 +104,3 @@ if(NOT SINGULARITY_SUBMODULE_MODE) ) endif() - -# TODO: Add tests for sesame2spiner here. From 590ff79068f67a9b7660995f55f6a9e174844316 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Tue, 9 Jun 2026 17:47:44 -0600 Subject: [PATCH 13/14] Install sesame2spiner as a part of singularity-eos_INTERFACE --- cmake/install.cmake | 10 ++++++++++ sesame2spiner/CMakeLists.txt | 20 -------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index 2924e424418..668b1eb809d 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -71,6 +71,16 @@ install( EXPORT singularity-eos_Interface DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# Install sesame2spiner-lib if it was built (required by singularity-eos_Interface when enabled) +if(TARGET sesame2spiner-lib) + install( + TARGETS sesame2spiner-lib + EXPORT singularity-eos_Interface + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION include + ) +endif() install( TARGETS singularity-eos_Interface EXPORT singularity-eos_Interface diff --git a/sesame2spiner/CMakeLists.txt b/sesame2spiner/CMakeLists.txt index 7f42e373d36..29c9ace5154 100644 --- a/sesame2spiner/CMakeLists.txt +++ b/sesame2spiner/CMakeLists.txt @@ -79,28 +79,8 @@ target_link_libraries(sesame2spiner install(TARGETS sesame2spiner DESTINATION ${CMAKE_INSTALL_BINDIR}) -# Install singularity-utils (required by sesame2spiner-lib) -install(TARGETS singularity-utils - EXPORT sesame2spiner-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR} -) - -install(TARGETS sesame2spiner-lib - EXPORT sesame2spiner-targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION include -) install(DIRECTORY sesame2spiner/ DESTINATION include/sesame2spiner ) -if(NOT SINGULARITY_SUBMODULE_MODE) - install(EXPORT sesame2spiner-targets - FILE sesame2spiner-targets.cmake - NAMESPACE sesame2spiner:: - DESTINATION lib/cmake/sesame2spiner - ) -endif() - From c49263784c2128b7ef5237aec251f7da5cf3a059 Mon Sep 17 00:00:00 2001 From: Adam Dempsey Date: Wed, 10 Jun 2026 12:42:42 -0600 Subject: [PATCH 14/14] Move up eigen finding --- CMakeLists.txt | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ab4dfffed6..aaecf898839 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,22 @@ if(SINGULARITY_BUILD_PYTHON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +# Use to determine if Eigen is used or not +set(SINGULARITY_USE_EIGEN + OFF + CACHE BOOL "" FORCE) +if(SINGULARITY_BUILD_CLOSURE AND NOT SINGULARITY_USE_KOKKOSKERNELS) + if(SINGULARITY_USE_CUDA) + message( + FATAL_ERROR + "\"SINGULARITY_BUILD_CLOSURE=ON\" and \"SINGULARITY_USE_CUDA=ON\" requires \"SINGULARITY_USE_KOKKOSKERNELS=ON\"" + ) + endif() + set(SINGULARITY_USE_EIGEN + ON + CACHE BOOL "" FORCE) +endif() + # ------------------------------------------------------------------------------# # Import/Find External Dependencies # ------------------------------------------------------------------------------# @@ -324,23 +340,6 @@ else() target_compile_features(singularity-eos_Interface INTERFACE cxx_std_17) endif() - -# Use to determine if Eigen is used or not -set(SINGULARITY_USE_EIGEN - OFF - CACHE BOOL "" FORCE) -if(SINGULARITY_BUILD_CLOSURE AND NOT SINGULARITY_USE_KOKKOSKERNELS) - if(SINGULARITY_USE_CUDA) - message( - FATAL_ERROR - "\"SINGULARITY_BUILD_CLOSURE=ON\" and \"SINGULARITY_USE_CUDA=ON\" requires \"SINGULARITY_USE_KOKKOSKERNELS=ON\"" - ) - endif() - set(SINGULARITY_USE_EIGEN - ON - CACHE BOOL "" FORCE) -endif() - # ------------------------------------------------------------------------------# # De-thaw some options # ------------------------------------------------------------------------------#