diff --git a/opm-common-prereqs.cmake b/opm-common-prereqs.cmake index 1939eda81..82f7a7b7d 100644 --- a/opm-common-prereqs.cmake +++ b/opm-common-prereqs.cmake @@ -3,7 +3,8 @@ # defines that must be present in config.h for our headers set (opm-common_CONFIG_VAR - "HAS_ATTRIBUTE_UNUSED") + HAVE_OPENMP + ) # dependencies set (opm-common_DEPS diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp index 93a476809..d6f3317ab 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -154,6 +154,7 @@ namespace Opm { std::array getCellCenter(size_t i,size_t j, size_t k) const; std::array getCellCenter(size_t globalIndex) const; std::array getCornerPos(size_t i,size_t j, size_t k, size_t corner_index) const; + std::vector activeVolume() const; double getCellVolume(size_t globalIndex) const; double getCellVolume(size_t i , size_t j , size_t k) const; double getCellThickness(size_t globalIndex) const; diff --git a/python/setup.py b/python/setup.py index d88acc284..c44a8d191 100644 --- a/python/setup.py +++ b/python/setup.py @@ -66,7 +66,8 @@ ext_modules = [ language='c++', undef_macros=["NDEBUG"], include_dirs=["pybind11/include"], - extra_compile_args=['-std=c++17'] + extra_compile_args=['-std=c++17', '-fopenmp'], + extra_link_args=['-fopenmp'] ) ] diff --git a/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index 6b813523e..16607ca47 100644 --- a/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -1343,8 +1343,23 @@ std::vector EclipseGrid::createDVector(const std::array& dims, st assertIJK(i,j,k); size_t globalIndex = getGlobalIndex(i,j,k); + return this->cellActive(globalIndex); + } - return m_actnum[globalIndex]>0; + std::vector EclipseGrid::activeVolume() const { + std::vector active_volume( this->m_nactive ); + + #pragma omp parallel for schedule(static) + for (std::size_t active_index = 0; active_index < this->m_active_to_global.size(); active_index++) { + std::array X; + std::array Y; + std::array Z; + auto global_index = this->m_active_to_global[active_index]; + this->getCellCorners(global_index, X, Y, Z ); + active_volume[active_index] = calculateCellVol(X, Y, Z); + } + + return active_volume; } @@ -1666,9 +1681,6 @@ std::vector EclipseGrid::createDVector(const std::array& dims, st this->resetACTNUM(); else { auto global_size = this->getCartesianSize(); - if (this->m_actnum.empty() || std::memcmp(actnum, this->m_actnum.data(), global_size * sizeof * actnum) != 0) { - } - this->m_global_to_active.clear(); this->m_active_to_global.clear(); this->m_actnum.resize(global_size); @@ -1682,15 +1694,16 @@ std::vector EclipseGrid::createDVector(const std::array& dims, st this->m_nactive++; } else { this->m_global_to_active.push_back(-1); + } } } } void EclipseGrid::resetACTNUM(const std::vector& actnum) { - if (actnum.size() != getCartesianSize()) { + if (actnum.size() != getCartesianSize()) throw std::runtime_error("resetACTNUM(): actnum vector size differs from logical cartesian size of grid."); - } + this->resetACTNUM(actnum.data()); } diff --git a/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp b/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp index 459018533..e8fd4afd7 100644 --- a/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp +++ b/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp @@ -388,10 +388,7 @@ void handle_box_keyword(const DeckKeyword& deckKeyword, Box& box) { std::vector extract_cell_volume(const EclipseGrid& grid) { - std::vector cell_volume(grid.getNumActive()); - for (std::size_t active_index = 0; active_index < grid.getNumActive(); active_index++) - cell_volume[active_index] = grid.getCellVolume( grid.getGlobalIndex(active_index)); - return cell_volume; + return grid.activeVolume(); } std::vector extract_cell_depth(const EclipseGrid& grid) {