diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cef8aaf..f8889033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,19 +81,7 @@ macro (sources_hook) ${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverIstl.cpp ) endif (NOT dune-istl_FOUND) - if (NOT SuiteSparse_FOUND) - list (REMOVE_ITEM opm-core_SOURCES - ${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_umfpack.c - ${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverUmfpack.cpp - ) - endif (NOT SuiteSparse_FOUND) - if (NOT PETSC_FOUND) - list (REMOVE_ITEM opm-core_SOURCES - ${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_petsc.c - ${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverPetsc.cpp - ) - endif (NOT PETSC_FOUND) if ((NOT MPI_FOUND) OR (NOT DUNE_ISTL_FOUND)) list (REMOVE_ITEM tests_SOURCES ${PROJECT_SOURCE_DIR}/tests/test_parallel_linearsolver.cpp diff --git a/examples/compute_eikonal_from_files.cpp b/examples/compute_eikonal_from_files.cpp index edecd251..8e054614 100644 --- a/examples/compute_eikonal_from_files.cpp +++ b/examples/compute_eikonal_from_files.cpp @@ -19,7 +19,7 @@ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/examples/compute_initial_state.cpp b/examples/compute_initial_state.cpp index 33c6f4a4..a2bae934 100644 --- a/examples/compute_initial_state.cpp +++ b/examples/compute_initial_state.cpp @@ -19,7 +19,7 @@ */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index b43452cc..f27d4fdb 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -19,7 +19,7 @@ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/examples/compute_tof_from_files.cpp b/examples/compute_tof_from_files.cpp index 2ca476e9..d35a50b8 100644 --- a/examples/compute_tof_from_files.cpp +++ b/examples/compute_tof_from_files.cpp @@ -18,7 +18,7 @@ */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 07aec746..7e7118e1 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -19,7 +19,7 @@ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index 5d71d720..b0890e59 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -17,7 +17,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/opm/core/linalg/LinearSolverIstl.cpp b/opm/core/linalg/LinearSolverIstl.cpp index 82ba1345..1ec4a161 100644 --- a/opm/core/linalg/LinearSolverIstl.cpp +++ b/opm/core/linalg/LinearSolverIstl.cpp @@ -18,7 +18,7 @@ */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/opm/core/linalg/LinearSolverPetsc.cpp b/opm/core/linalg/LinearSolverPetsc.cpp index 57823aad..89521aff 100644 --- a/opm/core/linalg/LinearSolverPetsc.cpp +++ b/opm/core/linalg/LinearSolverPetsc.cpp @@ -19,6 +19,9 @@ */ #include "config.h" + +#if HAVE_PETSC + #include #include #include @@ -287,3 +290,4 @@ namespace{ } // namespace Opm +#endif // HAVE_PETSC diff --git a/opm/core/linalg/LinearSolverPetsc.hpp b/opm/core/linalg/LinearSolverPetsc.hpp index c5ba9a50..e8b9931c 100644 --- a/opm/core/linalg/LinearSolverPetsc.hpp +++ b/opm/core/linalg/LinearSolverPetsc.hpp @@ -20,6 +20,11 @@ #ifndef OPM_LINEARSOLVERPETSC_HEADER_INCLUDED #define OPM_LINEARSOLVERPETSC_HEADER_INCLUDED + +#if !HAVE_PETSC +#error "LinearSolverPetsc.hpp included, but the PETSc libraries are not available!" +#endif + #include #include #include diff --git a/opm/core/linalg/call_umfpack.c b/opm/core/linalg/call_umfpack.c index 9f721141..f8b926e6 100644 --- a/opm/core/linalg/call_umfpack.c +++ b/opm/core/linalg/call_umfpack.c @@ -34,6 +34,8 @@ */ #include "config.h" + +#if HAVE_UMFPACK #include #include @@ -183,3 +185,15 @@ call_UMFPACK(struct CSRMatrix *A, const double *b, double *x) csc_deallocate(csc); } +#else +#include +#include + +void +call_UMFPACK(struct CSRMatrix *A, const double *b, double *x) +{ + /* UMFPACK is not available */ + abort(); +} + +#endif diff --git a/opm/core/simulator/SimulatorState.cpp b/opm/core/simulator/SimulatorState.cpp deleted file mode 100644 index 180dc141..00000000 --- a/opm/core/simulator/SimulatorState.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -using namespace Opm; - -bool -SimulatorState::equals (const SimulatorState& other, - double epsilon) const { - bool equal = (num_phases_ == other.num_phases_); - - // if we use &=, then all the tests will be run regardless - equal = equal && cmp::vector_equal( pressure() , other.pressure() , cmp::default_abs_epsilon , epsilon); - equal = equal && cmp::vector_equal( temperature() , other.temperature() , cmp::default_abs_epsilon , epsilon); - equal = equal && cmp::vector_equal( facepressure() , other.facepressure() , cmp::default_abs_epsilon , epsilon); - equal = equal && cmp::vector_equal( faceflux() , other.faceflux() , cmp::default_abs_epsilon , epsilon); - equal = equal && cmp::vector_equal( saturation() , other.saturation() , cmp::default_abs_epsilon , epsilon); - - return equal; -} - - - -void -SimulatorState::init(int number_of_cells, int number_of_faces, int num_phases) -{ - num_cells_ = number_of_cells; - num_faces_ = number_of_faces; - num_phases_ = num_phases; - - // clear memory - cellData_ = std::vector< std::vector > (); - faceData_ = std::vector< std::vector > (); - - int id; - id = registerCellData("PRESSURE", 1, 0.0 ); - if( id != pressureId_ ) - OPM_THROW(std::logic_error,"ids in SimulatorState do not match"); - assert( pressureId_ == id ); - id = registerCellData("TEMPERATURE", 1, 273.15 + 20 ); - assert( temperatureId_ == id ); - id = registerCellData("SATURATION", num_phases_, 0.0 ); - assert( saturationId_ == id ); - - for (int cell = 0; cell < number_of_cells; ++cell) { - // Defaulting the second saturation to 1.0. - // This will usually be oil in a water-oil case, - // gas in an oil-gas case. - // For proper initialization, one should not rely on this, - // but use available phase information instead. - saturation()[num_phases_*cell + 1] = 1.0; - } - - id = registerFaceData("FACEPRESSURE", 1, 0.0 ); - assert( facePressureId_ == id ); - id = registerFaceData("FACEFLUX", 1, 0.0 ); - assert( faceFluxId_ == id ); -} - -size_t -SimulatorState::registerCellData( const std::string& name, const int components, const double initialValue ) -{ - // check if init has been called - const size_t pos = cellData_.size(); - cellDataNames_.emplace_back( name ); - cellData_.emplace_back( num_cells_ * components, initialValue ); - return pos; -} - -size_t -SimulatorState::registerFaceData( const std::string& name, const int components, const double initialValue ) -{ - // check if init has been called - const size_t pos = faceData_.size(); - faceDataNames_.emplace_back( name ); - faceData_.emplace_back( num_faces_ * components, initialValue ); - return pos ; -} - -void SimulatorState::setCellDataComponent( const std::string& name , size_t component , const std::vector& cells , const std::vector& values) { - const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name); - int id = iter - cellDataNames_.begin(); - auto& data = cellData_[id]; - if (component >= size_t(num_phases_)) - throw std::invalid_argument("Invalid component"); - - if (cells.size() != values.size()) - throw std::invalid_argument("size mismatch between cells and values"); - - /* This is currently quite broken; the setCellDataComponent - method assumes that the number of components in the field - we are currently focusing on has num_phases components in - total. This restriction should be lifted by allowing a per - field number of components. - */ - if (data.size() != size_t(num_phases_ * num_cells_)) - throw std::invalid_argument("Can currently only be used on fields with num_components == num_phases (i.e. saturation...) "); - - for (size_t i = 0; i < cells.size(); i++) { - if (cells[i] < num_cells_) { - auto field_index = cells[i] * num_phases_ + component; - auto value = values[i]; - - data[field_index] = value; - } else { - throw std::invalid_argument("Invalid cell number"); - } - } -} - - -std::vector& SimulatorState::getCellData( const std::string& name ) { - const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name); - int id = iter - cellDataNames_.begin(); - auto& data = cellData_[id]; - return data; -} - - -const std::vector& SimulatorState::getCellData( const std::string& name ) const { - const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name); - int id = iter - cellDataNames_.begin(); - const auto& data = cellData_[id]; - return data; -} - diff --git a/opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp b/opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp index e8c1af72..84cb6943 100644 --- a/opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp +++ b/opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp @@ -26,7 +26,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H diff --git a/travis/build-and-test-opm-core.sh b/travis/build-and-test-opm-core.sh deleted file mode 100755 index 2810c7d4..00000000 --- a/travis/build-and-test-opm-core.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -e - -pushd . > /dev/null -opm-core/travis/build-opm-core.sh -cd opm-core/build -ctest --output-on-failure -popd > /dev/null diff --git a/travis/build-opm-core.sh b/travis/build-opm-core.sh deleted file mode 100755 index fad3f8ed..00000000 --- a/travis/build-opm-core.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -e - -pushd . > /dev/null -cd opm-core -mkdir build -cd build -cmake -D SUPERLU_ROOT=../../SuperLU ../ -make -popd > /dev/null diff --git a/travis/clone-and-build-dune-istl.sh b/travis/clone-and-build-dune-istl.sh deleted file mode 100755 index 2ca08304..00000000 --- a/travis/clone-and-build-dune-istl.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -e - -pushd . > /dev/null -git clone https://github.com/dune-project/dune-istl.git -cd dune-istl -git checkout tags/v2.3.1 -mkdir build -cd build -cmake ../ -make -popd > /dev/null diff --git a/travis/clone-and-build-superlu.sh b/travis/clone-and-build-superlu.sh deleted file mode 100755 index 77affea7..00000000 --- a/travis/clone-and-build-superlu.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -pushd . > /dev/null -git clone https://github.com/starseeker/SuperLU.git -cd SuperLU -mkdir build -cd build -cmake -D CMAKE_INSTALL_PREFIX=.. -D SUPERLU_BUILD_EXAMPLES=OFF -D SUPERLU_ENABLE_TESTING=OFF ../ -make install -popd > /dev/null