diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a8045220..270a57269 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ #========================================================================================= -# (C) (or copyright) 2021. Triad National Security, LLC. All rights reserved. +# (C) (or copyright) 2021-2024. 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 @@ -11,9 +11,11 @@ # the public, perform publicly and display publicly, and to permit others to do so. #========================================================================================= -add_executable(phoebus - main.cpp # first +set(MAX_NUMBER_CONSERVED_VARS 9 CACHE INTEGER "Maximum number of conserved variables") + +configure_file(compile_constants.hpp.in generated/compile_constants.hpp @ONLY) +set (SRC_LIST # alphabetical fixup/fixup.hpp fixup/fixup.cpp @@ -29,6 +31,7 @@ add_executable(phoebus fluid/con2prim_statistics.hpp fluid/fluid.cpp fluid/fluid.hpp + fluid/prim2con.hpp fluid/riemann.hpp fluid/tmunu.cpp fluid/tmunu.hpp @@ -150,13 +153,15 @@ add_executable(phoebus tracers/tracers.hpp tracers/tracers.cpp + + # Generated + $/compile_constants.hpp ) -set(MAX_NUMBER_CONSERVED_VARS 9 CACHE INTEGER "Maximum number of conserved variables") -configure_file(compile_constants.hpp.in generated/compile_constants.hpp @ONLY) +add_library(phoebuslib ${SRC_LIST}) -target_include_directories(phoebus PRIVATE +target_include_directories(phoebuslib PUBLIC $ $ # JMM: Not needed, but can't hurt @@ -169,29 +174,37 @@ target_include_directories(phoebus PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../external/singularity-opac/utils" ) -target_compile_features(phoebus PUBLIC cxx_std_14) +target_compile_features(phoebuslib PUBLIC cxx_std_17) +# TODO(JMM): Remove this since we're never going to run on XL again (I hope) if (CMAKE_CXX_COMPILER_ID STREQUAL "XL") - target_compile_options(phoebus PUBLIC -std=c++1y -qxflag=disable__cplusplusOverride) + target_compile_options(phoebuslib PUBLIC -std=c++1y -qxflag=disable__cplusplusOverride) endif() -target_compile_definitions(phoebus PRIVATE PORTABILITY_STRATEGY_KOKKOS) +target_compile_definitions(phoebuslib PUBLIC PORTABILITY_STRATEGY_KOKKOS) if (PHOEBUS_ENABLE_HDF5) - target_compile_definitions(phoebus PRIVATE + target_compile_definitions(phoebuslib PUBLIC SINGULARITY_USE_HDF SPINER_USE_HDF ) endif() if (Kokkos_ENABLE_CUDA) - target_compile_options(phoebus PUBLIC --expt-relaxed-constexpr) + target_compile_options(phoebuslib PUBLIC --expt-relaxed-constexpr) endif() -# target_compile_options(phoebus PUBLIC -G -lineinfo) - -target_link_libraries(phoebus PRIVATE parthenon +target_link_libraries(phoebuslib PUBLIC parthenon singularity-eos::singularity-eos # singularity-opac::singularity-opac ) if (PHOEBUS_ENABLE_HDF5) - target_link_libraries(phoebus PRIVATE hdf5::hdf5 hdf5::hdf5_hl) + target_link_libraries(phoebuslib PUBLIC hdf5::hdf5 hdf5::hdf5_hl) +endif() + +# Disable executable automatically for builds with downstream codes +if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + message(STATUS "Standalone mode. Adding Phoebus executable") + add_executable(phoebus main.cpp) + target_link_libraries(phoebus PRIVATE phoebuslib) endif() + +# target_compile_options(phoebus PUBLIC -G -lineinfo) diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index 66a145802..d8264a134 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -441,6 +441,15 @@ TaskStatus ConservedToPrimitiveRegion(T *rc, const IndexRange &ib, const IndexRa auto c2p = pkg->Param>("c2p_func"); return c2p(rc, ib, jb, kb); } +// JMM: Must specialize function for both potential use cases so we +// can keep it in this file. +template TaskStatus ConservedToPrimitiveRegion>(MeshData *rc, + const IndexRange &ib, + const IndexRange &jb, + const IndexRange &kb); +template TaskStatus ConservedToPrimitiveRegion>( + MeshBlockData *rc, const IndexRange &ib, const IndexRange &jb, + const IndexRange &kb); template TaskStatus ConservedToPrimitive(T *rc) { diff --git a/src/fluid/fluid.hpp b/src/fluid/fluid.hpp index fa206f8e2..702d1ab3b 100644 --- a/src/fluid/fluid.hpp +++ b/src/fluid/fluid.hpp @@ -29,9 +29,19 @@ std::shared_ptr Initialize(ParameterInput *pin); TaskStatus PrimitiveToConserved(MeshBlockData *rc); TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange &ib, const IndexRange &jb, const IndexRange &kb); +// JMM: Not sure how the templated value here worked in the first +// place. But proper solution is need to tell the linker it's +// available elsewhere. template TaskStatus ConservedToPrimitiveRegion(T *rc, const IndexRange &ib, const IndexRange &jb, const IndexRange &kb); +extern template TaskStatus +ConservedToPrimitiveRegion>(MeshData *rc, const IndexRange &ib, + const IndexRange &jb, const IndexRange &kb); +extern template TaskStatus ConservedToPrimitiveRegion>( + MeshBlockData *rc, const IndexRange &ib, const IndexRange &jb, + const IndexRange &kb); + template TaskStatus ConservedToPrimitive(T *rc); template diff --git a/tst/CMakeLists.txt b/tst/CMakeLists.txt index 9f4d23aaf..52902bc78 100644 --- a/tst/CMakeLists.txt +++ b/tst/CMakeLists.txt @@ -1,4 +1,4 @@ -# © 2021. Triad National Security, LLC. All rights reserved. This +# © 2021-2024. 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 @@ -15,6 +15,7 @@ include(Catch) add_executable(phoebus_unit_tests phoebus_unit_test_main.cpp) target_link_libraries(phoebus_unit_tests PRIVATE + phoebuslib parthenon Catch2::Catch2 Kokkos::kokkos diff --git a/tst/unit/geometry/CMakeLists.txt b/tst/unit/geometry/CMakeLists.txt index 7f4fa69fb..d9621f464 100644 --- a/tst/unit/geometry/CMakeLists.txt +++ b/tst/unit/geometry/CMakeLists.txt @@ -1,4 +1,4 @@ -# © 2021. Triad National Security, LLC. All rights reserved. This +# © 2021-2024. 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,57 +13,15 @@ add_library(geometry_unit_tests OBJECT test_geometry.cpp test_tetrads.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/analysis/history.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/analysis/history.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/analytic_system.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/boyer_lindquist.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/boyer_lindquist.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/cached_system.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/flrw.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/flrw.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/fmks.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/fmks.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/geometry_defaults.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/geometry_utils.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/mckinney_gammie_ryan.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/mckinney_gammie_ryan.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/modified_system.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/minkowski.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/minkowski.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/snake.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/snake.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/spherical_kerr_schild.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/spherical_kerr_schild.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/spherical_minkowski.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/spherical_minkowski.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/phoebus_utils/phoebus_interpolation.hpp ) -# Super annoying but it had to be done. -set(MAX_NUMBER_CONSERVED_VARS 9 CACHE STRING "Maximum number of conserved variables") -configure_file(../../../src/compile_constants.hpp.in generated/compile_constants.hpp @ONLY) - target_link_libraries(geometry_unit_tests PRIVATE + phoebuslib parthenon singularity-eos::singularity-eos Catch2::Catch2 Kokkos::kokkos) -target_include_directories(geometry_unit_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" - $ - $ - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/ports-of-call" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/spiner" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/variant/include" - ) - -target_compile_definitions(geometry_unit_tests PRIVATE - PORTABILITY_STRATEGY_KOKKOS) - target_link_libraries(geometry_unit_tests PRIVATE Catch2::Catch2) target_sources(phoebus_unit_tests PRIVATE $) diff --git a/tst/unit/monopole_gr/CMakeLists.txt b/tst/unit/monopole_gr/CMakeLists.txt index dbbcb8671..24982bbda 100644 --- a/tst/unit/monopole_gr/CMakeLists.txt +++ b/tst/unit/monopole_gr/CMakeLists.txt @@ -1,4 +1,4 @@ -# © 2021. Triad National Security, LLC. All rights reserved. This +# © 2021-2024. 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,42 +13,16 @@ add_library(monopole_gr_unit_tests OBJECT test_monopole_gr.cpp test_interp_3d_to_1d.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/monopole_gr/monopole_gr.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/monopole_gr/monopole_gr_utils.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/monopole_gr/monopole_gr.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/tov/tov.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/tov/tov.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/phoebus_utils/unit_conversions.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/phoebus_utils/unit_conversions.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/microphysics/eos_phoebus/eos_phoebus.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/microphysics/eos_phoebus/eos_phoebus.cpp ) target_link_libraries(monopole_gr_unit_tests PRIVATE + phoebuslib parthenon Catch2::Catch2 Kokkos::kokkos singularity-eos::singularity-eos ) -target_include_directories(monopole_gr_unit_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/ports-of-call" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/spiner" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/variant/include" - $ - $ - ) - target_compile_definitions(monopole_gr_unit_tests PRIVATE PHOEBUS_IN_UNIT_TESTS) -target_compile_definitions(monopole_gr_unit_tests PRIVATE - PORTABILITY_STRATEGY_KOKKOS) - target_sources(phoebus_unit_tests PRIVATE $) diff --git a/tst/unit/phoebus_utils/CMakeLists.txt b/tst/unit/phoebus_utils/CMakeLists.txt index fcae7fc50..81077e781 100644 --- a/tst/unit/phoebus_utils/CMakeLists.txt +++ b/tst/unit/phoebus_utils/CMakeLists.txt @@ -1,4 +1,4 @@ -# © 2021. Triad National Security, LLC. All rights reserved. This +# © 2021-2024. 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 @@ -38,41 +38,21 @@ add_library(phoebus_utils_unit_tests OBJECT test_relativity_utils.cpp test_reader.cpp test_adiabats.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/geometry/geometry.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/progenitor/ascii_reader.cpp ) +target_include_directories(phoebus_utils_unit_tests PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../../" + $ + $ + ) + target_link_libraries(phoebus_utils_unit_tests PRIVATE + phoebuslib parthenon Catch2::Catch2 Kokkos::kokkos singularity-eos::singularity-eos ) -if (PHOEBUS_ENABLE_HDF5) - target_link_libraries(phoebus_utils_unit_tests PRIVATE hdf5::hdf5 hdf5::hdf5_hl ) -endif() - -target_include_directories(phoebus_utils_unit_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/ports-of-call" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/spiner" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/variant/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../../" - $ - $ - ) - -target_compile_definitions(phoebus_utils_unit_tests PRIVATE - PORTABILITY_STRATEGY_KOKKOS) -if (PHOEBUS_ENABLE_HDF5) - target_compile_definitions(phoebus_utils_unit_tests PRIVATE - SINGULARITY_USE_HDF - SPINER_USE_HDF - ) -endif() target_sources(phoebus_unit_tests PRIVATE $) diff --git a/tst/unit/phoebus_utils/compile_constants.hpp b/tst/unit/phoebus_utils/compile_constants.hpp deleted file mode 100644 index fb26373d7..000000000 --- a/tst/unit/phoebus_utils/compile_constants.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// © 2021. 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 COMPILE_CONSTANTS_HPP_ -#define COMPILE_CONSTANTS_HPP_ - -#define NCONS_MAX 10 - -#define PHOEBUS_GEOMETRY Geometry::Minkowski -#define GEOMETRY_MESH Analytic -#define GEOMETRY_MESH_BLOCK Analytic - -#define PRINT_RHS 0 - -#endif // COMPILE_CONSTANTS_HPP_ diff --git a/tst/unit/phoebus_utils/test_relativity_utils.cpp b/tst/unit/phoebus_utils/test_relativity_utils.cpp index 7dc24fe08..73a5982c9 100644 --- a/tst/unit/phoebus_utils/test_relativity_utils.cpp +++ b/tst/unit/phoebus_utils/test_relativity_utils.cpp @@ -43,7 +43,8 @@ TEST_CASE("RELATIVITY", "[relativity_utils]") { GIVEN("A three-velocity and a coordinate system") { auto mb = GetDummyMeshBlock(); auto rc = GetDummyMeshBlockData(mb); - auto system = GetCoordinateSystem(rc.get()); + auto indexer = GetIndexer(rc.get()); + auto system = MinkowskiMeshBlock(indexer); // Dummy grid position const CellLocation loc = CellLocation::Cent; const int k = 0; diff --git a/tst/unit/radiation/CMakeLists.txt b/tst/unit/radiation/CMakeLists.txt index d1de5a1ba..fd9cd4864 100644 --- a/tst/unit/radiation/CMakeLists.txt +++ b/tst/unit/radiation/CMakeLists.txt @@ -1,4 +1,4 @@ -# © 2021. Triad National Security, LLC. All rights reserved. This +# © 2021-2024. 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,32 +12,16 @@ add_library(radiation_unit_tests OBJECT test_closure.cpp - - ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/radiation/closure.hpp - ) target_link_libraries(radiation_unit_tests PRIVATE + phoebuslib parthenon Catch2::Catch2 Kokkos::kokkos singularity-eos::singularity-eos ) -target_include_directories(radiation_unit_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/ports-of-call" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/spiner" - "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/singularity-eos/utils/variant/include" - $ - $ - ) - -target_compile_definitions(radiation_unit_tests PRIVATE - PORTABILITY_STRATEGY_KOKKOS) - target_link_libraries(radiation_unit_tests PRIVATE Catch2::Catch2) target_sources(phoebus_unit_tests PRIVATE $)