diff --git a/Applications/CLI/CMakeLists.txt b/Applications/CLI/CMakeLists.txt index 836daed4fc4d91f02b0737bf9dae3bad7e1b9d1c..a5724eff5bbe2fcab919aa3e3b31d00fe42d49d6 100644 --- a/Applications/CLI/CMakeLists.txt +++ b/Applications/CLI/CMakeLists.txt @@ -12,7 +12,7 @@ TARGET_LINK_LIBRARIES(ogs ) IF(OGS_USE_PETSC) - TARGET_LINK_LIBRARIES(ogs ${ogs} ${PETSC_LIBRARIES}) + TARGET_LINK_LIBRARIES(ogs ${PETSC_LIBRARIES}) ENDIF() INCLUDE(Tests.cmake) diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt index 1fcbef437fae4fc58e5b15d08dda6f1b89ebd7ee..4ccc1008d13b462fc32378ac0faf42ad61436e4d 100644 --- a/BaseLib/CMakeLists.txt +++ b/BaseLib/CMakeLists.txt @@ -2,10 +2,6 @@ GET_SOURCE_FILES(SOURCES) -IF(NOT OGS_USE_PETSC) - list(REMOVE_ITEM SOURCES PETScWallClockTimer.h) -ENDIF() - LIST(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/BuildInfo.cpp" BuildInfo.h) # Create the library diff --git a/BaseLib/PETScWallClockTimer.h b/BaseLib/PETScWallClockTimer.h deleted file mode 100644 index 018526a3d9c5b0535857c958a1d19ce49a227aac..0000000000000000000000000000000000000000 --- a/BaseLib/PETScWallClockTimer.h +++ /dev/null @@ -1,57 +0,0 @@ -/*! - \file PETScWallClockTimer.h - \author Wenqing Wang - \date 2014.08 - \brief Declare a class to record wall clock time in computation with PETSc. - - \copyright - Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - Distributed under a Modified BSD License. - See accompanying file LICENSE.txt or - http://www.opengeosys.org/project/license - -*/ - -#ifndef PETSC_WALL_CLOCK_TIMER_H -#define PETSC_WALL_CLOCK_TIMER_H - -#include <petsctime.h> - -namespace BaseLib -{ - -/// Count wall clock time for computations with PETSc. -class PETScWallClockTimer -{ - public: - /// Record the start time. - void start() - { -#if (PETSC_VERSION_NUMBER > 3020) - PetscTime(&_start_time); -#else - PetscGetTime(&_start_time); -#endif - } - - /// Return the elapsed time when this function is called. - PetscLogDouble elapsed() const - { - PetscLogDouble current_time; -#if (PETSC_VERSION_NUMBER > 3020) - PetscTime(¤t_time); -#else - PetscGetTime(¤t_time); -#endif - return current_time - _start_time; - } - - private: - /// Start time. - PetscLogDouble _start_time = 0.; -}; - -} // end namespace BaseLib - -#endif - diff --git a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp index a10318d7e4c4fb040439cbe201ddd732180ab44a..a1a562dff936cdd9dcb13047c9036c89f4d7f555 100644 --- a/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp +++ b/MathLib/LinAlg/PETSc/PETScLinearSolver.cpp @@ -15,7 +15,7 @@ */ #include "PETScLinearSolver.h" -#include "BaseLib/PETScWallClockTimer.h" +#include "BaseLib/RunTime.h" namespace MathLib { @@ -37,8 +37,8 @@ PETScLinearSolver::PETScLinearSolver(PETScMatrix &A, const std::string &prefix) bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x) { - BaseLib::PETScWallClockTimer ctimer; - ctimer.start(); + BaseLib::RunTime wtimer; + wtimer.start(); // define TEST_MEM_PETSC #ifdef TEST_MEM_PETSC @@ -106,7 +106,7 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x) PetscPrintf(PETSC_COMM_WORLD, "###Memory usage by solver. Before :%f After:%f Increase:%d\n", mem1, mem2, (int)(mem2 - mem1)); #endif - _elapsed_ctime += ctimer.elapsed(); + _elapsed_ctime += wtimer.elapsed(); return converged; } diff --git a/MathLib/LinAlg/PETSc/PETScLinearSolver.h b/MathLib/LinAlg/PETSc/PETScLinearSolver.h index d65efa4191189671f4cc27a1525b8e786b7c294c..c908e914c93ecc7ea8af3fddaa2d4b3c0c5ec476 100644 --- a/MathLib/LinAlg/PETSc/PETScLinearSolver.h +++ b/MathLib/LinAlg/PETSc/PETScLinearSolver.h @@ -68,7 +68,7 @@ class PETScLinearSolver } /// Get elapsed wall clock time. - PetscLogDouble getElapsedTime() const + double getElapsedTime() const { return _elapsed_ctime; } @@ -81,7 +81,7 @@ class PETScLinearSolver KSP _solver; ///< Solver type. PC _pc; ///< Preconditioner type. - PetscLogDouble _elapsed_ctime; ///< Clock time + double _elapsed_ctime; ///< Clock time }; } // end namespace diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index ead7273033c90703b9b6fa6546e6bc08719092f9..9a68e213ed6e8cc884a672fa090bce9cbeb29a6f 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -116,6 +116,14 @@ IF(OGS_USE_LIS) FIND_PACKAGE( LIS REQUIRED ) ENDIF() +## Check MPI package +IF(OGS_USE_PETSC OR OGS_USE_MPI) + FIND_PACKAGE(MPI) + IF(NOT MPI_FOUND) + MESSAGE(FATAL_ERROR "MPI is required but was not found!") + ENDIF() +ENDIF() + IF(OGS_USE_PETSC) MESSAGE (STATUS "Configuring for PETSc" ) @@ -133,7 +141,6 @@ IF(OGS_USE_PETSC) include_directories( ${PETSC_INCLUDES} ) - FIND_PACKAGE(MPI REQUIRED) IF(WIN32) ADD_DEFINITIONS(/DPETSC_VERSION_NUMBER=PETSC_VERSION_MAJOR*1000+PETSC_VERSION_MINOR*10) @@ -144,6 +151,5 @@ IF(OGS_USE_PETSC) ENDIF() IF(OGS_USE_MPI) - FIND_PACKAGE( MPI REQUIRED ) INCLUDE_DIRECTORIES(SYSTEM ${MPI_CXX_INCLUDE_PATH}) ENDIF()