Commit 45fe37ad authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

Merge branch 'upgrade-c++17' of git.scc.kit.edu:yq8188/mpp

parents 09b45559 dc3458e5
# Includes for the mpp library
#---------------------------------------------------------------------------------------#
# Google test
add_subdirectory(${PROJECT_MPP_DIR}/googletest)
include_directories(${PROJECT_MPP_DIR}/googletest/googletest/include)
include_directories(${PROJECT_MPP_DIR}/googletest/googlemock/include)
set(GTEST_LIB gtest gtest_main gmock gmock_main)
#---------------------------------------------------------------------------------------#
# MPI
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
set(CMAKE_BUILD_TYPE distribution)
if (NOT CMAKE_CXX_FLAGS_DISTRIBUTION)
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-Ofast")
endif ()
message(STATUS "Compiler option " ${CMAKE_CXX_FLAGS_DISTRIBUTION})
if (NO_DEPRECATED)
set(CMAKE_CXX_FLAGS "-fPIC -g -Wno-deprecated -std=c++11")
else ()
set(CMAKE_CXX_FLAGS "-fPIC -g -std=c++11")
endif()
#---------------------------------------------------------------------------------------#
# Blas Lapack
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
add_definitions(-DLAPACK)
add_definitions(-DRIB)
add_definitions(-DGCC_4_4)
#---------------------------------------------------------------------------------------#
# Manage folder structure build folder
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/vtk)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/gp)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/py)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/log)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/dual)
#---------------------------------------------------------------------------------------#
# Link superlu
if (USE_SUPERLU30)
message(FATAL_ERROR "SuperLU 3.0 not available!")
add_definitions(-DSUPERLU30)
add_definitions(-DLIB_PS_SUPERLU30)
include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib)
else ()
message(STATUS "Using SuperLU 4.0")
add_definitions(-DSUPERLU)
add_definitions(-DLIB_PS_SUPERLU)
include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib)
if (UNIX AND NOT APPLE)
set(SUPERLU superlu_4.3)
elseif (APPLE)
set(SUPERLU superlu_4.3_mac10.10)
elseif (WIN32)
set(SUPERLU superlu_4.3_cygwin)
endif ()
endif ()
#---------------------------------------------------------------------------------------#
# Link cxsc
if (USE_CXSC)
message(STATUS "Using cxsc library for interval arithmetic computation")
add_definitions(-DCXSC_INTVALCOMP)
include_directories(${PROJECT_MPP_DIR}/cxsc/include)
link_directories(${PROJECT_MPP_DIR}/cxsc/lib)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/src)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/eigenvaluemethods)
endif ()
#---------------------------------------------------------------------------------------#
# Problem options
if (PROBLEM_NO_TIME)
message(STATUS "Time independent problem")
add_definitions(-DTimeDimension=0)
else ()
message(STATUS "Time dependent problem")
add_definitions(-DTimeDimension=1)
endif ()
if (PROBLEM_1D)
message(FATAL_ERROR "Space dimension 1 not implemented!")
elseif (PROBLEM_2D)
message(STATUS "2 dimensional problem")
add_definitions(-DPROBLEM_2D)
add_definitions(-DSpaceDimension=2)
else ()
message(STATUS "3 dimensional problem")
add_definitions(-DPROBLEM_3D)
add_definitions(-DSpaceDimension=3)
endif ()
if (AFFINE_LINEAR_TRAFO)
message(STATUS "Only affine linear transformations")
add_definitions(-DAFFINE_TRANSFORMATION)
else ()
message(STATUS "General transformations")
endif ()
#---------------------------------------------------------------------------------------#
# Include directories
include_directories(${PROJECT_MPP_DIR}/src/LIB_PS)
include_directories(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------#
# Subdirectories
add_subdirectory(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------#
# Tests
if (BUILD_TESTS)
include(${PROJECT_MPP_DIR}/tests/CMakeLists.txt)
endif ()
#---------------------------------------------------------------------------------------#
# Includes for the mpp library
#---------------------------------------------------------------------------------------#
# Google test
add_subdirectory(${PROJECT_MPP_DIR}/googletest)
include_directories(${PROJECT_MPP_DIR}/googletest/googletest/include)
include_directories(${PROJECT_MPP_DIR}/googletest/googlemock/include)
set(GTEST_LIB gtest gtest_main gmock gmock_main)
#---------------------------------------------------------------------------------------#
# MPI
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
set(CMAKE_BUILD_TYPE distribution)
if (NOT CMAKE_CXX_FLAGS_DISTRIBUTION)
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-Ofast")
endif ()
message(STATUS "Compiler option " ${CMAKE_CXX_FLAGS_DISTRIBUTION})
if (NO_DEPRECATED)
set(CMAKE_CXX_FLAGS "-fPIC -g -Wno-deprecated -std=c++17")
else ()
set(CMAKE_CXX_FLAGS "-fPIC -g -std=c++17")
endif()
#---------------------------------------------------------------------------------------#
# Blas Lapack
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
add_definitions(-DLAPACK)
add_definitions(-DRIB)
add_definitions(-DGCC_4_4)
#---------------------------------------------------------------------------------------#
# Manage folder structure build folder
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/vtk)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/gp)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/py)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/log)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/dual)
#---------------------------------------------------------------------------------------#
# Link superlu
if (USE_SUPERLU30)
message(FATAL_ERROR "SuperLU 3.0 not available!")
add_definitions(-DSUPERLU30)
add_definitions(-DLIB_PS_SUPERLU30)
include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib)
else ()
message(STATUS "Using SuperLU 4.0")
add_definitions(-DSUPERLU)
add_definitions(-DLIB_PS_SUPERLU)
include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib)
if (UNIX AND NOT APPLE)
set(SUPERLU superlu_4.3)
elseif (APPLE)
set(SUPERLU superlu_4.3_mac10.10)
elseif (WIN32)
set(SUPERLU superlu_4.3_cygwin)
endif ()
endif ()
#---------------------------------------------------------------------------------------#
# Link cxsc
if (USE_CXSC)
message(STATUS "Using cxsc library for interval arithmetic computation")
add_definitions(-DCXSC_INTVALCOMP)
include_directories(${PROJECT_MPP_DIR}/cxsc/include)
link_directories(${PROJECT_MPP_DIR}/cxsc/lib)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/src)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/eigenvaluemethods)
endif ()
#---------------------------------------------------------------------------------------#
# Problem options
if (PROBLEM_NO_TIME)
message(STATUS "Time independent problem")
add_definitions(-DTimeDimension=0)
else ()
message(STATUS "Time dependent problem")
add_definitions(-DTimeDimension=1)
endif ()
if (PROBLEM_1D)
message(FATAL_ERROR "Space dimension 1 not implemented!")
elseif (PROBLEM_2D)
message(STATUS "2 dimensional problem")
add_definitions(-DPROBLEM_2D)
add_definitions(-DSpaceDimension=2)
else ()
message(STATUS "3 dimensional problem")
add_definitions(-DPROBLEM_3D)
add_definitions(-DSpaceDimension=3)
endif ()
if (AFFINE_LINEAR_TRAFO)
message(STATUS "Only affine linear transformations")
add_definitions(-DAFFINE_TRANSFORMATION)
else ()
message(STATUS "General transformations")
endif ()
#---------------------------------------------------------------------------------------#
# Include directories
include_directories(${PROJECT_MPP_DIR}/src/LIB_PS)
include_directories(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------#
# Subdirectories
add_subdirectory(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------#
# Tests
if (BUILD_TESTS)
include(${PROJECT_MPP_DIR}/tests/CMakeLists.txt)
endif ()
#---------------------------------------------------------------------------------------#
......@@ -735,10 +735,20 @@ RowBndValues::RowBndValues(Vector &u, const tcell &tc) : BF(u.GetSTMesh(), tc),
/*******************/
/* extra functions */
/*******************/
// Upgrade to c++17:
// This operator is only used in the function RandomVector, where it throws a compiler error...
template<class F>
Vector &operator<<(Vector &u, const F &f) {
for (row r = u.rows(); r != u.rows_end(); ++r)
u(r, 0) = eval(f(r()));
// Upgrade to c++17: Changed line to ensure this works.
// Note that this operator is not flexible, as it only creates Scalar Random Vectors.
u(r, 0) = eval(f());
// LEGACY ========================================================================
// The evaluation of an arbitrary function at an object of type row seems unstable
// Upgrade to c++17: This throws an error from RandomVector, because "rand" is a
// function with zero input arguments.
//u(r, 0) = eval(f(r()));
// ===============================================================================
return u;
}
......@@ -757,6 +767,8 @@ void RandomVector(Vector &u, Operator &B, Operator &IA) {
double s = sqrt(std::real(b * v));
b /= s;
u = IA * b;
// See comments above on the operator <<
Exit("RandomVector should be refactored.")
}
void RandomVectors(Vectors &u, Operator &B, Operator &IA) {
......@@ -772,6 +784,8 @@ void RandomVectors(Vectors &u, Operator &B, Operator &IA) {
b[i] /= s;
}
u = IA * b;
// See comments above on the operator <<
Exit("RandomVectors should be refactored.")
}
/****************/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment