From 1cf0cdc626f4d6b25f76b155665c47d852cbdccf Mon Sep 17 00:00:00 2001 From: IvBu <st116086@stud.uni-stuttgart.de> Date: Wed, 25 Oct 2023 14:32:55 +0200 Subject: [PATCH] [cmake][config] Prefix dumux-specific preprocessor macros. --- CHANGELOG.md | 8 ++++++++ cmake/modules/AddKokkosFlags.cmake | 2 +- cmake/modules/AddOpenMPFlags.cmake | 2 +- cmake/modules/DumuxMacros.cmake | 4 ++-- cmake/modules/FindGmsh.cmake | 2 +- cmake/modules/FindGstat.cmake | 2 +- cmake/modules/FindPVPython.cmake | 2 +- config.h.cmake | 18 +++++++++--------- dumux/common/initialize.hh | 12 ++++++------ dumux/io/gnuplotinterface.hh | 4 ++-- dumux/material/gstatrandomfield.hh | 2 +- dumux/parallel/parallel_for.hh | 8 ++++---- .../facecentered/staggered/drawgrid.hh | 2 +- test/porenetwork/2p/static/main.cc | 2 +- .../1p/isothermal/CMakeLists.txt | 2 +- test/porousmediumflow/1p/rootbenchmark/main.cc | 4 ++-- 16 files changed, 42 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dd527e6f..5513284987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,14 @@ be evaluated with the function values provided in the same order as the names wh - __Newton__: The Newton solver no longer supports linear solvers without a `norm` interface when computing the resisual norm is required. The linear solvers available in Dumux all have such an interface. - __MultiDomain__: The MDTraits are now required to state the LocalResidual type in the Subdomain policy (see multidomain/traits.hh). This only affects users that created their own MDTraits and don't use the default MDTraits. - __PDESolver__: The PDESolver interface now requires an `apply` method that returns a `bool` instead of throwing when not converged +- DuMux-specific preprocessor macros (defined in `config.h`) are now prefixed by `DUMUX_` in order to avoid name conflicts when being passed down to other modules. Corresponding CMake variables (if existing) are now also prefixed. Explicitly, the following macros have been renamed: + - `HAVE_KOKKOS` to `DUMUX_HAVE_KOKKOS` + - `HAVE_OPENMP` to `DUMUX_HAVE_OPENMP` + - `HAVE_GNUPLOT` to `DUMUX_HAVE_GNUPLOT` + - `HAVE_CPP_PARALLEL_ALGORITHMS` to `DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS` + - `HAVE_GMSH` to `DUMUX_HAVE_GMSH` + - `HAVE_GSTAT` to `DUMUX_HAVE_GSTAT` + - `HAVE_PVPYTHON` to `DUMUX_HAVE_PVPYTHON` ### Deprecated properties/classes/functions/files, to be removed after 3.8: diff --git a/cmake/modules/AddKokkosFlags.cmake b/cmake/modules/AddKokkosFlags.cmake index 7fceb0bd2d..1c2c023566 100644 --- a/cmake/modules/AddKokkosFlags.cmake +++ b/cmake/modules/AddKokkosFlags.cmake @@ -4,7 +4,7 @@ include_guard(GLOBAL) # set variable for config.h -set(HAVE_KOKKOS ${Kokkos_FOUND}) +set(DUMUX_HAVE_KOKKOS ${Kokkos_FOUND}) # perform DUNE-specific setup tasks if (Kokkos_FOUND) diff --git a/cmake/modules/AddOpenMPFlags.cmake b/cmake/modules/AddOpenMPFlags.cmake index d4732623b2..006cc61061 100644 --- a/cmake/modules/AddOpenMPFlags.cmake +++ b/cmake/modules/AddOpenMPFlags.cmake @@ -4,7 +4,7 @@ include_guard(GLOBAL) # set variable for config.h -set(HAVE_OPENMP ${OpenMP_FOUND}) +set(DUMUX_HAVE_OPENMP ${OpenMP_FOUND}) # perform DUNE-specific setup tasks if (OpenMP_FOUND) diff --git a/cmake/modules/DumuxMacros.cmake b/cmake/modules/DumuxMacros.cmake index 00789290a2..01f384076c 100644 --- a/cmake/modules/DumuxMacros.cmake +++ b/cmake/modules/DumuxMacros.cmake @@ -9,7 +9,7 @@ include(DumuxTestMacros) find_package(GLPK QUIET) find_package(Gnuplot QUIET) -set(HAVE_GNUPLOT ${GNUPLOT_FOUND}) +set(DUMUX_HAVE_GNUPLOT ${GNUPLOT_FOUND}) find_package(Gstat QUIET) find_package(Gmsh QUIET) find_package(NLOPT QUIET) @@ -63,7 +63,7 @@ check_cxx_symbol_exists( ) if(DUMUX_HAVE_CXX_EXECUTION_POLICY) - set(HAVE_CPP_PARALLEL_ALGORITHMS TRUE) + set(DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS TRUE) endif() # setup multithreading backend diff --git a/cmake/modules/FindGmsh.cmake b/cmake/modules/FindGmsh.cmake index ff760a6a88..cacf7e0e09 100644 --- a/cmake/modules/FindGmsh.cmake +++ b/cmake/modules/FindGmsh.cmake @@ -45,7 +45,7 @@ find_package_handle_standard_args( ) # set macros for config.h -set(HAVE_GMSH ${Gmsh_FOUND}) +set(DUMUX_HAVE_GMSH ${Gmsh_FOUND}) set(GMSH_EXECUTABLE ${GMSH_EXECUTABLE}) # text for feature summary diff --git a/cmake/modules/FindGstat.cmake b/cmake/modules/FindGstat.cmake index abba48d84f..c695a0b471 100644 --- a/cmake/modules/FindGstat.cmake +++ b/cmake/modules/FindGstat.cmake @@ -45,7 +45,7 @@ find_package_handle_standard_args( ) # set macros for config.h -set(HAVE_GSTAT ${GSTAT_FOUND}) +set(DUMUX_HAVE_GSTAT ${GSTAT_FOUND}) set(GSTAT_EXECUTABLE ${GSTAT_EXECUTABLE}) # text for feature summary diff --git a/cmake/modules/FindPVPython.cmake b/cmake/modules/FindPVPython.cmake index 4ea29ecd9b..8757b8dbab 100644 --- a/cmake/modules/FindPVPython.cmake +++ b/cmake/modules/FindPVPython.cmake @@ -45,7 +45,7 @@ find_package_handle_standard_args( ) # set macros for config.h -set(HAVE_PVPYTHON ${PVPYTHON_FOUND}) +set(DUMUX_HAVE_PVPYTHON ${PVPYTHON_FOUND}) set(PVPYTHON_EXECUTABLE ${PVPYTHON_EXECUTABLE}) # text for feature summary diff --git a/config.h.cmake b/config.h.cmake index 4c9390e290..71bfe1eea6 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -52,45 +52,45 @@ #define OPM_GRID_VERSION_MINOR ${OPM_GRID_VERSION_MINOR} /* Define to 1 if gnuplot was found */ -#cmakedefine HAVE_GNUPLOT 1 +#cmakedefine DUMUX_HAVE_GNUPLOT 1 /* Define path to gnuplot executable */ #cmakedefine GNUPLOT_EXECUTABLE "@GNUPLOT_EXECUTABLE@" /* Define to 1 if gstat was found */ -#cmakedefine HAVE_GSTAT 1 +#cmakedefine DUMUX_HAVE_GSTAT 1 /* Define path to gstat executable */ #cmakedefine GSTAT_EXECUTABLE "@GSTAT_EXECUTABLE@" /* Define to 1 if gmsh was found */ -#cmakedefine HAVE_GMSH 1 +#cmakedefine DUMUX_HAVE_GMSH 1 /* Define path to gmsh executable */ #cmakedefine GMSH_EXECUTABLE "@GMSH_EXECUTABLE@" /* Defines whether pvpython has been found */ -#cmakedefine HAVE_PVPYTHON 1 +#cmakedefine DUMUX_HAVE_PVPYTHON 1 /* Define the path to pvpython */ #define PVPYTHON_EXECUTABLE "${PVPYTHON_EXECUTABLE}" /* Define to 1 if quadmath was found */ -#cmakedefine HAVE_QUAD 1 +#cmakedefine DUMUX_HAVE_QUAD 1 /* Set if Kokkos was found */ -#cmakedefine HAVE_KOKKOS ENABLE_KOKKOS +#cmakedefine DUMUX_HAVE_KOKKOS ENABLE_KOKKOS /* Set if OpenMP was found */ -#cmakedefine HAVE_OPENMP ENABLE_OPENMP +#cmakedefine DUMUX_HAVE_OPENMP ENABLE_OPENMP /* Set the DUMUX_MULTITHREADING_BACKEND */ #ifndef DUMUX_MULTITHREADING_BACKEND #define DUMUX_MULTITHREADING_BACKEND ${DUMUX_MULTITHREADING_BACKEND} #endif -/* Set HAVE_CPP_PARALLEL_ALGORITHMS if available */ -#cmakedefine HAVE_CPP_PARALLEL_ALGORITHMS 1 +/* Set DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS if available */ +#cmakedefine DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS 1 /* end dumux Everything below here will be overwritten diff --git a/dumux/common/initialize.hh b/dumux/common/initialize.hh index 54a0c71e60..8ccbcb72f5 100644 --- a/dumux/common/initialize.hh +++ b/dumux/common/initialize.hh @@ -48,12 +48,12 @@ public: #endif // HAVE_TBB -#if HAVE_OPENMP +#if DUMUX_HAVE_OPENMP #include <omp.h> -#endif // HAVE_OPENMP +#endif // DUMUX_HAVE_OPENMP -#if HAVE_KOKKOS +#if DUMUX_HAVE_KOKKOS #include <Kokkos_Core.hpp> #ifndef DOXYGEN @@ -76,7 +76,7 @@ public: } // namespace Dumux::Detail #endif // DOXYGEN -#endif // HAVE_KOKKOS +#endif // DUMUX_HAVE_KOKKOS namespace Dumux { @@ -91,14 +91,14 @@ void initialize(int& argc, char* argv[]) Detail::TBBGlobalControl::instance(argc, argv); #endif -#if HAVE_OPENMP +#if DUMUX_HAVE_OPENMP if (const char* dumuxNumThreads = std::getenv("DUMUX_NUM_THREADS")) omp_set_num_threads( std::max(1, std::stoi(std::string{ dumuxNumThreads })) ); #endif -#if HAVE_KOKKOS +#if DUMUX_HAVE_KOKKOS // initialize Kokkos (command line / environmental variable interface) Detail::KokkosScopeGuard::instance(argc, argv); #endif diff --git a/dumux/io/gnuplotinterface.hh b/dumux/io/gnuplotinterface.hh index f366e2f1dc..dce6d78111 100644 --- a/dumux/io/gnuplotinterface.hh +++ b/dumux/io/gnuplotinterface.hh @@ -16,7 +16,7 @@ #ifndef DUMUX_GNUPLOT_INTERFACE_HH #define DUMUX_GNUPLOT_INTERFACE_HH -#if !HAVE_GNUPLOT +#if !DUMUX_HAVE_GNUPLOT // Gnuplot has not been found by CMake, no output possible. #define GNUPLOT_EXECUTABLE "/usr/bin/gnuplot" #endif @@ -379,7 +379,7 @@ private: // Give plot command to gnuplot void executeGnuplot(const std::string& plotCommand, std::FILE * pipe) const { -#ifdef HAVE_GNUPLOT +#ifdef DUMUX_HAVE_GNUPLOT fputs((plotCommand + "\n").c_str(), pipe); fflush(pipe); #else diff --git a/dumux/material/gstatrandomfield.hh b/dumux/material/gstatrandomfield.hh index 01e32cffe2..ffe21dab84 100644 --- a/dumux/material/gstatrandomfield.hh +++ b/dumux/material/gstatrandomfield.hh @@ -87,7 +87,7 @@ public: fieldType_ = fieldType; if (createNew) { -#if !HAVE_GSTAT +#if !DUMUX_HAVE_GSTAT DUNE_THROW(Dune::InvalidStateException, "Requested data field generation with gstat" << " but gstat was not found on your system. Set GSTAT_ROOT to the path where gstat " << " is installed and pass it to CMake, e.g. through an opts file."); diff --git a/dumux/parallel/parallel_for.hh b/dumux/parallel/parallel_for.hh index f54d4e5e39..32befe762e 100644 --- a/dumux/parallel/parallel_for.hh +++ b/dumux/parallel/parallel_for.hh @@ -16,7 +16,7 @@ #include <dumux/parallel/multithreading.hh> -#if HAVE_CPP_PARALLEL_ALGORITHMS +#if DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS #include <algorithm> #include <execution> #include <dune/common/rangeutilities.hh> @@ -59,7 +59,7 @@ private: std::size_t count_; }; -#if HAVE_CPP_PARALLEL_ALGORITHMS +#if DUMUX_HAVE_CPP_PARALLEL_ALGORITHMS // C++ parallel algorithms backend implementation template<class FunctorType> class ParallelFor<FunctorType, Multithreading::ExecutionBackends::Cpp> @@ -121,7 +121,7 @@ private: #endif // HAVE_KOKKOS -#if HAVE_OPENMP +#if DUMUX_HAVE_OPENMP // OpenMP backend implementation template<class FunctorType> class ParallelFor<FunctorType, Multithreading::ExecutionBackends::OpenMP> @@ -141,7 +141,7 @@ private: FunctorType functor_; std::size_t count_; }; -#endif // HAVE_OPENMP +#endif // DUMUX_HAVE_OPENMP } // end namespace Detail diff --git a/test/discretization/facecentered/staggered/drawgrid.hh b/test/discretization/facecentered/staggered/drawgrid.hh index f0b3e5e172..f0e2386929 100644 --- a/test/discretization/facecentered/staggered/drawgrid.hh +++ b/test/discretization/facecentered/staggered/drawgrid.hh @@ -269,7 +269,7 @@ void drawGridGeometry(const GridGeometry& gridGeometry, << ":" << maxCoord[1] << "] NaN notitle" << std::endl; plotFile.close(); -#if HAVE_GNUPLOT +#if DUMUX_HAVE_GNUPLOT if (executePlot) { std::string cmd = "gnuplot -p '" + plotFileName + "'"; diff --git a/test/porenetwork/2p/static/main.cc b/test/porenetwork/2p/static/main.cc index 3230168676..70acb6effa 100644 --- a/test/porenetwork/2p/static/main.cc +++ b/test/porenetwork/2p/static/main.cc @@ -254,7 +254,7 @@ int main(int argc, char** argv) } //plot the pc-S curve, if desired -#ifdef HAVE_GNUPLOT +#ifdef DUMUX_HAVE_GNUPLOT if (getParam<bool>("Problem.PlotPcS")) { Dumux::GnuplotInterface<Scalar> gnuplot(true); diff --git a/test/porousmediumflow/1p/isothermal/CMakeLists.txt b/test/porousmediumflow/1p/isothermal/CMakeLists.txt index ebf3ebb008..62529bba8b 100644 --- a/test/porousmediumflow/1p/isothermal/CMakeLists.txt +++ b/test/porousmediumflow/1p/isothermal/CMakeLists.txt @@ -63,6 +63,6 @@ dumux_add_test(NAME test_1p_gstat LABELS porousmediumflow 1p SOURCES main.cc COMPILE_DEFINITIONS TYPETAG=OnePTestCCTpfa - CMAKE_GUARD HAVE_GSTAT + CMAKE_GUARD DUMUX_HAVE_GSTAT COMMAND ./test_1p_gstat CMD_ARGS params_gstat.input) diff --git a/test/porousmediumflow/1p/rootbenchmark/main.cc b/test/porousmediumflow/1p/rootbenchmark/main.cc index 6158d4be17..9620399b9e 100644 --- a/test/porousmediumflow/1p/rootbenchmark/main.cc +++ b/test/porousmediumflow/1p/rootbenchmark/main.cc @@ -26,7 +26,7 @@ #include <dumux/assembly/fvassembler.hh> -#if HAVE_GNUPLOT +#if DUMUX_HAVE_GNUPLOT #include <dumux/io/gnuplotinterface.hh> #endif #include <dumux/io/vtkoutputmodule.hh> @@ -99,7 +99,7 @@ int main(int argc, char** argv) // write more output for benchmark plot problem->outputL2Norm(x); -#if HAVE_GNUPLOT +#if DUMUX_HAVE_GNUPLOT // plot with gnuplot bool enablePlot = getParam<bool>("Problem.EnablePlot", false); if (enablePlot) -- GitLab