From a5f8e7958b63749b19cacb04a36add797040d539 Mon Sep 17 00:00:00 2001 From: Bernd Flemisch <bernd@iws.uni-stuttgart.de> Date: Fri, 15 Jun 2018 11:15:54 +0200 Subject: [PATCH] [cornerpoint] update CpGridCreator to Opm 2018.04 It is not possible to ask for the employed Opm version in a convenient way. Therefore, support for older versions has to be dropped. Adapt an include. Get rid of the `TypeTag` template parameter. Perform `loadBlance` only in a parallel run. Otherwise, the boundary segment indices are lost. Add a small workaround for the `static Deck` to prevent segfaults. Provide a patch for opm-grid, delete patches for older versions. Update `patches/README`. --- dumux/io/cpgridcreator.hh | 21 ++--- patches/README | 13 +-- patches/opm-common-2017.04.patch | 15 ---- patches/opm-common-2017.10.patch | 15 ---- patches/opm-core-2017.04.patch | 49 ------------ patches/opm-grid-2017.04.patch | 132 ------------------------------- patches/opm-grid-2018.04.patch | 10 +++ patches/opm-parser-2017.04.patch | 45 ----------- patches/opm-parser-2017.10.patch | 20 ----- 9 files changed, 21 insertions(+), 299 deletions(-) delete mode 100644 patches/opm-common-2017.04.patch delete mode 100644 patches/opm-common-2017.10.patch delete mode 100644 patches/opm-core-2017.04.patch delete mode 100644 patches/opm-grid-2017.04.patch create mode 100644 patches/opm-grid-2018.04.patch delete mode 100644 patches/opm-parser-2017.04.patch delete mode 100644 patches/opm-parser-2017.10.patch diff --git a/dumux/io/cpgridcreator.hh b/dumux/io/cpgridcreator.hh index 9cec6ee56d..8f1e27ef69 100644 --- a/dumux/io/cpgridcreator.hh +++ b/dumux/io/cpgridcreator.hh @@ -25,32 +25,23 @@ #define DUMUX_CPGRID_CREATOR_HH #if HAVE_OPM_GRID -#include <dune/grid/CpGrid.hpp> +#include <opm/grid/CpGrid.hpp> #include <opm/parser/eclipse/Parser/Parser.hpp> #include <opm/parser/eclipse/Parser/ParseContext.hpp> #include <opm/parser/eclipse/Deck/Deck.hpp> -#include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> namespace Dumux { -namespace Properties -{ -NEW_PROP_TAG(Scalar); -NEW_PROP_TAG(Grid); -} - /*! * \ingroup InputOutput * \brief A grid creator that reads Petrel files and generates a CpGrid. */ -template <class TypeTag> class CpGridCreator { - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using Grid = typename GET_PROP_TYPE(TypeTag, Grid); + using Grid = Dune::CpGrid; using GridPointer = std::shared_ptr<Grid>; using Deck = Opm::Deck; @@ -62,8 +53,9 @@ public: { auto fileName = getParam<std::string>("Grid.File"); - deck() = Opm::Parser().parseFile(fileName); - Opm::EclipseGrid ecl_grid(deck()); + static auto deckLocal = Opm::Parser().parseFile(fileName); + Opm::EclipseGrid ecl_grid(deckLocal); + deck() = deckLocal; gridPtr() = std::make_shared<Grid>(*(new Grid())); gridPtr()->processEclipseFormat(ecl_grid, false, false); @@ -102,7 +94,8 @@ public: */ static void loadBalance() { - gridPtr()->loadBalance(); + if (gridPtr()->comm().size() > 1) + gridPtr()->loadBalance(); } }; } diff --git a/patches/README b/patches/README index 9ea8dad5fe..cc8f37bd91 100644 --- a/patches/README +++ b/patches/README @@ -5,14 +5,9 @@ patch -p1 <../dumux/patches/istl-2.4.1.patch - If opm-grid has to be used for, e.g., employing the CpGridCreator, - and Opm is compiled from source, it might be necessary to patch opm-parser and opm-common: - patch -p1 <../dumux/patches/opm-parser-2017.10.patch - patch -p1 <../dumux/patches/opm-common-2017.10.patch - In addition, it might be necessary to set manually some CMake variables in the + and Opm is compiled from source, it is necessary to patch opm-grid: + patch -p1 <../dumux/patches/opm-grid-2018.04.patch + In addition, it might be necessary to set manually a CMake variable in the CMAKE_FLAGS section of the .opts-file: - -DOPM_COMMON_ROOT=/path/to/opm-common/ \ - -Dopm-grid_PREFIX=/path/to/opm-grid \ - -Dopm-common_PREFIX=/path/to/opm-common \ - -Dopm-parser_PREFIX=/path/to/opm-parser \ -DHAVE_OPM_GRID=1 \ - Currently, Dumux is supposed to be compatible with the Opm 2017.04 and 2017.10 releases. + Currently, Dumux is supposed to be compatible with the Opm 2018.04 release. diff --git a/patches/opm-common-2017.04.patch b/patches/opm-common-2017.04.patch deleted file mode 100644 index 8d684466e1..0000000000 --- a/patches/opm-common-2017.04.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake -index a0b0b08..eb142dd 100644 ---- a/cmake/Modules/Findopm-parser.cmake -+++ b/cmake/Modules/Findopm-parser.cmake -@@ -38,8 +38,8 @@ string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PR - # or in relative directories to this one - if (OPM_PARSER_ROOT) - set (_no_default_path "NO_DEFAULT_PATH") -- set (_opm_parser_source "") -- set (_opm_parser_build "") -+ set (_opm_parser_source "${OPM_PARSER_ROOT}") -+ set (_opm_parser_build "${OPM_PARSER_ROOT}/${BUILD_DIR_SUFFIX}") - else () - set (_no_default_path "") - set (_opm_parser_source diff --git a/patches/opm-common-2017.10.patch b/patches/opm-common-2017.10.patch deleted file mode 100644 index 0fc80ce2fb..0000000000 --- a/patches/opm-common-2017.10.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake -index 42b5ae9..2977ee9 100644 ---- a/cmake/Modules/Findopm-parser.cmake -+++ b/cmake/Modules/Findopm-parser.cmake -@@ -31,8 +31,8 @@ string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PR - # or in relative directories to this one - if (OPM_PARSER_ROOT) - set (_no_default_path "NO_DEFAULT_PATH") -- set (_opm_parser_source "") -- set (_opm_parser_build "") -+ set (_opm_parser_source "${OPM_PARSER_ROOT}") -+ set (_opm_parser_build "${OPM_PARSER_ROOT}/${BUILD_DIR_SUFFIX}") - else () - set (_no_default_path "") - set (_opm_parser_source diff --git a/patches/opm-core-2017.04.patch b/patches/opm-core-2017.04.patch deleted file mode 100644 index 103d09da17..0000000000 --- a/patches/opm-core-2017.04.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake -index fbbdaf05..34cdc425 100644 ---- a/CMakeLists_files.cmake -+++ b/CMakeLists_files.cmake -@@ -36,7 +36,7 @@ list (APPEND MAIN_SOURCE_FILES - opm/core/flowdiagnostics/TofReorder.cpp - opm/core/linalg/LinearSolverFactory.cpp - opm/core/linalg/LinearSolverInterface.cpp -- opm/core/linalg/LinearSolverIstl.cpp -+# opm/core/linalg/LinearSolverIstl.cpp - opm/core/linalg/LinearSolverPetsc.cpp - opm/core/linalg/LinearSolverUmfpack.cpp - opm/core/linalg/call_umfpack.c -@@ -133,12 +133,12 @@ list (APPEND TEST_SOURCE_FILES - tests/test_nonuniformtablelinear.cpp - tests/test_parallelistlinformation.cpp - tests/test_sparsevector.cpp -- tests/test_velocityinterpolation.cpp -+ tests/test_velocityinterpolation.cpp - tests/test_uniformtablelinear.cpp - tests/test_wells.cpp - tests/test_wachspresscoord.cpp -- tests/test_linearsolver.cpp -- tests/test_parallel_linearsolver.cpp -+# tests/test_linearsolver.cpp -+# tests/test_parallel_linearsolver.cpp - tests/test_param.cpp - tests/test_satfunc.cpp - tests/test_shadow.cpp -@@ -153,7 +153,7 @@ list (APPEND TEST_SOURCE_FILES - tests/test_anisotropiceikonal.cpp - tests/test_stoppedwells.cpp - tests/test_relpermdiagnostics.cpp -- tests/test_norne_pvt.cpp -+ tests/test_norne_pvt.cpp - ) - - # originally generated with the command: -@@ -194,8 +194,8 @@ list (APPEND TEST_DATA_FILES - list (APPEND EXAMPLE_SOURCE_FILES - examples/compute_eikonal_from_files.cpp - examples/compute_initial_state.cpp -- examples/compute_tof.cpp -- examples/compute_tof_from_files.cpp -+# examples/compute_tof.cpp -+# examples/compute_tof_from_files.cpp - examples/diagnose_relperm.cpp - tutorials/tutorial1.cpp - tutorials/tutorial2.cpp diff --git a/patches/opm-grid-2017.04.patch b/patches/opm-grid-2017.04.patch deleted file mode 100644 index f0a83a2bec..0000000000 --- a/patches/opm-grid-2017.04.patch +++ /dev/null @@ -1,132 +0,0 @@ -diff --git a/dune/grid/cpgrid/Entity.hpp b/dune/grid/cpgrid/Entity.hpp -index eadcb33..0efcedd 100644 ---- a/dune/grid/cpgrid/Entity.hpp -+++ b/dune/grid/cpgrid/Entity.hpp -@@ -148,7 +148,7 @@ namespace Dune - } - - /// Returns the geometry of the entity (does not depend on its orientation). -- const Geometry& geometry() const; -+ Geometry geometry() const; - - /// We do not support refinement, so level() is always 0. - int level() const -@@ -182,7 +182,7 @@ namespace Dune - /// The count of subentities of codimension cc - unsigned int subEntities ( const unsigned int cc ) const - { -- static_assert(codim == 0, ""); -+// static_assert(codim == 0, ""); - if (cc == 0) { - return 1; - } else if (cc == 3) { -@@ -412,7 +412,7 @@ namespace Dune { - namespace cpgrid { - - template <int codim> --const typename Entity<codim>::Geometry& Entity<codim>::geometry() const -+typename Entity<codim>::Geometry Entity<codim>::geometry() const - { - return pgrid_->geomVector<codim>()[*this]; - } -diff --git a/dune/grid/cpgrid/Geometry.hpp b/dune/grid/cpgrid/Geometry.hpp -index 86d82a5..10c7e14 100644 ---- a/dune/grid/cpgrid/Geometry.hpp -+++ b/dune/grid/cpgrid/Geometry.hpp -@@ -41,8 +41,13 @@ - - #include <dune/common/version.hh> - #include <dune/geometry/referenceelements.hh> -+ -+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 5 ) -+#include <dune/geometry/type.hh> -+#else - #include <dune/geometry/genericgeometry/geometrytraits.hh> - #include <dune/geometry/genericgeometry/matrixhelper.hh> -+#endif - - #include <opm/common/utility/platform_dependent/reenable_warnings.h> - -@@ -99,6 +104,12 @@ namespace Dune - /// Type of the inverse of the transposed Jacobian matrix - typedef FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed; - -+#if DUNE_VERSION_NEWER(DUNE_GRID,2,5) -+ typedef Dune::Impl::FieldMatrixHelper< double > MatrixHelperType; -+#else -+ typedef Dune::GenericGeometry::MatrixHelper< Dune::GenericGeometry::DuneCoordTraits<double> > MatrixHelperType; -+#endif -+ - /// @brief Construct from centroid, volume (1- and 0-moments) and - /// corners. - /// @param pos the centroid of the entity -@@ -189,12 +200,11 @@ namespace Dune - LocalCoordinate x = refElement.position(0,0); - LocalCoordinate dx; - do { -- using namespace GenericGeometry; - // DF^n dx^n = F^n, x^{n+1} -= dx^n - JacobianTransposed JT = jacobianTransposed(x); - GlobalCoordinate z = global(x); - z -= y; -- MatrixHelper<DuneCoordTraits<double> >::template xTRightInvA<3, 3>(JT, z, dx ); -+ MatrixHelperType::template xTRightInvA<3, 3>(JT, z, dx ); - x -= dx; - } while (dx.two_norm2() > epsilon*epsilon); - return x; -@@ -206,9 +216,8 @@ namespace Dune - /// and {u_j} are the reference coordinates. - double integrationElement(const LocalCoordinate& local_coord) const - { -- FieldMatrix<ctype, coorddimension, mydimension> Jt = jacobianTransposed(local_coord); -- using namespace GenericGeometry; -- return MatrixHelper<DuneCoordTraits<double> >::template sqrtDetAAT<3, 3>(Jt); -+ JacobianTransposed Jt = jacobianTransposed(local_coord); -+ return MatrixHelperType::template sqrtDetAAT<3, 3>(Jt); - } - - /// Using the cube type for all entities now (cells and vertices), -diff --git a/dune/grid/cpgrid/Intersection.hpp b/dune/grid/cpgrid/Intersection.hpp -index f7152ef..cf01473 100644 ---- a/dune/grid/cpgrid/Intersection.hpp -+++ b/dune/grid/cpgrid/Intersection.hpp -@@ -188,7 +188,7 @@ namespace Dune - /// @brief - /// @todo Doc me! - /// @return -- const Geometry& geometry() const -+ Geometry geometry() const - { - return global_geom_; - } -diff --git a/dune/grid/polyhedralgrid/geometry.hh b/dune/grid/polyhedralgrid/geometry.hh -index 64a15fc..9c3c0b4 100644 ---- a/dune/grid/polyhedralgrid/geometry.hh -+++ b/dune/grid/polyhedralgrid/geometry.hh -@@ -42,6 +42,12 @@ namespace Dune - typedef typename Grid::Traits::ExtraData ExtraData; - typedef typename Grid::Traits::template Codim<codimension>::EntitySeed EntitySeed; - -+#if DUNE_VERSION_NEWER(DUNE_GRID,2,5) -+ typedef Dune::Impl::FieldMatrixHelper< double > MatrixHelperType; -+#else -+ typedef Dune::GenericGeometry::MatrixHelper< Dune::GenericGeometry::DuneCoordTraits<double> > MatrixHelperType; -+#endif -+ - explicit PolyhedralGridBasicGeometry ( ExtraData data ) - : data_( data ), - seed_( ) -@@ -136,12 +142,11 @@ namespace Dune - LocalCoordinate x = refElement.position(0,0); - LocalCoordinate dx; - do { -- using namespace GenericGeometry; - // DF^n dx^n = F^n, x^{n+1} -= dx^n - JacobianTransposed JT = jacobianTransposed(x); - GlobalCoordinate z = global(x); - z -= y; -- MatrixHelper<DuneCoordTraits<double> >::template xTRightInvA<mydimension,coorddimension>(JT, z, dx ); -+ MatrixHelperType::template xTRightInvA<mydimension,coorddimension>(JT, z, dx ); - x -= dx; - } while (dx.two_norm2() > epsilon*epsilon); - return x; diff --git a/patches/opm-grid-2018.04.patch b/patches/opm-grid-2018.04.patch new file mode 100644 index 0000000000..a2ab10147c --- /dev/null +++ b/patches/opm-grid-2018.04.patch @@ -0,0 +1,10 @@ +diff --git a/opm-grid-prereqs.cmake b/opm-grid-prereqs.cmake +index 2ad0d86..032ac19 100644 +--- a/opm-grid-prereqs.cmake ++++ b/opm-grid-prereqs.cmake +@@ -34,4 +34,5 @@ set (opm-grid_DEPS + "ecl REQUIRED" + ) + ++include(OpmPackage) + find_package_deps(opm-grid) diff --git a/patches/opm-parser-2017.04.patch b/patches/opm-parser-2017.04.patch deleted file mode 100644 index a9fbd643fe..0000000000 --- a/patches/opm-parser-2017.04.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a53c6634..2a6b5147 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -99,24 +99,8 @@ SET( CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 ${CMAKE_C_FLAGS} ${CMAKE_ - SET( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -mtune=native ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") - - --if (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS) -- set (Boost_NO_SYSTEM_PATHS TRUE) --endif (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS) -- --# if we are building shared libraries ourselves, then don't include Boost in them --if (BUILD_SHARED_LIBS) -- set(Boost_USE_STATIC_LIBS OFF) --elseif (DEFINED BUILD_SHARED_LIBS) -- set(Boost_USE_STATIC_LIBS ON) --endif () --set(Boost_USE_MULTITHREADED ON) --set(Boost_USE_STATIC_RUNTIME OFF) -- -- --add_definitions(-DOPM_PARSER_DECK_API=1) --# Requires BOOST filesystem version 3, thus 1.44 is necessary. --add_definitions(-DBOOST_FILESYSTEM_VERSION=3) --find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex REQUIRED) -+# get the prerequisite Boost libraries -+find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET}) - include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) - - include_directories(BEFORE ${PROJECT_SOURCE_DIR}) -@@ -177,9 +161,9 @@ include(OpmProject) - include(ConfigVars) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) - set(opm-parser_NAME opm-parser) --set(opm-parser_LIBRARIES opmparser opmjson) --if(NOT BUILD_SHARED_LIBS) -- list(APPEND opm-parser_LIBRARIES cjson) --endif() -+#set(opm-parser_LIBRARIES opmparser opmjson) -+#if(NOT BUILD_SHARED_LIBS) -+# list(APPEND opm-parser_LIBRARIES cjson) -+#endif() - set(opm-parser_TARGET opmparser) - opm_cmake_config(opm-parser) diff --git a/patches/opm-parser-2017.10.patch b/patches/opm-parser-2017.10.patch deleted file mode 100644 index 77f691d9b2..0000000000 --- a/patches/opm-parser-2017.10.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d81c5dc2..964c19de 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -91,14 +91,7 @@ else () - add_subdirectory(external/cjson) - endif() - --# if building shared libraries, then don't include Boost in them --if (BUILD_SHARED_LIBS) -- set(Boost_USE_STATIC_LIBS OFF) -- set(Boost_USE_STATIC_RUNTIME OFF) --else () --# if using dynamic boost, the header file must generate a main() function -- set(Boost_USE_STATIC_LIBS ON) --endif () -+add_definitions(-DBOOST_TEST_DYN_LINK) - - find_package(Boost 1.44.0 - COMPONENTS filesystem -- GitLab