diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index dd873158..755d331a 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -41,6 +41,7 @@ list (APPEND MAIN_SOURCE_FILES opm/core/grid/cpgpreprocess/uniquepoints.c opm/core/io/eclipse/EclipseGridInspector.cpp opm/core/io/eclipse/EclipseWriter.cpp + opm/core/io/eclipse/EclipseReader.cpp opm/core/io/eclipse/EclipseWriteRFTHandler.cpp opm/core/io/eclipse/writeECLData.cpp opm/core/io/OutputWriter.cpp @@ -289,6 +290,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/core/io/eclipse/EclipseGridInspector.hpp opm/core/io/eclipse/EclipseUnits.hpp opm/core/io/eclipse/EclipseWriter.hpp + opm/core/io/eclipse/EclipseReader.hpp opm/core/io/eclipse/EclipseWriteRFTHandler.hpp opm/core/io/eclipse/writeECLData.hpp opm/core/io/OutputWriter.hpp diff --git a/opm/core/io/eclipse/EclipseReader.cpp b/opm/core/io/eclipse/EclipseReader.cpp new file mode 100644 index 00000000..d7a871aa --- /dev/null +++ b/opm/core/io/eclipse/EclipseReader.cpp @@ -0,0 +1,62 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include "EclipseReader.hpp" +#include +#include + +#include + +namespace Opm +{ + void restoreOPM_XWELKeyword(const std::string restart_filename, int reportstep, WellState& wellstate) + { + const char * keyword = "OPM_XWEL"; + const char* filename = restart_filename.c_str(); + + ecl_file_type* file_type = ecl_file_open(filename, 0); + bool block_selected = ecl_file_select_rstblock_report_step(file_type , reportstep); + + if (block_selected) { + ecl_kw_type* xwel = ecl_file_iget_named_kw(file_type , keyword, 0); + const double* xwel_data = ecl_kw_get_double_ptr(xwel); + size_t offset = 0; + + for (size_t i = 0; i < wellstate.bhp().size(); ++i) { + wellstate.bhp()[i] = xwel_data[offset++]; + } + + for (size_t i = 0; i < wellstate.perfPress().size(); ++i) { + wellstate.perfPress()[i] = xwel_data[offset++]; + } + + for (size_t i = 0; i < wellstate.perfRates().size(); ++i) { + wellstate.perfRates()[i] = xwel_data[offset++]; + } + + for (size_t i = 0; i < wellstate.temperature().size(); ++i) { + wellstate.temperature()[i] = xwel_data[offset++]; + } + + for (size_t i = 0; i < wellstate.wellRates().size(); ++i) { + wellstate.wellRates()[i] = xwel_data[offset++]; + } + } + } +} // namespace Opm diff --git a/opm/core/io/eclipse/EclipseReader.hpp b/opm/core/io/eclipse/EclipseReader.hpp new file mode 100644 index 00000000..15868715 --- /dev/null +++ b/opm/core/io/eclipse/EclipseReader.hpp @@ -0,0 +1,23 @@ +#ifndef ECLIPSEREADER_HPP +#define ECLIPSEREADER_HPP + +#include +#include + +namespace Opm +{ +/// +/// \brief restoreOPM_XWELKeyword +/// Reading from the restart file, information stored under the OPM_XWEL keyword is in this method filled into +/// an instance of a wellstate object. +/// \param restart_filename +/// The filename of the restart file. +/// \param reportstep +/// The report step to restart from. +/// \param wellstate +/// An instance of a WellState object, with correct size for each of the 5 contained std::vector objects. +/// + void restoreOPM_XWELKeyword(const std::string restart_filename, int report_step, WellState& wellState); +} + +#endif // ECLIPSEREADER_HPP