diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index 034123a2..0e22910b 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -31,7 +31,10 @@ #include #endif +#if HAVE_PETSC #include +#endif + #include #include #include @@ -46,9 +49,9 @@ namespace Opm solver_.reset(new LinearSolverUmfpack); #elif HAVE_DUNE_ISTL solver_.reset(new LinearSolverIstl); -#else +#elif HAVE_PETSC 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."); #endif } @@ -73,7 +76,9 @@ namespace Opm #endif } else if (ls == "petsc"){ +#if HAVE_PETSC solver_.reset(new LinearSolverPetsc(param)); +#endif } else { diff --git a/opm/core/linalg/LinearSolverFactory.hpp b/opm/core/linalg/LinearSolverFactory.hpp index f27140bc..92f70c33 100644 --- a/opm/core/linalg/LinearSolverFactory.hpp +++ b/opm/core/linalg/LinearSolverFactory.hpp @@ -42,16 +42,19 @@ namespace Opm /// Construct from parameters. /// 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 /// compiled with UMFPACK support, as indicated by the /// variable HAVE_SUITESPARSE_UMFPACK_H in config.h. /// For the istl solver to be available, this class must be /// compiled with dune-istl support, as indicated by the /// 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 - /// of the actual solver used, see LinearSolverUmfpack - /// and LinearSolverIstl for details. + /// of the actual solver used, see LinearSolverUmfpack, + /// LinearSolverIstl and LinearSolverPetsc for details. LinearSolverFactory(const parameter::ParameterGroup& param); /// Destructor. diff --git a/tests/test_linearsolver.cpp b/tests/test_linearsolver.cpp index 2143fe00..6021218e 100644 --- a/tests/test_linearsolver.cpp +++ b/tests/test_linearsolver.cpp @@ -185,6 +185,7 @@ BOOST_AUTO_TEST_CASE(KAMGTest) #endif #endif +#if HAVE_PETSC BOOST_AUTO_TEST_CASE(PETScTest) { Opm::parameter::ParameterGroup param; @@ -195,3 +196,4 @@ BOOST_AUTO_TEST_CASE(PETScTest) param.insertParameter(std::string("ksp_view"), std::string("0")); run_test(param); } +#endif