Skip to content
Snippets Groups Projects
Commit c2470b09 authored by wenqing's avatar wenqing
Browse files

Added PETScWallClockTimer

parent 42b38d1b
No related branches found
No related tags found
No related merge requests found
/*!
\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) 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
{
/// Record 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(&current_time);
#else
PetscGetTime(&current_time);
#endif
return current_time - _start_time;
}
private:
/// Start time.
PetscLogDouble _start_time = 0.;
};
} // end namespace BaseLib
#endif
...@@ -64,6 +64,8 @@ OPTION(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF) ...@@ -64,6 +64,8 @@ OPTION(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF)
# Linear solvers # Linear solvers
OPTION(OGS_USE_LIS "Use Lis" OFF) OPTION(OGS_USE_LIS "Use Lis" OFF)
# Parallel computing
OPTION(OGS_USE_PETSC "Use PETSc routines" OFF) OPTION(OGS_USE_PETSC "Use PETSc routines" OFF)
# Paralleization # Paralleization
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "PETScMatrix.h" #include "PETScMatrix.h"
#include "PETScVector.h" #include "PETScVector.h"
#include "BaseLib/PETScWallClockTimer.h"
namespace MathLib namespace MathLib
{ {
......
...@@ -134,6 +134,14 @@ IF(OGS_USE_PETSC) ...@@ -134,6 +134,14 @@ IF(OGS_USE_PETSC)
include_directories( include_directories(
${PETSC_INCLUDES} ${PETSC_INCLUDES}
) )
FIND_PACKAGE(MPI REQUIRED)
IF(WIN32)
ADD_DEFINITIONS(/DPETSC_VERSION_NUMBER=PETSC_VERSION_MAJOR*1000+PETSC_VERSION_MINOR*10)
ELSE()
ADD_DEFINITIONS(-DPETSC_VERSION_NUMBER=PETSC_VERSION_MAJOR*1000+PETSC_VERSION_MINOR*10)
ENDIF()
ENDIF() ENDIF()
IF(OGS_USE_MPI) IF(OGS_USE_MPI)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment