From 9796066199637668d197b4ac38560465417f7b8c Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 12 Oct 2017 17:27:45 +0200 Subject: [PATCH 1/6] remove bit-rotten SimulatorState.cpp file the corresponding header file is MIA. --- opm/core/simulator/SimulatorState.cpp | 130 -------------------------- 1 file changed, 130 deletions(-) delete mode 100644 opm/core/simulator/SimulatorState.cpp 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; -} - From fbec8c2300adf6d1b56c7a12b945cd622f36d00a Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 12 Oct 2017 17:27:46 +0200 Subject: [PATCH 2/6] make the PETSc code compile even if PETSc is not available if PETSc is not available, the .cpp file will compile fine because it will be reduced to be empty, but trying to include LinearSolverPetsc.hpp in this case will result in an error. --- opm/core/linalg/LinearSolverPetsc.cpp | 4 ++++ opm/core/linalg/LinearSolverPetsc.hpp | 5 +++++ 2 files changed, 9 insertions(+) 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 From 634a7bef4229fac13cdcd972570e1913ed2c7463 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 23 Nov 2017 00:04:17 +0100 Subject: [PATCH 3/6] make call_umfpack.c compile even if UMFPACK is not available That said, don't try to call any of its functions or you'll regret it at runtime! --- opm/core/linalg/call_umfpack.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 From 204ef58bb6cbf75bb7353bff0f97dbc3231c217d Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 12 Oct 2017 17:27:46 +0200 Subject: [PATCH 4/6] replace #if HAVE_CONFIG_H by #ifdef HAVE_CONFIG_H it seems like most build systems pass a -DHAVE_CONFIG_H flag to the compiler which still causes `#if HAVE_CONFIG_H` to be false while it clearly is supposed to be triggered. That said, I do not really see a good reason why the inclusion of the `config.h` file should be guarded in the first place: the file is guaranteed to always available by proper build systems, and if it was not included the build either breaks at the linking stage or -- at the very least -- the runtime behavior of the resulting libraries will be very awkward. --- examples/compute_eikonal_from_files.cpp | 2 +- examples/compute_initial_state.cpp | 2 +- examples/compute_tof.cpp | 2 +- examples/compute_tof_from_files.cpp | 2 +- examples/diagnose_relperm.cpp | 2 +- opm/core/linalg/LinearSolverFactory.cpp | 2 +- opm/core/linalg/LinearSolverIstl.cpp | 2 +- opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) 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/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 From a1543115aad1eea076623169cb53425b12bcf842 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 13 Oct 2017 16:36:22 +0200 Subject: [PATCH 5/6] remove unused travis files these have not been used for a while. .travis.yml and the files in opm-common/travis/ are in charge --- travis/build-and-test-opm-core.sh | 8 -------- travis/build-opm-core.sh | 10 ---------- travis/clone-and-build-dune-istl.sh | 12 ------------ travis/clone-and-build-superlu.sh | 11 ----------- 4 files changed, 41 deletions(-) delete mode 100755 travis/build-and-test-opm-core.sh delete mode 100755 travis/build-opm-core.sh delete mode 100755 travis/clone-and-build-dune-istl.sh delete mode 100755 travis/clone-and-build-superlu.sh 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 From 8d98d76c17f52a4f942a71bf7968ce2d0309cb7c Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 14 Dec 2017 12:17:59 +0100 Subject: [PATCH 6/6] do not conditionally remove the PETSc and UMFPack source files from the list anymore these files should now compile even if the corresponding libraries are not available. --- CMakeLists.txt | 12 ------------ 1 file changed, 12 deletions(-) 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