OPM-188: Added EclipseReader class for read of Restart wellstate data

This commit is contained in:
Edvin Brudevoll 2015-06-11 11:35:37 +02:00
parent 80dd0ef570
commit 6283a8621b
3 changed files with 87 additions and 0 deletions

View File

@ -41,6 +41,7 @@ list (APPEND MAIN_SOURCE_FILES
opm/core/grid/cpgpreprocess/uniquepoints.c opm/core/grid/cpgpreprocess/uniquepoints.c
opm/core/io/eclipse/EclipseGridInspector.cpp opm/core/io/eclipse/EclipseGridInspector.cpp
opm/core/io/eclipse/EclipseWriter.cpp opm/core/io/eclipse/EclipseWriter.cpp
opm/core/io/eclipse/EclipseReader.cpp
opm/core/io/eclipse/EclipseWriteRFTHandler.cpp opm/core/io/eclipse/EclipseWriteRFTHandler.cpp
opm/core/io/eclipse/writeECLData.cpp opm/core/io/eclipse/writeECLData.cpp
opm/core/io/OutputWriter.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/EclipseGridInspector.hpp
opm/core/io/eclipse/EclipseUnits.hpp opm/core/io/eclipse/EclipseUnits.hpp
opm/core/io/eclipse/EclipseWriter.hpp opm/core/io/eclipse/EclipseWriter.hpp
opm/core/io/eclipse/EclipseReader.hpp
opm/core/io/eclipse/EclipseWriteRFTHandler.hpp opm/core/io/eclipse/EclipseWriteRFTHandler.hpp
opm/core/io/eclipse/writeECLData.hpp opm/core/io/eclipse/writeECLData.hpp
opm/core/io/OutputWriter.hpp opm/core/io/OutputWriter.hpp

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "EclipseReader.hpp"
#include <iostream>
#include <opm/core/simulator/WellState.hpp>
#include <ert/ecl/ecl_file.h>
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

View File

@ -0,0 +1,23 @@
#ifndef ECLIPSEREADER_HPP
#define ECLIPSEREADER_HPP
#include <iostream>
#include <opm/core/simulator/WellState.hpp>
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<double> objects.
///
void restoreOPM_XWELKeyword(const std::string restart_filename, int report_step, WellState& wellState);
}
#endif // ECLIPSEREADER_HPP