Add HAVE_PETSC macro.

This commit is contained in:
Liu Ming 2014-07-08 10:58:39 +08:00
parent 399a8f6884
commit d8962ff1ce
3 changed files with 15 additions and 5 deletions

View File

@ -31,7 +31,10 @@
#include <opm/core/linalg/LinearSolverIstl.hpp> #include <opm/core/linalg/LinearSolverIstl.hpp>
#endif #endif
#if HAVE_PETSC
#include <opm/core/linalg/LinearSolverPetsc.hpp> #include <opm/core/linalg/LinearSolverPetsc.hpp>
#endif
#include <opm/core/utility/parameters/ParameterGroup.hpp> #include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/core/utility/ErrorMacros.hpp> #include <opm/core/utility/ErrorMacros.hpp>
#include <string> #include <string>
@ -46,9 +49,9 @@ namespace Opm
solver_.reset(new LinearSolverUmfpack); solver_.reset(new LinearSolverUmfpack);
#elif HAVE_DUNE_ISTL #elif HAVE_DUNE_ISTL
solver_.reset(new LinearSolverIstl); solver_.reset(new LinearSolverIstl);
#else #elif HAVE_PETSC
solver_.reset(new LinearSolverPetsc); solver_.reset(new LinearSolverPetsc);
#else
OPM_THROW(std::runtime_error, "No linear solver available, you must have UMFPACK , dune-istl or Petsc installed to use LinearSolverFactory."); OPM_THROW(std::runtime_error, "No linear solver available, you must have UMFPACK , dune-istl or Petsc installed to use LinearSolverFactory.");
#endif #endif
} }
@ -73,7 +76,9 @@ namespace Opm
#endif #endif
} }
else if (ls == "petsc"){ else if (ls == "petsc"){
#if HAVE_PETSC
solver_.reset(new LinearSolverPetsc(param)); solver_.reset(new LinearSolverPetsc(param));
#endif
} }
else { else {

View File

@ -42,16 +42,19 @@ namespace Opm
/// Construct from parameters. /// Construct from parameters.
/// The accepted parameters are (default) (allowed values): /// The accepted parameters are (default) (allowed values):
/// linsolver ("umfpack") ("umfpack", "istl") /// linsolver ("umfpack") ("umfpack", "istl", "petsc")
/// For the umfpack solver to be available, this class must be /// For the umfpack solver to be available, this class must be
/// compiled with UMFPACK support, as indicated by the /// compiled with UMFPACK support, as indicated by the
/// variable HAVE_SUITESPARSE_UMFPACK_H in config.h. /// variable HAVE_SUITESPARSE_UMFPACK_H in config.h.
/// For the istl solver to be available, this class must be /// For the istl solver to be available, this class must be
/// compiled with dune-istl support, as indicated by the /// compiled with dune-istl support, as indicated by the
/// variable HAVE_DUNE_ISTL in config.h. /// variable HAVE_DUNE_ISTL in config.h.
/// For the petsc solver to be available, this class must be
/// compiled with petsc support, as indicated by the
/// variable HAVE_PETSC in config.h.
/// Any further parameters are passed on to the constructors /// Any further parameters are passed on to the constructors
/// of the actual solver used, see LinearSolverUmfpack /// of the actual solver used, see LinearSolverUmfpack,
/// and LinearSolverIstl for details. /// LinearSolverIstl and LinearSolverPetsc for details.
LinearSolverFactory(const parameter::ParameterGroup& param); LinearSolverFactory(const parameter::ParameterGroup& param);
/// Destructor. /// Destructor.

View File

@ -185,6 +185,7 @@ BOOST_AUTO_TEST_CASE(KAMGTest)
#endif #endif
#endif #endif
#if HAVE_PETSC
BOOST_AUTO_TEST_CASE(PETScTest) BOOST_AUTO_TEST_CASE(PETScTest)
{ {
Opm::parameter::ParameterGroup param; Opm::parameter::ParameterGroup param;
@ -195,3 +196,4 @@ BOOST_AUTO_TEST_CASE(PETScTest)
param.insertParameter(std::string("ksp_view"), std::string("0")); param.insertParameter(std::string("ksp_view"), std::string("0"));
run_test(param); run_test(param);
} }
#endif