Commits (2)
# Includes for the mpp library # Includes for the mpp library
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Google test # Google test
add_subdirectory(${PROJECT_MPP_DIR}/googletest) add_subdirectory(${PROJECT_MPP_DIR}/googletest)
include_directories(${PROJECT_MPP_DIR}/googletest/googletest/include) include_directories(${PROJECT_MPP_DIR}/googletest/googletest/include)
include_directories(${PROJECT_MPP_DIR}/googletest/googlemock/include) include_directories(${PROJECT_MPP_DIR}/googletest/googlemock/include)
set(GTEST_LIB gtest gtest_main gmock gmock_main) set(GTEST_LIB gtest gtest_main gmock gmock_main)
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# MPI # MPI
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH}) include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_C_COMPILER ${MPI_C_COMPILER}) set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER}) set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS}) 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_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
set(CMAKE_BUILD_TYPE distribution) set(CMAKE_BUILD_TYPE distribution)
if (NOT CMAKE_CXX_FLAGS_DISTRIBUTION) if (NOT CMAKE_CXX_FLAGS_DISTRIBUTION)
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-Ofast") set(CMAKE_CXX_FLAGS_DISTRIBUTION "-Ofast")
endif () endif ()
message(STATUS "Compiler option " ${CMAKE_CXX_FLAGS_DISTRIBUTION}) message(STATUS "Compiler option " ${CMAKE_CXX_FLAGS_DISTRIBUTION})
if (NO_DEPRECATED) if (NO_DEPRECATED)
set(CMAKE_CXX_FLAGS "-fPIC -g -Wno-deprecated -std=c++11") set(CMAKE_CXX_FLAGS "-fPIC -g -Wno-deprecated -std=c++17")
else () else ()
set(CMAKE_CXX_FLAGS "-fPIC -g -std=c++11") set(CMAKE_CXX_FLAGS "-fPIC -g -std=c++17")
endif() endif()
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Blas Lapack # Blas Lapack
find_package(BLAS REQUIRED) find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED) find_package(LAPACK REQUIRED)
add_definitions(-DLAPACK) add_definitions(-DLAPACK)
add_definitions(-DRIB) add_definitions(-DRIB)
add_definitions(-DGCC_4_4) add_definitions(-DGCC_4_4)
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Manage folder structure build folder # Manage folder structure build folder
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/vtk) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/vtk)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/gp) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/gp)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/py) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/py)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/log) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/log)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/dual) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/data/dual)
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Link superlu # Link superlu
if (USE_SUPERLU30) if (USE_SUPERLU30)
message(FATAL_ERROR "SuperLU 3.0 not available!") message(FATAL_ERROR "SuperLU 3.0 not available!")
add_definitions(-DSUPERLU30) add_definitions(-DSUPERLU30)
add_definitions(-DLIB_PS_SUPERLU30) add_definitions(-DLIB_PS_SUPERLU30)
include_directories(${PROJECT_MPP_DIR}/superlu/include) include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib) link_directories(${PROJECT_MPP_DIR}/superlu/lib)
else () else ()
message(STATUS "Using SuperLU 4.0") message(STATUS "Using SuperLU 4.0")
add_definitions(-DSUPERLU) add_definitions(-DSUPERLU)
add_definitions(-DLIB_PS_SUPERLU) add_definitions(-DLIB_PS_SUPERLU)
include_directories(${PROJECT_MPP_DIR}/superlu/include) include_directories(${PROJECT_MPP_DIR}/superlu/include)
link_directories(${PROJECT_MPP_DIR}/superlu/lib) link_directories(${PROJECT_MPP_DIR}/superlu/lib)
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
set(SUPERLU superlu_4.3) set(SUPERLU superlu_4.3)
elseif (APPLE) elseif (APPLE)
set(SUPERLU superlu_4.3_mac10.10) set(SUPERLU superlu_4.3_mac10.10)
elseif (WIN32) elseif (WIN32)
set(SUPERLU superlu_4.3_cygwin) set(SUPERLU superlu_4.3_cygwin)
endif () endif ()
endif () endif ()
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Link cxsc # Link cxsc
if (USE_CXSC) if (USE_CXSC)
message(STATUS "Using cxsc library for interval arithmetic computation") message(STATUS "Using cxsc library for interval arithmetic computation")
add_definitions(-DCXSC_INTVALCOMP) add_definitions(-DCXSC_INTVALCOMP)
include_directories(${PROJECT_MPP_DIR}/cxsc/include) include_directories(${PROJECT_MPP_DIR}/cxsc/include)
link_directories(${PROJECT_MPP_DIR}/cxsc/lib) link_directories(${PROJECT_MPP_DIR}/cxsc/lib)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic) include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/src) include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/src)
include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/eigenvaluemethods) include_directories(${PROJECT_MPP_DIR}/src/intervalarithmetic/eigenvaluemethods)
endif () endif ()
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Problem options # Problem options
if (PROBLEM_NO_TIME) if (PROBLEM_NO_TIME)
message(STATUS "Time independent problem") message(STATUS "Time independent problem")
add_definitions(-DTimeDimension=0) add_definitions(-DTimeDimension=0)
else () else ()
message(STATUS "Time dependent problem") message(STATUS "Time dependent problem")
add_definitions(-DTimeDimension=1) add_definitions(-DTimeDimension=1)
endif () endif ()
if (PROBLEM_1D) if (PROBLEM_1D)
message(FATAL_ERROR "Space dimension 1 not implemented!") message(FATAL_ERROR "Space dimension 1 not implemented!")
elseif (PROBLEM_2D) elseif (PROBLEM_2D)
message(STATUS "2 dimensional problem") message(STATUS "2 dimensional problem")
add_definitions(-DPROBLEM_2D) add_definitions(-DPROBLEM_2D)
add_definitions(-DSpaceDimension=2) add_definitions(-DSpaceDimension=2)
else () else ()
message(STATUS "3 dimensional problem") message(STATUS "3 dimensional problem")
add_definitions(-DPROBLEM_3D) add_definitions(-DPROBLEM_3D)
add_definitions(-DSpaceDimension=3) add_definitions(-DSpaceDimension=3)
endif () endif ()
if (AFFINE_LINEAR_TRAFO) if (AFFINE_LINEAR_TRAFO)
message(STATUS "Only affine linear transformations") message(STATUS "Only affine linear transformations")
add_definitions(-DAFFINE_TRANSFORMATION) add_definitions(-DAFFINE_TRANSFORMATION)
else () else ()
message(STATUS "General transformations") message(STATUS "General transformations")
endif () endif ()
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Include directories # Include directories
include_directories(${PROJECT_MPP_DIR}/src/LIB_PS) include_directories(${PROJECT_MPP_DIR}/src/LIB_PS)
include_directories(${PROJECT_MPP_DIR}/src) include_directories(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Subdirectories # Subdirectories
add_subdirectory(${PROJECT_MPP_DIR}/src) add_subdirectory(${PROJECT_MPP_DIR}/src)
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
# Tests # Tests
if (BUILD_TESTS) if (BUILD_TESTS)
include(${PROJECT_MPP_DIR}/tests/CMakeLists.txt) include(${PROJECT_MPP_DIR}/tests/CMakeLists.txt)
endif () endif ()
#---------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------#
...@@ -735,10 +735,20 @@ RowBndValues::RowBndValues(Vector &u, const tcell &tc) : BF(u.GetSTMesh(), tc), ...@@ -735,10 +735,20 @@ RowBndValues::RowBndValues(Vector &u, const tcell &tc) : BF(u.GetSTMesh(), tc),
/*******************/ /*******************/
/* extra functions */ /* extra functions */
/*******************/ /*******************/
// Upgrade to c++17:
// This operator is only used in the function RandomVector, where it throws a compiler error...
template<class F> template<class F>
Vector &operator<<(Vector &u, const F &f) { Vector &operator<<(Vector &u, const F &f) {
for (row r = u.rows(); r != u.rows_end(); ++r) 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; return u;
} }
...@@ -757,6 +767,8 @@ void RandomVector(Vector &u, Operator &B, Operator &IA) { ...@@ -757,6 +767,8 @@ void RandomVector(Vector &u, Operator &B, Operator &IA) {
double s = sqrt(std::real(b * v)); double s = sqrt(std::real(b * v));
b /= s; b /= s;
u = IA * b; u = IA * b;
// See comments above on the operator <<
Exit("RandomVector should be refactored.")
} }
void RandomVectors(Vectors &u, Operator &B, Operator &IA) { void RandomVectors(Vectors &u, Operator &B, Operator &IA) {
...@@ -772,6 +784,8 @@ void RandomVectors(Vectors &u, Operator &B, Operator &IA) { ...@@ -772,6 +784,8 @@ void RandomVectors(Vectors &u, Operator &B, Operator &IA) {
b[i] /= s; b[i] /= s;
} }
u = IA * b; u = IA * b;
// See comments above on the operator <<
Exit("RandomVectors should be refactored.")
} }
/****************/ /****************/
......