From 599088d964a028416ddd91397f05bb0eff720ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 11:26:52 +0100 Subject: [PATCH 1/6] Refactor build process Now include/app paths are combined in the src dir. --- app/CMakeLists.txt | 9 ++++---- app/poet.h.in | 11 --------- src/{ => Base}/Grid.cpp | 5 ++-- {include/poet => src/Base}/Grid.hpp | 3 ++- src/{ => Base}/SimParams.cpp | 6 +++-- {include/poet => src/Base}/SimParams.hpp | 10 ++++---- {include/poet => src/Base}/argh.hpp | 0 src/CMakeLists.txt | 23 +++++++++++++------ .../ChemistryModule.cpp | 10 ++++---- .../Chemistry}/ChemistryModule.hpp | 13 ++++++----- .../MasterFunctions.cpp | 5 ++-- .../SurrogateModels/CMakeLists.txt | 0 .../SurrogateModels/DHT.c | 3 ++- .../Chemistry/SurrogateModels}/DHT.h | 0 .../SurrogateModels/DHT_Wrapper.cpp | 16 ++++--------- .../SurrogateModels}/DHT_Wrapper.hpp | 14 +++++------ .../SurrogateModels/HashFunctions.cpp | 2 +- .../SurrogateModels}/HashFunctions.hpp | 0 .../SurrogateModels}/Interpolation.hpp | 13 +++++------ .../SurrogateModels/InterpolationModule.cpp | 19 ++++++++------- .../Chemistry/SurrogateModels}/LookupKey.hpp | 3 ++- .../SurrogateModels/ProximityHashTable.cpp | 14 ++++++----- .../Chemistry/SurrogateModels}/Rounding.hpp | 0 .../WorkerFunctions.cpp | 6 ++--- {include/poet => src/Chemistry}/enums.hpp | 0 .../DataStructures}/DataStructures.hpp | 3 ++- src/DataStructures/Field.cpp | 3 ++- {include/poet => src}/Macros.hpp | 0 {include/poet => src}/RInsidePOET.hpp | 0 src/{ => Transport}/DiffusionModule.cpp | 16 ++++++------- .../Transport}/DiffusionModule.hpp | 13 ++++++----- {app => src}/poet.cpp | 16 +++++++------ src/poet.h.in | 8 +++++++ 33 files changed, 131 insertions(+), 113 deletions(-) delete mode 100644 app/poet.h.in rename src/{ => Base}/Grid.cpp (99%) rename {include/poet => src/Base}/Grid.hpp (99%) rename src/{ => Base}/SimParams.cpp (99%) rename {include/poet => src/Base}/SimParams.hpp (98%) rename {include/poet => src/Base}/argh.hpp (100%) rename src/{ChemistryModule => Chemistry}/ChemistryModule.cpp (99%) rename {include/poet => src/Chemistry}/ChemistryModule.hpp (98%) rename src/{ChemistryModule => Chemistry}/MasterFunctions.cpp (99%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/CMakeLists.txt (100%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/DHT.c (99%) rename {include/poet => src/Chemistry/SurrogateModels}/DHT.h (100%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/DHT_Wrapper.cpp (96%) rename {include/poet => src/Chemistry/SurrogateModels}/DHT_Wrapper.hpp (97%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/HashFunctions.cpp (98%) rename {include/poet => src/Chemistry/SurrogateModels}/HashFunctions.hpp (100%) rename {include/poet => src/Chemistry/SurrogateModels}/Interpolation.hpp (97%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/InterpolationModule.cpp (94%) rename {include/poet => src/Chemistry/SurrogateModels}/LookupKey.hpp (97%) rename src/{ChemistryModule => Chemistry}/SurrogateModels/ProximityHashTable.cpp (97%) rename {include/poet => src/Chemistry/SurrogateModels}/Rounding.hpp (100%) rename src/{ChemistryModule => Chemistry}/WorkerFunctions.cpp (98%) rename {include/poet => src/Chemistry}/enums.hpp (100%) rename {include/poet => src/DataStructures}/DataStructures.hpp (99%) rename {include/poet => src}/Macros.hpp (100%) rename {include/poet => src}/RInsidePOET.hpp (100%) rename src/{ => Transport}/DiffusionModule.cpp (96%) rename {include/poet => src/Transport}/DiffusionModule.hpp (96%) rename {app => src}/poet.cpp (98%) create mode 100644 src/poet.h.in diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 1aa791dd4..bd4fc4bf1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,7 +1,6 @@ -configure_file(poet.h.in poet.h) -add_executable(poet poet.cpp) -target_include_directories(poet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") -target_link_libraries(poet PUBLIC poet_lib MPI::MPI_CXX) +# add_executable(poet poet.cpp) +# target_include_directories(poet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") +# target_link_libraries(poet PUBLIC poet_lib MPI::MPI_CXX) -install(TARGETS poet DESTINATION bin) +# install(TARGETS poet DESTINATION bin) diff --git a/app/poet.h.in b/app/poet.h.in deleted file mode 100644 index 96a25a2c1..000000000 --- a/app/poet.h.in +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef POET_H -#define POET_H - -#include "poet/ChemistryModule.hpp" -#include -const char *poet_version = "@POET_VERSION@"; - -const char *CHEMISTRY_MODULE_NAME = "state_C"; - - -#endif // POET_H diff --git a/src/Grid.cpp b/src/Base/Grid.cpp similarity index 99% rename from src/Grid.cpp rename to src/Base/Grid.cpp index 64561b5ae..e51b114ba 100644 --- a/src/Grid.cpp +++ b/src/Base/Grid.cpp @@ -18,7 +18,9 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "poet/SimParams.hpp" +#include "Grid.hpp" +#include "SimParams.hpp" + #include #include #include @@ -26,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/include/poet/Grid.hpp b/src/Base/Grid.hpp similarity index 99% rename from include/poet/Grid.hpp rename to src/Base/Grid.hpp index 2ea2068b9..deec5c04a 100644 --- a/include/poet/Grid.hpp +++ b/src/Base/Grid.hpp @@ -21,7 +21,8 @@ #ifndef GRID_H #define GRID_H -#include "poet/SimParams.hpp" +#include "SimParams.hpp" + #include #include #include diff --git a/src/SimParams.cpp b/src/Base/SimParams.cpp similarity index 99% rename from src/SimParams.cpp rename to src/Base/SimParams.cpp index e02046392..f711e796a 100644 --- a/src/SimParams.cpp +++ b/src/Base/SimParams.cpp @@ -20,11 +20,13 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "poet/enums.hpp" +#include "SimParams.hpp" + +#include "../Chemistry/enums.hpp" + #include #include #include -#include #include #include diff --git a/include/poet/SimParams.hpp b/src/Base/SimParams.hpp similarity index 98% rename from include/poet/SimParams.hpp rename to src/Base/SimParams.hpp index 9928bcdba..212ec9948 100644 --- a/include/poet/SimParams.hpp +++ b/src/Base/SimParams.hpp @@ -21,6 +21,12 @@ #ifndef PARSER_H #define PARSER_H +#include "../DataStructures/DataStructures.hpp" +#include "../Macros.hpp" +#include "../RInsidePOET.hpp" + +#include "argh.hpp" // Argument handler https://github.com/adishavit/argh + #include #include #include @@ -28,10 +34,6 @@ #include #include -#include "DataStructures.hpp" -#include "Macros.hpp" -#include "RInsidePOET.hpp" -#include "argh.hpp" // Argument handler https://github.com/adishavit/argh #include #include // BSD-licenced diff --git a/include/poet/argh.hpp b/src/Base/argh.hpp similarity index 100% rename from include/poet/argh.hpp rename to src/Base/argh.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74a61c8c7..addb7c11b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,12 +2,19 @@ file(GLOB_RECURSE poet_lib_SRC CONFIGURE_DEPENDS "*.cpp" "*.c") -add_library(poet_lib ${poet_lib_SRC}) -target_include_directories(poet_lib PUBLIC ${PROJECT_SOURCE_DIR}/include) -target_link_libraries(poet_lib PUBLIC - MPI::MPI_CXX ${MATH_LIBRARY} RRuntime PhreeqcRM tug) +configure_file(poet.h.in poet.h) -target_compile_definitions(poet_lib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX) +add_executable(poet ${poet_lib_SRC}) +target_link_libraries(poet + MPI::MPI_CXX + ${MATH_LIBRARY} + RRuntime + PhreeqcRM + tug +) +target_include_directories(poet PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +target_compile_definitions(poet PRIVATE STRICT_R_HEADERS OMPI_SKIP_MPICXX) mark_as_advanced(PHREEQCRM_BUILD_MPI PHREEQCRM_DISABLE_OPENMP) set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE) @@ -15,11 +22,13 @@ set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE) option(POET_DHT_DEBUG "Build with DHT debug info" OFF) if(POET_DHT_DEBUG) - target_compile_definitions(poet_lib PRIVATE DHT_STATISTICS) + target_compile_definitions(poet PRIVATE DHT_STATISTICS) endif() option(POET_PHT_ADDITIONAL_INFO "Enables additional information in the PHT" OFF) if (POET_PHT_ADDITIONAL_INFO) - target_compile_definitions(poet_lib PRIVATE POET_PHT_ADD) + target_compile_definitions(poet PRIVATE POET_PHT_ADD) endif() + +install(TARGETS poet DESTINATION bin) \ No newline at end of file diff --git a/src/ChemistryModule/ChemistryModule.cpp b/src/Chemistry/ChemistryModule.cpp similarity index 99% rename from src/ChemistryModule/ChemistryModule.cpp rename to src/Chemistry/ChemistryModule.cpp index a1b1a8837..46531f2c6 100644 --- a/src/ChemistryModule/ChemistryModule.cpp +++ b/src/Chemistry/ChemistryModule.cpp @@ -1,7 +1,9 @@ -#include "poet/ChemistryModule.hpp" -#include "PhreeqcRM.h" -#include "poet/DHT_Wrapper.hpp" -#include "poet/Interpolation.hpp" +#include "ChemistryModule.hpp" + +#include "SurrogateModels/DHT_Wrapper.hpp" +#include "SurrogateModels/Interpolation.hpp" + +#include #include #include diff --git a/include/poet/ChemistryModule.hpp b/src/Chemistry/ChemistryModule.hpp similarity index 98% rename from include/poet/ChemistryModule.hpp rename to src/Chemistry/ChemistryModule.hpp index c0c7f9083..a17069d53 100644 --- a/include/poet/ChemistryModule.hpp +++ b/src/Chemistry/ChemistryModule.hpp @@ -3,12 +3,13 @@ #ifndef CHEMISTRYMODULE_H_ #define CHEMISTRYMODULE_H_ -#include "DHT_Wrapper.hpp" -#include "DataStructures.hpp" -#include "Interpolation.hpp" -#include "IrmResult.h" -#include "PhreeqcRM.h" -#include "SimParams.hpp" +#include "../Base/SimParams.hpp" +#include "../DataStructures/DataStructures.hpp" +#include "SurrogateModels/DHT_Wrapper.hpp" +#include "SurrogateModels/Interpolation.hpp" + +#include +#include #include #include diff --git a/src/ChemistryModule/MasterFunctions.cpp b/src/Chemistry/MasterFunctions.cpp similarity index 99% rename from src/ChemistryModule/MasterFunctions.cpp rename to src/Chemistry/MasterFunctions.cpp index 51b656da3..543cd21a8 100644 --- a/src/ChemistryModule/MasterFunctions.cpp +++ b/src/Chemistry/MasterFunctions.cpp @@ -1,5 +1,6 @@ -#include "PhreeqcRM.h" -#include "poet/ChemistryModule.hpp" +#include "ChemistryModule.hpp" + +#include #include #include diff --git a/src/ChemistryModule/SurrogateModels/CMakeLists.txt b/src/Chemistry/SurrogateModels/CMakeLists.txt similarity index 100% rename from src/ChemistryModule/SurrogateModels/CMakeLists.txt rename to src/Chemistry/SurrogateModels/CMakeLists.txt diff --git a/src/ChemistryModule/SurrogateModels/DHT.c b/src/Chemistry/SurrogateModels/DHT.c similarity index 99% rename from src/ChemistryModule/SurrogateModels/DHT.c rename to src/Chemistry/SurrogateModels/DHT.c index 0a7261049..b0d5b3caa 100644 --- a/src/ChemistryModule/SurrogateModels/DHT.c +++ b/src/Chemistry/SurrogateModels/DHT.c @@ -16,8 +16,9 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "DHT.h" + #include -#include #include #include diff --git a/include/poet/DHT.h b/src/Chemistry/SurrogateModels/DHT.h similarity index 100% rename from include/poet/DHT.h rename to src/Chemistry/SurrogateModels/DHT.h diff --git a/src/ChemistryModule/SurrogateModels/DHT_Wrapper.cpp b/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp similarity index 96% rename from src/ChemistryModule/SurrogateModels/DHT_Wrapper.cpp rename to src/Chemistry/SurrogateModels/DHT_Wrapper.cpp index 861375c04..69491b2c2 100644 --- a/src/ChemistryModule/SurrogateModels/DHT_Wrapper.cpp +++ b/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp @@ -20,14 +20,7 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "poet/DHT_Wrapper.hpp" -#include "poet/HashFunctions.hpp" -#include "poet/Interpolation.hpp" -#include "poet/LookupKey.hpp" -#include "poet/Rounding.hpp" -#include "poet/enums.hpp" - -#include "poet/RInsidePOET.hpp" +#include "DHT_Wrapper.hpp" #include #include @@ -150,10 +143,9 @@ void DHT_Wrapper::fillDHT(const WorkPackage &work_package) { uint32_t proc, index; auto &key = dht_results.keys[i]; const auto data = - (with_interp - ? outputToInputAndRates(work_package.input[i], - work_package.output[i]) - : work_package.output[i]); + (with_interp ? outputToInputAndRates(work_package.input[i], + work_package.output[i]) + : work_package.output[i]); // void *data = (void *)&(work_package[i * this->data_count]); // fuzz data (round, logarithm etc.) diff --git a/include/poet/DHT_Wrapper.hpp b/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp similarity index 97% rename from include/poet/DHT_Wrapper.hpp rename to src/Chemistry/SurrogateModels/DHT_Wrapper.hpp index 115d5e769..083fe9d25 100644 --- a/include/poet/DHT_Wrapper.hpp +++ b/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp @@ -23,14 +23,14 @@ #ifndef DHT_WRAPPER_H #define DHT_WRAPPER_H -#include "DataStructures.hpp" +#include "../../Base/SimParams.hpp" +#include "../../DataStructures/DataStructures.hpp" +#include "../../RInsidePOET.hpp" +#include "../enums.hpp" +#include "HashFunctions.hpp" #include "LookupKey.hpp" -#include "RInsidePOET.hpp" -#include "SimParams.hpp" -#include "enums.hpp" -#include "poet/HashFunctions.hpp" -#include "poet/LookupKey.hpp" -#include "poet/Rounding.hpp" +#include "Rounding.hpp" + #include #include #include diff --git a/src/ChemistryModule/SurrogateModels/HashFunctions.cpp b/src/Chemistry/SurrogateModels/HashFunctions.cpp similarity index 98% rename from src/ChemistryModule/SurrogateModels/HashFunctions.cpp rename to src/Chemistry/SurrogateModels/HashFunctions.cpp index 431cd286f..d93702990 100644 --- a/src/ChemistryModule/SurrogateModels/HashFunctions.cpp +++ b/src/Chemistry/SurrogateModels/HashFunctions.cpp @@ -24,7 +24,7 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "poet/HashFunctions.hpp" +#include "HashFunctions.hpp" #if defined(_MSC_VER) diff --git a/include/poet/HashFunctions.hpp b/src/Chemistry/SurrogateModels/HashFunctions.hpp similarity index 100% rename from include/poet/HashFunctions.hpp rename to src/Chemistry/SurrogateModels/HashFunctions.hpp diff --git a/include/poet/Interpolation.hpp b/src/Chemistry/SurrogateModels/Interpolation.hpp similarity index 97% rename from include/poet/Interpolation.hpp rename to src/Chemistry/SurrogateModels/Interpolation.hpp index 71b9f9a01..15361f4bf 100644 --- a/include/poet/Interpolation.hpp +++ b/src/Chemistry/SurrogateModels/Interpolation.hpp @@ -3,13 +3,12 @@ #ifndef INTERPOLATION_H_ #define INTERPOLATION_H_ -#include "DHT.h" +#include "../../Base/SimParams.hpp" +#include "../../DataStructures/DataStructures.hpp" #include "DHT_Wrapper.hpp" -#include "DataStructures.hpp" #include "LookupKey.hpp" -#include "poet/DHT_Wrapper.hpp" -#include "poet/Rounding.hpp" -#include "poet/SimParams.hpp" +#include "Rounding.hpp" + #include #include #include @@ -17,11 +16,11 @@ #include #include #include + extern "C" { -#include "poet/DHT.h" +#include "DHT.h" } -#include "poet/LookupKey.hpp" #include #include #include diff --git a/src/ChemistryModule/SurrogateModels/InterpolationModule.cpp b/src/Chemistry/SurrogateModels/InterpolationModule.cpp similarity index 94% rename from src/ChemistryModule/SurrogateModels/InterpolationModule.cpp rename to src/Chemistry/SurrogateModels/InterpolationModule.cpp index 9384731b2..26bfd4ab0 100644 --- a/src/ChemistryModule/SurrogateModels/InterpolationModule.cpp +++ b/src/Chemistry/SurrogateModels/InterpolationModule.cpp @@ -1,13 +1,15 @@ // Time-stamp: "Last modified 2023-08-16 17:02:31 mluebke" +#include "Interpolation.hpp" -#include "poet/DHT_Wrapper.hpp" -#include "poet/DataStructures.hpp" -#include "poet/HashFunctions.hpp" -#include "poet/Interpolation.hpp" -#include "poet/LookupKey.hpp" -#include "poet/Rounding.hpp" -#include +#include "../../DataStructures/DataStructures.hpp" +#include "DHT_Wrapper.hpp" +#include "HashFunctions.hpp" +#include "LookupKey.hpp" +#include "Rounding.hpp" + +#include #include + #include #include #include @@ -20,8 +22,9 @@ #include #include #include + extern "C" { -#include "poet/DHT.h" +#include "DHT.h" } namespace poet { diff --git a/include/poet/LookupKey.hpp b/src/Chemistry/SurrogateModels/LookupKey.hpp similarity index 97% rename from include/poet/LookupKey.hpp rename to src/Chemistry/SurrogateModels/LookupKey.hpp index fbb064c53..f64b92721 100644 --- a/include/poet/LookupKey.hpp +++ b/src/Chemistry/SurrogateModels/LookupKey.hpp @@ -3,7 +3,8 @@ #ifndef LOOKUPKEY_H_ #define LOOKUPKEY_H_ -#include "poet/HashFunctions.hpp" +#include "HashFunctions.hpp" + #include #include #include diff --git a/src/ChemistryModule/SurrogateModels/ProximityHashTable.cpp b/src/Chemistry/SurrogateModels/ProximityHashTable.cpp similarity index 97% rename from src/ChemistryModule/SurrogateModels/ProximityHashTable.cpp rename to src/Chemistry/SurrogateModels/ProximityHashTable.cpp index 3ea44430d..f1589fa21 100644 --- a/src/ChemistryModule/SurrogateModels/ProximityHashTable.cpp +++ b/src/Chemistry/SurrogateModels/ProximityHashTable.cpp @@ -1,10 +1,11 @@ // Time-stamp: "Last modified 2023-08-15 14:50:59 mluebke" +#include "Interpolation.hpp" + +#include "DHT_Wrapper.hpp" +#include "HashFunctions.hpp" +#include "LookupKey.hpp" +#include "Rounding.hpp" -#include "poet/DHT_Wrapper.hpp" -#include "poet/HashFunctions.hpp" -#include "poet/Interpolation.hpp" -#include "poet/LookupKey.hpp" -#include "poet/Rounding.hpp" #include #include #include @@ -12,8 +13,9 @@ #include #include #include + extern "C" { -#include "poet/DHT.h" +#include "DHT.h" } namespace poet { diff --git a/include/poet/Rounding.hpp b/src/Chemistry/SurrogateModels/Rounding.hpp similarity index 100% rename from include/poet/Rounding.hpp rename to src/Chemistry/SurrogateModels/Rounding.hpp diff --git a/src/ChemistryModule/WorkerFunctions.cpp b/src/Chemistry/WorkerFunctions.cpp similarity index 98% rename from src/ChemistryModule/WorkerFunctions.cpp rename to src/Chemistry/WorkerFunctions.cpp index 624a78b4f..faa99834b 100644 --- a/src/ChemistryModule/WorkerFunctions.cpp +++ b/src/Chemistry/WorkerFunctions.cpp @@ -1,8 +1,8 @@ // Time-stamp: "Last modified 2023-08-16 14:50:04 mluebke" -#include "poet/ChemistryModule.hpp" -#include "poet/DHT_Wrapper.hpp" -#include "poet/Interpolation.hpp" +#include "ChemistryModule.hpp" +#include "SurrogateModels/DHT_Wrapper.hpp" +#include "SurrogateModels/Interpolation.hpp" #include #include diff --git a/include/poet/enums.hpp b/src/Chemistry/enums.hpp similarity index 100% rename from include/poet/enums.hpp rename to src/Chemistry/enums.hpp diff --git a/include/poet/DataStructures.hpp b/src/DataStructures/DataStructures.hpp similarity index 99% rename from include/poet/DataStructures.hpp rename to src/DataStructures/DataStructures.hpp index 834ceca50..30f69e5dd 100644 --- a/include/poet/DataStructures.hpp +++ b/src/DataStructures/DataStructures.hpp @@ -1,7 +1,7 @@ #ifndef DATASTRUCTURES_H_ #define DATASTRUCTURES_H_ -#include "enums.hpp" +#include "../Chemistry/enums.hpp" #include @@ -13,6 +13,7 @@ #include #include #include + namespace poet { struct WorkPackage { diff --git a/src/DataStructures/Field.cpp b/src/DataStructures/Field.cpp index de364a599..71d51dea4 100644 --- a/src/DataStructures/Field.cpp +++ b/src/DataStructures/Field.cpp @@ -1,4 +1,5 @@ -#include "poet/DataStructures.hpp" +#include "DataStructures.hpp" + #include #include #include diff --git a/include/poet/Macros.hpp b/src/Macros.hpp similarity index 100% rename from include/poet/Macros.hpp rename to src/Macros.hpp diff --git a/include/poet/RInsidePOET.hpp b/src/RInsidePOET.hpp similarity index 100% rename from include/poet/RInsidePOET.hpp rename to src/RInsidePOET.hpp diff --git a/src/DiffusionModule.cpp b/src/Transport/DiffusionModule.cpp similarity index 96% rename from src/DiffusionModule.cpp rename to src/Transport/DiffusionModule.cpp index ba7a60e62..b02f5ca0b 100644 --- a/src/DiffusionModule.cpp +++ b/src/Transport/DiffusionModule.cpp @@ -18,15 +18,15 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "DiffusionModule.hpp" +#include "../Macros.hpp" + +#include +#include + #include #include #include -#include -#include -#include -#include -#include -#include #include #include @@ -177,11 +177,11 @@ void DiffusionModule::simulate(double dt) { t_field = field_2d; - sim_a_transport = MPI_Wtime(); transport_t += sim_a_transport - sim_b_transport; - std::cout << " done in "<< sim_a_transport - sim_b_transport << "sec" << std::endl; + std::cout << " done in " << sim_a_transport - sim_b_transport << "sec" + << std::endl; } void DiffusionModule::end() { diff --git a/include/poet/DiffusionModule.hpp b/src/Transport/DiffusionModule.hpp similarity index 96% rename from include/poet/DiffusionModule.hpp rename to src/Transport/DiffusionModule.hpp index 8ea379027..a31bc0738 100644 --- a/include/poet/DiffusionModule.hpp +++ b/src/Transport/DiffusionModule.hpp @@ -21,16 +21,17 @@ #ifndef DIFFUSION_MODULE_H #define DIFFUSION_MODULE_H -#include "DataStructures.hpp" -#include "SimParams.hpp" -#include "poet/SimParams.hpp" +#include "../Base/Grid.hpp" +#include "../Base/SimParams.hpp" +#include "../DataStructures/DataStructures.hpp" + +#include +#include + #include #include #include -#include #include -#include -#include #include namespace poet { diff --git a/app/poet.cpp b/src/poet.cpp similarity index 98% rename from app/poet.cpp rename to src/poet.cpp index 4095cf858..aa6c22cb6 100644 --- a/app/poet.cpp +++ b/src/poet.cpp @@ -18,15 +18,18 @@ ** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "Base/Grid.hpp" +#include "Base/SimParams.hpp" +#include "Chemistry/ChemistryModule.hpp" +#include "Macros.hpp" +#include "RInsidePOET.hpp" +#include "Transport/DiffusionModule.hpp" + +#include + #include #include #include -#include -#include -#include -#include -#include -#include #include #include @@ -34,7 +37,6 @@ #include #include -#include using namespace std; using namespace poet; diff --git a/src/poet.h.in b/src/poet.h.in new file mode 100644 index 000000000..6a85179d4 --- /dev/null +++ b/src/poet.h.in @@ -0,0 +1,8 @@ +#ifndef POET_H +#define POET_H + +static const char *poet_version = "@POET_VERSION@"; + +static const char *CHEMISTRY_MODULE_NAME = "state_C"; + +#endif // POET_H From 547156b01743e6a91d1216e51b6d41ed1d33bcb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 11:32:45 +0100 Subject: [PATCH 2/6] Remove unused 'app' directory --- CMakeLists.txt | 1 - app/CMakeLists.txt | 6 ------ 2 files changed, 7 deletions(-) delete mode 100644 app/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd34afeb..68cc4db1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,6 @@ find_package(RRuntime REQUIRED) add_subdirectory(src) add_subdirectory(R_lib) -add_subdirectory(app) add_subdirectory(bench) # as tug will also pull in doctest as a dependency diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt deleted file mode 100644 index bd4fc4bf1..000000000 --- a/app/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ - -# add_executable(poet poet.cpp) -# target_include_directories(poet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") -# target_link_libraries(poet PUBLIC poet_lib MPI::MPI_CXX) - -# install(TARGETS poet DESTINATION bin) From a17f40d31c77ae491132c23f4c14b038dda3d418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 11:59:12 +0100 Subject: [PATCH 3/6] Add Macros.hpp and RInsidePOET.hpp*** ***Add RInsidePOET class and RHookFunction template*** ***Update include paths in SimParams.hpp*** ***Update CMakeLists.txt to link poetlib*** ***Update DHT_Wrapper.hpp include path*** ***Update DiffusionModule.cpp include path*** ***Update poet.cpp include paths*** ***Add poet.hpp.in --- src/{ => Base}/Macros.hpp | 0 src/{ => Base}/RInsidePOET.hpp | 0 src/Base/SimParams.hpp | 4 +- src/CMakeLists.txt | 39 ++++++++++++------- src/Chemistry/SurrogateModels/DHT_Wrapper.hpp | 2 +- src/Transport/DiffusionModule.cpp | 2 +- src/poet.cpp | 6 +-- src/{poet.h.in => poet.hpp.in} | 0 8 files changed, 33 insertions(+), 20 deletions(-) rename src/{ => Base}/Macros.hpp (100%) rename src/{ => Base}/RInsidePOET.hpp (100%) rename src/{poet.h.in => poet.hpp.in} (100%) diff --git a/src/Macros.hpp b/src/Base/Macros.hpp similarity index 100% rename from src/Macros.hpp rename to src/Base/Macros.hpp diff --git a/src/RInsidePOET.hpp b/src/Base/RInsidePOET.hpp similarity index 100% rename from src/RInsidePOET.hpp rename to src/Base/RInsidePOET.hpp diff --git a/src/Base/SimParams.hpp b/src/Base/SimParams.hpp index 212ec9948..523b5b105 100644 --- a/src/Base/SimParams.hpp +++ b/src/Base/SimParams.hpp @@ -22,8 +22,8 @@ #define PARSER_H #include "../DataStructures/DataStructures.hpp" -#include "../Macros.hpp" -#include "../RInsidePOET.hpp" +#include "Macros.hpp" +#include "RInsidePOET.hpp" #include "argh.hpp" // Argument handler https://github.com/adishavit/argh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index addb7c11b..51261c39a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,20 +1,27 @@ -file(GLOB_RECURSE poet_lib_SRC - CONFIGURE_DEPENDS - "*.cpp" "*.c") +add_library(poetlib + Base/Grid.cpp + Base/SimParams.cpp + Chemistry/ChemistryModule.cpp + Chemistry/MasterFunctions.cpp + Chemistry/WorkerFunctions.cpp + Chemistry/SurrogateModels/DHT_Wrapper.cpp + Chemistry/SurrogateModels/DHT.c + Chemistry/SurrogateModels/HashFunctions.cpp + Chemistry/SurrogateModels/InterpolationModule.cpp + Chemistry/SurrogateModels/ProximityHashTable.cpp + DataStructures/Field.cpp + Transport/DiffusionModule.cpp +) -configure_file(poet.h.in poet.h) - -add_executable(poet ${poet_lib_SRC}) -target_link_libraries(poet - MPI::MPI_CXX +target_link_libraries(poetlib PUBLIC + MPI::MPI_C ${MATH_LIBRARY} RRuntime PhreeqcRM tug ) -target_include_directories(poet PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") -target_compile_definitions(poet PRIVATE STRICT_R_HEADERS OMPI_SKIP_MPICXX) +target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS) mark_as_advanced(PHREEQCRM_BUILD_MPI PHREEQCRM_DISABLE_OPENMP) set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE) @@ -22,13 +29,19 @@ set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE) option(POET_DHT_DEBUG "Build with DHT debug info" OFF) if(POET_DHT_DEBUG) - target_compile_definitions(poet PRIVATE DHT_STATISTICS) + target_compile_definitions(poetlib PRIVATE DHT_STATISTICS) endif() option(POET_PHT_ADDITIONAL_INFO "Enables additional information in the PHT" OFF) if (POET_PHT_ADDITIONAL_INFO) - target_compile_definitions(poet PRIVATE POET_PHT_ADD) + target_compile_definitions(poetlib PRIVATE POET_PHT_ADD) endif() -install(TARGETS poet DESTINATION bin) \ No newline at end of file +configure_file(poet.hpp.in poet.hpp) + +add_executable(poet poet.cpp) +target_link_libraries(poet PRIVATE poetlib MPI::MPI_C RRuntime) +target_include_directories(poet PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +install(TARGETS poet DESTINATION bin) diff --git a/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp b/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp index 083fe9d25..791be2d1b 100644 --- a/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp +++ b/src/Chemistry/SurrogateModels/DHT_Wrapper.hpp @@ -23,9 +23,9 @@ #ifndef DHT_WRAPPER_H #define DHT_WRAPPER_H +#include "../../Base/RInsidePOET.hpp" #include "../../Base/SimParams.hpp" #include "../../DataStructures/DataStructures.hpp" -#include "../../RInsidePOET.hpp" #include "../enums.hpp" #include "HashFunctions.hpp" #include "LookupKey.hpp" diff --git a/src/Transport/DiffusionModule.cpp b/src/Transport/DiffusionModule.cpp index b02f5ca0b..abbecce95 100644 --- a/src/Transport/DiffusionModule.cpp +++ b/src/Transport/DiffusionModule.cpp @@ -19,7 +19,7 @@ */ #include "DiffusionModule.hpp" -#include "../Macros.hpp" +#include "../Base/Macros.hpp" #include #include diff --git a/src/poet.cpp b/src/poet.cpp index aa6c22cb6..c4996dc97 100644 --- a/src/poet.cpp +++ b/src/poet.cpp @@ -19,13 +19,13 @@ */ #include "Base/Grid.hpp" +#include "Base/Macros.hpp" +#include "Base/RInsidePOET.hpp" #include "Base/SimParams.hpp" #include "Chemistry/ChemistryModule.hpp" -#include "Macros.hpp" -#include "RInsidePOET.hpp" #include "Transport/DiffusionModule.hpp" -#include +#include #include #include diff --git a/src/poet.h.in b/src/poet.hpp.in similarity index 100% rename from src/poet.h.in rename to src/poet.hpp.in From 5ddc239499ff61e3337af26ea66b42a78b63ee41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 11:59:18 +0100 Subject: [PATCH 4/6] Update CMakeLists.txt and include headers in test files --- test/CMakeLists.txt | 3 ++- test/testField.cpp | 5 +++-- test/testNamedVector.cpp | 5 +++-- test/testRounding.cpp | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 32078d388..884750735 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,8 @@ file(GLOB test_SRC "*.cpp" "*.c") add_executable(testPOET ${test_SRC}) -target_link_libraries(testPOET doctest poet_lib) +target_link_libraries(testPOET doctest poetlib) +target_include_directories(testPOET PRIVATE "${PROJECT_SOURCE_DIR}/src") get_filename_component(TEST_RInsideSourceFile "RInsidePOET_funcs.R" REALPATH) configure_file(testDataStructures.hpp.in testDataStructures.hpp) diff --git a/test/testField.cpp b/test/testField.cpp index 8ee1bf5d6..acfe8d1a8 100644 --- a/test/testField.cpp +++ b/test/testField.cpp @@ -5,11 +5,12 @@ #include #include #include -#include -#include #include #include +#include +#include + #include "testDataStructures.hpp" using namespace poet; diff --git a/test/testNamedVector.cpp b/test/testNamedVector.cpp index 713f2729b..d5ee908f5 100644 --- a/test/testNamedVector.cpp +++ b/test/testNamedVector.cpp @@ -1,11 +1,12 @@ #include #include #include -#include -#include #include #include +#include +#include + #include "testDataStructures.hpp" TEST_CASE("NamedVector") { diff --git a/test/testRounding.cpp b/test/testRounding.cpp index 06deef193..be50fac99 100644 --- a/test/testRounding.cpp +++ b/test/testRounding.cpp @@ -1,6 +1,6 @@ #include -#include "poet/Rounding.hpp" +#include TEST_CASE("Rounding") { constexpr int signif = 3; From 58435a94d6b0e71fa8a612a89bdd7c4c9019606a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 12:01:19 +0100 Subject: [PATCH 5/6] Add OMPI_SKIP_MPICXX to target_compile_definitions in CMakeLists.txt --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51261c39a..984e2c2d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(poetlib PUBLIC tug ) -target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS) +target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX) mark_as_advanced(PHREEQCRM_BUILD_MPI PHREEQCRM_DISABLE_OPENMP) set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE) From f1f56494f9ed9bdfd727738adab1a258fd76c82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 6 Mar 2024 12:03:02 +0100 Subject: [PATCH 6/6] Remove unused CMakeLists.txt file for SurrogateModels --- src/Chemistry/SurrogateModels/CMakeLists.txt | 21 -------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/Chemistry/SurrogateModels/CMakeLists.txt diff --git a/src/Chemistry/SurrogateModels/CMakeLists.txt b/src/Chemistry/SurrogateModels/CMakeLists.txt deleted file mode 100644 index 334ec98b5..000000000 --- a/src/Chemistry/SurrogateModels/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -file(GLOB surrogate_models_SRC - CONFIGURE_DEPENDS - "*.cpp" "*.c") - -find_library(MATH_LIBRARY m) - -add_library(surrogate_models ${surrogate_models_SRC}) -target_include_directories(surrogate_models PUBLIC ${PROJECT_SOURCE_DIR}/include) -target_link_libraries(surrogate_models PUBLIC - MPI::MPI_CXX ${MATH_LIBRARY}) -target_compile_definitions(surrogate_models PUBLIC OMPI_SKIP_MPICXX) - -option(POET_PHT_ADDITIONAL_INFO "Enables additional information in the PHT" OFF) - -if (POET_PHT_ADDITIONAL_INFO) - target_compile_definitions(surrogate_models PRIVATE POET_PHT_ADD) -endif() - -if(POET_DHT_DEBUG) - target_compile_definitions(surrogate_models PRIVATE DHT_STATISTICS) -endif()