#742 Added custom-opm-parser, compiles on Windows

This commit is contained in:
Magne Sjaastad
2016-05-27 16:00:50 +02:00
parent 758b4a452b
commit 2892653298
911 changed files with 106002 additions and 0 deletions

View File

@@ -378,6 +378,7 @@ set( LINK_LIBRARIES
${ERT_LIBRARIES}
custom-opm-common
custom-opm-parser
NRLib

View File

@@ -147,6 +147,7 @@ endif(RESINSIGHT_ERT_EXTERNAL_LIB_ROOT OR RESINSIGHT_ERT_EXTERNAL_INCLUDE_ROOT)
################################################################################
add_subdirectory(ThirdParty/custom-opm-common)
add_subdirectory(ThirdParty/custom-opm-parser)
################################################################################

View File

@@ -0,0 +1,314 @@
cmake_minimum_required (VERSION 2.8)
project (custom-opm-parser)
include_directories(
${Boost_INCLUDE_DIRS}
${custom-opm-common_SOURCE_DIR}/opm-common
${ERT_INCLUDE_DIRS}
)
# TODO: opm-parser should hold a cmake file with source code files only
#include(opm-parser/CMakeLists_files.cmake)
set( rawdeck_source
RawDeck/StarToken.cpp
RawDeck/RawKeyword.cpp
RawDeck/RawRecord.cpp )
set( unit_source
Units/UnitSystem.cpp
Units/Dimension.cpp)
set( deck_source
Deck/Deck.cpp
Deck/DeckKeyword.cpp
Deck/DeckRecord.cpp
Deck/DeckItem.cpp
Deck/Section.cpp
Deck/SCHEDULESection.cpp
Deck/DeckTimeStep.cpp
)
set( parser_source
Parser/ParseContext.cpp
Parser/MessageContainer.cpp
Parser/ParserEnums.cpp
Parser/ParserKeyword.cpp
Parser/Parser.cpp
Parser/ParserRecord.cpp
Parser/ParserItem.cpp
Parser/ParserIntItem.cpp
Parser/ParserDoubleItem.cpp
Parser/ParserStringItem.cpp
)
set( generator_source
Generator/KeywordGenerator.cpp
Generator/KeywordLoader.cpp )
set( build_parser_source
Parser/ParseContext.cpp
Parser/MessageContainer.cpp
Parser/ParserEnums.cpp
Parser/ParserKeyword.cpp
Parser/ParserRecord.cpp
Parser/ParserItem.cpp
Parser/ParserIntItem.cpp
Parser/ParserDoubleItem.cpp
Parser/ParserStringItem.cpp
${generator_source}
)
set (state_source
EclipseState/EclipseState.cpp
EclipseState/Eclipse3DProperties.cpp
EclipseState/Messages.cpp
#
EclipseState/checkDeck.cpp
#
EclipseState/Schedule/OilVaporizationProperties.cpp
EclipseState/Schedule/TimeMap.cpp
EclipseState/Schedule/Schedule.cpp
EclipseState/Schedule/Well.cpp
EclipseState/Schedule/WellProductionProperties.cpp
EclipseState/Schedule/WellInjectionProperties.cpp
EclipseState/Schedule/WellPolymerProperties.cpp
EclipseState/Schedule/MSW/Segment.cpp
EclipseState/Schedule/MSW/SegmentSet.cpp
EclipseState/Schedule/MSW/Compsegs.cpp
EclipseState/Schedule/WellSet.cpp
EclipseState/Schedule/Group.cpp
EclipseState/Schedule/Completion.cpp
EclipseState/Schedule/CompletionSet.cpp
EclipseState/Schedule/ScheduleEnums.cpp
EclipseState/Schedule/GroupTreeNode.cpp
EclipseState/Schedule/GroupTree.cpp
EclipseState/Schedule/Tuning.cpp
EclipseState/Schedule/Events.cpp
#
EclipseState/Tables/SimpleTable.cpp
EclipseState/Tables/VFPProdTable.cpp
EclipseState/Tables/VFPInjTable.cpp
EclipseState/Tables/TableManager.cpp
EclipseState/Tables/TableContainer.cpp
EclipseState/Tables/TableColumn.cpp
EclipseState/Tables/ColumnSchema.cpp
EclipseState/Tables/TableSchema.cpp
EclipseState/Tables/TableIndex.cpp
EclipseState/Tables/PvtxTable.cpp
EclipseState/Tables/Tables.cpp
#
EclipseState/Grid/SatfuncPropertyInitializers.cpp
EclipseState/Grid/GridProperty.cpp
EclipseState/Grid/Box.cpp
EclipseState/Grid/BoxManager.cpp
EclipseState/Grid/FaceDir.cpp
EclipseState/Grid/TransMult.cpp
EclipseState/Grid/MULTREGTScanner.cpp
EclipseState/Grid/EclipseGrid.cpp
EclipseState/Grid/FaultFace.cpp
EclipseState/Grid/Fault.cpp
EclipseState/Grid/FaultCollection.cpp
EclipseState/Grid/NNC.cpp
EclipseState/Grid/PinchMode.cpp
#
EclipseState/InitConfig/InitConfig.cpp
EclipseState/InitConfig/Equil.cpp
EclipseState/SimulationConfig/SimulationConfig.cpp
EclipseState/SimulationConfig/ThresholdPressure.cpp
EclipseState/SummaryConfig/SummaryConfig.cpp
EclipseState/IOConfig/IOConfig.cpp)
#
set( utility_source
Utility/Functional.cpp
Utility/Stringview.cpp
)
set( HEADER_FILES
RawDeck/RawConsts.hpp
RawDeck/RawKeyword.hpp
RawDeck/RawRecord.hpp
RawDeck/StarToken.hpp
RawDeck/RawEnums.hpp
#
Deck/Deck.hpp
Deck/DeckKeyword.hpp
Deck/DeckRecord.hpp
Deck/DeckItem.hpp
Deck/Section.hpp
Deck/SCHEDULESection.hpp
Deck/DeckTimeStep.hpp
#
Parser/ParserEnums.hpp
Parser/ParserKeyword.hpp
Parser/Parser.hpp
Parser/ParserRecord.hpp
Parser/ParserItem.hpp
Parser/ParserIntItem.hpp
Parser/ParserDoubleItem.hpp
Parser/ParserStringItem.hpp
Parser/InputErrorAction.hpp
Parser/ParseContext.hpp
Parser/MessageContainer.hpp
#
Generator/KeywordLoader.hpp
Generator/KeywordGenerator.hpp
#
Units/UnitSystem.hpp
Units/Dimension.hpp
Units/ConversionFactors.hpp
#
EclipseState/EclipseState.hpp
EclipseState/Eclipse3DProperties.hpp
EclipseState/Messages.hpp
#
EclipseState/checkDeck.hpp
#
EclipseState/Schedule/OilVaporizationProperties.hpp
EclipseState/Schedule/TimeMap.hpp
EclipseState/Schedule/Schedule.hpp
EclipseState/Schedule/Well.hpp
EclipseState/Schedule/WellProductionProperties.hpp
EclipseState/Schedule/WellInjectionProperties.hpp
EclipseState/Schedule/WellPolymerProperties.hpp
EclipseState/Schedule/MSW/Segment.hpp
EclipseState/Schedule/MSW/SegmentSet.hpp
EclipseState/Schedule/MSW/Compsegs.hpp
EclipseState/Schedule/WellSet.hpp
EclipseState/Schedule/Group.hpp
EclipseState/Schedule/DynamicState.hpp
EclipseState/Schedule/DynamicVector.hpp
EclipseState/Schedule/Completion.hpp
EclipseState/Schedule/CompletionSet.hpp
EclipseState/Schedule/ScheduleEnums.hpp
EclipseState/Schedule/GroupTreeNode.hpp
EclipseState/Schedule/GroupTree.hpp
EclipseState/Schedule/Tuning.hpp
EclipseState/Schedule/Events.hpp
#
EclipseState/Util/RecordVector.hpp
EclipseState/Util/OrderedMap.hpp
EclipseState/Util/Value.hpp
#
EclipseState/Grid/EclipseGrid.hpp
EclipseState/Grid/GridProperty.hpp
EclipseState/Grid/GridProperties.hpp
EclipseState/Grid/SatfuncPropertyInitializers.hpp
EclipseState/Grid/Box.hpp
EclipseState/Grid/BoxManager.hpp
EclipseState/Grid/FaceDir.hpp
EclipseState/Grid/MinpvMode.hpp
EclipseState/Grid/PinchMode.hpp
EclipseState/Grid/MULTREGTScanner.hpp
EclipseState/Grid/TransMult.hpp
EclipseState/Grid/FaultFace.hpp
EclipseState/Grid/Fault.hpp
EclipseState/Grid/FaultCollection.hpp
EclipseState/Grid/NNC.hpp
#
EclipseState/InitConfig/InitConfig.hpp
EclipseState/InitConfig/Equil.hpp
EclipseState/SimulationConfig/SimulationConfig.hpp
EclipseState/SimulationConfig/ThresholdPressure.hpp
EclipseState/SummaryConfig/SummaryConfig.hpp
EclipseState/IOConfig/IOConfig.hpp
#
EclipseState/Tables/Tabdims.hpp
EclipseState/Tables/Eqldims.hpp
EclipseState/Tables/Regdims.hpp
EclipseState/Tables/PlyadsTable.hpp
EclipseState/Tables/PvtoTable.hpp
EclipseState/Tables/RocktabTable.hpp
EclipseState/Tables/PvdoTable.hpp
EclipseState/Tables/PvdgTable.hpp
EclipseState/Tables/PvdsTable.hpp
EclipseState/Tables/SimpleTable.hpp
EclipseState/Tables/PlymaxTable.hpp
EclipseState/Tables/PlyrockTable.hpp
EclipseState/Tables/SwofTable.hpp
EclipseState/Tables/SgwfnTable.hpp
EclipseState/Tables/SwfnTable.hpp
EclipseState/Tables/SgfnTable.hpp
EclipseState/Tables/SsfnTable.hpp
EclipseState/Tables/Sof2Table.hpp
EclipseState/Tables/Sof3Table.hpp
EclipseState/Tables/EnptvdTable.hpp
EclipseState/Tables/PlyviscTable.hpp
EclipseState/Tables/PlydhflfTable.hpp
EclipseState/Tables/PlyshlogTable.hpp
EclipseState/Tables/EnkrvdTable.hpp
EclipseState/Tables/ImkrvdTable.hpp
EclipseState/Tables/SgofTable.hpp
EclipseState/Tables/SlgofTable.hpp
EclipseState/Tables/PvtxTable.hpp
EclipseState/Tables/ImptvdTable.hpp
EclipseState/Tables/RsvdTable.hpp
EclipseState/Tables/RvvdTable.hpp
EclipseState/Tables/RtempvdTable.hpp
EclipseState/Tables/OilvisctTable.hpp
EclipseState/Tables/GasvisctTable.hpp
EclipseState/Tables/WatvisctTable.hpp
EclipseState/Tables/PvtgTable.hpp
EclipseState/Tables/VFPProdTable.hpp
EclipseState/Tables/VFPInjTable.hpp
EclipseState/Tables/TableManager.hpp
EclipseState/Tables/TableContainer.hpp
EclipseState/Tables/SorwmisTable.hpp
EclipseState/Tables/SgcwmisTable.hpp
EclipseState/Tables/MiscTable.hpp
EclipseState/Tables/PmiscTable.hpp
EclipseState/Tables/TlpmixpaTable.hpp
EclipseState/Tables/MsfnTable.hpp
EclipseState/Tables/TableColumn.hpp
EclipseState/Tables/ColumnSchema.hpp
EclipseState/Tables/TableEnums.hpp
EclipseState/Tables/TableSchema.hpp
EclipseState/Tables/TableIndex.hpp
#
Utility/Functional.hpp
Utility/Stringview.hpp)
include_directories(
opm-parser
generated-source/include
)
set(opm_parser_source_files
${generated_source}
${state_source}
${rawdeck_source}
${parser_source}
${deck_source}
${unit_source}
${generator_source}
${utility_source}
)
foreach (file ${opm_parser_source_files} )
list(APPEND incl_path "opm-parser/opm/parser/eclipse/${file}" )
endforeach()
set(opm_parser_generated_source_files
generated-source/ParserKeywords.cpp
generated-source/ParserKeywords0.cpp
generated-source/ParserKeywords1.cpp
generated-source/ParserKeywords2.cpp
generated-source/ParserKeywords3.cpp
)
add_library(${PROJECT_NAME}
${incl_path}
${opm_parser_generated_source_files}
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
#include <opm/parser/eclipse/Parser/ParserItem.hpp>
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords.hpp>
namespace Opm {
namespace ParserKeywords {
void addDefaultKeywords0(Parser& p) {
p.addKeyword< ParserKeywords::ACTDIMS >();
p.addKeyword< ParserKeywords::ACTNUM >();
p.addKeyword< ParserKeywords::ADD >();
p.addKeyword< ParserKeywords::ADDREG >();
p.addKeyword< ParserKeywords::ADSALNOD >();
p.addKeyword< ParserKeywords::ALL >();
p.addKeyword< ParserKeywords::API >();
p.addKeyword< ParserKeywords::AQUCON >();
p.addKeyword< ParserKeywords::AQUDIMS >();
p.addKeyword< ParserKeywords::AQUNUM >();
p.addKeyword< ParserKeywords::BLOCK_PROBE >();
p.addKeyword< ParserKeywords::BLOCK_PROBE300 >();
p.addKeyword< ParserKeywords::BOX >();
p.addKeyword< ParserKeywords::COMPDAT >();
p.addKeyword< ParserKeywords::COMPLUMP >();
p.addKeyword< ParserKeywords::COMPORD >();
p.addKeyword< ParserKeywords::COMPS >();
p.addKeyword< ParserKeywords::COMPSEGS >();
p.addKeyword< ParserKeywords::CONNECTION_PROBE >();
p.addKeyword< ParserKeywords::COORD >();
p.addKeyword< ParserKeywords::COPY >();
p.addKeyword< ParserKeywords::COPYREG >();
p.addKeyword< ParserKeywords::CPR >();
p.addKeyword< ParserKeywords::CREF >();
p.addKeyword< ParserKeywords::CREFS >();
p.addKeyword< ParserKeywords::DATE >();
p.addKeyword< ParserKeywords::DATES >();
p.addKeyword< ParserKeywords::DENSITY >();
p.addKeyword< ParserKeywords::DEPTH >();
p.addKeyword< ParserKeywords::DEPTHZ >();
p.addKeyword< ParserKeywords::DIMENS >();
p.addKeyword< ParserKeywords::DISGAS >();
p.addKeyword< ParserKeywords::DREF >();
p.addKeyword< ParserKeywords::DREFS >();
p.addKeyword< ParserKeywords::DRSDT >();
p.addKeyword< ParserKeywords::DRVDT >();
p.addKeyword< ParserKeywords::DX >();
p.addKeyword< ParserKeywords::DXV >();
p.addKeyword< ParserKeywords::DY >();
p.addKeyword< ParserKeywords::DYV >();
p.addKeyword< ParserKeywords::DZ >();
p.addKeyword< ParserKeywords::DZV >();
p.addKeyword< ParserKeywords::ECHO >();
p.addKeyword< ParserKeywords::EDIT >();
p.addKeyword< ParserKeywords::EDITNNC >();
p.addKeyword< ParserKeywords::EHYSTR >();
p.addKeyword< ParserKeywords::END >();
p.addKeyword< ParserKeywords::ENDBOX >();
p.addKeyword< ParserKeywords::ENDINC >();
p.addKeyword< ParserKeywords::ENDNUM >();
p.addKeyword< ParserKeywords::ENDPOINT_SPECIFIERS >();
p.addKeyword< ParserKeywords::ENDSCALE >();
p.addKeyword< ParserKeywords::ENDSKIP >();
p.addKeyword< ParserKeywords::ENKRVD >();
p.addKeyword< ParserKeywords::ENPTVD >();
p.addKeyword< ParserKeywords::EQLDIMS >();
p.addKeyword< ParserKeywords::EQLNUM >();
p.addKeyword< ParserKeywords::EQLOPTS >();
p.addKeyword< ParserKeywords::EQUALREG >();
p.addKeyword< ParserKeywords::EQUALS >();
p.addKeyword< ParserKeywords::EQUIL >();
p.addKeyword< ParserKeywords::EXCEL >();
p.addKeyword< ParserKeywords::EXTRAPMS >();
p.addKeyword< ParserKeywords::FAULTDIM >();
p.addKeyword< ParserKeywords::FAULTS >();
p.addKeyword< ParserKeywords::FIELD >();
p.addKeyword< ParserKeywords::FIELD_PROBE >();
p.addKeyword< ParserKeywords::FILLEPS >();
p.addKeyword< ParserKeywords::FIPNUM >();
p.addKeyword< ParserKeywords::FLUXNUM >();
p.addKeyword< ParserKeywords::FMTIN >();
p.addKeyword< ParserKeywords::FMTOUT >();
p.addKeyword< ParserKeywords::FULLIMP >();
p.addKeyword< ParserKeywords::GAS >();
p.addKeyword< ParserKeywords::GASVISCT >();
p.addKeyword< ParserKeywords::GCOMPIDX >();
p.addKeyword< ParserKeywords::GCONINJE >();
p.addKeyword< ParserKeywords::GCONPROD >();
p.addKeyword< ParserKeywords::GDORIENT >();
p.addKeyword< ParserKeywords::GECON >();
p.addKeyword< ParserKeywords::GEFAC >();
p.addKeyword< ParserKeywords::GRID >();
p.addKeyword< ParserKeywords::GRIDFILE >();
}}}

View File

@@ -0,0 +1,99 @@
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
#include <opm/parser/eclipse/Parser/ParserItem.hpp>
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords.hpp>
namespace Opm {
namespace ParserKeywords {
void addDefaultKeywords1(Parser& p) {
p.addKeyword< ParserKeywords::GRIDOPTS >();
p.addKeyword< ParserKeywords::GRIDUNIT >();
p.addKeyword< ParserKeywords::GROUP_PROBE >();
p.addKeyword< ParserKeywords::GRUPNET >();
p.addKeyword< ParserKeywords::GRUPTREE >();
p.addKeyword< ParserKeywords::IMBNUM >();
p.addKeyword< ParserKeywords::IMKRVD >();
p.addKeyword< ParserKeywords::IMPES >();
p.addKeyword< ParserKeywords::IMPTVD >();
p.addKeyword< ParserKeywords::INCLUDE >();
p.addKeyword< ParserKeywords::INIT >();
p.addKeyword< ParserKeywords::IPCG >();
p.addKeyword< ParserKeywords::IPCW >();
p.addKeyword< ParserKeywords::ISGCR >();
p.addKeyword< ParserKeywords::ISGL >();
p.addKeyword< ParserKeywords::ISGU >();
p.addKeyword< ParserKeywords::ISOGCR >();
p.addKeyword< ParserKeywords::ISOWCR >();
p.addKeyword< ParserKeywords::ISWCR >();
p.addKeyword< ParserKeywords::ISWL >();
p.addKeyword< ParserKeywords::ISWU >();
p.addKeyword< ParserKeywords::MAPAXES >();
p.addKeyword< ParserKeywords::MAPUNITS >();
p.addKeyword< ParserKeywords::MAXVALUE >();
p.addKeyword< ParserKeywords::MEMORY >();
p.addKeyword< ParserKeywords::MESSAGES >();
p.addKeyword< ParserKeywords::METRIC >();
p.addKeyword< ParserKeywords::MINPV >();
p.addKeyword< ParserKeywords::MINPVFIL >();
p.addKeyword< ParserKeywords::MINVALUE >();
p.addKeyword< ParserKeywords::MISC >();
p.addKeyword< ParserKeywords::MISCIBLE >();
p.addKeyword< ParserKeywords::MISCNUM >();
p.addKeyword< ParserKeywords::MONITOR >();
p.addKeyword< ParserKeywords::MSFN >();
p.addKeyword< ParserKeywords::MSGFILE >();
p.addKeyword< ParserKeywords::MULTFLT >();
p.addKeyword< ParserKeywords::MULTIPLY >();
p.addKeyword< ParserKeywords::MULTIREG >();
p.addKeyword< ParserKeywords::MULTNUM >();
p.addKeyword< ParserKeywords::MULTPV >();
p.addKeyword< ParserKeywords::MULTREGT >();
p.addKeyword< ParserKeywords::MULT_XYZ >();
p.addKeyword< ParserKeywords::MW >();
p.addKeyword< ParserKeywords::MWS >();
p.addKeyword< ParserKeywords::NETBALAN >();
p.addKeyword< ParserKeywords::NEWTRAN >();
p.addKeyword< ParserKeywords::NEXTSTEP >();
p.addKeyword< ParserKeywords::NNC >();
p.addKeyword< ParserKeywords::NOCASC >();
p.addKeyword< ParserKeywords::NOECHO >();
p.addKeyword< ParserKeywords::NOGGF >();
p.addKeyword< ParserKeywords::NOGRAV >();
p.addKeyword< ParserKeywords::NOINSPEC >();
p.addKeyword< ParserKeywords::NOMONITO >();
p.addKeyword< ParserKeywords::NONNC >();
p.addKeyword< ParserKeywords::NORSSPEC >();
p.addKeyword< ParserKeywords::NOSIM >();
p.addKeyword< ParserKeywords::NSTACK >();
p.addKeyword< ParserKeywords::NTG >();
p.addKeyword< ParserKeywords::NUMRES >();
p.addKeyword< ParserKeywords::NUPCOL >();
p.addKeyword< ParserKeywords::OCOMPIDX >();
p.addKeyword< ParserKeywords::OIL >();
p.addKeyword< ParserKeywords::OILCOMPR >();
p.addKeyword< ParserKeywords::OILMW >();
p.addKeyword< ParserKeywords::OILVISCT >();
p.addKeyword< ParserKeywords::OILVTIM >();
p.addKeyword< ParserKeywords::OLDTRAN >();
p.addKeyword< ParserKeywords::OPTIONS >();
p.addKeyword< ParserKeywords::PARALLEL >();
p.addKeyword< ParserKeywords::PATHS >();
p.addKeyword< ParserKeywords::PBVD >();
p.addKeyword< ParserKeywords::PCG >();
p.addKeyword< ParserKeywords::PERFORMANCE_PROBE >();
p.addKeyword< ParserKeywords::PERMX >();
p.addKeyword< ParserKeywords::PERMXY >();
p.addKeyword< ParserKeywords::PERMY >();
p.addKeyword< ParserKeywords::PERMYZ >();
p.addKeyword< ParserKeywords::PERMZ >();
p.addKeyword< ParserKeywords::PERMZX >();
p.addKeyword< ParserKeywords::PIMTDIMS >();
p.addKeyword< ParserKeywords::PIMULTAB >();
}}}

View File

@@ -0,0 +1,99 @@
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
#include <opm/parser/eclipse/Parser/ParserItem.hpp>
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords.hpp>
namespace Opm {
namespace ParserKeywords {
void addDefaultKeywords2(Parser& p) {
p.addKeyword< ParserKeywords::PINCH >();
p.addKeyword< ParserKeywords::PLMIXPAR >();
p.addKeyword< ParserKeywords::PLYADS >();
p.addKeyword< ParserKeywords::PLYADSS >();
p.addKeyword< ParserKeywords::PLYDHFLF >();
p.addKeyword< ParserKeywords::PLYMAX >();
p.addKeyword< ParserKeywords::PLYROCK >();
p.addKeyword< ParserKeywords::PLYSHEAR >();
p.addKeyword< ParserKeywords::PLYSHLOG >();
p.addKeyword< ParserKeywords::PLYVISC >();
p.addKeyword< ParserKeywords::PMISC >();
p.addKeyword< ParserKeywords::POLYMER >();
p.addKeyword< ParserKeywords::PORO >();
p.addKeyword< ParserKeywords::PORV >();
p.addKeyword< ParserKeywords::PREF >();
p.addKeyword< ParserKeywords::PREFS >();
p.addKeyword< ParserKeywords::PRESSURE >();
p.addKeyword< ParserKeywords::PROPS >();
p.addKeyword< ParserKeywords::PVCDO >();
p.addKeyword< ParserKeywords::PVDG >();
p.addKeyword< ParserKeywords::PVDO >();
p.addKeyword< ParserKeywords::PVDS >();
p.addKeyword< ParserKeywords::PVTG >();
p.addKeyword< ParserKeywords::PVTNUM >();
p.addKeyword< ParserKeywords::PVTO >();
p.addKeyword< ParserKeywords::PVTW >();
p.addKeyword< ParserKeywords::RADFIN4 >();
p.addKeyword< ParserKeywords::REGDIMS >();
p.addKeyword< ParserKeywords::REGIONS >();
p.addKeyword< ParserKeywords::REGION_PROBE >();
p.addKeyword< ParserKeywords::RESTART >();
p.addKeyword< ParserKeywords::RKTRMDIR >();
p.addKeyword< ParserKeywords::ROCK >();
p.addKeyword< ParserKeywords::ROCKCOMP >();
p.addKeyword< ParserKeywords::ROCKOPTS >();
p.addKeyword< ParserKeywords::ROCKTAB >();
p.addKeyword< ParserKeywords::RPTGRID >();
p.addKeyword< ParserKeywords::RPTONLY >();
p.addKeyword< ParserKeywords::RPTONLYO >();
p.addKeyword< ParserKeywords::RPTPROPS >();
p.addKeyword< ParserKeywords::RPTRST >();
p.addKeyword< ParserKeywords::RPTRUNSP >();
p.addKeyword< ParserKeywords::RPTSCHED >();
p.addKeyword< ParserKeywords::RPTSOL >();
p.addKeyword< ParserKeywords::RS >();
p.addKeyword< ParserKeywords::RSVD >();
p.addKeyword< ParserKeywords::RTEMPVD >();
p.addKeyword< ParserKeywords::RUNSPEC >();
p.addKeyword< ParserKeywords::RUNSUM >();
p.addKeyword< ParserKeywords::RV >();
p.addKeyword< ParserKeywords::RVVD >();
p.addKeyword< ParserKeywords::SATNUM >();
p.addKeyword< ParserKeywords::SATOPTS >();
p.addKeyword< ParserKeywords::SAVE >();
p.addKeyword< ParserKeywords::SCALECRS >();
p.addKeyword< ParserKeywords::SCHEDULE >();
p.addKeyword< ParserKeywords::SDENSITY >();
p.addKeyword< ParserKeywords::SEPARATE >();
p.addKeyword< ParserKeywords::SGAS >();
p.addKeyword< ParserKeywords::SGCR >();
p.addKeyword< ParserKeywords::SGCWMIS >();
p.addKeyword< ParserKeywords::SGFN >();
p.addKeyword< ParserKeywords::SGL >();
p.addKeyword< ParserKeywords::SGOF >();
p.addKeyword< ParserKeywords::SGU >();
p.addKeyword< ParserKeywords::SGWFN >();
p.addKeyword< ParserKeywords::SHRATE >();
p.addKeyword< ParserKeywords::SKIP >();
p.addKeyword< ParserKeywords::SKIP100 >();
p.addKeyword< ParserKeywords::SKIP300 >();
p.addKeyword< ParserKeywords::SKIPREST >();
p.addKeyword< ParserKeywords::SLGOF >();
p.addKeyword< ParserKeywords::SMRYDIMS >();
p.addKeyword< ParserKeywords::SOF2 >();
p.addKeyword< ParserKeywords::SOF3 >();
p.addKeyword< ParserKeywords::SOGCR >();
p.addKeyword< ParserKeywords::SOIL >();
p.addKeyword< ParserKeywords::SOLUTION >();
p.addKeyword< ParserKeywords::SOLVENT >();
p.addKeyword< ParserKeywords::SORWMIS >();
p.addKeyword< ParserKeywords::SOWCR >();
p.addKeyword< ParserKeywords::SPECGRID >();
p.addKeyword< ParserKeywords::SPECHEAT >();
}}}

View File

@@ -0,0 +1,98 @@
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
#include <opm/parser/eclipse/Parser/ParserItem.hpp>
#include <opm/parser/eclipse/Parser/ParserIntItem.hpp>
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
#include <opm/parser/eclipse/Parser/ParserDoubleItem.hpp>
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords.hpp>
namespace Opm {
namespace ParserKeywords {
void addDefaultKeywords3(Parser& p) {
p.addKeyword< ParserKeywords::SPECROCK >();
p.addKeyword< ParserKeywords::SSFN >();
p.addKeyword< ParserKeywords::SSOL >();
p.addKeyword< ParserKeywords::START >();
p.addKeyword< ParserKeywords::STCOND >();
p.addKeyword< ParserKeywords::STONE1 >();
p.addKeyword< ParserKeywords::STONE1EX >();
p.addKeyword< ParserKeywords::SUMMARY >();
p.addKeyword< ParserKeywords::SUMTHIN >();
p.addKeyword< ParserKeywords::SWAT >();
p.addKeyword< ParserKeywords::SWATINIT >();
p.addKeyword< ParserKeywords::SWCR >();
p.addKeyword< ParserKeywords::SWFN >();
p.addKeyword< ParserKeywords::SWL >();
p.addKeyword< ParserKeywords::SWOF >();
p.addKeyword< ParserKeywords::SWU >();
p.addKeyword< ParserKeywords::TABDIMS >();
p.addKeyword< ParserKeywords::TEMP >();
p.addKeyword< ParserKeywords::TEMPI >();
p.addKeyword< ParserKeywords::TEMPVD >();
p.addKeyword< ParserKeywords::THCONR >();
p.addKeyword< ParserKeywords::THERMAL >();
p.addKeyword< ParserKeywords::THERMEX1 >();
p.addKeyword< ParserKeywords::THPRES >();
p.addKeyword< ParserKeywords::TITLE >();
p.addKeyword< ParserKeywords::TLMIXPAR >();
p.addKeyword< ParserKeywords::TLPMIXPA >();
p.addKeyword< ParserKeywords::TOPS >();
p.addKeyword< ParserKeywords::TRACER >();
p.addKeyword< ParserKeywords::TRACERS >();
p.addKeyword< ParserKeywords::TRANX >();
p.addKeyword< ParserKeywords::TRANY >();
p.addKeyword< ParserKeywords::TRANZ >();
p.addKeyword< ParserKeywords::TREF >();
p.addKeyword< ParserKeywords::TREFS >();
p.addKeyword< ParserKeywords::TSTEP >();
p.addKeyword< ParserKeywords::TUNING >();
p.addKeyword< ParserKeywords::TVDP >();
p.addKeyword< ParserKeywords::UDADIMS >();
p.addKeyword< ParserKeywords::UDQDIMS >();
p.addKeyword< ParserKeywords::UNIFIN >();
p.addKeyword< ParserKeywords::UNIFOUT >();
p.addKeyword< ParserKeywords::VAPOIL >();
p.addKeyword< ParserKeywords::VAPPARS >();
p.addKeyword< ParserKeywords::VFPIDIMS >();
p.addKeyword< ParserKeywords::VFPINJ >();
p.addKeyword< ParserKeywords::VFPPDIMS >();
p.addKeyword< ParserKeywords::VFPPROD >();
p.addKeyword< ParserKeywords::VISCREF >();
p.addKeyword< ParserKeywords::WATDENT >();
p.addKeyword< ParserKeywords::WATER >();
p.addKeyword< ParserKeywords::WATVISCT >();
p.addKeyword< ParserKeywords::WCONHIST >();
p.addKeyword< ParserKeywords::WCONINJ >();
p.addKeyword< ParserKeywords::WCONINJE >();
p.addKeyword< ParserKeywords::WCONINJH >();
p.addKeyword< ParserKeywords::WCONPROD >();
p.addKeyword< ParserKeywords::WELLDIMS >();
p.addKeyword< ParserKeywords::WELL_PROBE >();
p.addKeyword< ParserKeywords::WELOPEN >();
p.addKeyword< ParserKeywords::WELSEGS >();
p.addKeyword< ParserKeywords::WELSPECS >();
p.addKeyword< ParserKeywords::WELTARG >();
p.addKeyword< ParserKeywords::WGRUPCON >();
p.addKeyword< ParserKeywords::WHISTCTL >();
p.addKeyword< ParserKeywords::WPAVE >();
p.addKeyword< ParserKeywords::WPIMULT >();
p.addKeyword< ParserKeywords::WPITAB >();
p.addKeyword< ParserKeywords::WPOLYMER >();
p.addKeyword< ParserKeywords::WRFT >();
p.addKeyword< ParserKeywords::WRFTPLT >();
p.addKeyword< ParserKeywords::WSEGDIMS >();
p.addKeyword< ParserKeywords::WSOLVENT >();
p.addKeyword< ParserKeywords::WTEMP >();
p.addKeyword< ParserKeywords::WTEST >();
p.addKeyword< ParserKeywords::WTRACER >();
p.addKeyword< ParserKeywords::ZCORN >();
p.addKeyword< ParserKeywords::ZFACT1 >();
p.addKeyword< ParserKeywords::ZFACT1S >();
p.addKeyword< ParserKeywords::ZFACTOR >();
p.addKeyword< ParserKeywords::ZFACTORS >();
p.addKeyword< ParserKeywords::ZIPPY2 >();
}}}

View File

@@ -0,0 +1,27 @@
#ifndef PARSER_KEYWORDS__HPP
#define PARSER_KEYWORDS__HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
}}
#include <opm/parser/eclipse/Parser/ParserKeywords/A.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/B.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/F.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/I.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/N.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/O.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/U.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/V.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/W.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/Z.hpp>
#endif

View File

@@ -0,0 +1,358 @@
#ifndef PARSER_KEYWORDS_A_HPP
#define PARSER_KEYWORDS_A_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class ACTDIMS : public ParserKeyword {
public:
ACTDIMS();
static const std::string keywordName;
class MAX_ACTION {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ACTION_LINES {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ACTION_LINE_CHARACTERS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ACTION_COND {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class ACTNUM : public ParserKeyword {
public:
ACTNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ADD : public ParserKeyword {
public:
ADD();
static const std::string keywordName;
class field {
public:
static const std::string itemName;
};
class shift {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class ADDREG : public ParserKeyword {
public:
ADDREG();
static const std::string keywordName;
class ARRAY {
public:
static const std::string itemName;
};
class SHIFT {
public:
static const std::string itemName;
static const double defaultValue;
};
class REGION_NUMBER {
public:
static const std::string itemName;
};
class REGION_NAME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class ADSALNOD : public ParserKeyword {
public:
ADSALNOD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class ALL : public ParserKeyword {
public:
ALL();
static const std::string keywordName;
};
class API : public ParserKeyword {
public:
API();
static const std::string keywordName;
};
class AQUCON : public ParserKeyword {
public:
AQUCON();
static const std::string keywordName;
class ID {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class CONNECT_FACE {
public:
static const std::string itemName;
};
class TRANS_MULT {
public:
static const std::string itemName;
};
class TRANS_OPTION {
public:
static const std::string itemName;
};
class ALLOW_INTERNAL_CELLS {
public:
static const std::string itemName;
};
class VEFRAC {
public:
static const std::string itemName;
};
class VEFRACP {
public:
static const std::string itemName;
};
};
class AQUDIMS : public ParserKeyword {
public:
AQUDIMS();
static const std::string keywordName;
class MXNAQN {
public:
static const std::string itemName;
static const int defaultValue;
};
class MXNAQC {
public:
static const std::string itemName;
static const int defaultValue;
};
class NIFTBL {
public:
static const std::string itemName;
static const int defaultValue;
};
class NRIFTB {
public:
static const std::string itemName;
static const int defaultValue;
};
class NANAQU {
public:
static const std::string itemName;
static const int defaultValue;
};
class NCAMAX {
public:
static const std::string itemName;
static const int defaultValue;
};
class MXNALI {
public:
static const std::string itemName;
static const int defaultValue;
};
class MXAAQL {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class AQUNUM : public ParserKeyword {
public:
AQUNUM();
static const std::string keywordName;
class AQUIFER_ID {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
class CROSS_SECTION {
public:
static const std::string itemName;
};
class LENGTH {
public:
static const std::string itemName;
};
class PORO {
public:
static const std::string itemName;
};
class PERM {
public:
static const std::string itemName;
};
class DEPTH {
public:
static const std::string itemName;
};
class INITIAL_PRESSURE {
public:
static const std::string itemName;
};
class PVT_TABLE_NUM {
public:
static const std::string itemName;
};
class SAT_TABLE_NUM {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,93 @@
#ifndef PARSER_KEYWORDS_B_HPP
#define PARSER_KEYWORDS_B_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class BLOCK_PROBE : public ParserKeyword {
public:
BLOCK_PROBE();
static const std::string keywordName;
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
};
class BLOCK_PROBE300 : public ParserKeyword {
public:
BLOCK_PROBE300();
static const std::string keywordName;
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
};
class BOX : public ParserKeyword {
public:
BOX();
static const std::string keywordName;
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,405 @@
#ifndef PARSER_KEYWORDS_C_HPP
#define PARSER_KEYWORDS_C_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class COMPDAT : public ParserKeyword {
public:
COMPDAT();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
static const int defaultValue;
};
class J {
public:
static const std::string itemName;
static const int defaultValue;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class STATE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class SAT_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class CONNECTION_TRANSMISSIBILITY_FACTOR {
public:
static const std::string itemName;
};
class DIAMETER {
public:
static const std::string itemName;
};
class Kh {
public:
static const std::string itemName;
static const double defaultValue;
};
class SKIN {
public:
static const std::string itemName;
static const double defaultValue;
};
class D_FACTOR {
public:
static const std::string itemName;
};
class DIR {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class PR {
public:
static const std::string itemName;
};
};
class COMPLUMP : public ParserKeyword {
public:
COMPLUMP();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class N {
public:
static const std::string itemName;
};
};
class COMPORD : public ParserKeyword {
public:
COMPORD();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class ORDER_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class COMPS : public ParserKeyword {
public:
COMPS();
static const std::string keywordName;
class NUM_COMPS {
public:
static const std::string itemName;
};
};
class COMPSEGS : public ParserKeyword {
public:
COMPSEGS();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
class BRANCH {
public:
static const std::string itemName;
};
class DISTANCE_START {
public:
static const std::string itemName;
};
class DISTANCE_END {
public:
static const std::string itemName;
};
class DIRECTION {
public:
static const std::string itemName;
};
class END_IJK {
public:
static const std::string itemName;
};
class CENTER_DEPTH {
public:
static const std::string itemName;
static const double defaultValue;
};
class THERMAL_LENGTH {
public:
static const std::string itemName;
};
class SEGMENT_NUMBER {
public:
static const std::string itemName;
};
};
class CONNECTION_PROBE : public ParserKeyword {
public:
CONNECTION_PROBE();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
};
class COORD : public ParserKeyword {
public:
COORD();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class COPY : public ParserKeyword {
public:
COPY();
static const std::string keywordName;
class src {
public:
static const std::string itemName;
};
class target {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class COPYREG : public ParserKeyword {
public:
COPYREG();
static const std::string keywordName;
class ARRAY {
public:
static const std::string itemName;
};
class TARGET_ARRAY {
public:
static const std::string itemName;
};
class REGION_NUMBER {
public:
static const std::string itemName;
};
class REGION_NAME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class CPR : public ParserKeyword {
public:
CPR();
static const std::string keywordName;
class WELL {
public:
static const std::string itemName;
};
class I {
public:
static const std::string itemName;
};
class J {
public:
static const std::string itemName;
};
class K {
public:
static const std::string itemName;
};
};
class CREF : public ParserKeyword {
public:
CREF();
static const std::string keywordName;
class COMPRESSIBILITY {
public:
static const std::string itemName;
};
};
class CREFS : public ParserKeyword {
public:
CREFS();
static const std::string keywordName;
class COMPRESSIBILITY {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,265 @@
#ifndef PARSER_KEYWORDS_D_HPP
#define PARSER_KEYWORDS_D_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class DATE : public ParserKeyword {
public:
DATE();
static const std::string keywordName;
};
class DATES : public ParserKeyword {
public:
DATES();
static const std::string keywordName;
class DAY {
public:
static const std::string itemName;
};
class MONTH {
public:
static const std::string itemName;
};
class YEAR {
public:
static const std::string itemName;
};
class TIME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class DENSITY : public ParserKeyword {
public:
DENSITY();
static const std::string keywordName;
class OIL {
public:
static const std::string itemName;
static const double defaultValue;
};
class WATER {
public:
static const std::string itemName;
static const double defaultValue;
};
class GAS {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class DEPTH : public ParserKeyword {
public:
DEPTH();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DEPTHZ : public ParserKeyword {
public:
DEPTHZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DIMENS : public ParserKeyword {
public:
DIMENS();
static const std::string keywordName;
class NX {
public:
static const std::string itemName;
};
class NY {
public:
static const std::string itemName;
};
class NZ {
public:
static const std::string itemName;
};
};
class DISGAS : public ParserKeyword {
public:
DISGAS();
static const std::string keywordName;
};
class DREF : public ParserKeyword {
public:
DREF();
static const std::string keywordName;
class DENSITY {
public:
static const std::string itemName;
};
};
class DREFS : public ParserKeyword {
public:
DREFS();
static const std::string keywordName;
class DENSITY {
public:
static const std::string itemName;
};
};
class DRSDT : public ParserKeyword {
public:
DRSDT();
static const std::string keywordName;
class DRSDT_MAX {
public:
static const std::string itemName;
};
class Option {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class DRVDT : public ParserKeyword {
public:
DRVDT();
static const std::string keywordName;
class DRVDT_MAX {
public:
static const std::string itemName;
};
};
class DX : public ParserKeyword {
public:
DX();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DXV : public ParserKeyword {
public:
DXV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DY : public ParserKeyword {
public:
DY();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DYV : public ParserKeyword {
public:
DYV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DZ : public ParserKeyword {
public:
DZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class DZV : public ParserKeyword {
public:
DZV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,547 @@
#ifndef PARSER_KEYWORDS_E_HPP
#define PARSER_KEYWORDS_E_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class ECHO : public ParserKeyword {
public:
ECHO();
static const std::string keywordName;
};
class EDIT : public ParserKeyword {
public:
EDIT();
static const std::string keywordName;
};
class EDITNNC : public ParserKeyword {
public:
EDITNNC();
static const std::string keywordName;
class I1 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class TRAN_MULT {
public:
static const std::string itemName;
};
class SAT_TABLE12 {
public:
static const std::string itemName;
};
class SAT_TABLE21 {
public:
static const std::string itemName;
};
class PRESS_TABLE12 {
public:
static const std::string itemName;
};
class PRESS_TABLE21 {
public:
static const std::string itemName;
};
class FACE_FLOW12 {
public:
static const std::string itemName;
};
class FACE_FLOW21 {
public:
static const std::string itemName;
};
class DIFFM {
public:
static const std::string itemName;
};
};
class EHYSTR : public ParserKeyword {
public:
EHYSTR();
static const std::string keywordName;
class curvature_caplillary_pressure_hyst {
public:
static const std::string itemName;
static const double defaultValue;
};
class relative_perm_hyst {
public:
static const std::string itemName;
static const int defaultValue;
};
class curvature_param_killough_wetting {
public:
static const std::string itemName;
static const double defaultValue;
};
class mod_param_trapped {
public:
static const std::string itemName;
static const double defaultValue;
};
class limiting_hyst_flag {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class shape_cap_press_flag {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class init_fluid_mob_flag {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class wetting_phase_flag {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class baker_flag_oil {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class baker_flag_gas {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class baker_flag_water {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class threshold_saturation {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class END : public ParserKeyword {
public:
END();
static const std::string keywordName;
};
class ENDBOX : public ParserKeyword {
public:
ENDBOX();
static const std::string keywordName;
};
class ENDINC : public ParserKeyword {
public:
ENDINC();
static const std::string keywordName;
};
class ENDNUM : public ParserKeyword {
public:
ENDNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ENDPOINT_SPECIFIERS : public ParserKeyword {
public:
ENDPOINT_SPECIFIERS();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ENDSCALE : public ParserKeyword {
public:
ENDSCALE();
static const std::string keywordName;
class DIRECT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class IRREVERS {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class NUM_TABLES {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUM_NODES {
public:
static const std::string itemName;
static const int defaultValue;
};
class COMB_MODE {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class ENDSKIP : public ParserKeyword {
public:
ENDSKIP();
static const std::string keywordName;
};
class ENKRVD : public ParserKeyword {
public:
ENKRVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class ENPTVD : public ParserKeyword {
public:
ENPTVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class EQLDIMS : public ParserKeyword {
public:
EQLDIMS();
static const std::string keywordName;
class NTEQUL {
public:
static const std::string itemName;
static const int defaultValue;
};
class DEPTH_NODES_P {
public:
static const std::string itemName;
static const int defaultValue;
};
class DEPTH_NODES_TAB {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTTRVD {
public:
static const std::string itemName;
static const int defaultValue;
};
class NSTRVD {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class EQLNUM : public ParserKeyword {
public:
EQLNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class EQLOPTS : public ParserKeyword {
public:
EQLOPTS();
static const std::string keywordName;
class OPTION1 {
public:
static const std::string itemName;
};
class OPTION2 {
public:
static const std::string itemName;
};
class OPTION3 {
public:
static const std::string itemName;
};
class OPTION4 {
public:
static const std::string itemName;
};
};
class EQUALREG : public ParserKeyword {
public:
EQUALREG();
static const std::string keywordName;
class ARRAY {
public:
static const std::string itemName;
};
class VALUE {
public:
static const std::string itemName;
static const double defaultValue;
};
class REGION_NUMBER {
public:
static const std::string itemName;
};
class REGION_NAME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class EQUALS : public ParserKeyword {
public:
EQUALS();
static const std::string keywordName;
class field {
public:
static const std::string itemName;
};
class value {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class EQUIL : public ParserKeyword {
public:
EQUIL();
static const std::string keywordName;
class DATUM_DEPTH {
public:
static const std::string itemName;
static const double defaultValue;
};
class DATUM_PRESSURE {
public:
static const std::string itemName;
};
class OWC {
public:
static const std::string itemName;
static const double defaultValue;
};
class PC_OWC {
public:
static const std::string itemName;
static const double defaultValue;
};
class GOC {
public:
static const std::string itemName;
static const double defaultValue;
};
class PC_GOC {
public:
static const std::string itemName;
static const double defaultValue;
};
class BLACK_OIL_INIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class BLACK_OIL_INIT_WG {
public:
static const std::string itemName;
static const int defaultValue;
};
class OIP_INIT {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class EXCEL : public ParserKeyword {
public:
EXCEL();
static const std::string keywordName;
};
class EXTRAPMS : public ParserKeyword {
public:
EXTRAPMS();
static const std::string keywordName;
class LEVEL {
public:
static const std::string itemName;
static const int defaultValue;
};
};
}
}
#endif

View File

@@ -0,0 +1,145 @@
#ifndef PARSER_KEYWORDS_F_HPP
#define PARSER_KEYWORDS_F_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class FAULTDIM : public ParserKeyword {
public:
FAULTDIM();
static const std::string keywordName;
class MFSEGS {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class FAULTS : public ParserKeyword {
public:
FAULTS();
static const std::string keywordName;
class NAME {
public:
static const std::string itemName;
};
class IX1 {
public:
static const std::string itemName;
};
class IX2 {
public:
static const std::string itemName;
};
class IY1 {
public:
static const std::string itemName;
};
class IY2 {
public:
static const std::string itemName;
};
class IZ1 {
public:
static const std::string itemName;
};
class IZ2 {
public:
static const std::string itemName;
};
class FACE {
public:
static const std::string itemName;
};
};
class FIELD : public ParserKeyword {
public:
FIELD();
static const std::string keywordName;
};
class FIELD_PROBE : public ParserKeyword {
public:
FIELD_PROBE();
static const std::string keywordName;
};
class FILLEPS : public ParserKeyword {
public:
FILLEPS();
static const std::string keywordName;
};
class FIPNUM : public ParserKeyword {
public:
FIPNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class FLUXNUM : public ParserKeyword {
public:
FLUXNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class FMTIN : public ParserKeyword {
public:
FMTIN();
static const std::string keywordName;
};
class FMTOUT : public ParserKeyword {
public:
FMTOUT();
static const std::string keywordName;
};
class FULLIMP : public ParserKeyword {
public:
FULLIMP();
static const std::string keywordName;
};
}
}
#endif

View File

@@ -0,0 +1,491 @@
#ifndef PARSER_KEYWORDS_G_HPP
#define PARSER_KEYWORDS_G_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class GAS : public ParserKeyword {
public:
GAS();
static const std::string keywordName;
};
class GASVISCT : public ParserKeyword {
public:
GASVISCT();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class GCOMPIDX : public ParserKeyword {
public:
GCOMPIDX();
static const std::string keywordName;
class GAS_COMPONENT_INDEX {
public:
static const std::string itemName;
};
};
class GCONINJE : public ParserKeyword {
public:
GCONINJE();
static const std::string keywordName;
class GROUP {
public:
static const std::string itemName;
};
class PHASE {
public:
static const std::string itemName;
};
class CONTROL_MODE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class SURFACE_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class RESV_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class REINJ_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class VOIDAGE_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class FREE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class GUIDE_FRACTION {
public:
static const std::string itemName;
static const double defaultValue;
};
class GUIDE_DEF {
public:
static const std::string itemName;
};
class REINJECT_GROUP {
public:
static const std::string itemName;
};
class VOIDAGE_GROUP {
public:
static const std::string itemName;
};
class WETGAS_TARGET {
public:
static const std::string itemName;
};
};
class GCONPROD : public ParserKeyword {
public:
GCONPROD();
static const std::string keywordName;
class GROUP {
public:
static const std::string itemName;
};
class CONTROL_MODE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class OIL_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class WATER_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class GAS_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class LIQUID_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class EXCEED_PROC {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class RESPOND_TO_PARENT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class GUIDE_RATE {
public:
static const std::string itemName;
};
class GUIDE_RATE_DEF {
public:
static const std::string itemName;
};
class WATER_EXCEED_PROCEDURE {
public:
static const std::string itemName;
};
class GAS_EXCEED_PROCEDURE {
public:
static const std::string itemName;
};
class LIQUID_EXCEED_PROCEDURE {
public:
static const std::string itemName;
};
class RESERVOIR_FLUID_TARGET {
public:
static const std::string itemName;
static const double defaultValue;
};
class RESERVOIR_VOLUME_BALANCE {
public:
static const std::string itemName;
};
};
class GDORIENT : public ParserKeyword {
public:
GDORIENT();
static const std::string keywordName;
class I {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class J {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class K {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class Z {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class HAND {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class GECON : public ParserKeyword {
public:
GECON();
static const std::string keywordName;
class GROUP {
public:
static const std::string itemName;
};
class MIN_OIL_RATE {
public:
static const std::string itemName;
static const double defaultValue;
};
class MIN_GAS_RATE {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_WCT {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_GOR {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_WATER_GAS_RATIO {
public:
static const std::string itemName;
static const double defaultValue;
};
class WORKOVER {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class END_RUN {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class MAX_OPEN_WELLS {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class GEFAC : public ParserKeyword {
public:
GEFAC();
static const std::string keywordName;
class GROUP {
public:
static const std::string itemName;
};
class EFFICIENCY_FACTOR {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRANSFER_EXT_NET {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class GRID : public ParserKeyword {
public:
GRID();
static const std::string keywordName;
};
class GRIDFILE : public ParserKeyword {
public:
GRIDFILE();
static const std::string keywordName;
class GRID {
public:
static const std::string itemName;
static const int defaultValue;
};
class EGRID {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class GRIDOPTS : public ParserKeyword {
public:
GRIDOPTS();
static const std::string keywordName;
class TRANMULT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class NRMULT {
public:
static const std::string itemName;
static const int defaultValue;
};
class NRPINC {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class GRIDUNIT : public ParserKeyword {
public:
GRIDUNIT();
static const std::string keywordName;
class LengthUnit {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class MAP {
public:
static const std::string itemName;
};
};
class GROUP_PROBE : public ParserKeyword {
public:
GROUP_PROBE();
static const std::string keywordName;
class GROUPS {
public:
static const std::string itemName;
};
};
class GRUPNET : public ParserKeyword {
public:
GRUPNET();
static const std::string keywordName;
class NAME {
public:
static const std::string itemName;
};
class TERMINAL_PRESSURE {
public:
static const std::string itemName;
};
class VFP_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class ALQ {
public:
static const std::string itemName;
static const double defaultValue;
};
class SUB_SEA_MANIFOLD {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class LIFT_GAS_FLOW_THROUGH {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class ALQ_SURFACE_EQV {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class GRUPTREE : public ParserKeyword {
public:
GRUPTREE();
static const std::string keywordName;
class CHILD_GROUP {
public:
static const std::string itemName;
};
class PARENT_GROUP {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
}
}
#endif

View File

@@ -0,0 +1,207 @@
#ifndef PARSER_KEYWORDS_I_HPP
#define PARSER_KEYWORDS_I_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class IMBNUM : public ParserKeyword {
public:
IMBNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class IMKRVD : public ParserKeyword {
public:
IMKRVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class IMPES : public ParserKeyword {
public:
IMPES();
static const std::string keywordName;
};
class IMPTVD : public ParserKeyword {
public:
IMPTVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class INCLUDE : public ParserKeyword {
public:
INCLUDE();
static const std::string keywordName;
class IncludeFile {
public:
static const std::string itemName;
};
};
class INIT : public ParserKeyword {
public:
INIT();
static const std::string keywordName;
};
class IPCG : public ParserKeyword {
public:
IPCG();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class IPCW : public ParserKeyword {
public:
IPCW();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISGCR : public ParserKeyword {
public:
ISGCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISGL : public ParserKeyword {
public:
ISGL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISGU : public ParserKeyword {
public:
ISGU();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISOGCR : public ParserKeyword {
public:
ISOGCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISOWCR : public ParserKeyword {
public:
ISOWCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISWCR : public ParserKeyword {
public:
ISWCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISWL : public ParserKeyword {
public:
ISWL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ISWU : public ParserKeyword {
public:
ISWU();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,579 @@
#ifndef PARSER_KEYWORDS_M_HPP
#define PARSER_KEYWORDS_M_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class MAPAXES : public ParserKeyword {
public:
MAPAXES();
static const std::string keywordName;
class X1 {
public:
static const std::string itemName;
};
class Y1 {
public:
static const std::string itemName;
};
class X2 {
public:
static const std::string itemName;
};
class Y2 {
public:
static const std::string itemName;
};
class X3 {
public:
static const std::string itemName;
};
class Y3 {
public:
static const std::string itemName;
};
};
class MAPUNITS : public ParserKeyword {
public:
MAPUNITS();
static const std::string keywordName;
class UNIT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class MAXVALUE : public ParserKeyword {
public:
MAXVALUE();
static const std::string keywordName;
class field {
public:
static const std::string itemName;
};
class value {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class MEMORY : public ParserKeyword {
public:
MEMORY();
static const std::string keywordName;
class UNUSED {
public:
static const std::string itemName;
};
class THOUSANDS_CHAR8 {
public:
static const std::string itemName;
};
};
class MESSAGES : public ParserKeyword {
public:
MESSAGES();
static const std::string keywordName;
class MESSAGE_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class COMMENT_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class WARNING_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class PROBLEM_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class ERROR_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class BUG_PRINT_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class MESSAGE_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class COMMENT_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class WARNING_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class PROBLEM_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class ERROR_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class BUG_STOP_LIMIT {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class METRIC : public ParserKeyword {
public:
METRIC();
static const std::string keywordName;
};
class MINPV : public ParserKeyword {
public:
MINPV();
static const std::string keywordName;
class VALUE {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class MINPVFIL : public ParserKeyword {
public:
MINPVFIL();
static const std::string keywordName;
class VALUE {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class MINVALUE : public ParserKeyword {
public:
MINVALUE();
static const std::string keywordName;
class field {
public:
static const std::string itemName;
};
class value {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class MISC : public ParserKeyword {
public:
MISC();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class MISCIBLE : public ParserKeyword {
public:
MISCIBLE();
static const std::string keywordName;
class NTMISC {
public:
static const std::string itemName;
static const int defaultValue;
};
class NSMISC {
public:
static const std::string itemName;
static const int defaultValue;
};
class TWOPOINT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class MISCNUM : public ParserKeyword {
public:
MISCNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class MONITOR : public ParserKeyword {
public:
MONITOR();
static const std::string keywordName;
};
class MSFN : public ParserKeyword {
public:
MSFN();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
class MSGFILE : public ParserKeyword {
public:
MSGFILE();
static const std::string keywordName;
class ENABLE_FLAG {
public:
static const std::string itemName;
};
};
class MULTFLT : public ParserKeyword {
public:
MULTFLT();
static const std::string keywordName;
class fault {
public:
static const std::string itemName;
};
class factor {
public:
static const std::string itemName;
};
};
class MULTIPLY : public ParserKeyword {
public:
MULTIPLY();
static const std::string keywordName;
class field {
public:
static const std::string itemName;
};
class factor {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
};
class MULTIREG : public ParserKeyword {
public:
MULTIREG();
static const std::string keywordName;
class ARRAY {
public:
static const std::string itemName;
};
class FACTOR {
public:
static const std::string itemName;
static const double defaultValue;
};
class REGION_NUMBER {
public:
static const std::string itemName;
};
class REGION_NAME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class MULTNUM : public ParserKeyword {
public:
MULTNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class MULTPV : public ParserKeyword {
public:
MULTPV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class MULTREGT : public ParserKeyword {
public:
MULTREGT();
static const std::string keywordName;
class SRC_REGION {
public:
static const std::string itemName;
};
class TARGET_REGION {
public:
static const std::string itemName;
};
class TRAN_MULT {
public:
static const std::string itemName;
};
class DIRECTIONS {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class NNC_MULT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class REGION_DEF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class MULT_XYZ : public ParserKeyword {
public:
MULT_XYZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class MW : public ParserKeyword {
public:
MW();
static const std::string keywordName;
class MOLAR_WEIGHT {
public:
static const std::string itemName;
};
};
class MWS : public ParserKeyword {
public:
MWS();
static const std::string keywordName;
class MOLAR_WEIGHT {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,322 @@
#ifndef PARSER_KEYWORDS_N_HPP
#define PARSER_KEYWORDS_N_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class NETBALAN : public ParserKeyword {
public:
NETBALAN();
static const std::string keywordName;
class TIME_INTERVAL {
public:
static const std::string itemName;
static const double defaultValue;
};
class PRESSURE_CONVERGENCE_LIMT {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_ITER {
public:
static const std::string itemName;
static const int defaultValue;
};
class THP_CONVERGENCE_LIMIT {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_ITER_THP {
public:
static const std::string itemName;
static const int defaultValue;
};
class TARGET_BALANCE_ERROR {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_BALANCE_ERROR {
public:
static const std::string itemName;
static const double defaultValue;
};
class MIN_TIME_STEP {
public:
static const std::string itemName;
};
};
class NEWTRAN : public ParserKeyword {
public:
NEWTRAN();
static const std::string keywordName;
};
class NEXTSTEP : public ParserKeyword {
public:
NEXTSTEP();
static const std::string keywordName;
class MAX_STEP {
public:
static const std::string itemName;
};
class APPLY_TO_ALL {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class NNC : public ParserKeyword {
public:
NNC();
static const std::string keywordName;
class I1 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class TRAN {
public:
static const std::string itemName;
static const double defaultValue;
};
class SIM_DEPENDENT1 {
public:
static const std::string itemName;
static const double defaultValue;
};
class SIM_DEPENDENT2 {
public:
static const std::string itemName;
static const double defaultValue;
};
class PRESSURE_TABLE1 {
public:
static const std::string itemName;
static const int defaultValue;
};
class PRESSURE_TABLE2 {
public:
static const std::string itemName;
static const int defaultValue;
};
class VE_FACE1 {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class VE_FACE2 {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class DIFFUSIVITY {
public:
static const std::string itemName;
static const double defaultValue;
};
class SIM_DEPENDENT3 {
public:
static const std::string itemName;
static const double defaultValue;
};
class VDFLOW_AREA {
public:
static const std::string itemName;
static const double defaultValue;
};
class VDFLOW_PERM {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class NOCASC : public ParserKeyword {
public:
NOCASC();
static const std::string keywordName;
};
class NOECHO : public ParserKeyword {
public:
NOECHO();
static const std::string keywordName;
};
class NOGGF : public ParserKeyword {
public:
NOGGF();
static const std::string keywordName;
};
class NOGRAV : public ParserKeyword {
public:
NOGRAV();
static const std::string keywordName;
};
class NOINSPEC : public ParserKeyword {
public:
NOINSPEC();
static const std::string keywordName;
};
class NOMONITO : public ParserKeyword {
public:
NOMONITO();
static const std::string keywordName;
};
class NONNC : public ParserKeyword {
public:
NONNC();
static const std::string keywordName;
};
class NORSSPEC : public ParserKeyword {
public:
NORSSPEC();
static const std::string keywordName;
};
class NOSIM : public ParserKeyword {
public:
NOSIM();
static const std::string keywordName;
};
class NSTACK : public ParserKeyword {
public:
NSTACK();
static const std::string keywordName;
class LINEAR_SOLVER_SIZE {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class NTG : public ParserKeyword {
public:
NTG();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class NUMRES : public ParserKeyword {
public:
NUMRES();
static const std::string keywordName;
class num {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class NUPCOL : public ParserKeyword {
public:
NUPCOL();
static const std::string keywordName;
class NUM_ITER {
public:
static const std::string itemName;
static const int defaultValue;
};
};
}
}
#endif

View File

@@ -0,0 +1,658 @@
#ifndef PARSER_KEYWORDS_P_HPP
#define PARSER_KEYWORDS_P_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class PARALLEL : public ParserKeyword {
public:
PARALLEL();
static const std::string keywordName;
class NDMAIN {
public:
static const std::string itemName;
static const int defaultValue;
};
class MACHINE_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class PATHS : public ParserKeyword {
public:
PATHS();
static const std::string keywordName;
class PathName {
public:
static const std::string itemName;
};
class PathValue {
public:
static const std::string itemName;
};
};
class PBVD : public ParserKeyword {
public:
PBVD();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
class PCG : public ParserKeyword {
public:
PCG();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PERFORMANCE_PROBE : public ParserKeyword {
public:
PERFORMANCE_PROBE();
static const std::string keywordName;
};
class PERMX : public ParserKeyword {
public:
PERMX();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PERMXY : public ParserKeyword {
public:
PERMXY();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PERMY : public ParserKeyword {
public:
PERMY();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class PERMYZ : public ParserKeyword {
public:
PERMYZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PERMZ : public ParserKeyword {
public:
PERMZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class PERMZX : public ParserKeyword {
public:
PERMZX();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PIMTDIMS : public ParserKeyword {
public:
PIMTDIMS();
static const std::string keywordName;
class NTPIMT {
public:
static const std::string itemName;
static const int defaultValue;
};
class NPPIMT {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class PIMULTAB : public ParserKeyword {
public:
PIMULTAB();
static const std::string keywordName;
class TABLE {
public:
static const std::string itemName;
};
};
class PINCH : public ParserKeyword {
public:
PINCH();
static const std::string keywordName;
class THRESHOLD_THICKNESS {
public:
static const std::string itemName;
static const double defaultValue;
};
class CONTROL_OPTION {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class MAX_EMPTY_GAP {
public:
static const std::string itemName;
static const double defaultValue;
};
class PINCHOUT_OPTION {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class MULTZ_OPTION {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class PLMIXPAR : public ParserKeyword {
public:
PLMIXPAR();
static const std::string keywordName;
class TODD_LONGSTAFF {
public:
static const std::string itemName;
};
};
class PLYADS : public ParserKeyword {
public:
PLYADS();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class PLYADSS : public ParserKeyword {
public:
PLYADSS();
static const std::string keywordName;
class POLYMER_C {
public:
static const std::string itemName;
};
class POLYMER_ADS_C {
public:
static const std::string itemName;
};
class DATA {
public:
static const std::string itemName;
};
};
class PLYDHFLF : public ParserKeyword {
public:
PLYDHFLF();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class PLYMAX : public ParserKeyword {
public:
PLYMAX();
static const std::string keywordName;
class MAX_POLYMER_CONCENTRATION {
public:
static const std::string itemName;
};
class MAX_SALT_CONCENTRATION {
public:
static const std::string itemName;
};
};
class PLYROCK : public ParserKeyword {
public:
PLYROCK();
static const std::string keywordName;
class IPV {
public:
static const std::string itemName;
};
class RRF {
public:
static const std::string itemName;
};
class ROCK_DENSITY {
public:
static const std::string itemName;
};
class AI {
public:
static const std::string itemName;
static const double defaultValue;
};
class MAX_ADSORPTION {
public:
static const std::string itemName;
};
};
class PLYSHEAR : public ParserKeyword {
public:
PLYSHEAR();
static const std::string keywordName;
class WATER_VELOCITY {
public:
static const std::string itemName;
};
class VRF {
public:
static const std::string itemName;
};
};
class PLYSHLOG : public ParserKeyword {
public:
PLYSHLOG();
static const std::string keywordName;
class REF_POLYMER_CONCENTRATION {
public:
static const std::string itemName;
};
class REF_SALINITY {
public:
static const std::string itemName;
};
class REF_TEMPERATURE {
public:
static const std::string itemName;
};
class DATA {
public:
static const std::string itemName;
};
};
class PLYVISC : public ParserKeyword {
public:
PLYVISC();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class PMISC : public ParserKeyword {
public:
PMISC();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class POLYMER : public ParserKeyword {
public:
POLYMER();
static const std::string keywordName;
};
class PORO : public ParserKeyword {
public:
PORO();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class PORV : public ParserKeyword {
public:
PORV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PREF : public ParserKeyword {
public:
PREF();
static const std::string keywordName;
class PRESSURE {
public:
static const std::string itemName;
};
};
class PREFS : public ParserKeyword {
public:
PREFS();
static const std::string keywordName;
class PRESSURE {
public:
static const std::string itemName;
};
};
class PRESSURE : public ParserKeyword {
public:
PRESSURE();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PROPS : public ParserKeyword {
public:
PROPS();
static const std::string keywordName;
};
class PVCDO : public ParserKeyword {
public:
PVCDO();
static const std::string keywordName;
class P_REF {
public:
static const std::string itemName;
};
class OIL_VOL_FACTOR {
public:
static const std::string itemName;
};
class OIL_COMPRESSIBILITY {
public:
static const std::string itemName;
};
class OIL_VISCOSITY {
public:
static const std::string itemName;
};
class OIL_VISCOSIBILITY {
public:
static const std::string itemName;
};
};
class PVDG : public ParserKeyword {
public:
PVDG();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PVDO : public ParserKeyword {
public:
PVDO();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PVDS : public ParserKeyword {
public:
PVDS();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PVTG : public ParserKeyword {
public:
PVTG();
static const std::string keywordName;
class GAS_PRESSURE {
public:
static const std::string itemName;
};
class DATA {
public:
static const std::string itemName;
};
};
class PVTNUM : public ParserKeyword {
public:
PVTNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class PVTO : public ParserKeyword {
public:
PVTO();
static const std::string keywordName;
class RS {
public:
static const std::string itemName;
};
class DATA {
public:
static const std::string itemName;
};
};
class PVTW : public ParserKeyword {
public:
PVTW();
static const std::string keywordName;
class P_REF {
public:
static const std::string itemName;
};
class WATER_VOL_FACTOR {
public:
static const std::string itemName;
static const double defaultValue;
};
class WATER_COMPRESSIBILITY {
public:
static const std::string itemName;
static const double defaultValue;
};
class WATER_VISCOSITY {
public:
static const std::string itemName;
static const double defaultValue;
};
class WATER_VISCOSIBILITY {
public:
static const std::string itemName;
static const double defaultValue;
};
};
}
}
#endif

View File

@@ -0,0 +1,461 @@
#ifndef PARSER_KEYWORDS_R_HPP
#define PARSER_KEYWORDS_R_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class RADFIN4 : public ParserKeyword {
public:
RADFIN4();
static const std::string keywordName;
class NAME {
public:
static const std::string itemName;
};
class I1 {
public:
static const std::string itemName;
};
class I2 {
public:
static const std::string itemName;
};
class J1 {
public:
static const std::string itemName;
};
class J2 {
public:
static const std::string itemName;
};
class K1 {
public:
static const std::string itemName;
};
class K2 {
public:
static const std::string itemName;
};
class NR {
public:
static const std::string itemName;
};
class NTHETA {
public:
static const std::string itemName;
};
class NZ {
public:
static const std::string itemName;
};
class NWMAX {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class REGDIMS : public ParserKeyword {
public:
REGDIMS();
static const std::string keywordName;
class NTFIP {
public:
static const std::string itemName;
static const int defaultValue;
};
class NMFIPR {
public:
static const std::string itemName;
static const int defaultValue;
};
class NRFREG {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTFREG {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ETRACK {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTCREG {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_OPERNUM {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_OPERATE_DWORK {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_OPERATE_IWORK {
public:
static const std::string itemName;
static const int defaultValue;
};
class NPLMIX {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class REGIONS : public ParserKeyword {
public:
REGIONS();
static const std::string keywordName;
};
class REGION_PROBE : public ParserKeyword {
public:
REGION_PROBE();
static const std::string keywordName;
class REGIONS {
public:
static const std::string itemName;
};
};
class RESTART : public ParserKeyword {
public:
RESTART();
static const std::string keywordName;
class ROOTNAME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class REPORTNUMBER {
public:
static const std::string itemName;
};
class SAVEFILE {
public:
static const std::string itemName;
};
class SAVEFILE_FORMAT {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class RKTRMDIR : public ParserKeyword {
public:
RKTRMDIR();
static const std::string keywordName;
};
class ROCK : public ParserKeyword {
public:
ROCK();
static const std::string keywordName;
class PREF {
public:
static const std::string itemName;
static const double defaultValue;
};
class COMPRESSIBILITY {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class ROCKCOMP : public ParserKeyword {
public:
ROCKCOMP();
static const std::string keywordName;
class HYSTERESIS {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class NTROCC {
public:
static const std::string itemName;
static const int defaultValue;
};
class WATER_COMPACTION {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class ROCKOPTS : public ParserKeyword {
public:
ROCKOPTS();
static const std::string keywordName;
class METHOD {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class REF_PRESSURE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class TABLE_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class HYST_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class ROCKTAB : public ParserKeyword {
public:
ROCKTAB();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class RPTGRID : public ParserKeyword {
public:
RPTGRID();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class RPTONLY : public ParserKeyword {
public:
RPTONLY();
static const std::string keywordName;
};
class RPTONLYO : public ParserKeyword {
public:
RPTONLYO();
static const std::string keywordName;
};
class RPTPROPS : public ParserKeyword {
public:
RPTPROPS();
static const std::string keywordName;
class mnemonics {
public:
static const std::string itemName;
};
};
class RPTRST : public ParserKeyword {
public:
RPTRST();
static const std::string keywordName;
class MNEMONIC_LIST {
public:
static const std::string itemName;
};
};
class RPTRUNSP : public ParserKeyword {
public:
RPTRUNSP();
static const std::string keywordName;
};
class RPTSCHED : public ParserKeyword {
public:
RPTSCHED();
static const std::string keywordName;
class MNEMONIC_LIST {
public:
static const std::string itemName;
};
};
class RPTSOL : public ParserKeyword {
public:
RPTSOL();
static const std::string keywordName;
class mnemonics {
public:
static const std::string itemName;
};
};
class RS : public ParserKeyword {
public:
RS();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class RSVD : public ParserKeyword {
public:
RSVD();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
class RTEMPVD : public ParserKeyword {
public:
RTEMPVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class RUNSPEC : public ParserKeyword {
public:
RUNSPEC();
static const std::string keywordName;
};
class RUNSUM : public ParserKeyword {
public:
RUNSUM();
static const std::string keywordName;
};
class RV : public ParserKeyword {
public:
RV();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class RVVD : public ParserKeyword {
public:
RVVD();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,639 @@
#ifndef PARSER_KEYWORDS_S_HPP
#define PARSER_KEYWORDS_S_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class SATNUM : public ParserKeyword {
public:
SATNUM();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SATOPTS : public ParserKeyword {
public:
SATOPTS();
static const std::string keywordName;
class options {
public:
static const std::string itemName;
};
};
class SAVE : public ParserKeyword {
public:
SAVE();
static const std::string keywordName;
class FILE_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class SCALECRS : public ParserKeyword {
public:
SCALECRS();
static const std::string keywordName;
class VALUE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class SCHEDULE : public ParserKeyword {
public:
SCHEDULE();
static const std::string keywordName;
};
class SDENSITY : public ParserKeyword {
public:
SDENSITY();
static const std::string keywordName;
class SOLVENT_DENSITY {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class SEPARATE : public ParserKeyword {
public:
SEPARATE();
static const std::string keywordName;
};
class SGAS : public ParserKeyword {
public:
SGAS();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SGCR : public ParserKeyword {
public:
SGCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SGCWMIS : public ParserKeyword {
public:
SGCWMIS();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SGFN : public ParserKeyword {
public:
SGFN();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SGL : public ParserKeyword {
public:
SGL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SGOF : public ParserKeyword {
public:
SGOF();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
class SGU : public ParserKeyword {
public:
SGU();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SGWFN : public ParserKeyword {
public:
SGWFN();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SHRATE : public ParserKeyword {
public:
SHRATE();
static const std::string keywordName;
class SHEAR_RATE {
public:
static const std::string itemName;
};
};
class SKIP : public ParserKeyword {
public:
SKIP();
static const std::string keywordName;
};
class SKIP100 : public ParserKeyword {
public:
SKIP100();
static const std::string keywordName;
};
class SKIP300 : public ParserKeyword {
public:
SKIP300();
static const std::string keywordName;
};
class SKIPREST : public ParserKeyword {
public:
SKIPREST();
static const std::string keywordName;
};
class SLGOF : public ParserKeyword {
public:
SLGOF();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SMRYDIMS : public ParserKeyword {
public:
SMRYDIMS();
static const std::string keywordName;
class DIMS {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class SOF2 : public ParserKeyword {
public:
SOF2();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SOF3 : public ParserKeyword {
public:
SOF3();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SOGCR : public ParserKeyword {
public:
SOGCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SOIL : public ParserKeyword {
public:
SOIL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SOLUTION : public ParserKeyword {
public:
SOLUTION();
static const std::string keywordName;
};
class SOLVENT : public ParserKeyword {
public:
SOLVENT();
static const std::string keywordName;
};
class SORWMIS : public ParserKeyword {
public:
SORWMIS();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SOWCR : public ParserKeyword {
public:
SOWCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SPECGRID : public ParserKeyword {
public:
SPECGRID();
static const std::string keywordName;
class NX {
public:
static const std::string itemName;
static const int defaultValue;
};
class NY {
public:
static const std::string itemName;
static const int defaultValue;
};
class NZ {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUMRES {
public:
static const std::string itemName;
static const int defaultValue;
};
class COORD_TYPE {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class SPECHEAT : public ParserKeyword {
public:
SPECHEAT();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SPECROCK : public ParserKeyword {
public:
SPECROCK();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SSFN : public ParserKeyword {
public:
SSFN();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SSOL : public ParserKeyword {
public:
SSOL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class START : public ParserKeyword {
public:
START();
static const std::string keywordName;
class DAY {
public:
static const std::string itemName;
static const int defaultValue;
};
class MONTH {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class YEAR {
public:
static const std::string itemName;
static const int defaultValue;
};
class TIME {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class STCOND : public ParserKeyword {
public:
STCOND();
static const std::string keywordName;
class TEMPERATURE {
public:
static const std::string itemName;
static const double defaultValue;
};
class PRESSURE {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class STONE1 : public ParserKeyword {
public:
STONE1();
static const std::string keywordName;
};
class STONE1EX : public ParserKeyword {
public:
STONE1EX();
static const std::string keywordName;
class EXP_VALUE {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class SUMMARY : public ParserKeyword {
public:
SUMMARY();
static const std::string keywordName;
};
class SUMTHIN : public ParserKeyword {
public:
SUMTHIN();
static const std::string keywordName;
class TIME {
public:
static const std::string itemName;
};
};
class SWAT : public ParserKeyword {
public:
SWAT();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SWATINIT : public ParserKeyword {
public:
SWATINIT();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SWCR : public ParserKeyword {
public:
SWCR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SWFN : public ParserKeyword {
public:
SWFN();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SWL : public ParserKeyword {
public:
SWL();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class SWOF : public ParserKeyword {
public:
SWOF();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class SWU : public ParserKeyword {
public:
SWU();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,698 @@
#ifndef PARSER_KEYWORDS_T_HPP
#define PARSER_KEYWORDS_T_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class TABDIMS : public ParserKeyword {
public:
TABDIMS();
static const std::string keywordName;
class NTSFUN {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTPVT {
public:
static const std::string itemName;
static const int defaultValue;
};
class NSSFUN {
public:
static const std::string itemName;
static const int defaultValue;
};
class NPPVT {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTFIP {
public:
static const std::string itemName;
static const int defaultValue;
};
class NRPVT {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_RV_NODES {
public:
static const std::string itemName;
};
class NTENDP {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUM_STATE_EQ {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUM_EOS_RES {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUM_EOS_SURFACE {
public:
static const std::string itemName;
};
class MAX_FLUX_REGIONS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_THERMAL_REGIONS {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTROCC {
public:
static const std::string itemName;
};
class MAX_PRESSURE_MAINTAINANCE_REGIONS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_KVALUE_TABLES {
public:
static const std::string itemName;
static const int defaultValue;
};
class NTALPHA {
public:
static const std::string itemName;
};
class ASPHALTENE_ASPKDAM_MAX_ROWS {
public:
static const std::string itemName;
static const int defaultValue;
};
class ASPHALTENE_ASPREWG_MAX_ROWS {
public:
static const std::string itemName;
static const int defaultValue;
};
class ASPHALTENE_ASPVISO_MAX_ROWS {
public:
static const std::string itemName;
static const int defaultValue;
};
class ITEM20_NOT_USED {
public:
static const std::string itemName;
};
class ASPHALTENE_ASPPW2D_MAX_COLUMNS {
public:
static const std::string itemName;
static const int defaultValue;
};
class ASPHALTENE_ASPPW2D_MAX_ROWS {
public:
static const std::string itemName;
static const int defaultValue;
};
class ASPHALTENE_ASPWETF_MAX_ROWS {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUM_KVALUE_TABLES {
public:
static const std::string itemName;
static const int defaultValue;
};
class RESERVED {
public:
static const std::string itemName;
};
};
class TEMP : public ParserKeyword {
public:
TEMP();
static const std::string keywordName;
};
class TEMPI : public ParserKeyword {
public:
TEMPI();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class TEMPVD : public ParserKeyword {
public:
TEMPVD();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class THCONR : public ParserKeyword {
public:
THCONR();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class THERMAL : public ParserKeyword {
public:
THERMAL();
static const std::string keywordName;
};
class THERMEX1 : public ParserKeyword {
public:
THERMEX1();
static const std::string keywordName;
class EXPANSION_COEFF {
public:
static const std::string itemName;
static const double defaultValue;
};
};
class THPRES : public ParserKeyword {
public:
THPRES();
static const std::string keywordName;
class REGION1 {
public:
static const std::string itemName;
};
class REGION2 {
public:
static const std::string itemName;
};
class VALUE {
public:
static const std::string itemName;
};
};
class TITLE : public ParserKeyword {
public:
TITLE();
static const std::string keywordName;
class TitleText {
public:
static const std::string itemName;
};
};
class TLMIXPAR : public ParserKeyword {
public:
TLMIXPAR();
static const std::string keywordName;
class TL_VISCOSITY_PARAMETER {
public:
static const std::string itemName;
};
class TL_DENSITY_PARAMETER {
public:
static const std::string itemName;
};
};
class TLPMIXPA : public ParserKeyword {
public:
TLPMIXPA();
static const std::string keywordName;
class DATA {
public:
static const std::string itemName;
};
};
class TOPS : public ParserKeyword {
public:
TOPS();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class TRACER : public ParserKeyword {
public:
TRACER();
static const std::string keywordName;
class NAME {
public:
static const std::string itemName;
};
class FLUID {
public:
static const std::string itemName;
};
class UNIT {
public:
static const std::string itemName;
};
class SOLUTION_PHASE {
public:
static const std::string itemName;
};
class NUM_PART_TABLE {
public:
static const std::string itemName;
};
class ADSORB_PHASE {
public:
static const std::string itemName;
};
};
class TRACERS : public ParserKeyword {
public:
TRACERS();
static const std::string keywordName;
class MAX_OIL_TRACERS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_WATER_TRACERS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_GAS_TRACERS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ENV_TRACERS {
public:
static const std::string itemName;
static const int defaultValue;
};
class NUMERIC_DIFF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class MAX_ITER {
public:
static const std::string itemName;
static const int defaultValue;
};
class MIN_ITER {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class TRANX : public ParserKeyword {
public:
TRANX();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class TRANY : public ParserKeyword {
public:
TRANY();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class TRANZ : public ParserKeyword {
public:
TRANZ();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class TREF : public ParserKeyword {
public:
TREF();
static const std::string keywordName;
class TEMPERATURE {
public:
static const std::string itemName;
};
};
class TREFS : public ParserKeyword {
public:
TREFS();
static const std::string keywordName;
class TEMPERATURE {
public:
static const std::string itemName;
};
};
class TSTEP : public ParserKeyword {
public:
TSTEP();
static const std::string keywordName;
class step_list {
public:
static const std::string itemName;
};
};
class TUNING : public ParserKeyword {
public:
TUNING();
static const std::string keywordName;
class TSINIT {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSMAXZ {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSMINZ {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSMCHP {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSFMAX {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSFMIN {
public:
static const std::string itemName;
static const double defaultValue;
};
class TSFCNV {
public:
static const std::string itemName;
static const double defaultValue;
};
class TFDIFF {
public:
static const std::string itemName;
static const double defaultValue;
};
class THRUPT {
public:
static const std::string itemName;
static const double defaultValue;
};
class TMAXWC {
public:
static const std::string itemName;
};
class TRGTTE {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGCNV {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGMBE {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGLCV {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXTTE {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXCNV {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXMBE {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXLCV {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXWFL {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGFIP {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGSFT {
public:
static const std::string itemName;
};
class THIONX {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRWGHT {
public:
static const std::string itemName;
static const int defaultValue;
};
class NEWTMX {
public:
static const std::string itemName;
static const int defaultValue;
};
class NEWTMN {
public:
static const std::string itemName;
static const int defaultValue;
};
class LITMAX {
public:
static const std::string itemName;
static const int defaultValue;
};
class LITMIN {
public:
static const std::string itemName;
static const int defaultValue;
};
class MXWSIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class MXWPIT {
public:
static const std::string itemName;
static const int defaultValue;
};
class DDPLIM {
public:
static const std::string itemName;
static const double defaultValue;
};
class DDSLIM {
public:
static const std::string itemName;
static const double defaultValue;
};
class TRGDPR {
public:
static const std::string itemName;
static const double defaultValue;
};
class XXXDPR {
public:
static const std::string itemName;
};
};
class TVDP : public ParserKeyword {
public:
TVDP();
static const std::string keywordName;
class table {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,125 @@
#ifndef PARSER_KEYWORDS_U_HPP
#define PARSER_KEYWORDS_U_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class UDADIMS : public ParserKeyword {
public:
UDADIMS();
static const std::string keywordName;
class NUM_UDQ_REPLACE {
public:
static const std::string itemName;
static const int defaultValue;
};
class IGNORED {
public:
static const std::string itemName;
static const int defaultValue;
};
class TOTAL_UDQ_UNIQUE {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class UDQDIMS : public ParserKeyword {
public:
UDQDIMS();
static const std::string keywordName;
class MAX_FUNCTIONS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ITEMS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_CONNECTIONS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_FIELDS {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_GROUP {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_REGION {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_SEGMENT {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_WELL {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_AQUIFER {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_BLOCK {
public:
static const std::string itemName;
static const int defaultValue;
};
class RESTART_NEW_SEED {
public:
static const std::string itemName;
static const std::string defaultValue;
};
};
class UNIFIN : public ParserKeyword {
public:
UNIFIN();
static const std::string keywordName;
};
class UNIFOUT : public ParserKeyword {
public:
UNIFOUT();
static const std::string keywordName;
};
}
}
#endif

View File

@@ -0,0 +1,288 @@
#ifndef PARSER_KEYWORDS_V_HPP
#define PARSER_KEYWORDS_V_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class VAPOIL : public ParserKeyword {
public:
VAPOIL();
static const std::string keywordName;
};
class VAPPARS : public ParserKeyword {
public:
VAPPARS();
static const std::string keywordName;
class OIL_VAP_PROPENSITY {
public:
static const std::string itemName;
};
class OIL_DENSITY_PROPENSITY {
public:
static const std::string itemName;
};
};
class VFPIDIMS : public ParserKeyword {
public:
VFPIDIMS();
static const std::string keywordName;
class MAX_FLOW_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_THP_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_INJ_VFP_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class VFPINJ : public ParserKeyword {
public:
VFPINJ();
static const std::string keywordName;
class TABLE {
public:
static const std::string itemName;
};
class DATUM_DEPTH {
public:
static const std::string itemName;
};
class RATE_TYPE {
public:
static const std::string itemName;
};
class PRESSURE_DEF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class UNITS {
public:
static const std::string itemName;
};
class BODY_DEF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class FLOW_VALUES {
public:
static const std::string itemName;
};
class THP_VALUES {
public:
static const std::string itemName;
};
class THP_INDEX {
public:
static const std::string itemName;
};
class VALUES {
public:
static const std::string itemName;
};
};
class VFPPDIMS : public ParserKeyword {
public:
VFPPDIMS();
static const std::string keywordName;
class MAX_FLOW_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_THP_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_WCT_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_GCT_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_ALQ_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
class MAX_PROD_VFP_TABLE {
public:
static const std::string itemName;
static const int defaultValue;
};
};
class VFPPROD : public ParserKeyword {
public:
VFPPROD();
static const std::string keywordName;
class TABLE {
public:
static const std::string itemName;
};
class DATUM_DEPTH {
public:
static const std::string itemName;
};
class RATE_TYPE {
public:
static const std::string itemName;
};
class WFR {
public:
static const std::string itemName;
};
class GFR {
public:
static const std::string itemName;
};
class PRESSURE_DEF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class ALQ_DEF {
public:
static const std::string itemName;
};
class UNITS {
public:
static const std::string itemName;
};
class BODY_DEF {
public:
static const std::string itemName;
static const std::string defaultValue;
};
class FLOW_VALUES {
public:
static const std::string itemName;
};
class THP_VALUES {
public:
static const std::string itemName;
};
class WFR_VALUES {
public:
static const std::string itemName;
};
class GFR_VALUES {
public:
static const std::string itemName;
};
class ALQ_VALUES {
public:
static const std::string itemName;
};
class THP_INDEX {
public:
static const std::string itemName;
};
class WFR_INDEX {
public:
static const std::string itemName;
};
class GFR_INDEX {
public:
static const std::string itemName;
};
class ALQ_INDEX {
public:
static const std::string itemName;
};
class VALUES {
public:
static const std::string itemName;
};
};
class VISCREF : public ParserKeyword {
public:
VISCREF();
static const std::string keywordName;
class REFERENCE_PRESSURE {
public:
static const std::string itemName;
};
class REFERENCE_RS {
public:
static const std::string itemName;
};
};
}
}
#endif

View File

@@ -0,0 +1,87 @@
#ifndef PARSER_KEYWORDS_Z_HPP
#define PARSER_KEYWORDS_Z_HPP
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
namespace ParserKeywords {
class ZCORN : public ParserKeyword {
public:
ZCORN();
static const std::string keywordName;
class data {
public:
static const std::string itemName;
};
};
class ZFACT1 : public ParserKeyword {
public:
ZFACT1();
static const std::string keywordName;
class Z0 {
public:
static const std::string itemName;
};
};
class ZFACT1S : public ParserKeyword {
public:
ZFACT1S();
static const std::string keywordName;
class Z0 {
public:
static const std::string itemName;
};
};
class ZFACTOR : public ParserKeyword {
public:
ZFACTOR();
static const std::string keywordName;
class Z0 {
public:
static const std::string itemName;
};
};
class ZFACTORS : public ParserKeyword {
public:
ZFACTORS();
static const std::string keywordName;
class Z0 {
public:
static const std::string itemName;
};
};
class ZIPPY2 : public ParserKeyword {
public:
ZIPPY2();
static const std::string keywordName;
class SETTINGS {
public:
static const std::string itemName;
};
};
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
*~
*.user
.dir-locals.el
gmon.out
log.log
build
install
.cproject
.project
/testdata/statoil
.idea
/Debug/

View File

@@ -0,0 +1,36 @@
language: cpp
matrix:
fast_finish: true
include:
- os: osx
osx_image: xcode7.3
compiler: clang
- os: linux
compiler: gcc
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
packages:
- libboost1.55-all-dev
- gcc-4.8
- g++-4.8
- gfortran-4.8
- liblapack-dev
- clang
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8" FC="gfortran-4.8"; fi
- cd ..
- git clone https://github.com/OPM/opm-common.git
- git clone https://github.com/OPM/opm-data.git
- opm-common/travis/build-opm-common-shared.sh
- opm-parser/travis/clone-and-build-ert.sh
script: opm-parser/travis/build-and-test-opm-parser.sh

View File

@@ -0,0 +1,184 @@
cmake_minimum_required (VERSION 2.6)
project (OPMParser CXX)
enable_testing()
enable_language(C)
include(CTest)
include(TestCXXAcceptsFlag)
# project information is in dune.module. Read this file and set variables.
# we cannot generate dune.module since it is read by dunecontrol before
# the build starts, so it makes sense to keep the data there then.
set( OPM_COMMON_ROOT "" CACHE PATH "Root directory containing OPM related cmake modules")
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
option(BUILD_TESTING "Build test applications by default?" ON)
if(NOT OPM_COMMON_ROOT)
find_package(opm-common QUIET)
endif()
#-----------------------------------------------------------------
option (ENABLE_PYTHON "Enable simple python wappers" OFF)
if (ENABLE_PYTHON)
if (NOT BUILD_SHARED_LIBS)
set( BUILD_SHARED_LIBS ON)
message( WARNING "When ENABLE_PYTHON is ON we must use shared libraries - forcing BUILD_SHARED_LIBS to ON")
endif()
endif()
#-----------------------------------------------------------------
if (NOT opm-common_FOUND)
unset(opm-common_FOUND)
if (NOT OPM_COMMON_ROOT AND SIBLING_SEARCH)
set(OPM_COMMON_ROOT ${PROJECT_SOURCE_DIR}/../opm-common)
endif()
if (OPM_COMMON_ROOT)
list( APPEND CMAKE_MODULE_PATH "${OPM_COMMON_ROOT}/cmake/Modules")
include (OpmInit OPTIONAL RESULT_VARIABLE OPM_INIT)
set( OPM_MACROS_ROOT ${OPM_COMMON_ROOT} )
endif()
if (NOT OPM_INIT)
message( "" )
message( " /---------------------------------------------------------------------------------\\")
message( " | Could not locate the opm build macros. The opm build macros |")
message( " | are in a separate repository - instructions to proceed: |")
message( " | |")
message( " | 1. Clone the repository: git clone git@github.com:OPM/opm-common.git |")
message( " | |")
message( " | 2. Run cmake in the current project with -DOPM_COMMON_ROOT=<path>/opm-common |")
message( " | |")
message( " \\---------------------------------------------------------------------------------/")
message( "" )
message( FATAL_ERROR "Could not find OPM Macros")
endif()
else()
include(OpmInit)
endif()
include(UseMultiArch)
include(OpmSatellites)
include(UseWarnings)
#-----------------------------------------------------------------
# This is modified copy & paste from the OpmDefaults.cmake module.
option (USE_RUNPATH "Embed original dependency paths in installed library" ON)
if (USE_RUNPATH)
check_cxx_accepts_flag("-Wl,--enable-new-dtags" HAVE_RUNPATH)
if (HAVE_RUNPATH)
SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags")
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
endif (USE_RUNPATH)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
else()
if (NOT DEFINED CMAKE_CXX_FLAGS)
SET( CMAKE_CXX_FLAGS "-pipe -std=c++0x -pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls")
endif()
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3")
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -mtune=native")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (NOT DEFINED CMAKE_C_FLAGS)
SET( CMAKE_C_FLAGS "-pipe -Wall -Wno-unknown-pragmas -std=c99")
endif()
SET( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3")
SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG -mtune=native")
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)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
# if we are using dynamic boost, the header file must generate a main() function
if (NOT Boost_USE_STATIC_LIBS)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif ()
find_package(CXX11Features)
if (HAVE_REGEX)
add_definitions(-DHAVE_REGEX=${HAVE_REGEX})
endif()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
find_package(cjson)
if (HAVE_CJSON)
include_directories( ${CJSON_INCLUDE_DIR} )
else()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/opm/json" )
endif()
include( cmake/Modules/CheckCaseSensitiveFileSystem.cmake )
add_definitions("-DHAVE_CASE_SENSITIVE_FILESYSTEM=${HAVE_CASE_SENSITIVE_FILESYSTEM}")
find_package(opm-common)
include_directories( ${opm-common_INCLUDE_DIRS} )
include( Findopm-data )
find_package(ERT)
include_directories( ${ERT_INCLUDE_DIRS} )
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
add_subdirectory(opm/json)
add_subdirectory(opm/parser)
add_custom_target(check ${CMAKE_CTEST_COMMAND} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_dependencies(check test-suite)
# use this target to check local git commits
add_custom_target(check-commits
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${OPM_MACROS_ROOT}/cmake/Scripts/CheckCommits.cmake)
# This commands should be run unconditionally; i.e. the testdata
# directory should be copied to the EXECUTABLE_OUTPUT_PATH for each
# invocation of cmake. This dependencies are currently not correctly
# handled.
file(COPY ${PROJECT_SOURCE_DIR}/testdata DESTINATION ${EXECUTABLE_OUTPUT_PATH})
install(FILES dune.module DESTINATION lib/dunecontrol/opm-parser)
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_TARGET opmparser)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
opm_cmake_config(opm-parser)
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")

View File

@@ -0,0 +1,10 @@
# opm-parser ![alt text](https://travis-ci.org/OPM/opm-parser.svg?branch=master "TravisCI Build Status")
### eclipse
A small library for parsing the ECLIPSE datafile.
Dependencies:
- boost version 1.45 or newer. If cmake does not find it, specify the
boost root when running cmake, like this:
`cmake -DBOOST_ROOT=/path/to/boost path/to/project`

View File

@@ -0,0 +1,29 @@
#
# Module to check whether the file system is case sensitive or not
#
# Sets the following variable:
#
# HAVE_CASE_SENSITIVE_FILESYSTEM True if the file system honors the case of files
message(STATUS "Checking whether the file system is case-sensitive")
# create a file containing uppercase characters
file(WRITE "${CMAKE_BINARY_DIR}/UPPER" "Foo")
# check if the all-lowercase file with the same name can be opened
set(FooContents "")
if (EXISTS "${CMAKE_BINARY_DIR}/upper")
file(READ "${CMAKE_BINARY_DIR}/upper" FooContents)
endif()
# remove the file again in order not to have it dangling around...
file(REMOVE "${CMAKE_BINARY_DIR}/UPPER")
# check the contents of the file opened with lower-case. If it is
# empty, the file system is case sensitive.
if ("${FooContents}" STREQUAL "Foo")
message(STATUS "File system is not case-sensitive")
set(HAVE_CASE_SENSITIVE_FILESYSTEM 0)
else()
message(STATUS "File system is case-sensitive")
set(HAVE_CASE_SENSITIVE_FILESYSTEM 1)
endif()

View File

@@ -0,0 +1,8 @@
function ( install_headers header-list prefix )
foreach (header ${header-list})
set( abs_path "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
get_filename_component( path ${abs_path} PATH )
file( RELATIVE_PATH rel_path "${PROJECT_SOURCE_DIR}" "${path}")
install ( FILES ${header} DESTINATION ${prefix}/include/${rel_path} )
endforeach()
endfunction()

View File

@@ -0,0 +1,35 @@
#!/bin/sh
# this file is supposed to be located in the source directory
src_dir=$(dirname $0)
# scan the arguments and set this if build macros could be specified
mod_dir=
for OPT in "$@"; do
case "$OPT" in
--with-opm-common=*)
# remove everything before equal sign and assign the rest
mod_dir=${OPT#*=}
# tilde expansion; note that doing eval may have side effects
mod_dir=$(eval echo $mod_dir)
# absolute path
[ -d "$mod_dir" ] && mod_dir=$(cd $mod_dir ; pwd)
;;
esac
done
# if it isn't specified, the look around in other known places
conf_file=cmake/Scripts/configure
if [ -z "$mod_dir" ]; then
if [ -r "$src_dir/$conf_file" ]; then
mod_dir="$src_dir"
fi
fi
# terminate with error message here if the module directory is not found
if [ ! -r "$mod_dir/$conf_file" ]; then
echo Build macros not located in \"$mod_dir\", use --with-opm-common= to specify! 1>&2
exit 1
fi
# forward to the corresponding script in the cmake/Scripts/ directory
exec "$mod_dir/$conf_file" --src-dir="$src_dir" "$@"

View File

@@ -0,0 +1,5 @@
opm-parser (2015.01-1~trusty) trusty; urgency=low
* New release
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Tue, 22 Oct 2013 12:22:29 +0200

View File

@@ -0,0 +1 @@
9

View File

@@ -0,0 +1,41 @@
Source: opm-parser
Priority: extra
Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no>
Build-Depends: build-essential, debhelper (>= 9), pkg-config, libopm-common-dev,
cmake, libtinyxml-dev, bc, libboost-filesystem-dev, zlib1g-dev,
libert.ecl-dev, git, libtool, doxygen, libboost-date-time-dev,
texlive-latex-extra, texlive-latex-recommended, ghostscript,
libboost-system-dev, libboost-test-dev, libboost-regex-dev
Standards-Version: 3.9.2
Section: libs
Homepage: http://opm-project.org
Vcs-Git: git://github.com/OPM/opm-core.git
Vcs-Browser: https://github.com/OPM/opm-core
Package: libopm-parser1-dev
Section: libdevel
Architecture: any
Multi-Arch: foreign
Depends: libopm-parser1 (= ${binary:Version})
Provides: libopm-parser-dev
Suggests: libopm-parser1-doc
Description: OPM parser library -- development files
The OPM parser library is the eclipse parser library within OPM
Package: libopm-parser1
Section: libs
Pre-Depends: ${misc:Pre-Depends}, multiarch-support
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: libopm-parser
Description: OPM parser library
The OPM parser library is the eclipse parser library within OPM
Package: libopm-parser1-dbg
Section: debug
Architecture: any
Multi-Arch: foreign
Provides: libopm-parser-dbg
Depends: libopm-parser1 (= ${binary:Version}), ${misc:Depends}
Description: OPM parser library -- debug symbols

View File

@@ -0,0 +1,13 @@
License: GPL-3+
This package 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.
This package 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 this program. If not, see <http://www.gnu.org/licenses/>

View File

@@ -0,0 +1 @@
README.md

View File

@@ -0,0 +1,5 @@
usr/include/*
usr/lib/*/lib*.so
usr/lib/dunecontrol/*
usr/share/cmake/*
usr/lib/*/pkgconfig/*

View File

@@ -0,0 +1 @@
usr/lib/*/lib*.so.*

View File

@@ -0,0 +1,29 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@
override_dh_auto_clean:
dh_auto_clean --buildsystem=cmake
override_dh_auto_build:
dh_auto_build --buildsystem=cmake
# consider using -DUSE_VERSIONED_DIR=ON if backporting
override_dh_auto_configure:
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1
override_dh_installdocs:
dh_installdocs --link-doc=libopm-parser1
override_dh_strip:
dh_strip -plibopm-parser1 --dbg-package=libopm-parser1-dbg

View File

@@ -0,0 +1 @@
1.0

View File

@@ -0,0 +1,336 @@
Keywords is the most important aspect of the ECLIPSE datafile
parser.
1. The structure of a keyword
-----------------------------
A keyword is the fundamental unit when parsing. Keywords are added to
the parser by schema definitions. The schema definition of the keywords
are given as Json files under the opm/share/keywords directory. Json
can be thought of as a lean alternative to XML, you will find it described
here: http://www.json.org/
As part of the build process these keyword definitions are compiled
to ParserKeyword instances.
1.1 Starting a keyword
----------------------
The keywords are defined as follows:
1. The keyword should start in column 0; everything beyond character
8 is ignored.
2. The keyword should start with a alphabet character, subsequent
characters should be alphanumeric or in the set [-,_,+].
3. We think ECLIPSE is case insensitive.
This is cehcked by the static method:
ParserKeyword::validDeckName(). An important part of the parsing of
keywords is to detect when the keyword specification is complete. For
most keywords we can detect that either by a terminating '/' or the
keywords have a predefined size, but for some odd keywords we can not
reliably detect the end-of-keyword condition and instead we terminate
keyword1 when we find a string which corresponds to the start of a new
keyword. Examples of such oddball keywords include: VFPPROD and
VFPINJ.
1.2 Records
-----------
The data content of a keyword comes as a collection of
records. Records are a collection of 'data', terminated by a '/'. Here
are three examples of records:
'METRES' /
1 'OFF' 100 '*' 24.0 /
0.26 0.27 0.26 0.78
0.82 0.66 0.27 0.78
0.76 0.56 0.23 0.67 /
From these examples we see that:
1. One record can contain a mix of integer, float and string values.
2. Records typically correspond to one line in the data-file, but
that is purely convention; the records can be sprinkled with
newlines.
3. Each record is terminated with a '/'
1.3 How many records in a keyword
---------------------------------
One of the first structural elements which must be configured into the
the parser keywords is the number of records in the different
keywords, this is closely related to how the keyboard is
terminated. Here comes some typical examples of keywords:
GRID
WCONHIST
... /
... /
... /
/
---\
EQLDIMS |
.... / |
|
EQUIL |
.... / |
.... / |
---/
VFPPROD
A .. /
B... /
.... /
.... /
PVGO
/
/
In the list above here the GRID keyword has zero records, i.e. no data
at all. The WCONHIST keyword has three records of data, the EQLDIMS
keyword has one record, the EQUIL keyword has two records and finally
the VFPPROD keyword has four records. The number of records, or how to
infer it, must be configured with the "size" attribute in the JSON
configuration. When it comes to the number of records and termination
we currently have five different categories:
1. Keywords with a fixed number of records. Both the GRID keyword
and the EQLDIMS keyword have a fixed number of records, zero and
one respectively. These keywords are therefor not explicitly
terminated in any way, and the "size" attribute has the numerical
explicitly:
{"name" : "EQLDIMS" , "size" : 1 , ....}
{"name" : "GRID" , "size" : 0, .... }
2. Keywords with a variable number of records like the
WCONHIST. Becase the number of records is not known in advance
this keyword must be explicitly terminated with a '/'. This is
the most common configuration and for keywords of this type it is
not necessary to specify a size attribute at all:
{"name" : "WCONHIST" , .... }
3. Keywords where the number of records is inferred from the content
of another keyword; this is the case with EQUIL which reads the
number of records from the xxx item of the EQLDIMS keyword. Since
the number of records is known in advance (indirectly through the
EQLDIMS keyword) the EQUIL keyword is not explicitly terminated
with a '/'. In the json file this is specified with the "size"
attribute being an object containing the name and item of keyword
which should be consulted to infer the size; so for the EQUIL
keyword the size attribute looks like:
{"name" : "EQUIL" ,
"size" : {"keyword" : "EQLDIMS" , "item" : "NTEQUL"} , ...
When parsing the EQUIL keyword the parser will consult the
already parsed content of the 'EQLDIMS' keyword (i.e. a
DeckKeyword instance) and get the numerical value of the 'NTEQUL'
item.
4. For some keywords the number of records should be calculated
run-time based based on the content of the first records in the
keyword - this at least applies to VFPPROD and VFPINJ. Since the
size of the keyword is deterministic - given the first few
records - the keyword is not slash terminated.
To infer the number of records in the keyword based on an
internal calculation is not supported, hence for these keywords
size is given as unkown, and the keywords are terminated when the
next valid keyword is found:
{"name" : "VFPPROD" , "size" : "UNKNOWN", ....
5. Tables PVTG and PVTO: The two tables PVTG and PVTO are special
cased. The special casing should probably be removed, and the
"size" : "UNKNOWN" could be used for these two keyword.
1.4 The content of a record: items
----------------------------------
A record consist of one or several items. An item can consist of one
or several values from the record, for items with more than one value
it is not possible to specify the exact number of values - the item
will just consume the remaining values in the input stream. An item
has a name, a data type and optionally a default value. For instance
the WCONHIST keyword has the the following items specification:
"items":
[{"name" : "WELL" , "value_type" : "STRING"},
{"name" : "STATUS" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "CMODE" , "value_type" : "STRING"},
{"name" : "ORAT" , "value_type" : "DOUBLE", "default" : 0.0, "dimension" : "LiquidSurfaceVolume/Time"},
{"name" : "WRAT" , "value_type" : "DOUBLE" , "default" : 0.0, "dimension" : "LiquidSurfaceVolume/Time"},
{"name" : "GRAT" , "value_type" : "DOUBLE" , "default" : 0.0, "dimension" : "GasSurfaceVolume/Time"},
{"name" : "VFPTable" , "value_type" : "INT" , "default" : 0.0 , "comment":"The default is a state variable"},
{"name" : "Lift" , "value_type" : "DOUBLE" , "default" : 0.0 , "comment":"The default is a state variable"},
{"name" : "THP" , "value_type" : "DOUBLE" , "default" : 0.0 , "dimension" : "Pressure"},
{"name" : "BHP" , "value_type" : "DOUBLE" , "default" : 0.0 ,"dimension" : "Pressure"},
{"name" : "NGLRAT" , "value_type" : "DOUBLE" , "default" : 0.0 ,"dimension" : "LiquidSurfaceVolume/Time"}]}
Here we can see the following:
1. The items can be of types string, integer and float, the type is
specified with the "value_type" attribute which must equal
"STRING", "DOUBLE" or "INT".
2. You can optionally specify a default value, see the discussion of
the parsing workflow below for the treatment of defaults.
3. For items of type double you can specify a dimension, see XXXX for
the available dimensions. For quantities with a dimension the
parser will convert to SI units, and the DeckDoubleItem class has
a getSIDouble() and getRawDouble() method.
Items consuming the rest of the record
--------------------------------------
Most of the items will consume exactly one value from the input deck,
but it is also possible that the last item consumes the remaining
items in the input deck, these typically correspond to table keywords
or lists of memnonics. In the input deck the PVTG keyword will
typically appear like this:
PVTG
200 0.15 0.15 10
0.20 0.20 12
0.25 0.20 15 /
250 0.05 0.05 20
0.15 0.10 40 /
...
In the manual this is described as two tables with three columns, one
with three rows and one with two rows. The leading values of 200 and
250 are the pressure values where the two tables apply. The visual
formatting in the deck, and also the written desciption in the manual,
strongly hints at a table structure - however from a parsing point of
view this corresponds to just two records of different length. Both
records start with a pressure value, and then follows 3n consecutive
values. The item configuration of PVTG looks like this:
"items" : [
{"name":"GAS_PRESSURE", "value_type" : "DOUBLE", "dimension":"Pressure" },
{"name":"DATA", "size_type" : "ALL" , "value_type":"DOUBLE" ,
"dimension" : ["OilDissolutionFactor","OilDissolutionFactor","Viscosity"]}
]
I.e. first we consume one value from the input deck and assign it to
the GAS_PRESSURE item, then the DATA item has "size_type" : "ALL" -
meaning that this item will consume the the rest of the values in the
input record. Also observe that for the "DATA" item the dimension is a
vector of three elements, when converting to SI the dimension applied
to element i is given as:
dim[i] = dimension[i % 3]
In addition to tables the grid property keywords use items which
consume the rest of the record. For instance the PORO keyword will
typcially look like this in the input deck:
PORO
0.14 0.15 0.0 0.10
0.16 0.25 0.1 0.11
0.14 0.15 0.0 0.09
...
0.21 0.07 0.1 0.13
/
From a parsing point of view this is one single record; which contains
one item consuming all of the values in the input deck. In the
configuration this could have been configured as:
"items" : [{"name" : "DATA",
"value_type" : "DOUBLE" ,
"size_type" : "ALL" ,
"default" : 0 ,
"dimension" : "1"}]
However, since keywords containing large data arrays, like e.g. COORD
and PERMX are quite common a shortcut has been created for such
keywords, for instance the PORO keyword is configures as:
{"name" : "PORO" , "sections" : ["GRID"],
"data" : {"value_type" : "DOUBLE" , "default" : 0 , "dimension":"1"}}
i.e. the "data" attribute is used as shorthand to configure a keyword
with one record and one item which consumes all the data of the input
deck.
Multirecord keyword configuration
---------------------------------
Units and dimensions
--------------------
The values given in the input dataset are generally dimensionfull, and
before the simulator can start we must convert to internal SI values
based on the unit system used in the input deck. In the input deck the
different physical quantities are generally expressed with
per-quantity units. The unit system is *not* based on selecting a unit
for the fundamental dimensions length, mass and time and then deriving
composite units based on the dimension of the composite quantity. As a
consequence the list of dimensions supported by the parser is long,
and growing. The current list can be found in the source file:
opm/parser/eclipse/Units/UnitSystem.cpp
Default values
--------------
Classes:
--------
The library contains classes along two dimensions:
+----------------+ +----------------+ +----------------+
| Parser | | RawDeck | | Deck |
+----------------+ +----------------+ +----------------+
+----------------+ +----------------+ +----------------+
| ParserKeyword | | Rawkeyword | | DeckKeyword |
+----------------+ +----------------+ +----------------+
+----------------+ +----------------+ +----------------+
| ParserRecord | | RawRecord | | DeckRecord |
+----------------+ +----------------+ +----------------+
+----------------+ +----------------+
| ParserItem | | DeckItem |
+----------------+ +----------------+

View File

@@ -0,0 +1,13 @@
####################################################################
# Dune module information file: This file gets parsed by dunecontrol
# and by the CMake build scripts.
####################################################################
Module: opm-parser
Description: Open Porous Media Initiative File Parser Library
Version: 2016.10-pre
Label: 2016.10-pre
Maintainer: joaho@statoil.com
MaintainerName: Joakim Hove
Url: http://opm-project.org
Depends: opm-common

View File

@@ -0,0 +1,21 @@
# opm-parser jenkins build scripts:
**build-opm-parser.sh**:
This is a helper script which contains a function for building,
testing and cloning opm-parser and its dependencies.
**build.sh**:
This script will build dependencies, then build opm-parser and execute its tests.
It is intended for post-merge builds of the master branch.
**build-pr.sh**:
This script will build dependencies, then build opm-parser and execute its tests.
It inspects the $ghbPrBuildComment environmental variable to obtain a pull request
to use for for ert and opm-common (defaults to master)
and then builds $sha1 of opm-parser.
It is intended for pre-merge builds of pull requests.
You specify a given pull request to use for opm-common through the trigger.
The trigger line needs to contain ert=&lt;pull request number&gt; and/or
opm-common=&lt;pull request number&gt;.

View File

@@ -0,0 +1,50 @@
#!/bin/bash
function build_opm_parser {
# Build ERT
pushd .
mkdir -p $WORKSPACE/deps/ert
cd $WORKSPACE/deps/ert
git init .
git remote add origin https://github.com/Ensembles/ert
git fetch --depth 1 origin $ERT:branch_to_build
test $? -eq 0 || exit 1
git checkout branch_to_build
popd
pushd .
mkdir -p serial/build-ert
cd serial/build-ert
cmake $WORKSPACE/deps/ert/devel -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install
make install
popd
# Build opm-common
pushd .
mkdir -p $WORKSPACE/deps/opm-common
cd $WORKSPACE/deps/opm-common
git init .
git remote add origin https://github.com/OPM/opm-common
git fetch --depth 1 origin $OPM_COMMON_REVISION:branch_to_build
test $? -eq 0 || exit 1
git checkout branch_to_build
popd
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
pushd .
mkdir serial/build-opm-common
cd serial/build-opm-common
build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 0 $WORKSPACE/deps/opm-common
popd
# Setup opm-data
source $WORKSPACE/deps/opm-common/jenkins/setup-opm-data.sh
# Build opm-parser
pushd .
mkdir serial/build-opm-parser
cd serial/build-opm-parser
build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install -DOPM_DATA_ROOT=$OPM_DATA_ROOT" 1 $WORKSPACE
test $? -eq 0 || exit 1
popd
}

View File

@@ -0,0 +1,53 @@
#!/bin/bash
source `dirname $0`/build-opm-parser.sh
# Upstream revisions
ERT_REVISION=master
OPM_COMMON_REVISION=master
if grep -q "ert=" <<< $ghprbCommentBody
then
ERT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*ert=([0-9]+).*/\1/g'`/merge
fi
if grep -q "opm-common=" <<< $ghprbCommentBody
then
OPM_COMMON_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge
fi
echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$sha1"
build_opm_parser
test $? -eq 0 || exit 1
# If no downstream builds we are done
if ! grep -q "with downstreams" <<< $ghprbCommentBody
then
cp serial/build-opm-parser/testoutput.xml .
exit 0
fi
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
# Downstream revisions
declare -a downstreams
downstreams=(opm-material
opm-core
opm-grid
opm-output
opm-simulators
opm-upscaling
ewoms)
declare -A downstreamRev
downstreamRev[opm-material]=master
downstreamRev[opm-core]=master
downstreamRev[opm-grid]=master
downstreamRev[opm-output]=master
downstreamRev[opm-simulators]=master
downstreamRev[opm-upscaling]=master
downstreamRev[ewoms]=master
build_downstreams opm-parser
test $? -eq 0 || exit 1

View File

@@ -0,0 +1,11 @@
#!/bin/bash
source `dirname $0`/build-opm-parser.sh
ERT_REVISION=master
OPM_COMMON_REVISION=master
build_opm_parser
test $? -eq 0 || exit 1
cp serial/build-opm-parser/testoutput.xml .

View File

@@ -0,0 +1,23 @@
set( json_source JsonObject.cpp )
set( json_headers JsonObject.hpp )
if (NOT HAVE_CJSON)
list(APPEND json_source cjson/cJSON.c)
set( CJSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
set(CJSON_LIBRARY "")
endif()
include_directories(
${Boost_INCLUDE_DIRS}
)
add_library(opmjson ${json_source})
target_link_libraries( opmjson ${CJSON_LIBRARY} ${Boost_LIBRARIES} )
#set_target_properties(opmjson PROPERTIES VERSION ${opm-parser_VERSION_MAJOR}.${opm-parser_VERSION_MINOR}
# SOVERSION ${opm-parser_VERSION_MAJOR})
install( TARGETS opmjson DESTINATION ${CMAKE_INSTALL_LIBDIR} )
foreach ( header ${json_headers} )
install( FILES ${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/opm/json RENAME ${header})
endforeach()
#add_subdirectory( tests )

View File

@@ -0,0 +1,206 @@
/*
Copyright 2013 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 <string>
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <opm/json/JsonObject.hpp>
#include "cjson/cJSON.h"
namespace Json {
void JsonObject::initialize(const std::string& inline_json) {
root = cJSON_Parse( inline_json.c_str() );
if (!root)
throw std::invalid_argument("Parsing json input failed");
owner = true;
}
JsonObject::JsonObject(const std::string& inline_json) {
initialize( inline_json );
}
JsonObject::JsonObject(const char * inline_json) {
initialize( inline_json );
}
JsonObject::JsonObject(const boost::filesystem::path& jsonFile ) {
std::ifstream stream(jsonFile.string().c_str());
if (stream) {
std::string content_from_file( (std::istreambuf_iterator<char>(stream)),
(std::istreambuf_iterator<char>()));
initialize( content_from_file );
} else
throw std::invalid_argument("Loading json from file: " + jsonFile.string() + " failed.");
}
JsonObject::JsonObject( cJSON * object ) {
root = object;
owner = false;
}
JsonObject::~JsonObject() {
if (owner && root)
cJSON_Delete(root);
}
bool JsonObject::has_item( const std::string& key) const {
cJSON * object = cJSON_GetObjectItem( root , key.c_str() );
if (object)
return true;
else
return false;
}
bool JsonObject::is_array( ) const {
if (root->type == cJSON_Array)
return true;
else
return false;
}
bool JsonObject::is_number( ) const {
if (root->type == cJSON_Number)
return true;
else
return false;
}
bool JsonObject::is_string( ) const {
if (root->type == cJSON_String)
return true;
else
return false;
}
bool JsonObject::is_object( ) const {
if (root->type == cJSON_Object)
return true;
else
return false;
}
size_t JsonObject::size() const {
int int_size = cJSON_GetArraySize( root );
return (size_t) int_size;
}
JsonObject JsonObject::get_array_item( size_t index ) const {
if (is_array()) {
cJSON * new_c_ptr = cJSON_GetArrayItem( root , index );
if (new_c_ptr)
return JsonObject( new_c_ptr );
else
throw std::invalid_argument("Index is out ouf range.");
} else
throw std::invalid_argument("Object is not an array.");
}
JsonObject JsonObject::get_item(const std::string& key) const {
cJSON * c_ptr = cJSON_GetObjectItem( root , key.c_str() );
if (c_ptr)
return JsonObject( c_ptr );
else
throw std::invalid_argument("Key: " + key + " does not exist in json object");
}
std::string JsonObject::get_string(const std::string& key) const {
JsonObject child = get_scalar_object( key );
return child.as_string();
}
std::string JsonObject::as_string() const {
if (is_string())
return root->valuestring;
else
throw std::invalid_argument("Object is not a string object");
}
int JsonObject::get_int(const std::string& key) const {
JsonObject child = get_scalar_object( key );
return child.as_int( );
}
int JsonObject::as_int() const {
if (root->type == cJSON_Number)
return root->valueint;
else
throw std::invalid_argument("Object is not a number object.");
}
double JsonObject::get_double(const std::string& key) const {
JsonObject child = get_scalar_object( key );
return child.as_double( );
}
double JsonObject::as_double() const {
if (root->type == cJSON_Number)
return root->valuedouble;
else
throw std::invalid_argument("Object is not a number object.");
}
JsonObject JsonObject::get_scalar_object(const std::string& key) const{
JsonObject child = get_item( key );
if (child.size())
throw std::invalid_argument("Key: " + key + " is not a scalar object");
else
return child;
}
std::string JsonObject::to_string() const {
char * c_str = cJSON_Print( root );
std::string s(c_str);
free( c_str );
return s;
}
}

View File

@@ -0,0 +1,74 @@
/*
Copyright 2013 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/>.
*/
#ifndef JSON_OBJECT_HPP
#define JSON_OBJECT_HPP
#include <string>
struct cJSON;
namespace boost {
namespace filesystem {
class path;
}
}
namespace Json {
class JsonObject {
public:
explicit JsonObject(const boost::filesystem::path& jsonFile );
explicit JsonObject(const std::string& inline_json);
explicit JsonObject(const char * inline_json);
explicit JsonObject(cJSON * root);
~JsonObject();
bool has_item(const std::string& key) const;
JsonObject get_array_item( size_t index ) const;
JsonObject get_item(const std::string& key) const;
std::string to_string() const;
std::string get_string(const std::string& key) const;
std::string as_string() const;
bool is_string( ) const;
bool is_number( ) const;
int get_int(const std::string& key) const;
int as_int() const;
double get_double(const std::string& key) const;
double as_double() const;
bool is_array( ) const;
bool is_object( ) const;
size_t size() const;
private:
JsonObject get_scalar_object(const std::string& key) const;
void initialize(const std::string& inline_json);
cJSON * root;
bool owner;
};
}
#endif

View File

@@ -0,0 +1,247 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
Welcome to cJSON.
cJSON aims to be the dumbest possible parser that you can get your job done with.
It's a single file of C, and a single header file.
JSON is described best here: http://www.json.org/
It's like XML, but fat-free. You use it to move data around, store things, or just
generally represent your program's state.
First up, how do I build?
Add cJSON.c to your project, and put cJSON.h somewhere in the header search path.
For example, to build the test app:
gcc cJSON.c test.c -o test -lm
./test
As a library, cJSON exists to take away as much legwork as it can, but not get in your way.
As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it
in one of two modes: Auto and Manual. Let's have a quick run-through.
I lifted some JSON from this page: http://www.json.org/fatfree.html
That page inspired me to write cJSON, which is a parser that tries to share the same
philosophy as JSON itself. Simple, dumb, out of the way.
Some JSON:
{
"name": "Jack (\"Bee\") Nimble",
"format": {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"frame rate": 24
}
}
Assume that you got this from a file, a webserver, or magic JSON elves, whatever,
you have a char * to it. Everything is a cJSON struct.
Get it parsed:
cJSON *root = cJSON_Parse(my_json_string);
This is an object. We're in C. We don't have objects. But we do have structs.
What's the framerate?
cJSON *format = cJSON_GetObjectItem(root,"format");
int framerate = cJSON_GetObjectItem(format,"frame rate")->valueint;
Want to change the framerate?
cJSON_GetObjectItem(format,"frame rate")->valueint=25;
Back to disk?
char *rendered=cJSON_Print(root);
Finished? Delete the root (this takes care of everything else).
cJSON_Delete(root);
That's AUTO mode. If you're going to use Auto mode, you really ought to check pointers
before you dereference them. If you want to see how you'd build this struct in code?
cJSON *root,*fmt;
root=cJSON_CreateObject();
cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack (\"Bee\") Nimble"));
cJSON_AddItemToObject(root, "format", fmt=cJSON_CreateObject());
cJSON_AddStringToObject(fmt,"type", "rect");
cJSON_AddNumberToObject(fmt,"width", 1920);
cJSON_AddNumberToObject(fmt,"height", 1080);
cJSON_AddFalseToObject (fmt,"interlace");
cJSON_AddNumberToObject(fmt,"frame rate", 24);
Hopefully we can agree that's not a lot of code? There's no overhead, no unnecessary setup.
Look at test.c for a bunch of nice examples, mostly all ripped off the json.org site, and
a few from elsewhere.
What about manual mode? First up you need some detail.
Let's cover how the cJSON objects represent the JSON data.
cJSON doesn't distinguish arrays from objects in handling; just type.
Each cJSON has, potentially, a child, siblings, value, a name.
The root object has: Object Type and a Child
The Child has name "name", with value "Jack ("Bee") Nimble", and a sibling:
Sibling has type Object, name "format", and a child.
That child has type String, name "type", value "rect", and a sibling:
Sibling has type Number, name "width", value 1920, and a sibling:
Sibling has type Number, name "height", value 1080, and a sibling:
Sibling hs type False, name "interlace", and a sibling:
Sibling has type Number, name "frame rate", value 24
Here's the structure:
typedef struct cJSON {
struct cJSON *next,*prev;
struct cJSON *child;
int type;
char *valuestring;
int valueint;
double valuedouble;
char *string;
} cJSON;
By default all values are 0 unless set by virtue of being meaningful.
next/prev is a doubly linked list of siblings. next takes you to your sibling,
prev takes you back from your sibling to you.
Only objects and arrays have a "child", and it's the head of the doubly linked list.
A "child" entry will have prev==0, but next potentially points on. The last sibling has next=0.
The type expresses Null/True/False/Number/String/Array/Object, all of which are #defined in
cJSON.h
A Number has valueint and valuedouble. If you're expecting an int, read valueint, if not read
valuedouble.
Any entry which is in the linked list which is the child of an object will have a "string"
which is the "name" of the entry. When I said "name" in the above example, that's "string".
"string" is the JSON name for the 'variable name' if you will.
Now you can trivially walk the lists, recursively, and parse as you please.
You can invoke cJSON_Parse to get cJSON to parse for you, and then you can take
the root object, and traverse the structure (which is, formally, an N-tree),
and tokenise as you please. If you wanted to build a callback style parser, this is how
you'd do it (just an example, since these things are very specific):
void parse_and_callback(cJSON *item,const char *prefix)
{
while (item)
{
char *newprefix=malloc(strlen(prefix)+strlen(item->name)+2);
sprintf(newprefix,"%s/%s",prefix,item->name);
int dorecurse=callback(newprefix, item->type, item);
if (item->child && dorecurse) parse_and_callback(item->child,newprefix);
item=item->next;
free(newprefix);
}
}
The prefix process will build you a separated list, to simplify your callback handling.
The 'dorecurse' flag would let the callback decide to handle sub-arrays on it's own, or
let you invoke it per-item. For the item above, your callback might look like this:
int callback(const char *name,int type,cJSON *item)
{
if (!strcmp(name,"name")) { /* populate name */ }
else if (!strcmp(name,"format/type") { /* handle "rect" */ }
else if (!strcmp(name,"format/width") { /* 800 */ }
else if (!strcmp(name,"format/height") { /* 600 */ }
else if (!strcmp(name,"format/interlace") { /* false */ }
else if (!strcmp(name,"format/frame rate") { /* 24 */ }
return 1;
}
Alternatively, you might like to parse iteratively.
You'd use:
void parse_object(cJSON *item)
{
int i; for (i=0;i<cJSON_GetArraySize(item);i++)
{
cJSON *subitem=cJSON_GetArrayItem(item,i);
// handle subitem.
}
}
Or, for PROPER manual mode:
void parse_object(cJSON *item)
{
cJSON *subitem=item->child;
while (subitem)
{
// handle subitem
if (subitem->child) parse_object(subitem->child);
subitem=subitem->next;
}
}
Of course, this should look familiar, since this is just a stripped-down version
of the callback-parser.
This should cover most uses you'll find for parsing. The rest should be possible
to infer.. and if in doubt, read the source! There's not a lot of it! ;)
In terms of constructing JSON data, the example code above is the right way to do it.
You can, of course, hand your sub-objects to other functions to populate.
Also, if you find a use for it, you can manually build the objects.
For instance, suppose you wanted to build an array of objects?
cJSON *objects[24];
cJSON *Create_array_of_anything(cJSON **items,int num)
{
int i;cJSON *prev, *root=cJSON_CreateArray();
for (i=0;i<24;i++)
{
if (!i) root->child=objects[i];
else prev->next=objects[i], objects[i]->prev=prev;
prev=objects[i];
}
return root;
}
and simply: Create_array_of_anything(objects,24);
cJSON doesn't make any assumptions about what order you create things in.
You can attach the objects, as above, and later add children to each
of those objects.
As soon as you call cJSON_Print, it renders the structure to text.
The test.c code shows how to handle a bunch of typical cases. If you uncomment
the code, it'll load, parse and print a bunch of test files, also from json.org,
which are more complex than I'd care to try and stash into a const char array[].
Enjoy cJSON!
- Dave Gamble, Aug 2009

View File

@@ -0,0 +1,4 @@
This directory contains the cJSON package downloaded unchanged from:
http://sourceforge.net/projects/cjson/. The cJSON package is plain C,
the JsonObject class provides a minimal C++ wrapping of this.

View File

@@ -0,0 +1,569 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* cJSON */
/* JSON parser in C. */
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include <limits.h>
#include <ctype.h>
#include "cJSON.h"
static const char *ep;
const char *cJSON_GetErrorPtr(void) {return ep;}
static int cJSON_strcasecmp(const char *s1,const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
static void *(*cJSON_malloc)(size_t sz) = malloc;
static void (*cJSON_free)(void *ptr) = free;
static char* cJSON_strdup(const char* str)
{
size_t len;
char* copy;
len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0;
memcpy(copy,str,len);
return copy;
}
void cJSON_InitHooks(cJSON_Hooks* hooks)
{
if (!hooks) { /* Reset hooks */
cJSON_malloc = malloc;
cJSON_free = free;
return;
}
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
}
/* Internal constructor. */
static cJSON *cJSON_New_Item(void)
{
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
if (node) memset(node,0,sizeof(cJSON));
return node;
}
/* Delete a cJSON structure. */
void cJSON_Delete(cJSON *c)
{
cJSON *next;
while (c)
{
next=c->next;
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
if (c->string) cJSON_free(c->string);
cJSON_free(c);
c=next;
}
}
/* Parse the input text to generate a number, and populate the result into item. */
static const char *parse_number(cJSON *item,const char *num)
{
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
/* Could use sscanf for this? */
if (*num=='-') sign=-1,num++; /* Has sign? */
if (*num=='0') num++; /* is zero */
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
if (*num=='e' || *num=='E') /* Exponent? */
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
}
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
item->valuedouble=n;
item->valueint=(int)n;
item->type=cJSON_Number;
return num;
}
/* Render the number nicely from the given item into a string. */
static char *print_number(cJSON *item)
{
char *str;
double d=item->valuedouble;
if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
{
str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
if (str) sprintf(str,"%d",item->valueint);
}
else
{
str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
if (str)
{
if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
else sprintf(str,"%f",d);
}
}
return str;
}
/* Parse the input text into an unescaped cstring, and populate item. */
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
static const char *parse_string(cJSON *item,const char *str)
{
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
if (*str!='\"') {ep=str;return 0;} /* not a string! */
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
if (!out) return 0;
ptr=str+1;ptr2=out;
while (*ptr!='\"' && *ptr)
{
if (*ptr!='\\') *ptr2++=*ptr++;
else
{
ptr++;
switch (*ptr)
{
case 'b': *ptr2++='\b'; break;
case 'f': *ptr2++='\f'; break;
case 'n': *ptr2++='\n'; break;
case 'r': *ptr2++='\r'; break;
case 't': *ptr2++='\t'; break;
case 'u': /* transcode utf16 to utf8. */
sscanf(ptr+1,"%4x",&uc);ptr+=4; /* get the unicode char. */
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
{
if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */
sscanf(ptr+3,"%4x",&uc2);ptr+=6;
if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
}
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 1: *--ptr2 =(uc | firstByteMark[len]);
}
ptr2+=len;
break;
default: *ptr2++=*ptr; break;
}
ptr++;
}
}
*ptr2=0;
if (*ptr=='\"') ptr++;
item->valuestring=out;
item->type=cJSON_String;
return ptr;
}
/* Render the cstring provided to an escaped version that can be printed. */
static char *print_string_ptr(const char *str)
{
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
if (!str) return cJSON_strdup("");
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
ptr2=out;ptr=str;
*ptr2++='\"';
while (*ptr)
{
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
else
{
*ptr2++='\\';
switch (token=*ptr++)
{
case '\\': *ptr2++='\\'; break;
case '\"': *ptr2++='\"'; break;
case '\b': *ptr2++='b'; break;
case '\f': *ptr2++='f'; break;
case '\n': *ptr2++='n'; break;
case '\r': *ptr2++='r'; break;
case '\t': *ptr2++='t'; break;
default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
}
}
}
*ptr2++='\"';*ptr2++=0;
return out;
}
/* Invote print_string_ptr (which is useful) on an item. */
static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
/* Predeclare these prototypes. */
static const char *parse_value(cJSON *item,const char *value);
static char *print_value(cJSON *item,int depth,int fmt);
static const char *parse_array(cJSON *item,const char *value);
static char *print_array(cJSON *item,int depth,int fmt);
static const char *parse_object(cJSON *item,const char *value);
static char *print_object(cJSON *item,int depth,int fmt);
/* Utility to jump whitespace and cr/lf */
static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
/* Parse an object - create a new root, and populate. */
cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
{
const char *end=0;
cJSON *c=cJSON_New_Item();
ep=0;
if (!c) return 0; /* memory fail */
end=parse_value(c,skip(value));
if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
if (return_parse_end) *return_parse_end=end;
return c;
}
/* Default options for cJSON_Parse */
cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
/* Render a cJSON item/entity/structure to text. */
char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
/* Parser core - when encountering text, process appropriately. */
static const char *parse_value(cJSON *item,const char *value)
{
if (!value) return 0; /* Fail on null. */
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
if (*value=='\"') { return parse_string(item,value); }
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
if (*value=='[') { return parse_array(item,value); }
if (*value=='{') { return parse_object(item,value); }
ep=value;return 0; /* failure. */
}
/* Render a value to text. */
static char *print_value(cJSON *item,int depth,int fmt)
{
char *out=0;
if (!item) return 0;
switch ((item->type)&255)
{
case cJSON_NULL: out=cJSON_strdup("null"); break;
case cJSON_False: out=cJSON_strdup("false");break;
case cJSON_True: out=cJSON_strdup("true"); break;
case cJSON_Number: out=print_number(item);break;
case cJSON_String: out=print_string(item);break;
case cJSON_Array: out=print_array(item,depth,fmt);break;
case cJSON_Object: out=print_object(item,depth,fmt);break;
}
return out;
}
/* Build an array from input text. */
static const char *parse_array(cJSON *item,const char *value)
{
cJSON *child;
if (*value!='[') {ep=value;return 0;} /* not an array! */
item->type=cJSON_Array;
value=skip(value+1);
if (*value==']') return value+1; /* empty array. */
item->child=child=cJSON_New_Item();
if (!item->child) return 0; /* memory fail */
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
if (!value) return 0;
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_value(child,skip(value+1)));
if (!value) return 0; /* memory fail */
}
if (*value==']') return value+1; /* end of array */
ep=value;return 0; /* malformed. */
}
/* Render an array to text */
static char *print_array(cJSON *item,int depth,int fmt)
{
char **entries;
char *out=0,*ptr,*ret;int len=5;
cJSON *child=item->child;
int numentries=0,i=0,fail=0;
/* How many entries in the array? */
while (child) numentries++,child=child->next;
/* Explicitly handle numentries==0 */
if (!numentries)
{
out=(char*)cJSON_malloc(3);
if (out) strcpy(out,"[]");
return out;
}
/* Allocate an array to hold the values for each */
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!entries) return 0;
memset(entries,0,numentries*sizeof(char*));
/* Retrieve all the results: */
child=item->child;
while (child && !fail)
{
ret=print_value(child,depth+1,fmt);
entries[i++]=ret;
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
child=child->next;
}
/* If we didn't fail, try to malloc the output string */
if (!fail) out=(char*)cJSON_malloc(len);
/* If that fails, we fail. */
if (!out) fail=1;
/* Handle failure. */
if (fail)
{
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
cJSON_free(entries);
return 0;
}
/* Compose the output array. */
*out='[';
ptr=out+1;*ptr=0;
for (i=0;i<numentries;i++)
{
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
cJSON_free(entries[i]);
}
cJSON_free(entries);
*ptr++=']';*ptr++=0;
return out;
}
/* Build an object from the text. */
static const char *parse_object(cJSON *item,const char *value)
{
cJSON *child;
if (*value!='{') {ep=value;return 0;} /* not an object! */
item->type=cJSON_Object;
value=skip(value+1);
if (*value=='}') return value+1; /* empty array. */
item->child=child=cJSON_New_Item();
if (!item->child) return 0;
value=skip(parse_string(child,skip(value)));
if (!value) return 0;
child->string=child->valuestring;child->valuestring=0;
if (*value!=':') {ep=value;return 0;} /* fail! */
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_string(child,skip(value+1)));
if (!value) return 0;
child->string=child->valuestring;child->valuestring=0;
if (*value!=':') {ep=value;return 0;} /* fail! */
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
}
if (*value=='}') return value+1; /* end of array */
ep=value;return 0; /* malformed. */
}
/* Render an object to text. */
static char *print_object(cJSON *item,int depth,int fmt)
{
char **entries=0,**names=0;
char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
cJSON *child=item->child;
int numentries=0,fail=0;
/* Count the number of entries. */
while (child) numentries++,child=child->next;
/* Explicitly handle empty object case */
if (!numentries)
{
out=(char*)cJSON_malloc(fmt?depth+3:3);
if (!out) return 0;
ptr=out;*ptr++='{';
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
*ptr++='}';*ptr++=0;
return out;
}
/* Allocate space for the names and the objects */
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!entries) return 0;
names=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!names) {cJSON_free(entries);return 0;}
memset(entries,0,sizeof(char*)*numentries);
memset(names,0,sizeof(char*)*numentries);
/* Collect all the results into our arrays: */
child=item->child;depth++;if (fmt) len+=depth;
while (child)
{
names[i]=str=print_string_ptr(child->string);
entries[i++]=ret=print_value(child,depth,fmt);
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
child=child->next;
}
/* Try to allocate the output string */
if (!fail) out=(char*)cJSON_malloc(len);
if (!out) fail=1;
/* Handle failure */
if (fail)
{
for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
cJSON_free(names);cJSON_free(entries);
return 0;
}
/* Compose the output: */
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
for (i=0;i<numentries;i++)
{
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
strcpy(ptr,names[i]);ptr+=strlen(names[i]);
*ptr++=':';if (fmt) *ptr++='\t';
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]);
}
cJSON_free(names);cJSON_free(entries);
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
*ptr++='}';*ptr++=0;
return out;
}
/* Get Array size/item / object item. */
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
/* Utility for array list handling. */
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
/* Utility for handling references. */
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
/* Add item to array/object. */
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
/* Replace array/object items with new ones. */
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
/* Create basic types: */
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
/* Create Arrays: */
cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateFloatArray(float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
/* Duplication */
cJSON *cJSON_Duplicate(cJSON *item,int recurse)
{
cJSON *newitem,*cptr,*nptr=0,*newchild;
/* Bail on bad ptr */
if (!item) return 0;
/* Create new item */
newitem=cJSON_New_Item();
if (!newitem) return 0;
/* Copy over all vars */
newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
/* If non-recursive, then we're done! */
if (!recurse) return newitem;
/* Walk the ->next chain for the child. */
cptr=item->child;
while (cptr)
{
newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
if (!newchild) {cJSON_Delete(newitem);return 0;}
if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
cptr=cptr->next;
}
return newitem;
}

View File

@@ -0,0 +1,143 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Number 3
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
#define cJSON_IsReference 256
/* The cJSON structure: */
typedef struct cJSON {
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
int valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks {
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern const char *cJSON_GetErrorPtr(void);
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull(void);
extern cJSON *cJSON_CreateTrue(void);
extern cJSON *cJSON_CreateFalse(void);
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateNumber(double num);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray(void);
extern cJSON *cJSON_CreateObject(void);
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
extern cJSON *cJSON_CreateFloatArray(float *numbers,int count);
extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count);
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,5 @@
opm_add_test(runjsonTests SOURCES jsonTests.cpp
LIBRARIES opmjson ${Boost_LIBRARIES})
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set_source_files_properties( jsonTests.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable")
endif()

View File

@@ -0,0 +1,281 @@
/*
Copyright 2013 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 <stdexcept>
#include <math.h>
#include <iostream>
#define BOOST_TEST_MODULE jsonParserTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/filesystem/path.hpp>
#include <opm/json/JsonObject.hpp>
BOOST_AUTO_TEST_CASE(ParseValidJson) {
std::string inline_json = "{\"key\": \"value\"}";
BOOST_CHECK_NO_THROW(Json::JsonObject parser(inline_json));
}
BOOST_AUTO_TEST_CASE(ParseValidJson_fromLiteral) {
BOOST_CHECK_NO_THROW(Json::JsonObject parser("{\"key\": \"value\"}"));
}
BOOST_AUTO_TEST_CASE(ParseInvalidJSON_throw) {
std::string inline_json = "{\"key\": \"value\"";
BOOST_CHECK_THROW(Json::JsonObject parser(inline_json) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getString) {
std::string inline_json = "{\"key\": \"value\"}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_EQUAL( "value" , parser.get_string("key") );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSONString_asString) {
std::string inline_json = "{\"key\": \"value\"}";
Json::JsonObject parser(inline_json);
Json::JsonObject value = parser.get_item("key");
BOOST_CHECK_EQUAL( "value" , value.as_string() );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSONnotString_asString_throws) {
std::string inline_json = "{\"key\": 100}";
Json::JsonObject parser(inline_json);
Json::JsonObject value = parser.get_item("key");
BOOST_CHECK_THROW( value.as_string() , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSONint_asNumber) {
std::string inline_json = "{\"key1\": 100, \"key2\" : 100.100 }";
Json::JsonObject parser(inline_json);
Json::JsonObject value1 = parser.get_item("key1");
Json::JsonObject value2 = parser.get_item("key2");
BOOST_CHECK_EQUAL( 100 , value1.as_int() );
BOOST_CHECK( fabs(100.100 - value2.as_double()) < 0.00001 );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSONint_isNumber) {
std::string inline_json = "{\"key1\": 100, \"key2\" : 100.100 , \"key3\": \"string\"}";
Json::JsonObject parser(inline_json);
Json::JsonObject value1 = parser.get_item("key1");
Json::JsonObject value2 = parser.get_item("key2");
Json::JsonObject value3 = parser.get_item("key3");
BOOST_CHECK( value1.is_number()) ;
BOOST_CHECK( value2.is_number()) ;
BOOST_CHECK_EQUAL( false , value3.is_number()) ;
}
BOOST_AUTO_TEST_CASE(ParsevalidJSONnotNumber_asNumber_throws) {
std::string inline_json = "{\"key\": \"100X\"}";
Json::JsonObject parser(inline_json);
Json::JsonObject value = parser.get_item("key");
BOOST_CHECK_THROW( value.as_int() , std::invalid_argument );
BOOST_CHECK_THROW( value.as_double() , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getInt_OK) {
std::string inline_json = "{\"key1\": 100 , \"key2\" : 200}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_EQUAL( 100 , parser.get_int("key1") );
BOOST_CHECK_EQUAL( 200 , parser.get_int("key2") );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_hasItem) {
std::string inline_json = "{\"key\": \"value\"}";
Json::JsonObject parser(inline_json);
BOOST_CHECK( parser.has_item("key"));
BOOST_CHECK_EQUAL( false , parser.has_item("keyX"));
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getMissingValue) {
std::string inline_json = "{\"key\": \"value\"}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_THROW( parser.get_string("keyX") , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getNotScalar_throws) {
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_EQUAL( "value" , parser.get_string("key"));
BOOST_CHECK_THROW( parser.get_string("list") , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getObject) {
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_NO_THROW( Json::JsonObject object = parser.get_item("list") );
BOOST_CHECK_NO_THROW( Json::JsonObject object = parser.get_item("key") );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_getObject_missing_throw) {
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
BOOST_CHECK_THROW( parser.get_item("listX") , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_CheckArraySize) {
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
Json::JsonObject object = parser.get_item("list");
BOOST_CHECK_EQUAL( 3U , object.size() );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_isArray){
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
Json::JsonObject list = parser.get_item("list");
Json::JsonObject key = parser.get_item("key");
BOOST_CHECK( list.is_array() );
BOOST_CHECK_EQUAL( false , key.is_array( ) );
}
BOOST_AUTO_TEST_CASE(ParsevalidJSON_arrayGet) {
std::string inline_json = "{\"key\": \"value\", \"list\": [1,2,3]}";
Json::JsonObject parser(inline_json);
Json::JsonObject list = parser.get_item("list");
Json::JsonObject key = parser.get_item("key");
BOOST_CHECK_NO_THROW( list.get_array_item( 0U ));
BOOST_CHECK_NO_THROW( list.get_array_item( 1U ));
BOOST_CHECK_NO_THROW( list.get_array_item( 2U ));
BOOST_CHECK_THROW( list.get_array_item( 3U ) , std::invalid_argument );
BOOST_CHECK_THROW( key.get_array_item( 0U ) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(parseJSONString_testType) {
std::string inline_json = "{\"item\": \"string\"}";
Json::JsonObject json(inline_json);
Json::JsonObject item = json.get_item( "item" );
BOOST_CHECK( item.is_string() );
BOOST_CHECK_EQUAL( false , item.is_number( ) );
BOOST_CHECK_EQUAL( false , item.is_array( ) );
BOOST_CHECK_EQUAL( false , item.is_object( ) );
}
BOOST_AUTO_TEST_CASE(parseJSONNumber_testType) {
std::string inline_json = "{\"item\": 100}";
Json::JsonObject json(inline_json);
Json::JsonObject item = json.get_item( "item" );
BOOST_CHECK_EQUAL( true , item.is_number( ) );
BOOST_CHECK_EQUAL( false , item.is_string() );
BOOST_CHECK_EQUAL( false , item.is_array( ) );
BOOST_CHECK_EQUAL( false , item.is_object( ) );
}
BOOST_AUTO_TEST_CASE(parseJSONArray_testType) {
std::string inline_json = "{\"item\": [1,2,3]}";
Json::JsonObject json(inline_json);
Json::JsonObject item = json.get_item( "item" );
BOOST_CHECK_EQUAL( false , item.is_number( ) );
BOOST_CHECK_EQUAL( false , item.is_string() );
BOOST_CHECK_EQUAL( true , item.is_array( ) );
BOOST_CHECK_EQUAL( false , item.is_object( ) );
}
BOOST_AUTO_TEST_CASE(parseJSONObject_testType) {
std::string inline_json = "{\"item\": {\"list\": [0,1,2]}}";
Json::JsonObject json(inline_json);
Json::JsonObject item = json.get_item( "item" );
BOOST_CHECK_EQUAL( false , item.is_number( ) );
BOOST_CHECK_EQUAL( false , item.is_string() );
BOOST_CHECK_EQUAL( false , item.is_array( ) );
BOOST_CHECK_EQUAL( true , item.is_object( ) );
}
BOOST_AUTO_TEST_CASE(Parse_fileDoesNotExist_Throws) {
boost::filesystem::path jsonFile("file/does/not/exist");
BOOST_CHECK_THROW( Json::JsonObject parser(jsonFile) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(Parse_fileExists_OK) {
boost::filesystem::path jsonFile("testdata/json/example1.json");
BOOST_CHECK_NO_THROW( Json::JsonObject parser(jsonFile) );
}
BOOST_AUTO_TEST_CASE(to_string_ok) {
boost::filesystem::path jsonFile("testdata/json/example1.json");
Json::JsonObject parser(jsonFile);
std::string json_string =
"{\n"
" \"keywords\": [{\n"
" \"name\": \"BPR\",\n"
" \"items\": [{\n"
" \"name\": \"ItemX\",\n"
" \"size_type\": \"SINGLE\",\n"
" \"value_type\": \"FLOAT\"\n"
" }]\n"
" }, {\n"
" \"name\": \"WWCT\",\n"
" \"size\": 0\n"
" }]\n"
"}";
BOOST_CHECK_EQUAL( parser.to_string() , json_string);
}

View File

@@ -0,0 +1,2 @@
add_subdirectory( share )
add_subdirectory( eclipse )

View File

@@ -0,0 +1,4 @@
add_executable(opmi opmi.cpp)
target_link_libraries(opmi opmparser)
install(TARGETS opmi DESTINATION "bin")

View File

@@ -0,0 +1,49 @@
/*
Copyright 2013 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 <iostream>
#include <memory>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
void loadDeck( const char * deck_file) {
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
std::shared_ptr<const Opm::Deck> deck;
std::shared_ptr<Opm::EclipseState> state;
std::cout << "Loading deck: " << deck_file << " ..... "; std::cout.flush();
deck = parser->parseFile(deck_file, parseContext);
std::cout << "parse complete - creating EclipseState .... "; std::cout.flush();
state = std::make_shared<Opm::EclipseState>( deck , parseContext );
std::cout << "complete." << std::endl;
}
int main(int argc, char** argv) {
for (int iarg = 1; iarg < argc; iarg++)
loadDeck( argv[iarg] );
return 0;
}

View File

@@ -0,0 +1,352 @@
include_directories(BEFORE ${PROJECT_BINARY_DIR}/generated-source/include)
add_subdirectory(Parser/tests)
#add_subdirectory(Generator/tests)
#add_subdirectory(RawDeck/tests)
#add_subdirectory(Deck/tests)
#add_subdirectory(Units/tests)
#add_subdirectory(EclipseState/tests)
#add_subdirectory(EclipseState/Schedule/tests)
#add_subdirectory(EclipseState/SimulationConfig/tests)
#add_subdirectory(EclipseState/Tables/tests)
#add_subdirectory(EclipseState/Grid/tests)
#add_subdirectory(EclipseState/Util/tests)
#add_subdirectory(EclipseState/IOConfig/tests)
#add_subdirectory(EclipseState/InitConfig/tests)
#add_subdirectory(EclipseState/SummaryConfig/tests)
#add_subdirectory(Utility/tests)
#add_subdirectory(Applications)
#add_subdirectory(IntegrationTests)
set( rawdeck_source
RawDeck/StarToken.cpp
RawDeck/RawKeyword.cpp
RawDeck/RawRecord.cpp )
set( unit_source
Units/UnitSystem.cpp
Units/Dimension.cpp)
set( deck_source
Deck/Deck.cpp
Deck/DeckKeyword.cpp
Deck/DeckRecord.cpp
Deck/DeckItem.cpp
Deck/Section.cpp
Deck/SCHEDULESection.cpp
Deck/DeckTimeStep.cpp
)
set( parser_source
Parser/ParseContext.cpp
Parser/MessageContainer.cpp
Parser/ParserEnums.cpp
Parser/ParserKeyword.cpp
Parser/Parser.cpp
Parser/ParserRecord.cpp
Parser/ParserItem.cpp
Parser/ParserIntItem.cpp
Parser/ParserDoubleItem.cpp
Parser/ParserStringItem.cpp
)
set( generator_source
Generator/KeywordGenerator.cpp
Generator/KeywordLoader.cpp )
set( build_parser_source
Parser/ParseContext.cpp
Parser/MessageContainer.cpp
Parser/ParserEnums.cpp
Parser/ParserKeyword.cpp
Parser/ParserRecord.cpp
Parser/ParserItem.cpp
Parser/ParserIntItem.cpp
Parser/ParserDoubleItem.cpp
Parser/ParserStringItem.cpp
${generator_source}
)
set (state_source
EclipseState/EclipseState.cpp
EclipseState/Eclipse3DProperties.cpp
EclipseState/Messages.cpp
#
EclipseState/checkDeck.cpp
#
EclipseState/Schedule/OilVaporizationProperties.cpp
EclipseState/Schedule/TimeMap.cpp
EclipseState/Schedule/Schedule.cpp
EclipseState/Schedule/Well.cpp
EclipseState/Schedule/WellProductionProperties.cpp
EclipseState/Schedule/WellInjectionProperties.cpp
EclipseState/Schedule/WellPolymerProperties.cpp
EclipseState/Schedule/MSW/Segment.cpp
EclipseState/Schedule/MSW/SegmentSet.cpp
EclipseState/Schedule/MSW/Compsegs.cpp
EclipseState/Schedule/WellSet.cpp
EclipseState/Schedule/Group.cpp
EclipseState/Schedule/Completion.cpp
EclipseState/Schedule/CompletionSet.cpp
EclipseState/Schedule/ScheduleEnums.cpp
EclipseState/Schedule/GroupTreeNode.cpp
EclipseState/Schedule/GroupTree.cpp
EclipseState/Schedule/Tuning.cpp
EclipseState/Schedule/Events.cpp
#
EclipseState/Tables/SimpleTable.cpp
EclipseState/Tables/VFPProdTable.cpp
EclipseState/Tables/VFPInjTable.cpp
EclipseState/Tables/TableManager.cpp
EclipseState/Tables/TableContainer.cpp
EclipseState/Tables/TableColumn.cpp
EclipseState/Tables/ColumnSchema.cpp
EclipseState/Tables/TableSchema.cpp
EclipseState/Tables/TableIndex.cpp
EclipseState/Tables/PvtxTable.cpp
EclipseState/Tables/Tables.cpp
#
EclipseState/Grid/SatfuncPropertyInitializers.cpp
EclipseState/Grid/GridProperty.cpp
EclipseState/Grid/Box.cpp
EclipseState/Grid/BoxManager.cpp
EclipseState/Grid/FaceDir.cpp
EclipseState/Grid/TransMult.cpp
EclipseState/Grid/MULTREGTScanner.cpp
EclipseState/Grid/EclipseGrid.cpp
EclipseState/Grid/FaultFace.cpp
EclipseState/Grid/Fault.cpp
EclipseState/Grid/FaultCollection.cpp
EclipseState/Grid/NNC.cpp
EclipseState/Grid/PinchMode.cpp
#
EclipseState/InitConfig/InitConfig.cpp
EclipseState/InitConfig/Equil.cpp
EclipseState/SimulationConfig/SimulationConfig.cpp
EclipseState/SimulationConfig/ThresholdPressure.cpp
EclipseState/SummaryConfig/SummaryConfig.cpp
EclipseState/IOConfig/IOConfig.cpp)
#
set( utility_source
Utility/Functional.cpp
Utility/Stringview.cpp
)
set( HEADER_FILES
RawDeck/RawConsts.hpp
RawDeck/RawKeyword.hpp
RawDeck/RawRecord.hpp
RawDeck/StarToken.hpp
RawDeck/RawEnums.hpp
#
Deck/Deck.hpp
Deck/DeckKeyword.hpp
Deck/DeckRecord.hpp
Deck/DeckItem.hpp
Deck/Section.hpp
Deck/SCHEDULESection.hpp
Deck/DeckTimeStep.hpp
#
Parser/ParserEnums.hpp
Parser/ParserKeyword.hpp
Parser/Parser.hpp
Parser/ParserRecord.hpp
Parser/ParserItem.hpp
Parser/ParserIntItem.hpp
Parser/ParserDoubleItem.hpp
Parser/ParserStringItem.hpp
Parser/InputErrorAction.hpp
Parser/ParseContext.hpp
Parser/MessageContainer.hpp
#
Generator/KeywordLoader.hpp
Generator/KeywordGenerator.hpp
#
Units/UnitSystem.hpp
Units/Dimension.hpp
Units/ConversionFactors.hpp
#
EclipseState/EclipseState.hpp
EclipseState/Eclipse3DProperties.hpp
EclipseState/Messages.hpp
#
EclipseState/checkDeck.hpp
#
EclipseState/Schedule/OilVaporizationProperties.hpp
EclipseState/Schedule/TimeMap.hpp
EclipseState/Schedule/Schedule.hpp
EclipseState/Schedule/Well.hpp
EclipseState/Schedule/WellProductionProperties.hpp
EclipseState/Schedule/WellInjectionProperties.hpp
EclipseState/Schedule/WellPolymerProperties.hpp
EclipseState/Schedule/MSW/Segment.hpp
EclipseState/Schedule/MSW/SegmentSet.hpp
EclipseState/Schedule/MSW/Compsegs.hpp
EclipseState/Schedule/WellSet.hpp
EclipseState/Schedule/Group.hpp
EclipseState/Schedule/DynamicState.hpp
EclipseState/Schedule/DynamicVector.hpp
EclipseState/Schedule/Completion.hpp
EclipseState/Schedule/CompletionSet.hpp
EclipseState/Schedule/ScheduleEnums.hpp
EclipseState/Schedule/GroupTreeNode.hpp
EclipseState/Schedule/GroupTree.hpp
EclipseState/Schedule/Tuning.hpp
EclipseState/Schedule/Events.hpp
#
EclipseState/Util/RecordVector.hpp
EclipseState/Util/OrderedMap.hpp
EclipseState/Util/Value.hpp
#
EclipseState/Grid/EclipseGrid.hpp
EclipseState/Grid/GridProperty.hpp
EclipseState/Grid/GridProperties.hpp
EclipseState/Grid/SatfuncPropertyInitializers.hpp
EclipseState/Grid/Box.hpp
EclipseState/Grid/BoxManager.hpp
EclipseState/Grid/FaceDir.hpp
EclipseState/Grid/MinpvMode.hpp
EclipseState/Grid/PinchMode.hpp
EclipseState/Grid/MULTREGTScanner.hpp
EclipseState/Grid/TransMult.hpp
EclipseState/Grid/FaultFace.hpp
EclipseState/Grid/Fault.hpp
EclipseState/Grid/FaultCollection.hpp
EclipseState/Grid/NNC.hpp
#
EclipseState/InitConfig/InitConfig.hpp
EclipseState/InitConfig/Equil.hpp
EclipseState/SimulationConfig/SimulationConfig.hpp
EclipseState/SimulationConfig/ThresholdPressure.hpp
EclipseState/SummaryConfig/SummaryConfig.hpp
EclipseState/IOConfig/IOConfig.hpp
#
EclipseState/Tables/Tabdims.hpp
EclipseState/Tables/Eqldims.hpp
EclipseState/Tables/Regdims.hpp
EclipseState/Tables/PlyadsTable.hpp
EclipseState/Tables/PvtoTable.hpp
EclipseState/Tables/RocktabTable.hpp
EclipseState/Tables/PvdoTable.hpp
EclipseState/Tables/PvdgTable.hpp
EclipseState/Tables/PvdsTable.hpp
EclipseState/Tables/SimpleTable.hpp
EclipseState/Tables/PlymaxTable.hpp
EclipseState/Tables/PlyrockTable.hpp
EclipseState/Tables/SwofTable.hpp
EclipseState/Tables/SgwfnTable.hpp
EclipseState/Tables/SwfnTable.hpp
EclipseState/Tables/SgfnTable.hpp
EclipseState/Tables/SsfnTable.hpp
EclipseState/Tables/Sof2Table.hpp
EclipseState/Tables/Sof3Table.hpp
EclipseState/Tables/EnptvdTable.hpp
EclipseState/Tables/PlyviscTable.hpp
EclipseState/Tables/PlydhflfTable.hpp
EclipseState/Tables/PlyshlogTable.hpp
EclipseState/Tables/EnkrvdTable.hpp
EclipseState/Tables/ImkrvdTable.hpp
EclipseState/Tables/SgofTable.hpp
EclipseState/Tables/SlgofTable.hpp
EclipseState/Tables/PvtxTable.hpp
EclipseState/Tables/ImptvdTable.hpp
EclipseState/Tables/RsvdTable.hpp
EclipseState/Tables/RvvdTable.hpp
EclipseState/Tables/RtempvdTable.hpp
EclipseState/Tables/OilvisctTable.hpp
EclipseState/Tables/GasvisctTable.hpp
EclipseState/Tables/WatvisctTable.hpp
EclipseState/Tables/PvtgTable.hpp
EclipseState/Tables/VFPProdTable.hpp
EclipseState/Tables/VFPInjTable.hpp
EclipseState/Tables/TableManager.hpp
EclipseState/Tables/TableContainer.hpp
EclipseState/Tables/SorwmisTable.hpp
EclipseState/Tables/SgcwmisTable.hpp
EclipseState/Tables/MiscTable.hpp
EclipseState/Tables/PmiscTable.hpp
EclipseState/Tables/TlpmixpaTable.hpp
EclipseState/Tables/MsfnTable.hpp
EclipseState/Tables/TableColumn.hpp
EclipseState/Tables/ColumnSchema.hpp
EclipseState/Tables/TableEnums.hpp
EclipseState/Tables/TableSchema.hpp
EclipseState/Tables/TableIndex.hpp
#
Utility/Functional.hpp
Utility/Stringview.hpp)
add_library(buildParser ${rawdeck_source} ${build_parser_source} ${deck_source} ${unit_source} ${generator_source} ${utility_source})
target_link_libraries(buildParser opmjson ${opm-common_LIBRARIES} ${Boost_LIBRARIES} ${ERT_LIBRARIES})
#-----------------------------------------------------------------
# This section manages the generation of C++ code for the default keywords.
# 1. Create an executable 'createDefaultKeywordList'.
add_executable( createDefaultKeywordList Parser/createDefaultKeywordList.cpp )
target_link_libraries( createDefaultKeywordList buildParser opmjson ${Boost_LIBRARIES})
# 2. Run the generated application createDefaultKeywordlist - this
# application will recursively scan through all the json keyword
# files in the source tree. It will maintain a signature of these json files,
# and only update the generated files if the json files have changed.
#
# This target will always run - the dependency "management" is
# implicitly handled in the createDefaultKeywordList application.
set( generated_source ${PROJECT_BINARY_DIR}/generated-source/ParserKeywords.cpp)
# to tune the number of files addDefaultKeywords is split into, change
# generated_num_files. 4 is a very reasonable estimate.
# TODO: support from command line options?
set( generated_num_files 4 )
math( EXPR generated_num_files_end "${generated_num_files} - 1" )
foreach( n RANGE ${generated_num_files_end} )
list(APPEND generated_source ${PROJECT_BINARY_DIR}/generated-source/ParserKeywords${n}.cpp)
set_source_files_properties(${PROJECT_BINARY_DIR}/generated-source/ParserKeywords${n}.cpp PROPERTIES GENERATED TRUE)
endforeach( n )
set_source_files_properties(${PROJECT_BINARY_DIR}/generated-source/ParserKeywords.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${PROJECT_BINARY_DIR}/generated-source/inlcude/opm/parser/eclipse/Parser/ParserKeywords.hpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${PROJECT_BINARY_DIR}/generated-source/inlineKeywordTest.cpp PROPERTIES GENERATED TRUE)
add_custom_target( generatedCode ALL COMMAND createDefaultKeywordList
${PROJECT_SOURCE_DIR}/opm/parser/share/keywords
${PROJECT_BINARY_DIR}/generated-source/ParserKeywords.cpp
${PROJECT_BINARY_DIR}/generated-source/include/
opm/parser/eclipse/Parser/ParserKeywords
${PROJECT_BINARY_DIR}/generated-source/inlineKeywordTest.cpp
${generated_num_files}
)
opm_add_test( runInlineKeywordTest SOURCES ${PROJECT_BINARY_DIR}/generated-source/inlineKeywordTest.cpp
LIBRARIES opmparser ${opm-common_LIBRARIES} ${Boost_LIBRARIES}
DEPENDS generatedCode )
#-----------------------------------------------------------------
add_library(opmparser ${generated_source} ${state_source} ${rawdeck_source} ${parser_source} ${deck_source} ${unit_source} ${generator_source} ${utility_source})
add_dependencies( opmparser generatedCode )
target_link_libraries(opmparser opmjson ${opm-common_LIBRARIES} ${Boost_LIBRARIES} ${ERT_LIBRARIES})
set_target_properties(opmparser PROPERTIES VERSION ${opm-parser_VERSION_MAJOR}.${opm-parser_VERSION_MINOR}
SOVERSION ${opm-parser_VERSION_MAJOR})
include( ${PROJECT_SOURCE_DIR}/cmake/Modules/install_headers.cmake )
install_headers( "${HEADER_FILES}" "${CMAKE_INSTALL_PREFIX}" )
install( TARGETS opmparser DESTINATION ${CMAKE_INSTALL_LIBDIR} )
install(FILES ${PROJECT_BINARY_DIR}/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords.hpp
DESTINATION include/opm/parser/eclipse/Parser)
install(DIRECTORY ${PROJECT_BINARY_DIR}/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords
DESTINATION include/opm/parser/eclipse/Parser)
if (ENABLE_PYTHON)
add_subdirectory( python )
endif()

View File

@@ -0,0 +1,214 @@
/*
Copyright 2013 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 <algorithm>
#include <vector>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
namespace Opm {
bool DeckView::hasKeyword( const DeckKeyword& keyword ) const {
auto key = this->keywordMap.find( keyword.name() );
if( key == this->keywordMap.end() ) return false;
for( auto index : key->second )
if( &this->getKeyword( index ) == &keyword ) return true;
return false;
}
bool DeckView::hasKeyword( const std::string& keyword ) const {
return this->keywordMap.find( keyword ) != this->keywordMap.end();
}
const DeckKeyword& DeckView::getKeyword( const std::string& keyword, size_t index ) const {
if( !this->hasKeyword( keyword ) )
throw std::invalid_argument("Keyword " + keyword + " not in deck.");
return this->getKeyword( this->offsets( keyword ).at( index ) );
}
const DeckKeyword& DeckView::getKeyword( const std::string& keyword ) const {
if( !this->hasKeyword( keyword ) )
throw std::invalid_argument("Keyword " + keyword + " not in deck.");
return this->getKeyword( this->offsets( keyword ).back() );
}
const DeckKeyword& DeckView::getKeyword( size_t index ) const {
if( index >= this->size() )
throw std::out_of_range("Keyword index " + std::to_string( index ) + " is out of range.");
return *( this->begin() + index );
}
size_t DeckView::count( const std::string& keyword ) const {
if( !this->hasKeyword( keyword ) ) return 0;
return this->offsets( keyword ).size();
}
const std::vector< const DeckKeyword* > DeckView::getKeywordList( const std::string& keyword ) const {
if( !hasKeyword( keyword ) ) return {};
const auto& indices = this->offsets( keyword );
std::vector< const DeckKeyword* > ret;
ret.reserve( indices.size() );
for( size_t i : indices )
ret.push_back( &this->getKeyword( i ) );
return ret;
}
size_t DeckView::size() const {
return std::distance( this->begin(), this->end() );
}
DeckView::const_iterator DeckView::begin() const {
return this->first;
}
DeckView::const_iterator DeckView::end() const {
return this->last;
}
void DeckView::add( const DeckKeyword* kw, const_iterator f, const_iterator l ) {
this->keywordMap[ kw->name() ].push_back( std::distance( f, l ) - 1 );
this->first = f;
this->last = l;
}
static const std::vector< size_t > empty_indices = {};
const std::vector< size_t >& DeckView::offsets( const std::string& keyword ) const {
if( !hasKeyword( keyword ) ) return empty_indices;
return this->keywordMap.find( keyword )->second;
}
DeckView::DeckView( const_iterator first_arg, const_iterator last_arg ) :
first( first_arg ), last( last_arg )
{
size_t index = 0;
for( const auto& kw : *this )
this->keywordMap[ kw.name() ].push_back( index++ );
}
DeckView::DeckView( std::pair< const_iterator, const_iterator > limits ) :
DeckView( limits.first, limits.second )
{}
Deck::Deck() :
Deck( std::vector< DeckKeyword >() )
{
m_dataFile = "";
}
Deck::Deck( std::vector< DeckKeyword >&& x ) :
DeckView( x.begin(), x.end() ),
keywordList( std::move( x ) ),
m_dataFile("")
{}
void Deck::addKeyword( DeckKeyword&& keyword ) {
this->keywordList.push_back( std::move( keyword ) );
auto first = this->keywordList.begin();
auto last = this->keywordList.end();
this->add( &this->keywordList.back(), first, last );
}
void Deck::addKeyword( const DeckKeyword& keyword ) {
DeckKeyword kw = keyword;
this->addKeyword( std::move( kw ) );
}
DeckKeyword& Deck::getKeyword( size_t index ) {
return this->keywordList.at( index );
}
MessageContainer& Deck::getMessageContainer() const {
return this->m_messageContainer;
}
UnitSystem& Deck::getDefaultUnitSystem() {
if( !this->defaultUnits ) this->initUnitSystem();
return *this->defaultUnits;
}
UnitSystem& Deck::getActiveUnitSystem() {
if( !this->activeUnits ) this->initUnitSystem();
return *this->activeUnits;
}
const UnitSystem& Deck::getDefaultUnitSystem() const {
if( !this->defaultUnits ) this->initUnitSystem();
return *this->defaultUnits;
}
const UnitSystem& Deck::getActiveUnitSystem() const {
if( !this->activeUnits ) this->initUnitSystem();
return *this->activeUnits;
}
void Deck::initUnitSystem() const {
/*
* The unit systems are lazily created as their exact value depend on
* input values of the deck, but in a constructed deck this can be
* considered constant (and in fact, if the deck is obtained through
* ParseFromString/File, this these values set before the Deck is
* available). The unit systems are needed from const contexts though,
* but might not have been generated at that time. Generation is done
* in this method, but it has to be callable from const'd this, and are
* marked mutable.
*/
this->defaultUnits = std::unique_ptr< UnitSystem >( UnitSystem::newMETRIC() );
if (hasKeyword("FIELD"))
this->activeUnits = std::unique_ptr< UnitSystem >( UnitSystem::newFIELD() );
else
this->activeUnits = std::unique_ptr< UnitSystem >( UnitSystem::newMETRIC() );
}
const std::string Deck::getDataFile() const {
return m_dataFile;
}
void Deck::setDataFile(const std::string& dataFile) {
m_dataFile = dataFile;
}
Deck::iterator Deck::begin() {
return this->keywordList.begin();
}
Deck::iterator Deck::end() {
return this->keywordList.end();
}
}

View File

@@ -0,0 +1,160 @@
/*
Copyright 2013 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/>.
*/
#ifndef DECK_HPP
#define DECK_HPP
#include <map>
#include <memory>
#include <vector>
#include <string>
#include <boost/filesystem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
#ifdef OPM_PARSER_DECK_API_WARNING
#ifndef OPM_PARSER_DECK_API
#pragma message "\n\n" \
" ----------------------------------------------------------------------------------\n" \
" The current compilation unit includes the header Deck.hpp. Outside of opm-parser \n" \
" you are encouraged to use the EclipseState API instead of the low level Deck API. \n" \
" If use of the Deck API is absolutely necessary you can silence this warning with \n" \
" #define OPM_PARSER_DECK_API before including the Deck.hpp header. \n" \
" ----------------------------------------------------------------------------------\n" \
""
#endif
#endif
namespace Opm {
/*
* The Deck (container) class owns all memory given to it via .addX(), as
* do all inner objects. This means that the Deck object itself must stay
* alive as long as DeckItem (and friends) are needed, to avoid
* use-after-free.
*/
class DeckView {
public:
typedef std::vector< DeckKeyword >::const_iterator const_iterator;
bool hasKeyword( const DeckKeyword& keyword ) const;
bool hasKeyword( const std::string& keyword ) const;
template< class Keyword >
bool hasKeyword() const {
return hasKeyword( Keyword::keywordName );
}
const DeckKeyword& getKeyword( const std::string& keyword, size_t index ) const;
const DeckKeyword& getKeyword( const std::string& keyword ) const;
const DeckKeyword& getKeyword( size_t index ) const;
DeckKeyword& getKeyword( size_t index );
template< class Keyword >
const DeckKeyword& getKeyword() const {
return getKeyword( Keyword::keywordName );
}
template< class Keyword >
const DeckKeyword& getKeyword( size_t index ) const {
return getKeyword( Keyword::keywordName, index );
}
const std::vector< const DeckKeyword* > getKeywordList( const std::string& keyword ) const;
template< class Keyword >
const std::vector< const DeckKeyword* > getKeywordList() const {
return getKeywordList( Keyword::keywordName );
}
size_t count(const std::string& keyword) const;
size_t size() const;
const_iterator begin() const;
const_iterator end() const;
protected:
void add( const DeckKeyword*, const_iterator, const_iterator );
const std::vector< size_t >& offsets( const std::string& ) const;
DeckView( const_iterator first, const_iterator last );
DeckView( std::pair< const_iterator, const_iterator > );
private:
const_iterator first;
const_iterator last;
std::map< std::string, std::vector< size_t > > keywordMap;
};
class Deck : private DeckView {
public:
using DeckView::const_iterator;
using DeckView::hasKeyword;
using DeckView::getKeyword;
using DeckView::getKeywordList;
using DeckView::count;
using DeckView::size;
using DeckView::begin;
using DeckView::end;
using iterator = std::vector< DeckKeyword >::iterator;
Deck();
void addKeyword( DeckKeyword&& keyword );
void addKeyword( const DeckKeyword& keyword );
DeckKeyword& getKeyword( size_t );
MessageContainer& getMessageContainer() const;
UnitSystem& getDefaultUnitSystem();
UnitSystem& getActiveUnitSystem();
const UnitSystem& getDefaultUnitSystem() const;
const UnitSystem& getActiveUnitSystem() const;
const std::string getDataFile() const;
void setDataFile(const std::string& dataFile);
iterator begin();
iterator end();
private:
Deck( std::vector< DeckKeyword >&& );
void initUnitSystem() const;
std::vector< DeckKeyword > keywordList;
mutable MessageContainer m_messageContainer;
mutable std::unique_ptr< UnitSystem > activeUnits;
mutable std::unique_ptr< UnitSystem > defaultUnits;
std::string m_dataFile;
};
typedef std::shared_ptr<Deck> DeckPtr;
typedef std::shared_ptr<const Deck> DeckConstPtr;
}
#endif /* DECK_HPP */

View File

@@ -0,0 +1,394 @@
/*
Copyright 2013 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 <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
#include <boost/algorithm/string.hpp>
#include <stdexcept>
namespace Opm {
template< typename T >
class DeckTypeItem : public DeckItemBase {
public:
const std::string& name() const override;
bool defaultApplied( size_t ) const override;
bool hasValue( size_t ) const override;
size_t size() const override;
void push_back( T );
void push_back( T, size_t numValues );
void push_backDefault( T );
void push_backDummyDefault() override;
const T& get( size_t ) const;
const std::vector< T >& getData() const;
protected:
DeckTypeItem( const std::string&, size_t );
private:
std::string item_name;
std::vector< bool > dataPointDefaulted;
std::vector< T > data;
};
template< typename T >
class DeckItemT : public DeckTypeItem< T > {
private:
using DeckTypeItem< T >::DeckTypeItem;
std::unique_ptr< DeckItemBase > clone() const override;
friend class DeckItem;
};
template<>
class DeckItemT< double > : public DeckTypeItem< double > {
public:
using DeckTypeItem< double >::DeckTypeItem;
const double& getSI( size_t ) const;
const std::vector< double >& getSIData() const;
void push_backDimension(
std::shared_ptr< const Dimension > activeDimension,
std::shared_ptr< const Dimension > defaultDimension );
private:
const std::vector< double >& assertSIData() const;
std::unique_ptr< DeckItemBase > clone() const override;
mutable std::vector< double > SIdata;
std::vector< std::shared_ptr< const Dimension > > dimensions;
friend class DeckItem;
};
template< typename T > static inline DeckItem::type type_to_tag();
template<>
DeckItem::type type_to_tag< int >() {
return DeckItem::integer;
}
template<>
DeckItem::type type_to_tag< double >() {
return DeckItem::fdouble;
}
template<>
DeckItem::type type_to_tag< std::string >() {
return DeckItem::string;
}
static inline std::string tag_to_string( DeckItem::type x ) {
switch( x ) {
case DeckItem::type::integer: return "int";
case DeckItem::type::string: return "std::string";
case DeckItem::type::fdouble: return "double";
case DeckItem::type::unknown: return "unknown";
}
return "unknown";
}
template< typename T >
DeckTypeItem< T >::DeckTypeItem( const std::string& name, size_t size ) :
DeckItemBase( type_to_tag< T >() ),
item_name( name )
{
this->dataPointDefaulted.reserve( size );
this->data.reserve( size );
}
template< typename T >
const std::string& DeckTypeItem< T >::name() const {
return this->item_name;
}
template< typename T >
bool DeckTypeItem< T >::defaultApplied( size_t index ) const {
return this->dataPointDefaulted.at( index );
}
template< typename T >
bool DeckTypeItem< T >::hasValue( size_t index ) const {
return index < this->size();
}
template< typename T >
size_t DeckTypeItem< T >::size() const {
return this->data.size();
}
template< typename T >
void DeckTypeItem< T >::push_back( T x ) {
if( this->dataPointDefaulted.size() != this->data.size() )
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
this->data.push_back( x );
this->dataPointDefaulted.push_back( false );
}
template< typename T >
void DeckTypeItem< T >::push_backDefault( T data_arg ) {
if( this->dataPointDefaulted.size() != this->data.size() )
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
this->data.push_back( data_arg );
this->dataPointDefaulted.push_back(true);
}
template< typename T >
void DeckTypeItem< T >::push_backDummyDefault() {
if( this->dataPointDefaulted.size() != 0 )
throw std::logic_error("Pseudo defaults can only be specified for empty items");
this->dataPointDefaulted.push_back( true );
}
template< typename T >
void DeckTypeItem< T >::push_back( T x, size_t numValues ) {
if( this->dataPointDefaulted.size() != this->data.size() )
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
this->data.insert( this->data.end(), numValues, x );
this->dataPointDefaulted.insert( this->dataPointDefaulted.end(), numValues, false );
}
template< typename T >
const T& DeckTypeItem< T >::get( size_t index ) const {
return this->data.at( index );
}
template< typename T >
const std::vector< T >& DeckTypeItem< T >::getData() const {
return this->data;
}
const double& DeckItemT< double >::getSI( size_t index ) const {
return this->assertSIData().at( index );
}
const std::vector< double >& DeckItemT< double >::getSIData() const {
return this->assertSIData();
}
void DeckItemT< double >::push_backDimension(
std::shared_ptr< const Dimension > activeDimension,
std::shared_ptr< const Dimension > defaultDimension ) {
if( this->size() == 0 || this->defaultApplied( this->size() - 1 ) )
this->dimensions.push_back( defaultDimension );
else
this->dimensions.push_back( activeDimension );
}
template< typename T >
std::unique_ptr< DeckItemBase > DeckItemT< T >::clone() const {
return std::unique_ptr< DeckItemBase > { new DeckItemT< T >( *this ) };
}
std::unique_ptr< DeckItemBase > DeckItemT< double >::clone() const {
return std::unique_ptr< DeckItemBase > { new DeckItemT< double >( *this ) };
}
const std::vector< double >& DeckItemT< double >::assertSIData() const {
const auto dim_size = dimensions.size();
if( dim_size <= 0 )
throw std::invalid_argument("No dimension has been set for item:" + this->name() + " can not ask for SI data");
// we already converted this item to SI?
if( this->SIdata.size() > 0 ) return this->SIdata;
/*
* This is an unobservable state change - SIData is lazily converted to
* SI units, so externally the object still behaves as const
*/
const auto size = this->size();
this->SIdata.resize( size );
for( size_t index = 0; index < size; index++ ) {
const auto dimIndex = index % dim_size;
this->SIdata[ index ] = this->dimensions[ dimIndex ]
->convertRawToSi( this->get( index ) );
}
return this->SIdata;
}
template< typename T >
static inline DeckItemT< T >* conv( std::unique_ptr< DeckItemBase >& ptr ) {
if( ptr->type_tag == type_to_tag< T >() )
return static_cast< DeckItemT< T >* >( ptr.get() );
throw std::logic_error(
"Treating item " + ptr->name()
+ " as " + tag_to_string( type_to_tag< T >() )
+ ", but is "
+ tag_to_string( ptr->type_tag ) );
}
template< typename T >
static inline
const DeckItemT< T >* conv( const std::unique_ptr< DeckItemBase >& ptr ) {
if( ptr->type_tag == type_to_tag< T >() )
return static_cast< const DeckItemT< T >* >( ptr.get() );
throw std::logic_error(
"Treating item " + ptr->name()
+ " as " + tag_to_string( type_to_tag< T >() )
+ ", but is "
+ tag_to_string( ptr->type_tag ) );
}
DeckItem::DeckItem( const DeckItem& rhs ) :
ptr( rhs.ptr->clone() )
{}
DeckItem::DeckItem( std::unique_ptr< DeckItemBase >&& x ) :
ptr( std::move( x ) )
{}
template< typename T >
DeckItem DeckItem::make( const std::string& name, size_t size ) {
return DeckItem( std::unique_ptr< DeckItemBase > { new DeckItemT< T >( name, size ) } );
}
const std::string& DeckItem::name() const {
return this->ptr->name();
}
bool DeckItem::defaultApplied( size_t index ) const {
return this->ptr->defaultApplied( index );
}
bool DeckItem::hasValue( size_t index ) const {
return this->ptr->hasValue( index );
}
size_t DeckItem::size() const {
return this->ptr->size();
}
template< typename T >
const T& DeckItem::get( size_t index ) const {
return conv< T >( this->ptr )->get( index );
}
template< typename T >
const std::vector< T >& DeckItem::getData() const {
return conv< T >( this->ptr )->getData();
}
template< typename T >
void DeckItem::push_back( T x ) {
return conv< T >( this->ptr )->push_back( x );
}
template< typename T >
void DeckItem::push_back( T x, size_t n ) {
return conv< T >( this->ptr )->push_back( x, n );
}
template< typename T >
void DeckItem::push_backDefault( T x ) {
return conv< T >( this->ptr )->push_backDefault( x );
}
template<>
void DeckItem::push_back( const char* x ) {
return conv< std::string >( this->ptr )->push_back( x );
}
template<>
void DeckItem::push_back( const char* x, size_t n ) {
return conv< std::string >( this->ptr )->push_back( x, n );
}
template<>
void DeckItem::push_backDefault( const char* x ) {
return conv< std::string >( this->ptr )->push_backDefault( x );
}
void DeckItem::push_backDummyDefault() {
return this->ptr->push_backDummyDefault();
}
std::string DeckItem::getTrimmedString( size_t index ) const {
return boost::algorithm::trim_copy(
conv< std::string >( this->ptr )->get( index )
);
}
double DeckItem::getSIDouble( size_t index ) const {
return conv< double >( this->ptr )->getSI( index );
}
const std::vector< double >& DeckItem::getSIDoubleData() const {
return conv< double >( this->ptr )->getSIData();
}
void DeckItem::push_backDimension( std::shared_ptr< const Dimension > active,
std::shared_ptr< const Dimension > def ) {
return conv< double >( this->ptr )->push_backDimension( active, def );
}
DeckItem::type DeckItem::typeof() const {
return this->ptr->type_tag;
}
/*
* Explicit template instantiations. These must be manually maintained and
* updated with changes in DeckItem so that code is emitted.
*/
template class DeckTypeItem< int >;
template class DeckTypeItem< double >;
template class DeckTypeItem< std::string >;
template class DeckItemT< int >;
template class DeckItemT< double >;
template class DeckItemT< std::string >;
template DeckItem DeckItem::make< int >( const std::string&, size_t );
template DeckItem DeckItem::make< double >( const std::string&, size_t );
template DeckItem DeckItem::make< std::string >( const std::string&, size_t );
template const int& DeckItem::get< int >( size_t ) const;
template const double& DeckItem::get< double >( size_t ) const;
template const std::string& DeckItem::get< std::string >( size_t ) const;
template const std::vector< int >& DeckItem::getData< int >() const;
template const std::vector< double >& DeckItem::getData< double >() const;
template const std::vector< std::string >& DeckItem::getData< std::string >() const;
template void DeckItem::push_back< int >( int );
template void DeckItem::push_back< double >( double );
template void DeckItem::push_back< std::string >( std::string );
template void DeckItem::push_back< int >( int, size_t );
template void DeckItem::push_back< double >( double, size_t );
template void DeckItem::push_back< std::string >( std::string, size_t );
template void DeckItem::push_backDefault< int >( int );
template void DeckItem::push_backDefault< double >( double );
template void DeckItem::push_backDefault< std::string >( std::string );
}

View File

@@ -0,0 +1,111 @@
/*
Copyright 2013 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/>.
*/
#ifndef DECKITEM_HPP
#define DECKITEM_HPP
#include <string>
#include <vector>
#include <memory>
namespace Opm {
class DeckItem;
class Dimension;
class DeckItemBase;
class DeckItem {
public:
DeckItem() = delete;
DeckItem( const DeckItem& );
/* for python interop as well as queries, must be manually synchronised
* with cdeck_item.cc and opm/deck/item_type_enum.py
*/
enum type {
unknown = 0, /* this signals an error */
integer = 1,
string = 2,
fdouble = 3
};
template< typename T >
static DeckItem make( const std::string&, size_t = 1 );
const std::string& name() const;
// return true if the default value was used for a given data point
bool defaultApplied( size_t ) const;
// Return true if the item has a value for the current index;
// does not differentiate between default values from the
// config and values which have been set in the deck.
bool hasValue( size_t ) const;
// if the number returned by this method is less than what is semantically
// expected (e.g. size() is less than the number of cells in the grid for
// keywords like e.g. SGL), then the remaining values are defaulted. The deck
// creates the defaulted items if all their sizes are fully specified by the
// keyword, though...
size_t size() const;
template< typename T > const T& get( size_t ) const;
double getSIDouble( size_t ) const;
std::string getTrimmedString( size_t ) const;
template< typename T > const std::vector< T >& getData() const;
const std::vector< double >& getSIDoubleData() const;
template< typename T > void push_back( T );
template< typename T > void push_back( T, size_t );
template< typename T > void push_backDefault( T );
// trying to access the data of a "dummy default item" will raise an exception
void push_backDummyDefault();
void push_backDimension(std::shared_ptr<const Dimension> /* activeDimension */,
std::shared_ptr<const Dimension> /* defaultDimension */);
type typeof() const;
private:
DeckItem( std::unique_ptr< DeckItemBase >&& );
std::unique_ptr< DeckItemBase > ptr;
};
class DeckItemBase {
public:
virtual const std::string& name() const = 0;
virtual bool defaultApplied( size_t ) const = 0;
virtual bool hasValue( size_t ) const = 0;
virtual size_t size() const = 0;
virtual void push_backDummyDefault() = 0;
virtual ~DeckItemBase() = default;
const DeckItem::type type_tag;
protected:
DeckItemBase( DeckItem::type tag ) : type_tag( tag ) {}
private:
virtual std::unique_ptr< DeckItemBase > clone() const = 0;
friend class DeckItem;
};
}
#endif /* DECKITEM_HPP */

View File

@@ -0,0 +1,128 @@
/*
Copyright 2013 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 "DeckKeyword.hpp"
#include "DeckRecord.hpp"
#include "DeckItem.hpp"
namespace Opm {
DeckKeyword::DeckKeyword(const std::string& keywordName) {
m_knownKeyword = true;
m_keywordName = keywordName;
m_isDataKeyword = false;
m_fileName = "";
m_lineNumber = -1;
}
DeckKeyword::DeckKeyword(const std::string& keywordName, bool knownKeyword) {
m_knownKeyword = knownKeyword;
m_keywordName = keywordName;
m_isDataKeyword = false;
m_fileName = "";
m_lineNumber = -1;
}
void DeckKeyword::setLocation(const std::string& fileName, int lineNumber) {
m_fileName = fileName;
m_lineNumber = lineNumber;
}
const std::string& DeckKeyword::getFileName() const {
return m_fileName;
}
int DeckKeyword::getLineNumber() const {
return m_lineNumber;
}
void DeckKeyword::setDataKeyword(bool isDataKeyword_) {
m_isDataKeyword = isDataKeyword_;
}
bool DeckKeyword::isDataKeyword() const {
return m_isDataKeyword;
}
const std::string& DeckKeyword::name() const {
return m_keywordName;
}
size_t DeckKeyword::size() const {
return m_recordList.size();
}
bool DeckKeyword::isKnown() const {
return m_knownKeyword;
}
void DeckKeyword::addRecord(DeckRecord&& record) {
this->m_recordList.push_back( std::move( record ) );
}
DeckKeyword::const_iterator DeckKeyword::begin() const {
return m_recordList.begin();
}
DeckKeyword::const_iterator DeckKeyword::end() const {
return m_recordList.end();
}
const DeckRecord& DeckKeyword::getRecord(size_t index) const {
return this->m_recordList.at( index );
}
DeckRecord& DeckKeyword::getRecord(size_t index) {
return this->m_recordList.at( index );
}
const DeckRecord& DeckKeyword::getDataRecord() const {
if (m_recordList.size() == 1)
return getRecord(0);
else
throw std::range_error("Not a data keyword ?");
}
size_t DeckKeyword::getDataSize() const {
return this->getDataRecord().getDataItem().size();
}
const std::vector<int>& DeckKeyword::getIntData() const {
return this->getDataRecord().getDataItem().getData< int >();
}
const std::vector<std::string>& DeckKeyword::getStringData() const {
return this->getDataRecord().getDataItem().getData< std::string >();
}
const std::vector<double>& DeckKeyword::getRawDoubleData() const {
return this->getDataRecord().getDataItem().getData< double >();
}
const std::vector<double>& DeckKeyword::getSIDoubleData() const {
return this->getDataRecord().getDataItem().getSIDoubleData();
}
}

View File

@@ -0,0 +1,82 @@
/*
Copyright 2016 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/>.
*/
#ifndef DECKKEYWORD_HPP
#define DECKKEYWORD_HPP
#include <string>
#include <vector>
#include <memory>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
namespace Opm {
class ParserKeyword;
class DeckKeyword {
public:
typedef std::vector< DeckRecord >::const_iterator const_iterator;
DeckKeyword(const std::string& keywordName);
DeckKeyword(const std::string& keywordName, bool knownKeyword);
const std::string& name() const;
void setLocation(const std::string& fileName, int lineNumber);
const std::string& getFileName() const;
int getLineNumber() const;
size_t size() const;
void addRecord(DeckRecord&& record);
const DeckRecord& getRecord(size_t index) const;
DeckRecord& getRecord(size_t index);
const DeckRecord& getDataRecord() const;
void setDataKeyword(bool isDataKeyword = true);
bool isKnown() const;
bool isDataKeyword() const;
const std::vector<int>& getIntData() const;
const std::vector<double>& getRawDoubleData() const;
const std::vector<double>& getSIDoubleData() const;
const std::vector<std::string>& getStringData() const;
size_t getDataSize() const;
template <class Keyword>
bool isKeyword() const {
if (Keyword::keywordName == m_keywordName)
return true;
else
return false;
}
const_iterator begin() const;
const_iterator end() const;
private:
std::string m_keywordName;
std::string m_fileName;
int m_lineNumber;
std::vector< DeckRecord > m_recordList;
bool m_knownKeyword;
bool m_isDataKeyword;
};
}
#endif /* DECKKEYWORD_HPP */

View File

@@ -0,0 +1,114 @@
/*
Copyright 2013 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 <stdexcept>
#include <string>
#include <algorithm>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
namespace Opm {
DeckRecord::DeckRecord( size_t size ) {
this->m_items.reserve( size );
}
size_t DeckRecord::size() const {
return m_items.size();
}
void DeckRecord::addItem( DeckItem&& deckItem ) {
if( this->hasItem( deckItem.name() ) )
throw std::invalid_argument(
"Item with name: "
+ deckItem.name()
+ " already exists in DeckRecord");
m_items.push_back( std::move( deckItem ) );
}
DeckItem& DeckRecord::getItem( size_t index ) {
return this->m_items.at( index );
}
DeckItem& DeckRecord::getItem(const std::string& name) {
const auto eq = [&name]( const DeckItem& e ) {
return e.name() == name;
};
auto item = std::find_if( m_items.begin(), m_items.end(), eq );
if( item == m_items.end() )
throw std::invalid_argument("Item: " + name + " does not exist.");
return *item;
}
DeckItem& DeckRecord::getDataItem() {
if (m_items.size() == 1)
return getItem(0);
else
throw std::range_error("Not a data keyword ?");
}
const DeckItem& DeckRecord::getItem( size_t index ) const {
return this->m_items.at( index );
}
const DeckItem& DeckRecord::getItem(const std::string& name) const {
const auto eq = [&name]( const DeckItem& e ) {
return e.name() == name;
};
auto item = std::find_if( this->begin(), this->end(), eq );
if( item == m_items.end() )
throw std::invalid_argument("Item: " + name + " does not exist.");
return *item;
}
const DeckItem& DeckRecord::getDataItem() const {
if (m_items.size() == 1)
return getItem(0);
else
throw std::range_error("Not a data keyword ?");
}
bool DeckRecord::hasItem(const std::string& name) const {
const auto eq = [&name]( const DeckItem& e ) {
return e.name() == name;
};
return std::any_of( this->begin(), this->end(), eq );
}
DeckRecord::const_iterator DeckRecord::begin() const {
return this->m_items.begin();
}
DeckRecord::const_iterator DeckRecord::end() const {
return this->m_items.end();
}
}

View File

@@ -0,0 +1,71 @@
/*
Copyright 2013 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/>.
*/
#ifndef DECKRECORD_HPP
#define DECKRECORD_HPP
#include <string>
#include <vector>
#include <memory>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
namespace Opm {
class DeckRecord {
public:
typedef std::vector< DeckItem >::const_iterator const_iterator;
DeckRecord() = default;
DeckRecord( size_t );
size_t size() const;
void addItem( DeckItem&& deckItem );
DeckItem& getItem( size_t index );
DeckItem& getItem( const std::string& name );
DeckItem& getDataItem();
const DeckItem& getItem( size_t index ) const;
const DeckItem& getItem( const std::string& name ) const;
const DeckItem& getDataItem() const;
bool hasItem(const std::string& name) const;
template <class Item>
DeckItem& getItem() {
return getItem( Item::itemName );
}
template <class Item>
const DeckItem& getItem() const {
return getItem( Item::itemName );
}
const_iterator begin() const;
const_iterator end() const;
private:
std::vector< DeckItem > m_items;
};
}
#endif /* DECKRECORD_HPP */

View File

@@ -0,0 +1,30 @@
/*
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 <opm/parser/eclipse/Deck/DeckTimeStep.hpp>
namespace Opm {
DeckTimeStep::DeckTimeStep() {
}
}

View File

@@ -0,0 +1,36 @@
/*
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/>.
*/
#ifndef DECKTIMESTEP_HPP
#define DECKTIMESTEP_HPP
#include <opm/parser/eclipse/Deck/Deck.hpp>
namespace Opm {
class DeckTimeStep : public Deck {
public:
DeckTimeStep();
};
typedef std::shared_ptr<DeckTimeStep> DeckTimeStepPtr;
typedef std::shared_ptr<const DeckTimeStep> DeckTimeStepConstPtr;
}
#endif

View File

@@ -0,0 +1,71 @@
/*
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 <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/DeckTimeStep.hpp>
#include <opm/parser/eclipse/Deck/SCHEDULESection.hpp>
namespace Opm {
SCHEDULESection::SCHEDULESection( const Deck& deck ) :
Section(deck, "SCHEDULE"), unit_system( deck.getActiveUnitSystem() )
{
populateDeckTimeSteps();
}
DeckTimeStepConstPtr SCHEDULESection::getDeckTimeStep(size_t timestep) const {
if (timestep < m_decktimesteps.size()) {
return m_decktimesteps[timestep];
} else {
throw std::out_of_range("No DeckTimeStep in ScheduleSection for timestep " + std::to_string(timestep));
}
}
void SCHEDULESection::populateDeckTimeSteps() {
DeckTimeStepPtr currentTimeStep = std::make_shared<DeckTimeStep>();
for( const auto& keyword : *this ) {
if (keyword.name() == "TSTEP") {
const auto& items = keyword.getDataRecord().getDataItem();
for (size_t item_iter = 0; item_iter < items.size(); ++item_iter) {
m_decktimesteps.push_back(currentTimeStep);
currentTimeStep = std::make_shared<DeckTimeStep>();
}
} else if (keyword.name() == "DATES") {
for (auto record_iter = keyword.begin(); record_iter != keyword.end(); ++record_iter ) {
m_decktimesteps.push_back(currentTimeStep);
currentTimeStep = std::make_shared<DeckTimeStep>();
}
} else {
currentTimeStep->addKeyword(keyword);
}
}
//push last step
m_decktimesteps.push_back(currentTimeStep);
}
const UnitSystem& SCHEDULESection::getActiveUnitSystem() const {
return this->unit_system;
}
}

View File

@@ -0,0 +1,49 @@
/*
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/>.
*/
#ifndef SCHEDULESECTION_HPP
#define SCHEDULESECTION_HPP
#include <memory>
#include <opm/parser/eclipse/Deck/Section.hpp>
namespace Opm {
class DeckTimeStep;
class SCHEDULESection : public Section {
public:
SCHEDULESection( const Deck& deck);
std::shared_ptr< const DeckTimeStep > getDeckTimeStep(size_t timestep) const;
const UnitSystem& getActiveUnitSystem() const;
private:
void populateDeckTimeSteps();
std::vector< std::shared_ptr< DeckTimeStep > > m_decktimesteps;
const UnitSystem& unit_system;
};
}
#endif // SCHEDULESECTION_HPP

View File

@@ -0,0 +1,81 @@
/*
Copyright 2013 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 <iostream>
#include <exception>
#include <algorithm>
#include <cassert>
#include <set>
#include <string>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {
static bool isSectionDelimiter( const DeckKeyword& keyword ) {
const auto& name = keyword.name();
for( const auto& x : { "RUNSPEC", "GRID", "EDIT", "PROPS",
"REGIONS", "SOLUTION", "SUMMARY", "SCHEDULE" } )
if( name == x ) return true;
return false;
}
static std::pair< DeckView::const_iterator, DeckView::const_iterator >
find_section( const Deck& deck, const std::string& keyword ) {
const auto fn = [&keyword]( const DeckKeyword& kw ) {
return kw.name() == keyword;
};
auto first = std::find_if( deck.begin(), deck.end(), fn );
if( first == deck.end() )
throw std::invalid_argument( std::string( "Deck requires a '" ) + keyword + "' section" );
auto last = std::find_if( first + 1, deck.end(), &isSectionDelimiter );
if( last != deck.end() && last->name() == keyword )
throw std::invalid_argument( std::string( "Deck contains the '" ) + keyword + "' section multiple times" );
return { first, last };
}
Section::Section( const Deck& deck, const std::string& section )
: DeckView( find_section( deck, section ) ),
section_name( section )
{}
const std::string& Section::name() const {
return this->section_name;
}
bool Section::hasRUNSPEC(const Deck& deck) { return deck.hasKeyword( "RUNSPEC" ); }
bool Section::hasGRID(const Deck& deck) { return deck.hasKeyword( "GRID" ); }
bool Section::hasEDIT(const Deck& deck) { return deck.hasKeyword( "EDIT" ); }
bool Section::hasPROPS(const Deck& deck) { return deck.hasKeyword( "PROPS" ); }
bool Section::hasREGIONS(const Deck& deck) { return deck.hasKeyword( "REGIONS" ); }
bool Section::hasSOLUTION(const Deck& deck) { return deck.hasKeyword( "SOLUTION" ); }
bool Section::hasSUMMARY(const Deck& deck) { return deck.hasKeyword( "SUMMARY" ); }
bool Section::hasSCHEDULE(const Deck& deck) { return deck.hasKeyword( "SCHEDULE" ); }
}

View File

@@ -0,0 +1,95 @@
/*
Copyright 2013 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/>.
*/
#ifndef SECTION_HPP
#define SECTION_HPP
#include <string>
#include <opm/parser/eclipse/Deck/Deck.hpp>
namespace Opm {
class UnitSystem;
class Parser;
class Section : public DeckView {
public:
using DeckView::const_iterator;
Section( const Deck& deck, const std::string& startKeyword );
const std::string& name() const;
static bool hasRUNSPEC( const Deck& );
static bool hasGRID( const Deck& );
static bool hasEDIT( const Deck& );
static bool hasPROPS( const Deck& );
static bool hasREGIONS( const Deck& );
static bool hasSOLUTION( const Deck& );
static bool hasSUMMARY( const Deck& );
static bool hasSCHEDULE( const Deck& );
// returns whether the deck has all mandatory sections and if all sections are in
// the right order
static bool checkSectionTopology(const Deck& deck,
const Parser&,
bool ensureKeywordSectionAffiliation = false);
private:
std::string section_name;
};
class RUNSPECSection : public Section {
public:
RUNSPECSection(const Deck& deck) : Section(deck, "RUNSPEC") {}
};
class GRIDSection : public Section {
public:
GRIDSection(const Deck& deck) : Section(deck, "GRID") {}
};
class EDITSection : public Section {
public:
EDITSection(const Deck& deck) : Section(deck, "EDIT") {}
};
class PROPSSection : public Section {
public:
PROPSSection(const Deck& deck) : Section(deck, "PROPS") {}
};
class REGIONSSection : public Section {
public:
REGIONSSection(const Deck& deck) : Section(deck, "REGIONS") {}
};
class SOLUTIONSection : public Section {
public:
SOLUTIONSection(const Deck& deck) : Section(deck, "SOLUTION") {}
};
class SUMMARYSection : public Section {
public:
SUMMARYSection(const Deck& deck) : Section(deck, "SUMMARY") {}
};
}
#endif // SECTION_HPP

View File

@@ -0,0 +1,6 @@
foreach(tapp DeckRecordTests DeckIntItemTests DeckDoubleItemTests
DeckStringItemTests DeckTests DeckKeywordTests SectionTests
DeckTimeStepTests)
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
LIBRARIES opmparser ${Boost_LIBRARIES})
endforeach()

View File

@@ -0,0 +1,166 @@
/*
Copyright 2013 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/>.
*/
#define BOOST_TEST_MODULE DeckItemTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <stdexcept>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(InitializeDouble) {
BOOST_REQUIRE_NO_THROW( DeckItem::make< double >("HEI") );
}
BOOST_AUTO_TEST_CASE(GetDoubleAtIndex_NoData_ExceptionThrown) {
auto deckDoubleItem = DeckItem::make< double >("TEST");
BOOST_CHECK_THROW(deckDoubleItem.get< double >(0), std::out_of_range);
deckDoubleItem.push_back(1.89);
BOOST_CHECK_THROW(deckDoubleItem.get< double >(1), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(sizeDouble_correct) {
auto deckDoubleItem = DeckItem::make< double >("TEST");
BOOST_CHECK_EQUAL( 0U , deckDoubleItem.size());
deckDoubleItem.push_back( 100.0 );
BOOST_CHECK_EQUAL( 1U , deckDoubleItem.size());
deckDoubleItem.push_back( 100.0 );
deckDoubleItem.push_back( 100.0 );
BOOST_CHECK_EQUAL( 3U , deckDoubleItem.size());
}
BOOST_AUTO_TEST_CASE(SetInDeck) {
auto deckDoubleItem = DeckItem::make< double >("TEST");
BOOST_CHECK( deckDoubleItem.size() == 0 );
deckDoubleItem.push_backDefault( 1.0 );
BOOST_CHECK( deckDoubleItem.size() == 1 );
BOOST_CHECK_EQUAL( true , deckDoubleItem.defaultApplied(0) );
deckDoubleItem.push_back( 10.0 );
BOOST_CHECK( deckDoubleItem.size() == 2 );
BOOST_CHECK_EQUAL( false , deckDoubleItem.defaultApplied(1) );
deckDoubleItem.push_backDefault( 1.0 );
BOOST_CHECK( deckDoubleItem.size() == 3 );
BOOST_CHECK_EQUAL( true , deckDoubleItem.defaultApplied(2) );
}
BOOST_AUTO_TEST_CASE(DummyDefaults) {
auto deckDoubleItem = DeckItem::make< double >("TEST");
BOOST_CHECK_EQUAL(deckDoubleItem.size(), 0);
deckDoubleItem.push_backDummyDefault();
BOOST_CHECK_EQUAL(deckDoubleItem.size(), 0);
BOOST_CHECK_EQUAL(true, deckDoubleItem.defaultApplied(0));
BOOST_CHECK_THROW(deckDoubleItem.get< double >(0), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(PushBackMultiple) {
auto item = DeckItem::make< double >("HEI");
item.push_back(10.22 , 100 );
BOOST_CHECK_EQUAL( 100U , item.size() );
for (size_t i=0; i < 100; i++)
BOOST_CHECK_EQUAL(10.22 , item.get< double >(i));
}
BOOST_AUTO_TEST_CASE(PushBackDimension) {
auto item = DeckItem::make< double >("HEI");
std::shared_ptr<Dimension> activeDimension(new Dimension("Length" , 100));
std::shared_ptr<Dimension> defaultDimension(new Dimension("Length" , 10));
item.push_back(1.234);
item.push_backDimension( activeDimension , defaultDimension);
item.push_backDefault(5.678);
item.push_backDimension( activeDimension , defaultDimension);
}
BOOST_AUTO_TEST_CASE(PushBackDimensionInvalidType) {
auto item = DeckItem::make< int >("HEI");
std::shared_ptr<Dimension> dim(new Dimension("Length" , 100));
BOOST_CHECK_THROW( item.push_backDimension( dim , dim ) , std::logic_error );
}
BOOST_AUTO_TEST_CASE(GetSIWithoutDimensionThrows) {
auto item = DeckItem::make< double >("HEI");
item.push_back(10.22 , 100 );
BOOST_CHECK_THROW( item.getSIDouble(0) , std::invalid_argument );
BOOST_CHECK_THROW( item.getSIDoubleData() , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(GetSISingleDimensionCorrect) {
auto item = DeckItem::make< double >("HEI");
std::shared_ptr<Dimension> dim(new Dimension("Length" , 100));
item.push_back(1.0 , 100 );
item.push_backDimension( dim , dim );
BOOST_CHECK_EQUAL( 1.0 , item.get< double >(0) );
BOOST_CHECK_EQUAL( 100 , item.getSIDouble(0) );
}
BOOST_AUTO_TEST_CASE(GetSISingleDefault) {
auto item = DeckItem::make< double >("HEI");
std::shared_ptr<Dimension> dim(new Dimension("Length" , 1));
std::shared_ptr<Dimension> defaultDim(new Dimension("Length" , 100));
item.push_backDefault( 1.0 );
item.push_backDimension( dim , defaultDim );
BOOST_CHECK_EQUAL( 1 , item.get< double >(0) );
BOOST_CHECK_EQUAL( 100 , item.getSIDouble(0) );
}
BOOST_AUTO_TEST_CASE(GetSIMultipleDim) {
auto item = DeckItem::make< double >("HEI");
std::shared_ptr<Dimension> dim1(new Dimension("Length" , 2));
std::shared_ptr<Dimension> dim2(new Dimension("Length" , 4));
std::shared_ptr<Dimension> dim3(new Dimension("Length" , 8));
std::shared_ptr<Dimension> dim4(new Dimension("Length" ,16));
std::shared_ptr<Dimension> defaultDim(new Dimension("Length" , 100));
item.push_back( 1.0, 16 );
item.push_backDimension( dim1 , defaultDim );
item.push_backDimension( dim2 , defaultDim );
item.push_backDimension( dim3 , defaultDim );
item.push_backDimension( dim4 , defaultDim );
for (size_t i=0; i < 16; i+= 4) {
BOOST_CHECK_EQUAL( 2 , item.getSIDouble(i) );
BOOST_CHECK_EQUAL( 4 , item.getSIDouble(i+ 1) );
BOOST_CHECK_EQUAL( 8 , item.getSIDouble(i+2) );
BOOST_CHECK_EQUAL(16 , item.getSIDouble(i+3) );
}
}

View File

@@ -0,0 +1,130 @@
/*
Copyright 2013 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/>.
*/
#define BOOST_TEST_MODULE DeckItemTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <stdexcept>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(Initialize) {
BOOST_REQUIRE_NO_THROW( DeckItem::make< int >("TEST") );
}
BOOST_AUTO_TEST_CASE(HasValue) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK_EQUAL( false , deckIntItem.hasValue(0) );
deckIntItem.push_back(1);
BOOST_CHECK_EQUAL( true , deckIntItem.hasValue(0) );
BOOST_CHECK_EQUAL( false , deckIntItem.hasValue(1) );
}
BOOST_AUTO_TEST_CASE(DummyDefaults) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK_EQUAL(deckIntItem.size(), 0);
deckIntItem.push_backDummyDefault();
BOOST_CHECK_EQUAL(deckIntItem.size(), 0);
BOOST_CHECK_EQUAL(true, deckIntItem.defaultApplied(0));
BOOST_CHECK_EQUAL( false , deckIntItem.hasValue(0));
BOOST_CHECK_EQUAL( false , deckIntItem.hasValue(1));
BOOST_CHECK_THROW(deckIntItem.get< int >(0), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(GetIntAtIndex_NoData_ExceptionThrown) {
auto deckIntItem = DeckItem::make< int >("TEST");
deckIntItem.push_back(100);
BOOST_CHECK(deckIntItem.get< int >(0) == 100);
BOOST_CHECK_THROW(deckIntItem.get< int >(1), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(InitializeDefaultApplied) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK( deckIntItem.size() == 0 );
}
BOOST_AUTO_TEST_CASE(size_correct) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK_EQUAL( 0U , deckIntItem.size());
deckIntItem.push_back( 100 );
BOOST_CHECK_EQUAL( 1U , deckIntItem.size());
deckIntItem.push_back( 100 );
deckIntItem.push_back( 100 );
BOOST_CHECK_EQUAL( 3U , deckIntItem.size());
}
BOOST_AUTO_TEST_CASE(DefaultNotApplied) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK( deckIntItem.size() == 0 );
deckIntItem.push_back( 100 );
BOOST_CHECK( deckIntItem.size() == 1 );
BOOST_CHECK( deckIntItem.get< int >(0) == 100 );
BOOST_CHECK( !deckIntItem.defaultApplied(0) );
BOOST_CHECK_THROW( deckIntItem.defaultApplied(1), std::out_of_range );
BOOST_CHECK_THROW( deckIntItem.get< int >(1), std::out_of_range );
}
BOOST_AUTO_TEST_CASE(UseDefault) {
auto deckIntItem = DeckItem::make< int >("TEST");
deckIntItem.push_backDefault( 100 );
BOOST_CHECK( deckIntItem.defaultApplied(0) );
BOOST_CHECK( deckIntItem.get< int >(0) == 100 );
BOOST_CHECK_THROW( deckIntItem.defaultApplied(1), std::out_of_range );
BOOST_CHECK_THROW( deckIntItem.get< int >(1), std::out_of_range );
}
BOOST_AUTO_TEST_CASE(DefaultApplied) {
auto deckIntItem = DeckItem::make< int >("TEST");
BOOST_CHECK( deckIntItem.size() == 0 );
deckIntItem.push_backDefault( 100 );
BOOST_CHECK( deckIntItem.size() == 1 );
BOOST_CHECK( deckIntItem.get< int >(0) == 100 );
BOOST_CHECK( deckIntItem.defaultApplied(0) );
deckIntItem.push_back( 10 );
BOOST_CHECK_EQUAL( false, deckIntItem.defaultApplied(1) );
deckIntItem.push_backDefault( 1 );
BOOST_CHECK_EQUAL( true , deckIntItem.defaultApplied(2) );
BOOST_CHECK_EQUAL( 3 , deckIntItem.size() );
}
BOOST_AUTO_TEST_CASE(PushBackMultiple) {
auto item = DeckItem::make< int >("HEI");
item.push_back(10 , 100U );
BOOST_CHECK_EQUAL( 100U , item.size() );
for (size_t i=0; i < 100; i++)
BOOST_CHECK_EQUAL(10 , item.get< int >(i));
}

View File

@@ -0,0 +1,84 @@
/*
Copyright 2013 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 <stdexcept>
#define BOOST_TEST_MODULE DeckKeywordTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(Initialize) {
DeckKeyword deckKeyword1("KW");
}
BOOST_AUTO_TEST_CASE(DataKeyword) {
DeckKeyword kw("KW");
BOOST_CHECK_EQUAL( false , kw.isDataKeyword());
kw.setDataKeyword( );
BOOST_CHECK_EQUAL( true , kw.isDataKeyword());
kw.setDataKeyword( false );
BOOST_CHECK_EQUAL( false , kw.isDataKeyword());
kw.setDataKeyword( true );
BOOST_CHECK_EQUAL( true , kw.isDataKeyword());
}
BOOST_AUTO_TEST_CASE(name_nameSetInConstructor_nameReturned) {
DeckKeyword deckKeyword( "KW" );
BOOST_CHECK_EQUAL("KW", deckKeyword.name());
}
BOOST_AUTO_TEST_CASE(size_noRecords_returnszero) {
DeckKeyword deckKeyword( "KW" );
BOOST_CHECK_EQUAL(0U, deckKeyword.size());
}
BOOST_AUTO_TEST_CASE(addRecord_onerecord_recordadded) {
DeckKeyword deckKeyword( "KW" );
deckKeyword.addRecord( DeckRecord() );
BOOST_CHECK_EQUAL(1U, deckKeyword.size());
for (auto iter = deckKeyword.begin(); iter != deckKeyword.end(); ++iter) {
//
}
}
BOOST_AUTO_TEST_CASE(getRecord_outofrange_exceptionthrown) {
DeckKeyword deckKeyword( "KW" );
deckKeyword.addRecord(DeckRecord());
BOOST_CHECK_THROW(deckKeyword.getRecord(1), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(setUnknown_wasknown_nowunknown) {
DeckKeyword deckKeyword( "KW", false );
BOOST_CHECK(!deckKeyword.isKnown());
}

View File

@@ -0,0 +1,111 @@
/*
Copyright 2013 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/>.
*/
#define BOOST_TEST_MODULE DeckRecordTests
#include <stdexcept>
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
#include <opm/parser/eclipse/Parser/ParserStringItem.hpp>
#include <boost/test/test_tools.hpp>
using namespace Opm;
static DeckItem mkIntItem( std::string name ) {
return DeckItem::make< int >( name );
}
BOOST_AUTO_TEST_CASE(Initialize) {
BOOST_CHECK_NO_THROW(DeckRecord deckRecord);
}
BOOST_AUTO_TEST_CASE(size_defaultConstructor_sizezero) {
DeckRecord deckRecord;
BOOST_CHECK_EQUAL(0U, deckRecord.size());
}
BOOST_AUTO_TEST_CASE(addItem_singleItem_sizeone) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
BOOST_CHECK_EQUAL(1U, deckRecord.size());
}
BOOST_AUTO_TEST_CASE(addItem_multipleItems_sizecorrect) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
deckRecord.addItem( mkIntItem( "TEST2" ) );
deckRecord.addItem( mkIntItem( "TEST3" ) );
BOOST_CHECK_EQUAL(3U, deckRecord.size());
}
BOOST_AUTO_TEST_CASE(addItem_sameItemTwoTimes_throws) {
DeckRecord deckRecord;
auto intItem1 = mkIntItem( "TEST" );
deckRecord.addItem( std::move( intItem1 ) );
BOOST_CHECK_THROW(deckRecord.addItem( std::move( intItem1 ) ), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(addItem_differentItemsSameName_throws) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
BOOST_CHECK_THROW( deckRecord.addItem( mkIntItem( "TEST" ) ), std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(get_byIndex_returnsItem) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
BOOST_CHECK_NO_THROW(deckRecord.getItem(0U));
}
BOOST_AUTO_TEST_CASE(get_indexoutofbounds_throws) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
BOOST_CHECK_THROW(deckRecord.getItem(1), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(get_byName_returnsItem) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
deckRecord.getItem("TEST");
}
BOOST_AUTO_TEST_CASE(get_byNameNonExisting_throws) {
DeckRecord deckRecord;
deckRecord.addItem( mkIntItem( "TEST" ) );
BOOST_CHECK_THROW(deckRecord.getItem("INVALID"), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(StringsWithSpaceOK) {
ParserStringItemPtr itemString(new ParserStringItem(std::string("STRINGITEM1")));
ParserRecordPtr record1(new ParserRecord());
RawRecord rawRecord( " ' VALUE ' " );
ParseContext parseContext;
record1->addItem( itemString );
const auto deckRecord = record1->parse( parseContext , rawRecord );
BOOST_CHECK_EQUAL(" VALUE " , deckRecord.getItem(0).get< std::string >(0));
}

View File

@@ -0,0 +1,93 @@
/*
Copyright 2013 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 <stdexcept>
#define BOOST_TEST_MODULE DeckStringItemTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(InitializeString) {
auto stringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK_EQUAL("TEST", stringItem.name());
}
BOOST_AUTO_TEST_CASE(DummyDefaults) {
auto deckStringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK_EQUAL(deckStringItem.size(), 0);
deckStringItem.push_backDummyDefault();
BOOST_CHECK_EQUAL(deckStringItem.size(), 0);
BOOST_CHECK_EQUAL(true, deckStringItem.defaultApplied(0));
BOOST_CHECK_THROW(deckStringItem.get< std::string >(0), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(GetStringAtIndex_NoData_ExceptionThrown) {
auto deckStringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK_THROW(deckStringItem.get< std::string >(0), std::out_of_range);
deckStringItem.push_back("SA");
BOOST_CHECK_THROW(deckStringItem.get< std::string >(1), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(size_variouspushes_sizecorrect) {
auto deckStringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK_EQUAL(0U, deckStringItem.size());
deckStringItem.push_back("WELL-3");
BOOST_CHECK_EQUAL(1U, deckStringItem.size());
deckStringItem.push_back("WELL-4");
deckStringItem.push_back("WELL-5");
BOOST_CHECK_EQUAL(3U, deckStringItem.size());
}
BOOST_AUTO_TEST_CASE(DefaultNotApplied) {
auto deckStringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK( deckStringItem.size() == 0 );
deckStringItem.push_back( "FOO") ;
BOOST_CHECK( deckStringItem.size() == 1 );
BOOST_CHECK( deckStringItem.get< std::string >(0) == "FOO" );
BOOST_CHECK( !deckStringItem.defaultApplied(0) );
}
BOOST_AUTO_TEST_CASE(DefaultApplied) {
auto deckStringItem = DeckItem::make< std::string >("TEST");
BOOST_CHECK( deckStringItem.size() == 0 );
deckStringItem.push_backDefault( "FOO" );
BOOST_CHECK( deckStringItem.size() == 1 );
BOOST_CHECK( deckStringItem.get< std::string >(0) == "FOO" );
BOOST_CHECK( deckStringItem.defaultApplied(0) );
}
BOOST_AUTO_TEST_CASE(PushBackMultiple) {
auto stringItem = DeckItem::make< std::string >("HEI");
stringItem.push_back("Heisann ", 100U );
BOOST_CHECK_EQUAL( 100U , stringItem.size() );
for (size_t i=0; i < 100; i++)
BOOST_CHECK_EQUAL("Heisann " , stringItem.get< std::string >(i));
}

View File

@@ -0,0 +1,163 @@
/*
Copyright 2013 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 <stdexcept>
#define BOOST_TEST_MODULE DeckTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(Initialize) {
BOOST_REQUIRE_NO_THROW(Deck deck);
BOOST_REQUIRE_NO_THROW(DeckPtr deckPtr(new Deck()));
BOOST_REQUIRE_NO_THROW(DeckConstPtr deckConstPtr(new Deck()));
}
BOOST_AUTO_TEST_CASE(hasKeyword_empty_returnFalse) {
Deck deck;
BOOST_CHECK_EQUAL(false, deck.hasKeyword("Bjarne"));
BOOST_CHECK_THROW( deck.getKeyword("Bjarne") , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(addKeyword_singlekeyword_keywordAdded) {
Deck deck;
BOOST_CHECK_NO_THROW(deck.addKeyword( DeckKeyword( "BJARNE" ) ) );
}
BOOST_AUTO_TEST_CASE(getKeywordList_empty_list) {
Deck deck;
auto kw_list = deck.getKeywordList("TRULS");
BOOST_CHECK_EQUAL( kw_list.size() , 0 );
}
BOOST_AUTO_TEST_CASE(getKeyword_singlekeyword_outRange_throws) {
Deck deck;
deck.addKeyword( DeckKeyword( "BJARNE" ) );
BOOST_CHECK_THROW(deck.getKeyword("BJARNE" , 10) , std::out_of_range);
}
BOOST_AUTO_TEST_CASE(getKeywordList_returnOK) {
Deck deck;
deck.addKeyword( DeckKeyword( "BJARNE" ) );
BOOST_CHECK_NO_THROW( deck.getKeywordList("BJARNE") );
}
BOOST_AUTO_TEST_CASE(getKeyword_indexok_returnskeyword) {
Deck deck;
deck.addKeyword( DeckKeyword( "BJARNE" ) );
BOOST_CHECK_NO_THROW(deck.getKeyword(0));
}
BOOST_AUTO_TEST_CASE(numKeyword_singlekeyword_return1) {
Deck deck;
deck.addKeyword( DeckKeyword( "BJARNE" ) );
BOOST_CHECK_EQUAL(1U , deck.count("BJARNE"));
}
BOOST_AUTO_TEST_CASE(numKeyword_twokeyword_return2) {
Deck deck;
DeckKeyword keyword("BJARNE");
deck.addKeyword(keyword);
deck.addKeyword(keyword);
BOOST_CHECK_EQUAL(2U , deck.count("BJARNE"));
}
BOOST_AUTO_TEST_CASE(numKeyword_nokeyword_return0) {
Deck deck;
deck.addKeyword( DeckKeyword( "BJARNE" ) );
BOOST_CHECK_EQUAL(0U , deck.count("BJARNEX"));
}
BOOST_AUTO_TEST_CASE(size_twokeyword_return2) {
Deck deck;
DeckKeyword keyword ("BJARNE");
deck.addKeyword(keyword);
deck.addKeyword(keyword);
BOOST_CHECK_EQUAL(2U , deck.size());
}
BOOST_AUTO_TEST_CASE(getKeyword_outOfRange_throws) {
Deck deck;
deck.addKeyword(DeckKeyword( "TRULS" ) );
BOOST_CHECK_THROW( deck.getKeyword("TRULS" , 3) , std::out_of_range);
}
BOOST_AUTO_TEST_CASE(getKeywordList_OK) {
Deck deck;
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULS" ) );
const auto& keywordList = deck.getKeywordList("TRULS");
BOOST_CHECK_EQUAL( 3U , keywordList.size() );
}
BOOST_AUTO_TEST_CASE(keywordList_getnum_OK) {
Deck deck;
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULSX" ) );
BOOST_CHECK_EQUAL( 0U , deck.count( "TRULSY" ));
BOOST_CHECK_EQUAL( 2U , deck.count( "TRULS" ));
BOOST_CHECK_EQUAL( 1U , deck.count( "TRULSX" ));
}
BOOST_AUTO_TEST_CASE(keywordList_getbyindexoutofbounds_exceptionthrown) {
Deck deck;
BOOST_CHECK_THROW(deck.getKeyword(0), std::out_of_range);
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULSX" ) );
BOOST_CHECK_NO_THROW(deck.getKeyword(2));
BOOST_CHECK_THROW(deck.getKeyword(3), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(keywordList_getbyindex_correctkeywordreturned) {
Deck deck;
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULS" ) );
deck.addKeyword( DeckKeyword( "TRULSX" ) );
BOOST_CHECK_EQUAL("TRULS", deck.getKeyword(0).name());
BOOST_CHECK_EQUAL("TRULS", deck.getKeyword(1).name());
BOOST_CHECK_EQUAL("TRULSX", deck.getKeyword(2).name());
}
BOOST_AUTO_TEST_CASE(set_and_get_data_file) {
Deck deck;
BOOST_CHECK_EQUAL("", deck.getDataFile());
std::string file("/path/to/file.DATA");
deck.setDataFile( file );
BOOST_CHECK_EQUAL(file, deck.getDataFile());
}

View File

@@ -0,0 +1,136 @@
/*
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/>.
*/
#define BOOST_TEST_MODULE DeckTimeStepTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <opm/parser/eclipse/Deck/DeckTimeStep.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/SCHEDULESection.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(testDeckTimeStepInitialize) {
BOOST_CHECK_NO_THROW(DeckTimeStep deckTimeStep);
}
BOOST_AUTO_TEST_CASE(testDeckTimeStepTSTEP) {
Opm::Parser parser;
std::string input =
"START -- 0 \n"
"19 JUN 2007 / \n"
"SCHEDULE\n"
"DATES -- 1,2\n"
" 10 OKT 2008 / \n"
" 11 OKT 2008 / \n"
"/\n"
"WELSPECS\n"
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
"/\n"
"COMPDAT\n"
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
" 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
"/\n"
"DATES -- 3,4\n"
" 20 JAN 2010 / \n"
" 21 JAN 2010 / \n"
"/\n";
ParseContext parseContext;
DeckPtr deck = parser.parseString(input, parseContext);
SCHEDULESection scheduleSection = SCHEDULESection(*deck);
DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0);
DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1);
DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2);
DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3);
BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), true);
BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false);
}
BOOST_AUTO_TEST_CASE(testDeckTimeStepDATES) {
Opm::Parser parser;
std::string input =
"RUNSPEC\n"
"INIT\n"
"UNIFOUT\n"
"OIL\n"
"GAS\n"
"WATER\n"
"METRIC\n"
"DIMENS\n"
"3 3 3/\n"
"GRID\n"
"DXV\n"
"1.0 2.0 3.0 /\n"
"DYV\n"
"4.0 5.0 6.0 /\n"
"DZV\n"
"7.0 8.0 9.0 /\n"
"TOPS\n"
"9*100 /\n"
"PROPS\n"
"PORO\n"
"27*0.3 /\n"
"PERMX\n"
"27*1 /\n"
"SOLUTION\n"
"RPTRST\n"
"BASIC=2\n"
"/\n"
"SCHEDULE\n"
"TSTEP\n"
"1.0 2.0 3.0 4.0 /\n"
"WELSPECS\n"
"'INJ' 'G' 1 1 2000 'GAS' /\n"
"'PROD' 'G' 3 3 1000 'OIL' /\n"
"/\n";
ParseContext parseContext;
DeckPtr deck = parser.parseString(input, parseContext);
SCHEDULESection scheduleSection = SCHEDULESection(*deck);
DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0);
DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1);
DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2);
DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3);
DeckTimeStepConstPtr step5 = scheduleSection.getDeckTimeStep(4);
BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step5->hasKeyword("WELSPECS"), true);
}

View File

@@ -0,0 +1,392 @@
/*
Copyright 2013 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/>.
*/
#define BOOST_TEST_MODULE SectionTests
#include <stdexcept>
#include <iostream>
#include <typeinfo>
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/SCHEDULESection.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(SectionTest) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword("TEST0") );
deck->addKeyword( DeckKeyword("RUNSPEC") );
deck->addKeyword( DeckKeyword("TEST1") );
deck->addKeyword( DeckKeyword("GRID") );
deck->addKeyword( DeckKeyword("TEST2") );
deck->addKeyword( DeckKeyword("SCHEDULE") );
deck->addKeyword( DeckKeyword("TEST3") );
Section runspecSection(*deck, "RUNSPEC");
Section gridSection(*deck, "GRID");
BOOST_CHECK(runspecSection.hasKeyword("TEST1"));
BOOST_CHECK(gridSection.hasKeyword("TEST2"));
BOOST_CHECK(!runspecSection.hasKeyword("TEST0"));
BOOST_CHECK(!gridSection.hasKeyword("TEST0"));
BOOST_CHECK(!runspecSection.hasKeyword("TEST3"));
BOOST_CHECK(!gridSection.hasKeyword("TEST3"));
BOOST_CHECK(!runspecSection.hasKeyword("TEST2"));
BOOST_CHECK(!gridSection.hasKeyword("TEST1"));
}
BOOST_AUTO_TEST_CASE(IteratorTest) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "RUNSPEC" ) );
deck->addKeyword( DeckKeyword("TEST2") );
deck->addKeyword( DeckKeyword( "TEST3" ) );
deck->addKeyword( DeckKeyword( "GRID" ) );
Section section(*deck, "RUNSPEC");
int numberOfItems = 0;
for (auto iter=section.begin(); iter != section.end(); ++iter) {
std::cout << iter->name() << std::endl;
numberOfItems++;
}
// the keywords expected here are RUNSPEC, TEST2 and TEST3...
BOOST_CHECK_EQUAL(3, numberOfItems);
}
BOOST_AUTO_TEST_CASE(RUNSPECSection_EmptyDeck) {
DeckPtr deck(new Deck());
BOOST_REQUIRE_THROW(RUNSPECSection section(*deck), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(RUNSPECSection_ReadSimpleDeck) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "TEST1") );
deck->addKeyword( DeckKeyword( "RUNSPEC") );
deck->addKeyword( DeckKeyword( "TEST2") );
deck->addKeyword( DeckKeyword( "TEST3") );
deck->addKeyword( DeckKeyword( "GRID") );
deck->addKeyword( DeckKeyword( "TEST4") );
RUNSPECSection section(*deck);
BOOST_CHECK(!section.hasKeyword("TEST1"));
BOOST_CHECK(section.hasKeyword("RUNSPEC"));
BOOST_CHECK(section.hasKeyword("TEST2"));
BOOST_CHECK(section.hasKeyword("TEST3"));
BOOST_CHECK(!section.hasKeyword("GRID"));
BOOST_CHECK(!section.hasKeyword("TEST4"));
}
BOOST_AUTO_TEST_CASE(RUNSPECSection_ReadSmallestPossibleDeck) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "RUNSPEC" ) );
deck->addKeyword( DeckKeyword( "GRID") );
RUNSPECSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("RUNSPEC"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("GRID"));
}
BOOST_AUTO_TEST_CASE(GRIDSection_TerminatedByEDITKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "GRID" ) );
deck->addKeyword( DeckKeyword( "EDIT" ) );
GRIDSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("GRID"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("EDIT"));
}
BOOST_AUTO_TEST_CASE(GRIDSection_TerminatedByPROPSKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "GRID" ) );
deck->addKeyword( DeckKeyword( "PROPS" ) );
GRIDSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("GRID"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("PROPS"));
}
BOOST_AUTO_TEST_CASE(EDITSection_TerminatedByPROPSKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "EDIT" ) );
deck->addKeyword( DeckKeyword( "PROPS" ) );
EDITSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("EDIT"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("PROPS"));
}
BOOST_AUTO_TEST_CASE(PROPSSection_TerminatedByREGIONSKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "PROPS" ) );
deck->addKeyword( DeckKeyword( "REGIONS" ) );
PROPSSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("PROPS"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("REGIONS"));
}
BOOST_AUTO_TEST_CASE(PROPSSection_TerminatedBySOLUTIONKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "PROPS" ) );
deck->addKeyword( DeckKeyword( "SOLUTION" ) );
PROPSSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("PROPS"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("SOLUTION"));
}
BOOST_AUTO_TEST_CASE(REGIONSSection_TerminatedBySOLUTIONKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "REGIONS" ) );
deck->addKeyword( DeckKeyword( "SOLUTION" ) );
REGIONSSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("REGIONS"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("SOLUTION"));
}
BOOST_AUTO_TEST_CASE(SOLUTIONSection_TerminatedBySUMMARYKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "SOLUTION" ) );
deck->addKeyword( DeckKeyword( "SUMMARY" ) );
SOLUTIONSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("SOLUTION"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("SUMMARY"));
}
BOOST_AUTO_TEST_CASE(SOLUTIONSection_TerminatedBySCHEDULEKeyword) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "SOLUTION" ) );
deck->addKeyword( DeckKeyword( "SCHEDULE" ) );
SOLUTIONSection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("SOLUTION"));
BOOST_CHECK_EQUAL(false, section.hasKeyword("SCHEDULE"));
}
BOOST_AUTO_TEST_CASE(SCHEDULESection_NotTerminated) {
DeckPtr deck(new Deck());
deck->addKeyword( DeckKeyword( "SCHEDULE" ) );
deck->addKeyword( DeckKeyword( "TEST1" ) );
deck->addKeyword( DeckKeyword( "TEST2" ) );
deck->addKeyword( DeckKeyword( "TEST3" ) );
deck->addKeyword( DeckKeyword( "TEST4" ) );
SCHEDULESection section(*deck);
BOOST_CHECK_EQUAL(true, section.hasKeyword("SCHEDULE"));
BOOST_CHECK_EQUAL(true, section.hasKeyword("TEST1"));
BOOST_CHECK_EQUAL(true, section.hasKeyword("TEST2"));
BOOST_CHECK_EQUAL(true, section.hasKeyword("TEST3"));
BOOST_CHECK( Section::hasSCHEDULE(*deck ));
BOOST_CHECK( !Section::hasREGIONS(*deck ));
}
BOOST_AUTO_TEST_CASE(Section_ValidDecks) {
ParseContext mode = { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE } } };
Parser parser;
const std::string minimal = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST3\n"
"SOLUTION\n"
"TEST4\n"
"SCHEDULE\n"
"TEST5\n";
std::unique_ptr< Deck > deck( parser.newDeckFromString( minimal, mode ) );
BOOST_CHECK( Opm::Section::checkSectionTopology(*deck, parser) );
const std::string with_opt = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"EDIT\n"
"TEST3\n"
"PROPS\n"
"TEST4\n"
"REGIONS\n"
"TEST5\n"
"SOLUTION\n"
"TEST6\n"
"SUMMARY\n"
"TEST7\n"
"SCHEDULE\n"
"TEST8\n";
deck.reset( parser.newDeckFromString( with_opt, mode ) );
BOOST_CHECK(Opm::Section::checkSectionTopology(*deck, parser));
}
BOOST_AUTO_TEST_CASE(Section_InvalidDecks) {
Parser parser;
ParseContext mode = { { { ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE } } };
const std::string keyword_before_RUNSPEC =
"WWCT \n /\n"
"RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST3\n"
"SOLUTION\n"
"TEST4\n"
"SCHEDULE\n"
"TEST5\n";
std::unique_ptr< Deck > deck( parser.newDeckFromString( keyword_before_RUNSPEC, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string wrong_order = "RUNSPEC\n"
"TEST1\n"
"EDIT\n"
"TEST3\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST4\n"
"REGIONS\n"
"TEST5\n"
"SOLUTION\n"
"TEST6\n"
"SUMMARY\n"
"TEST7\n"
"SCHEDULE\n"
"TEST8\n";
deck.reset( parser.newDeckFromString( wrong_order, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string duplicate = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"GRID\n"
"TEST21\n"
"EDIT\n"
"TEST3\n"
"PROPS\n"
"TEST4\n"
"REGIONS\n"
"TEST5\n"
"SOLUTION\n"
"TEST6\n"
"SUMMARY\n"
"TEST7\n"
"SCHEDULE\n"
"TEST8\n";
deck.reset( parser.newDeckFromString( duplicate, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string section_after_SCHEDULE = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST4\n"
"REGIONS\n"
"TEST5\n"
"SOLUTION\n"
"TEST6\n"
"SUMMARY\n"
"TEST7\n"
"SCHEDULE\n"
"TEST8\n"
"EDIT\n"
"TEST3\n";
deck.reset( parser.newDeckFromString( section_after_SCHEDULE, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string missing_runspec = "GRID\n"
"TEST2\n"
"PROPS\n"
"TEST3\n"
"SOLUTION\n"
"TEST4\n"
"SCHEDULE\n"
"TEST5\n";
deck.reset( parser.newDeckFromString( missing_runspec, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string missing_GRID = "RUNSPEC\n"
"TEST1\n"
"PROPS\n"
"TEST3\n"
"SOLUTION\n"
"TEST4\n"
"SCHEDULE\n"
"TEST5\n";
deck.reset( parser.newDeckFromString( missing_GRID, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string missing_PROPS = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"SOLUTION\n"
"TEST4\n"
"SCHEDULE\n"
"TEST5\n";
deck.reset( parser.newDeckFromString( missing_PROPS, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string missing_SOLUTION = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST3\n"
"SCHEDULE\n"
"TEST5\n";
deck.reset( parser.newDeckFromString( missing_SOLUTION, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
const std::string missing_SCHEDULE = "RUNSPEC\n"
"TEST1\n"
"GRID\n"
"TEST2\n"
"PROPS\n"
"TEST3\n"
"SOLUTION\n"
"TEST4\n";
deck.reset( parser.newDeckFromString( missing_SCHEDULE, mode ) );
BOOST_CHECK(!Opm::Section::checkSectionTopology(*deck, parser));
}

View File

@@ -0,0 +1,910 @@
/*
Copyright 2013 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 <functional>
#include <boost/algorithm/string/join.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
namespace Opm {
namespace GridPropertyPostProcessor {
void distTopLayer( std::vector<double>& values,
const EclipseGrid* eclipseGrid )
{
size_t layerSize = eclipseGrid->getNX() * eclipseGrid->getNY();
size_t gridSize = eclipseGrid->getCartesianSize();
for( size_t globalIndex = layerSize; globalIndex < gridSize; globalIndex++ ) {
if( std::isnan( values[ globalIndex ] ) )
values[globalIndex] = values[globalIndex - layerSize];
}
}
/// initPORV uses doubleGridProperties: PORV, PORO, NTG, MULTPV
void initPORV( std::vector<double>& values,
const EclipseGrid* eclipseGrid,
GridProperties<double>* doubleGridProperties)
{
/*
Observe that this apply method does not alter the values input
vector, instead it fetches the PORV property one more time, and
then manipulates that.
*/
const auto& porv = doubleGridProperties->getOrCreateProperty("PORV");
if (porv.containsNaN()) {
const auto& poro = doubleGridProperties->getOrCreateProperty("PORO");
const auto& ntg = doubleGridProperties->getOrCreateProperty("NTG");
if (poro.containsNaN())
throw std::logic_error("Do not have information for the PORV keyword - some defaulted values in PORO");
else {
const auto& poroData = poro.getData();
for (size_t globalIndex = 0; globalIndex < porv.getCartesianSize(); globalIndex++) {
if (std::isnan(values[globalIndex])) {
double cell_poro = poroData[globalIndex];
double cell_ntg = ntg.iget(globalIndex);
double cell_volume = eclipseGrid->getCellVolume(globalIndex);
values[globalIndex] = cell_poro * cell_volume * cell_ntg;
}
}
}
}
if (doubleGridProperties->hasKeyword("MULTPV")) {
const auto& multpvData = doubleGridProperties->getKeyword("MULTPV").getData();
for (size_t globalIndex = 0; globalIndex < porv.getCartesianSize(); globalIndex++) {
values[globalIndex] *= multpvData[globalIndex];
}
}
}
}
static std::vector< GridProperties< int >::SupportedKeywordInfo >
makeSupportedIntKeywords() {
return {GridProperties< int >::SupportedKeywordInfo( "ACTNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "SATNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "IMBNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "PVTNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "EQLNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "ENDNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "FLUXNUM", 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "MULTNUM", 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "FIPNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "MISCNUM", 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "OPERNUM", 1, "1" ),
};
}
static std::vector< GridProperties< double >::SupportedKeywordInfo >
makeSupportedDoubleKeywords(const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties)
{
using std::placeholders::_1;
const auto SGLLookup = std::bind( SGLEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISGLLookup = std::bind( ISGLEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SWLLookup = std::bind( SWLEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISWLLookup = std::bind( ISWLEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SGULookup = std::bind( SGUEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISGULookup = std::bind( ISGUEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SWULookup = std::bind( SWUEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISWULookup = std::bind( ISWUEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SGCRLookup = std::bind( SGCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISGCRLookup = std::bind( ISGCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SOWCRLookup = std::bind( SOWCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISOWCRLookup = std::bind( ISOWCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SOGCRLookup = std::bind( SOGCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISOGCRLookup = std::bind( ISOGCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto SWCRLookup = std::bind( SWCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto ISWCRLookup = std::bind( ISWCREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto PCWLookup = std::bind( PCWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IPCWLookup = std::bind( IPCWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto PCGLookup = std::bind( PCGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IPCGLookup = std::bind( IPCGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRWLookup = std::bind( KRWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRWLookup = std::bind( IKRWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRWRLookup = std::bind( KRWREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRWRLookup = std::bind( IKRWREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KROLookup = std::bind( KROEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKROLookup = std::bind( IKROEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRORWLookup = std::bind( KRORWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRORWLookup = std::bind( IKRORWEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRORGLookup = std::bind( KRORGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRORGLookup = std::bind( IKRORGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRGLookup = std::bind( KRGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRGLookup = std::bind( IKRGEndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto KRGRLookup = std::bind( KRGREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto IKRGRLookup = std::bind( IKRGREndpoint, _1, tableManager, eclipseGrid, intGridProperties );
const auto tempLookup = std::bind( temperature_lookup, _1, tableManager, eclipseGrid, intGridProperties );
const auto distributeTopLayer = std::bind( &GridPropertyPostProcessor::distTopLayer, _1, eclipseGrid );
std::vector< GridProperties< double >::SupportedKeywordInfo > supportedDoubleKeywords;
// keywords to specify the scaled connate gas saturations.
for( const auto& kw : { "SGL", "SGLX", "SGLX-", "SGLY", "SGLY-", "SGLZ", "SGLZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGLLookup, "1" );
for( const auto& kw : { "ISGL", "ISGLX", "ISGLX-", "ISGLY", "ISGLY-", "ISGLZ", "ISGLZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGLLookup, "1" );
// keywords to specify the connate water saturation.
for( const auto& kw : { "SWL", "SWLX", "SWLX-", "SWLY", "SWLY-", "SWLZ", "SWLZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWLLookup, "1" );
for( const auto& kw : { "ISWL", "ISWLX", "ISWLX-", "ISWLY", "ISWLY-", "ISWLZ", "ISWLZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWLLookup, "1" );
// keywords to specify the maximum gas saturation.
for( const auto& kw : { "SGU", "SGUX", "SGUX-", "SGUY", "SGUY-", "SGUZ", "SGUZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGULookup, "1" );
for( const auto& kw : { "ISGU", "ISGUX", "ISGUX-", "ISGUY", "ISGUY-", "ISGUZ", "ISGUZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGULookup, "1" );
// keywords to specify the maximum water saturation.
for( const auto& kw : { "SWU", "SWUX", "SWUX-", "SWUY", "SWUY-", "SWUZ", "SWUZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWULookup, "1" );
for( const auto& kw : { "ISWU", "ISWUX", "ISWUX-", "ISWUY", "ISWUY-", "ISWUZ", "ISWUZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWULookup, "1" );
// keywords to specify the scaled critical gas saturation.
for( const auto& kw : { "SGCR", "SGCRX", "SGCRX-", "SGCRY", "SGCRY-", "SGCRZ", "SGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGCRLookup, "1" );
for( const auto& kw : { "ISGCR", "ISGCRX", "ISGCRX-", "ISGCRY", "ISGCRY-", "ISGCRZ", "ISGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGCRLookup, "1" );
// keywords to specify the scaled critical oil-in-water saturation.
for( const auto& kw : { "SOWCR", "SOWCRX", "SOWCRX-", "SOWCRY", "SOWCRY-", "SOWCRZ", "SOWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SOWCRLookup, "1" );
for( const auto& kw : { "ISOWCR", "ISOWCRX", "ISOWCRX-", "ISOWCRY", "ISOWCRY-", "ISOWCRZ", "ISOWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISOWCRLookup, "1" );
// keywords to specify the scaled critical oil-in-gas saturation.
for( const auto& kw : { "SOGCR", "SOGCRX", "SOGCRX-", "SOGCRY", "SOGCRY-", "SOGCRZ", "SOGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SOGCRLookup, "1" );
for( const auto& kw : { "ISOGCR", "ISOGCRX", "ISOGCRX-", "ISOGCRY", "ISOGCRY-", "ISOGCRZ", "ISOGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISOGCRLookup, "1" );
// keywords to specify the scaled critical water saturation.
for( const auto& kw : { "SWCR", "SWCRX", "SWCRX-", "SWCRY", "SWCRY-", "SWCRZ", "SWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWCRLookup, "1" );
for( const auto& kw : { "ISWCR", "ISWCRX", "ISWCRX-", "ISWCRY", "ISWCRY-", "ISWCRZ", "ISWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWCRLookup, "1" );
// keywords to specify the scaled oil-water capillary pressure
for( const auto& kw : { "PCW", "PCWX", "PCWX-", "PCWY", "PCWY-", "PCWZ", "PCWZ-" } )
supportedDoubleKeywords.emplace_back( kw, PCWLookup, "1" );
for( const auto& kw : { "IPCW", "IPCWX", "IPCWX-", "IPCWY", "IPCWY-", "IPCWZ", "IPCWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IPCWLookup, "1" );
// keywords to specify the scaled gas-oil capillary pressure
for( const auto& kw : { "PCG", "PCGX", "PCGX-", "PCGY", "PCGY-", "PCGZ", "PCGZ-" } )
supportedDoubleKeywords.emplace_back( kw, PCGLookup, "1" );
for( const auto& kw : { "IPCG", "IPCGX", "IPCGX-", "IPCGY", "IPCGY-", "IPCGZ", "IPCGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IPCGLookup, "1" );
// keywords to specify the scaled water relative permeability
for( const auto& kw : { "KRW", "KRWX", "KRWX-", "KRWY", "KRWY-", "KRWZ", "KRWZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRWLookup, "1" );
for( const auto& kw : { "IKRW", "IKRWX", "IKRWX-", "IKRWY", "IKRWY-", "IKRWZ", "IKRWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRWLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// saturation
for( const auto& kw : { "KRWR" , "KRWRX" , "KRWRX-" , "KRWRY" , "KRWRY-" , "KRWRZ" , "KRWRZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRWRLookup, "1" );
for( const auto& kw : { "IKRWR" , "IKRWRX" , "IKRWRX-" , "IKRWRY" , "IKRWRY-" , "IKRWRZ" , "IKRWRZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRWRLookup, "1" );
// keywords to specify the scaled oil relative permeability
for( const auto& kw : { "KRO", "KROX", "KROX-", "KROY", "KROY-", "KROZ", "KROZ-" } )
supportedDoubleKeywords.emplace_back( kw, KROLookup, "1" );
for( const auto& kw : { "IKRO", "IKROX", "IKROX-", "IKROY", "IKROY-", "IKROZ", "IKROZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKROLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// water saturation
for( const auto& kw : { "KRORW", "KRORWX", "KRORWX-", "KRORWY", "KRORWY-", "KRORWZ", "KRORWZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRORWLookup, "1" );
for( const auto& kw : { "IKRORW", "IKRORWX", "IKRORWX-", "IKRORWY", "IKRORWY-", "IKRORWZ", "IKRORWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRORWLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// water saturation
for( const auto& kw : { "KRORG", "KRORGX", "KRORGX-", "KRORGY", "KRORGY-", "KRORGZ", "KRORGZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRORGLookup, "1" );
for( const auto& kw : { "IKRORG", "IKRORGX", "IKRORGX-", "IKRORGY", "IKRORGY-", "IKRORGZ", "IKRORGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRORGLookup, "1" );
// keywords to specify the scaled gas relative permeability
for( const auto& kw : { "KRG", "KRGX", "KRGX-", "KRGY", "KRGY-", "KRGZ", "KRGZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRGLookup, "1" );
for( const auto& kw : { "IKRG", "IKRGX", "IKRGX-", "IKRGY", "IKRGY-", "IKRGZ", "IKRGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRGLookup, "1" );
// keywords to specify the scaled gas relative permeability
for( const auto& kw : { "KRGR", "KRGRX", "KRGRX-", "KRGRY", "KRGRY-", "KRGRZ", "KRGRZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRGRLookup, "1" );
for( const auto& kw : { "IKRGR", "IKRGRX", "IKRGRX-", "IKRGRY", "IKRGRY-", "IKRGRZ", "IKRGRZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRGRLookup, "1" );
// Solution keywords - required fror enumerated restart.
supportedDoubleKeywords.emplace_back( "PRESSURE", 0.0 , "Pressure" );
supportedDoubleKeywords.emplace_back( "SWAT", 0.0 , "1" );
supportedDoubleKeywords.emplace_back( "SGAS", 0.0 , "1" );
// cell temperature (E300 only, but makes a lot of sense for E100, too)
supportedDoubleKeywords.emplace_back( "TEMPI", tempLookup, "Temperature" );
const double nan = std::numeric_limits<double>::quiet_NaN();
// porosity
supportedDoubleKeywords.emplace_back( "PORO", nan, distributeTopLayer, "1" );
// pore volume multipliers
supportedDoubleKeywords.emplace_back( "MULTPV", 1.0, "1" );
// the permeability keywords
for( const auto& kw : { "PERMX", "PERMY", "PERMZ" } )
supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" );
/* E300 only */
for( const auto& kw : { "PERMXY", "PERMYZ", "PERMZX" } )
supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" );
/* the transmissibility keywords for neighboring connections. note that
* these keywords don't seem to require a post-processor
*/
for( const auto& kw : { "TRANX", "TRANY", "TRANZ" } )
supportedDoubleKeywords.emplace_back( kw, nan, "Transmissibility" );
/* gross-to-net thickness (acts as a multiplier for PORO and the
* permeabilities in the X-Y plane as well as for the well rates.)
*/
supportedDoubleKeywords.emplace_back( "NTG", 1.0, "1" );
// transmissibility multipliers
for( const auto& kw : { "MULTX", "MULTY", "MULTZ", "MULTX-", "MULTY-", "MULTZ-" } )
supportedDoubleKeywords.emplace_back( kw, 1.0, "1" );
// initialisation
supportedDoubleKeywords.emplace_back( "SWATINIT", 0.0, "1");
supportedDoubleKeywords.emplace_back( "THCONR", 0.0, "1");
return supportedDoubleKeywords;
}
Eclipse3DProperties::Eclipse3DProperties( const Deck& deck,
const TableManager& tableManager,
const EclipseGrid& eclipseGrid)
:
m_defaultRegion("FLUXNUM"),
m_deckUnitSystem(deck.getActiveUnitSystem()),
// Note that the variants of grid keywords for radial grids are not
// supported. (and hopefully never will be)
// register the grid properties
m_intGridProperties(eclipseGrid, makeSupportedIntKeywords()),
m_doubleGridProperties(eclipseGrid,
makeSupportedDoubleKeywords(&tableManager, &eclipseGrid, &m_intGridProperties))
{
/*
* The EQUALREG, MULTREG, COPYREG, ... keywords are used to manipulate
* vectors based on region values; for instance the statement
*
* EQUALREG
* PORO 0.25 3 / -- Region array not specified
* PERMX 100 3 F /
* /
*
* will set the PORO field to 0.25 for all cells in region 3 and the PERMX
* value to 100 mD for the same cells. The fourth optional argument to the
* EQUALREG keyword is used to indicate which REGION array should be used
* for the selection.
*
* If the REGION array is not indicated (as in the PORO case) above, the
* default region to use in the xxxREG keywords depends on the GRIDOPTS
* keyword:
*
* 1. If GRIDOPTS is present, and the NRMULT item is greater than zero,
* the xxxREG keywords will default to use the MULTNUM region.
*
* 2. If the GRIDOPTS keyword is not present - or the NRMULT item equals
* zero, the xxxREG keywords will default to use the FLUXNUM keyword.
*
* This quite weird behaviour comes from reading the GRIDOPTS and MULTNUM
* documentation, and practical experience with ECLIPSE
* simulations. Ufortunately the documentation of the xxxREG keywords does
* not confirm this.
*/
if (deck.hasKeyword( "GRIDOPTS" )) {
const auto& gridOpts = deck.getKeyword( "GRIDOPTS" );
const auto& record = gridOpts.getRecord( 0 );
const auto& nrmult_item = record.getItem( "NRMULT" );
if (nrmult_item.get<int>( 0 ) > 0)
m_defaultRegion = "MULTNUM"; // GRIDOPTS and positive NRMULT
}
auto initPORV = std::bind(&GridPropertyPostProcessor::initPORV,
std::placeholders::_1,
&eclipseGrid,
&m_doubleGridProperties);
// pore volume
m_doubleGridProperties.postAddKeyword( "PORV",
std::numeric_limits<double>::quiet_NaN(),
initPORV,
"Volume" );
// actually create the grid property objects. we need to first process
// all integer grid properties before the double ones as these may be
// needed in order to initialize the double properties
processGridProperties(deck, eclipseGrid, /*enabledTypes=*/IntProperties);
processGridProperties(deck, eclipseGrid, /*enabledTypes=*/DoubleProperties);
}
bool Eclipse3DProperties::supportsGridProperty(const std::string& keyword,
int enabledTypes) const
{
bool result = false;
if (enabledTypes & IntProperties)
result = result ||
m_intGridProperties.supportsKeyword( keyword );
if (enabledTypes & DoubleProperties)
result = result ||
m_doubleGridProperties.supportsKeyword( keyword );
return result;
}
bool Eclipse3DProperties::hasDeckIntGridProperty(const std::string& keyword) const {
if (!m_intGridProperties.supportsKeyword( keyword ))
throw std::logic_error("Integer grid property " + keyword + " is unsupported!");
return m_intGridProperties.hasKeyword( keyword );
}
bool Eclipse3DProperties::hasDeckDoubleGridProperty(const std::string& keyword) const {
if (!m_doubleGridProperties.supportsKeyword( keyword ))
throw std::logic_error("Double grid property " + keyword + " is unsupported!");
return m_doubleGridProperties.hasKeyword( keyword );
}
/*
1. The public methods getIntGridProperty & getDoubleGridProperty will
invoke and run the property post processor (if any is registered); the
post processor will only run one time.
It is important that post processor is not run prematurely, internal
functions in EclipseState should therefore ask for properties by
invoking the getKeyword() method of the m_intGridProperties /
m_doubleGridProperties() directly and not through these methods.
2. Observe that this will autocreate a property if it has not been
explicitly added.
*/
const GridProperty<int>& Eclipse3DProperties::getIntGridProperty( const std::string& keyword ) const {
return m_intGridProperties.getKeyword( keyword );
}
/// gets property from doubleGridProperty --- and calls the runPostProcessor
const GridProperty<double>& Eclipse3DProperties::getDoubleGridProperty( const std::string& keyword ) const {
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( keyword );
gridProperty.runPostProcessor();
return gridProperty;
}
std::string Eclipse3DProperties::getDefaultRegionKeyword() const {
return m_defaultRegion;
}
const GridProperty<int>& Eclipse3DProperties::getRegion( const DeckItem& regionItem ) const {
if (regionItem.defaultApplied(0))
return m_intGridProperties.getKeyword( m_defaultRegion );
else {
const std::string regionArray = MULTREGT::RegionNameFromDeckValue( regionItem.get< std::string >(0) );
return m_intGridProperties.getInitializedKeyword( regionArray );
}
}
/// Due to the post processor which might be applied to the GridProperty
/// objects it is essential that this method use the m_intGridProperties /
/// m_doubleGridProperties fields directly and *NOT* use the public methods
/// getIntGridProperty / getDoubleGridProperty.
void Eclipse3DProperties::loadGridPropertyFromDeckKeyword(const Box& inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes)
{
const std::string& keyword = deckKeyword.name();
if (m_intGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & IntProperties) {
auto& gridProperty = m_intGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox, deckKeyword );
}
} else if (m_doubleGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & DoubleProperties) {
auto& gridProperty = m_doubleGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox, deckKeyword );
}
} else {
throw std::logic_error( "Tried to load unsupported grid property from keyword: " + deckKeyword.name() );
}
}
static bool isInt(double value) {
return fabs( nearbyint( value ) - value ) < 1e-6;
}
void Eclipse3DProperties::processGridProperties( const Deck& deck,
const EclipseGrid& eclipseGrid,
int enabledTypes) {
if (Section::hasGRID(deck)) {
scanSection(GRIDSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasEDIT(deck)) {
scanSection(EDITSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasPROPS(deck)) {
scanSection(PROPSSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasREGIONS(deck)) {
scanSection(REGIONSSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasSOLUTION(deck)) {
scanSection(SOLUTIONSection(deck), eclipseGrid, enabledTypes);
}
}
// private method
double Eclipse3DProperties::getSIScaling(const std::string &dimensionString) const
{
return m_deckUnitSystem.getDimension(dimensionString)->getSIScaling();
}
void Eclipse3DProperties::scanSection(const Section& section,
const EclipseGrid& eclipseGrid,
int enabledTypes) {
BoxManager boxManager(eclipseGrid.getNX(),
eclipseGrid.getNY(),
eclipseGrid.getNZ());
for( const auto& deckKeyword : section ) {
if (supportsGridProperty(deckKeyword.name(), enabledTypes) )
loadGridPropertyFromDeckKeyword( *boxManager.getActiveBox(),
deckKeyword,
enabledTypes);
else {
if (deckKeyword.name() == "ADD")
handleADDKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "BOX")
handleBOXKeyword(deckKeyword, boxManager);
if (deckKeyword.name() == "COPY")
handleCOPYKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "EQUALS")
handleEQUALSKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "MULTIPLY")
handleMULTIPLYKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "ENDBOX")
handleENDBOXKeyword(boxManager);
if (deckKeyword.name() == "EQUALREG")
handleEQUALREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "ADDREG")
handleADDREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "MULTIREG")
handleMULTIREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "COPYREG")
handleCOPYREGKeyword(deckKeyword, enabledTypes);
boxManager.endKeyword();
}
}
boxManager.endSection();
}
void Eclipse3DProperties::handleBOXKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
const auto& record = deckKeyword.getRecord(0);
int I1 = record.getItem("I1").get< int >(0) - 1;
int I2 = record.getItem("I2").get< int >(0) - 1;
int J1 = record.getItem("J1").get< int >(0) - 1;
int J2 = record.getItem("J2").get< int >(0) - 1;
int K1 = record.getItem("K1").get< int >(0) - 1;
int K2 = record.getItem("K2").get< int >(0) - 1;
boxManager.setInputBox( I1 , I2 , J1 , J2 , K1 , K2 );
}
void Eclipse3DProperties::handleENDBOXKeyword(BoxManager& boxManager) {
boxManager.endInputBox();
}
void Eclipse3DProperties::handleEQUALREGKeyword( const DeckKeyword& deckKeyword,
int enabledTypes)
{
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray);
double doubleValue = record.getItem("VALUE").template get<double>(0);
int regionValue = record.getItem("REGION_NUMBER").template get<int>(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (m_intGridProperties.supportsKeyword( targetArray )) {
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
auto& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedSet( intValue , mask);
} else
throw std::invalid_argument("Fatal error processing EQUALREG keyword - expected integer value for: " + targetArray);
}
}
else if (m_doubleGridProperties.supportsKeyword( targetArray )) {
if (enabledTypes & DoubleProperties) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty( targetArray );
const std::string& dimensionString = targetProperty.getDimensionString();
double SIValue = doubleValue * getSIScaling( dimensionString );
targetProperty.maskedSet( SIValue , mask);
}
}
else {
throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
void Eclipse3DProperties::handleADDREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing ADDREG keyword - invalid/undefined keyword: " + targetArray);
if (supportsGridProperty( targetArray , enabledTypes)) {
double doubleValue = record.getItem("SHIFT").get< double >(0);
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (m_intGridProperties.hasKeyword( targetArray )) {
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
GridProperty<int>& targetProperty = m_intGridProperties.getKeyword(targetArray);
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedAdd( intValue , mask);
} else
throw std::invalid_argument("Fatal error processing ADDREG keyword - expected integer value for: " + targetArray);
}
}
else if (m_doubleGridProperties.hasKeyword( targetArray )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& targetProperty = m_doubleGridProperties.getKeyword(targetArray);
const std::string& dimensionString = targetProperty.getDimensionString();
double SIValue = doubleValue * getSIScaling( dimensionString );
targetProperty.maskedAdd( SIValue , mask);
}
}
else {
throw std::invalid_argument("Fatal error processing ADDREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
}
void Eclipse3DProperties::handleMULTIREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray);
if (supportsGridProperty( targetArray , enabledTypes)) {
double doubleValue = record.getItem("FACTOR").get< double >(0);
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
auto& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedMultiply( intValue , mask);
} else
throw std::invalid_argument(
"Fatal error processing MULTIREG keyword - expected"
" integer value for: " + targetArray);
}
if (enabledTypes & DoubleProperties) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty(targetArray);
targetProperty.maskedMultiply( doubleValue , mask);
}
}
}
}
void Eclipse3DProperties::handleCOPYREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& srcArray = record.getItem("ARRAY").get< std::string >(0);
const std::string& targetArray = record.getItem("TARGET_ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray);
if (!supportsGridProperty( srcArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + srcArray);
if (supportsGridProperty( srcArray , enabledTypes))
{
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask );
if (m_intGridProperties.hasKeyword( srcArray )) {
auto& srcProperty = m_intGridProperties.getInitializedKeyword( srcArray );
if (supportsGridProperty( targetArray , IntProperties)) {
GridProperty<int>& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
targetProperty.maskedCopy( srcProperty , mask );
} else
throw std::invalid_argument("Fatal error processing COPYREG keyword.");
} else if (m_doubleGridProperties.hasKeyword( srcArray )) {
const GridProperty<double>& srcProperty = m_doubleGridProperties.getInitializedKeyword( srcArray );
if (supportsGridProperty( targetArray , DoubleProperties)) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty( targetArray );
targetProperty.maskedCopy( srcProperty , mask );
}
}
else {
throw std::invalid_argument("Fatal error processing COPYREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
}
void Eclipse3DProperties::handleMULTIPLYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double scaleFactor = record.getItem("factor").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( field )) {
if (enabledTypes & IntProperties) {
int intFactor = static_cast<int>(scaleFactor);
GridProperty<int>& property = m_intGridProperties.getKeyword( field );
property.scale( intFactor , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.hasKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getKeyword( field );
property.scale( scaleFactor , *boxManager.getActiveBox() );
}
} else if (!m_intGridProperties.supportsKeyword(field) &&
!m_doubleGridProperties.supportsKeyword(field))
throw std::invalid_argument("Fatal error processing MULTIPLY keyword. Tried to multiply not defined keyword " + field);
}
}
/**
The fine print of the manual says the ADD keyword should support
some state dependent semantics regarding endpoint scaling arrays
in the PROPS section. That is not supported.
*/
void Eclipse3DProperties::handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double shiftValue = record.getItem("shift").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( field )) {
if (enabledTypes & IntProperties) {
int intShift = static_cast<int>(shiftValue);
GridProperty<int>& property = m_intGridProperties.getKeyword( field );
property.add( intShift , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.hasKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getKeyword( field );
double siShiftValue = shiftValue * getSIScaling(property.getDimensionString());
property.add(siShiftValue , *boxManager.getActiveBox() );
}
} else if (!m_intGridProperties.supportsKeyword(field) &&
!m_doubleGridProperties.supportsKeyword(field))
throw std::invalid_argument("Fatal error processing ADD keyword. Tried to shift not defined keyword " + field);
}
}
void Eclipse3DProperties::handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double value = record.getItem("value").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.supportsKeyword( field )) {
if (enabledTypes & IntProperties) {
int intValue = static_cast<int>(value);
GridProperty<int>& property = m_intGridProperties.getOrCreateProperty( field );
property.setScalar( intValue , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.supportsKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getOrCreateProperty( field );
double siValue = value * getSIScaling(property.getKeywordInfo().getDimensionString());
property.setScalar( siValue , *boxManager.getActiveBox() );
}
} else
throw std::invalid_argument("Fatal error processing EQUALS keyword. Tried to set not defined keyword " + field);
}
}
void Eclipse3DProperties::handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& srcField = record.getItem("src").get< std::string >(0);
const std::string& targetField = record.getItem("target").get< std::string >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( srcField )) {
if (enabledTypes & IntProperties)
m_intGridProperties.copyKeyword( srcField , targetField , *boxManager.getActiveBox() );
}
else if (m_doubleGridProperties.hasKeyword( srcField )) {
if (enabledTypes & DoubleProperties)
m_doubleGridProperties.copyKeyword( srcField , targetField , *boxManager.getActiveBox() );
}
else
if (!m_intGridProperties.supportsKeyword(srcField) &&
!m_doubleGridProperties.supportsKeyword(srcField))
throw std::invalid_argument("Fatal error processing COPY keyword."
" Tried to copy from not defined keyword " + srcField);
}
}
MessageContainer Eclipse3DProperties::getMessageContainer() {
MessageContainer messages;
messages.appendMessages(m_intGridProperties.getMessageContainer());
messages.appendMessages(m_doubleGridProperties.getMessageContainer());
return messages;
}
void Eclipse3DProperties::setKeywordBox( const DeckKeyword& deckKeyword,
const DeckRecord& deckRecord,
BoxManager& boxManager) {
const auto& I1Item = deckRecord.getItem("I1");
const auto& I2Item = deckRecord.getItem("I2");
const auto& J1Item = deckRecord.getItem("J1");
const auto& J2Item = deckRecord.getItem("J2");
const auto& K1Item = deckRecord.getItem("K1");
const auto& K2Item = deckRecord.getItem("K2");
size_t setCount = 0;
if (!I1Item.defaultApplied(0))
setCount++;
if (!I2Item.defaultApplied(0))
setCount++;
if (!J1Item.defaultApplied(0))
setCount++;
if (!J2Item.defaultApplied(0))
setCount++;
if (!K1Item.defaultApplied(0))
setCount++;
if (!K2Item.defaultApplied(0))
setCount++;
if (setCount == 6) {
boxManager.setKeywordBox( I1Item.get< int >(0) - 1,
I2Item.get< int >(0) - 1,
J1Item.get< int >(0) - 1,
J2Item.get< int >(0) - 1,
K1Item.get< int >(0) - 1,
K2Item.get< int >(0) - 1);
} else if (setCount != 0) {
std::string msg = "BOX modifiers on keywords must be either "
"specified completely or not at all. Ignoring.";
m_intGridProperties.getMessageContainer().error(deckKeyword.getFileName() + std::to_string(deckKeyword.getLineNumber()) + msg);
}
}
}

View File

@@ -0,0 +1,110 @@
/*
Copyright 2013 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/>.
*/
#ifndef OPM_ECLIPSE_PROPERTIES_HPP
#define OPM_ECLIPSE_PROPERTIES_HPP
#include <utility>
#include <memory>
#include <set>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
namespace Opm {
class Box;
class BoxManager;
class Deck;
class DeckItem;
class DeckKeyword;
class DeckRecord;
class EclipseGrid;
class EclipseState;
class InitConfig;
class IOConfig;
class Schedule;
class Section;
class TableManager;
class TransMult;
class UnitSystem;
/// Class representing properties on 3D grid for use in EclipseState.
class Eclipse3DProperties
{
public:
enum EnabledTypes {
IntProperties = 0x01,
DoubleProperties = 0x02,
AllProperties = IntProperties | DoubleProperties
};
Eclipse3DProperties(const Deck& deck,
const TableManager& tableManager,
const EclipseGrid& eclipseGrid);
const GridProperty<int>& getRegion(const DeckItem& regionItem) const;
std::string getDefaultRegionKeyword() const;
const GridProperty<int>& getIntGridProperty ( const std::string& keyword ) const;
const GridProperty<double>& getDoubleGridProperty ( const std::string& keyword ) const;
bool hasDeckIntGridProperty(const std::string& keyword) const;
bool hasDeckDoubleGridProperty(const std::string& keyword) const;
bool supportsGridProperty(const std::string& keyword, int enabledTypes = AllProperties) const;
MessageContainer getMessageContainer();
private:
void processGridProperties(const Deck& deck,
const EclipseGrid& eclipseGrid,
int enabledTypes);
double getSIScaling(const std::string &dimensionString) const;
void scanSection(const Section& section,
const EclipseGrid& eclipseGrid,
int enabledTypes);
void handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleBOXKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager);
void handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleENDBOXKeyword( BoxManager& boxManager);
void handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleMULTIPLYKeyword(const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleADDREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes);
void handleCOPYREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes);
void handleEQUALREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void handleMULTIREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void loadGridPropertyFromDeckKeyword(const Box& inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes);
void setKeywordBox(const DeckKeyword& deckKeyword, const DeckRecord&, BoxManager& boxManager);
std::string m_defaultRegion;
const UnitSystem& m_deckUnitSystem;
GridProperties<int> m_intGridProperties;
GridProperties<double> m_doubleGridProperties;
};
}
#endif // OPM_ECLIPSE_PROPERTIES_HPP

View File

@@ -0,0 +1,328 @@
/*
Copyright 2013 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 <set>
#include <boost/algorithm/string/join.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
namespace Opm {
EclipseState::EclipseState(std::shared_ptr<const Deck> deckptr, ParseContext parseContext) :
EclipseState(*deckptr, parseContext)
{}
EclipseState::EclipseState(const Deck& deck, ParseContext parseContext) :
m_deckUnitSystem( deck.getActiveUnitSystem() ),
m_parseContext( parseContext ),
m_tables( deck ),
m_inputGrid( std::make_shared<EclipseGrid>(deck, nullptr)),
m_eclipseProperties( deck, m_tables, *m_inputGrid)
{
// after Eclipse3DProperties has been constructed, we have complete ACTNUM info
if (m_eclipseProperties.hasDeckIntGridProperty("ACTNUM"))
m_inputGrid->resetACTNUM(m_eclipseProperties.getIntGridProperty("ACTNUM").getData().data());
initIOConfig(deck);
m_schedule = ScheduleConstPtr(new Schedule(m_parseContext, getInputGrid(), deck, m_ioConfig));
initIOConfigPostSchedule(deck);
if (deck.hasKeyword( "TITLE" )) {
const auto& titleKeyword = deck.getKeyword( "TITLE" );
const auto& item = titleKeyword.getRecord( 0 ).getItem( 0 );
std::vector<std::string> itemValue = item.getData<std::string>();
m_title = boost::algorithm::join( itemValue, " " );
}
m_initConfig = std::make_shared<const InitConfig>(deck);
m_simulationConfig = std::make_shared<const SimulationConfig>(m_parseContext, deck,
m_eclipseProperties);
initTransMult();
initFaults(deck);
initMULTREGT(deck);
m_nnc = NNC(deck, getInputGrid());
m_messageContainer.appendMessages(m_tables.getMessageContainer());
m_messageContainer.appendMessages(m_schedule->getMessageContainer());
m_messageContainer.appendMessages(m_inputGrid->getMessageContainer());
m_messageContainer.appendMessages(m_eclipseProperties.getMessageContainer());
}
const UnitSystem& EclipseState::getDeckUnitSystem() const {
return m_deckUnitSystem;
}
EclipseGridConstPtr EclipseState::getInputGrid() const {
return m_inputGrid;
}
EclipseGridPtr EclipseState::getInputGridCopy() const {
return std::make_shared<EclipseGrid>( m_inputGrid->c_ptr() );
}
const Eclipse3DProperties& EclipseState::get3DProperties() const {
return m_eclipseProperties;
}
const MessageContainer& EclipseState::getMessageContainer() const {
return m_messageContainer;
}
MessageContainer& EclipseState::getMessageContainer() {
return m_messageContainer;
}
const TableManager& EclipseState::getTableManager() const {
return m_tables;
}
const ParseContext& EclipseState::getParseContext() const {
return m_parseContext;
}
ScheduleConstPtr EclipseState::getSchedule() const {
return m_schedule;
}
IOConfigConstPtr EclipseState::getIOConfigConst() const {
return m_ioConfig;
}
IOConfigPtr EclipseState::getIOConfig() const {
return m_ioConfig;
}
InitConfigConstPtr EclipseState::getInitConfig() const {
return m_initConfig;
}
SimulationConfigConstPtr EclipseState::getSimulationConfig() const {
return m_simulationConfig;
}
const FaultCollection& EclipseState::getFaults() const {
return m_faults;
}
std::shared_ptr<const TransMult> EclipseState::getTransMult() const {
return m_transMult;
}
const NNC& EclipseState::getNNC() const {
return m_nnc;
}
bool EclipseState::hasNNC() const {
return m_nnc.hasNNC();
}
std::string EclipseState::getTitle() const {
return m_title;
}
void EclipseState::initIOConfig(const Deck& deck) {
std::string dataFile = deck.getDataFile();
m_ioConfig = std::make_shared<IOConfig>(dataFile);
if (Section::hasGRID(deck)) {
auto gridSection = std::make_shared<const GRIDSection>(deck);
m_ioConfig->handleGridSection(gridSection);
}
if (Section::hasRUNSPEC(deck)) {
auto runspecSection = std::make_shared<const RUNSPECSection>(deck);
m_ioConfig->handleRunspecSection(runspecSection);
}
}
// Hmmm - would have thought this should iterate through the SCHEDULE section as well?
void EclipseState::initIOConfigPostSchedule(const Deck& deck) {
if (Section::hasSOLUTION(deck)) {
std::shared_ptr<const SOLUTIONSection> solutionSection = std::make_shared<const SOLUTIONSection>(deck);
m_ioConfig->handleSolutionSection(m_schedule->getTimeMap(), solutionSection);
}
m_ioConfig->initFirstOutput( *m_schedule );
}
void EclipseState::initTransMult() {
EclipseGridConstPtr grid = getInputGrid();
m_transMult = std::make_shared<TransMult>( grid->getNX() , grid->getNY() , grid->getNZ());
const auto& p = m_eclipseProperties;
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTX"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTX"), FaceDir::XPlus);
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTX-"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTX-"), FaceDir::XMinus);
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTY"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTY"), FaceDir::YPlus);
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTY-"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTY-"), FaceDir::YMinus);
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTZ"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTZ"), FaceDir::ZPlus);
if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTZ-"))
m_transMult->applyMULT(p.getDoubleGridProperty("MULTZ-"), FaceDir::ZMinus);
}
void EclipseState::initFaults(const Deck& deck) {
EclipseGridConstPtr grid = getInputGrid();
std::shared_ptr<GRIDSection> gridSection = std::make_shared<GRIDSection>( deck );
m_faults = FaultCollection(gridSection, grid);
setMULTFLT(gridSection);
if (Section::hasEDIT(deck)) {
std::shared_ptr<EDITSection> editSection = std::make_shared<EDITSection>( deck );
setMULTFLT(editSection);
}
m_transMult->applyMULTFLT( m_faults );
}
void EclipseState::setMULTFLT(std::shared_ptr<const Section> section) {
for (size_t index=0; index < section->count("MULTFLT"); index++) {
const auto& faultsKeyword = section->getKeyword("MULTFLT" , index);
for (auto iter = faultsKeyword.begin(); iter != faultsKeyword.end(); ++iter) {
const auto& faultRecord = *iter;
const std::string& faultName = faultRecord.getItem(0).get< std::string >(0);
double multFlt = faultRecord.getItem(1).get< double >(0);
m_faults.setTransMult( faultName , multFlt );
}
}
}
void EclipseState::initMULTREGT(const Deck& deck) {
EclipseGridConstPtr grid = getInputGrid();
std::vector< const DeckKeyword* > multregtKeywords;
if (deck.hasKeyword("MULTREGT"))
multregtKeywords = deck.getKeywordList("MULTREGT");
std::shared_ptr<MULTREGTScanner> scanner =
std::make_shared<MULTREGTScanner>(
m_eclipseProperties,
multregtKeywords ,
m_eclipseProperties.getDefaultRegionKeyword());
m_transMult->setMultregtScanner( scanner );
}
std::vector< int > EclipseState::getRegions( const std::string& kw ) const {
if( !this->get3DProperties().hasDeckIntGridProperty( kw ) ) return {};
const auto& property = this->get3DProperties().getIntGridProperty( kw );
std::set< int > regions( property.getData().begin(),
property.getData().end() );
return { regions.begin(), regions.end() };
}
void EclipseState::complainAboutAmbiguousKeyword(const Deck& deck, const std::string& keywordName) {
m_messageContainer.error("The " + keywordName + " keyword must be unique in the deck. Ignoring all!");
auto keywords = deck.getKeywordList(keywordName);
for (size_t i = 0; i < keywords.size(); ++i) {
std::string msg = "Ambiguous keyword "+keywordName+" defined here";
m_messageContainer.error(keywords[i]->getFileName(), msg, keywords[i]->getLineNumber());
}
}
void EclipseState::applyModifierDeck(std::shared_ptr<const Deck> deckptr) {
applyModifierDeck(*deckptr);
}
void EclipseState::applyModifierDeck(const Deck& deck) {
using namespace ParserKeywords;
for (const auto& keyword : deck) {
if (keyword.isKeyword<MULTFLT>()) {
for (const auto& record : keyword) {
const std::string& faultName = record.getItem<MULTFLT::fault>().get< std::string >(0);
auto& fault = m_faults.getFault( faultName );
double tmpMultFlt = record.getItem<MULTFLT::factor>().get< double >(0);
double oldMultFlt = fault.getTransMult( );
double newMultFlt = oldMultFlt * tmpMultFlt;
/*
This extremely contrived way of doing it is because of difference in
behavior and section awareness between the Fault object and the
Transmult object:
1. MULTFLT keywords found in the SCHEDULE section should apply the
transmissibility modifiers cumulatively - i.e. the current
transmissibility across the fault should be *multiplied* with the
newly entered MULTFLT value, and the resulting transmissibility
multplier for this fault should be the product of the newly
entered value and the current value.
2. The TransMult::applyMULTFLT() implementation will *multiply* the
transmissibility across a face with the value in the fault
object. Hence the current value has already been multiplied in;
we therefor first *set* the MULTFLT value to the new value, then
apply it to the TransMult object and then eventually update the
MULTFLT value in the fault instance.
*/
fault.setTransMult( tmpMultFlt );
m_transMult->applyMULTFLT( fault );
fault.setTransMult( newMultFlt );
}
}
}
}
}

View File

@@ -0,0 +1,144 @@
/*
Copyright 2013 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/>.
*/
#ifndef OPM_ECLIPSE_STATE_HPP
#define OPM_ECLIPSE_STATE_HPP
#include <memory>
#include <set>
#include <utility>
#include <vector>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
namespace Opm {
template< typename > class GridProperty;
template< typename > class GridProperties;
class Box;
class BoxManager;
class Deck;
class DeckItem;
class DeckKeyword;
class DeckRecord;
class EclipseGrid;
class Eclipse3DProperties;
class InitConfig;
class IOConfig;
class NNC;
class ParseContext;
class Schedule;
class Section;
class SimulationConfig;
class TableManager;
class TransMult;
class UnitSystem;
class MessageContainer;
class EclipseState {
public:
enum EnabledTypes {
IntProperties = 0x01,
DoubleProperties = 0x02,
AllProperties = IntProperties | DoubleProperties
};
EclipseState(const Deck& deck , ParseContext parseContext = ParseContext());
/// [deprecated]
EclipseState(std::shared_ptr< const Deck > deck , ParseContext parseContext = ParseContext());
const ParseContext& getParseContext() const;
std::shared_ptr< const Schedule > getSchedule() const;
std::shared_ptr< const IOConfig > getIOConfigConst() const;
std::shared_ptr< IOConfig > getIOConfig() const;
std::shared_ptr< const InitConfig > getInitConfig() const;
std::shared_ptr< const SimulationConfig > getSimulationConfig() const;
std::shared_ptr< const EclipseGrid > getInputGrid() const;
std::shared_ptr< EclipseGrid > getInputGridCopy() const;
const MessageContainer& getMessageContainer() const;
MessageContainer& getMessageContainer();
std::string getTitle() const;
const FaultCollection& getFaults() const;
std::shared_ptr<const TransMult> getTransMult() const;
const NNC& getNNC() const;
bool hasNNC() const;
const Eclipse3DProperties& get3DProperties() const;
const TableManager& getTableManager() const;
std::vector< int > getRegions( const std::string& kw ) const;
// the unit system used by the deck. note that it is rarely needed to convert
// units because internally to opm-parser everything is represented by SI
// units...
const UnitSystem& getDeckUnitSystem() const;
/// [deprecated]
void applyModifierDeck(std::shared_ptr<const Deck>);
void applyModifierDeck(const Deck& deck);
private:
void initIOConfig(const Deck& deck);
void initIOConfigPostSchedule(const Deck& deck);
void initTransMult();
void initFaults(const Deck& deck);
void setMULTFLT(std::shared_ptr<const Opm::Section> section);
void initMULTREGT(const Deck& deck);
void complainAboutAmbiguousKeyword(const Deck& deck,
const std::string& keywordName);
std::shared_ptr< IOConfig > m_ioConfig;
std::shared_ptr< const InitConfig > m_initConfig;
std::shared_ptr< const Schedule > m_schedule;
std::shared_ptr< const SimulationConfig > m_simulationConfig;
std::string m_title;
std::shared_ptr<TransMult> m_transMult;
FaultCollection m_faults;
NNC m_nnc;
const UnitSystem& m_deckUnitSystem;
const ParseContext m_parseContext;
const TableManager m_tables;
std::shared_ptr<EclipseGrid> m_inputGrid;
Eclipse3DProperties m_eclipseProperties;
MessageContainer m_messageContainer;
};
typedef std::shared_ptr<EclipseState> EclipseStatePtr;
typedef std::shared_ptr<const EclipseState> EclipseStateConstPtr;
}
#endif // OPM_ECLIPSE_STATE_HPP

View File

@@ -0,0 +1,154 @@
/*
Copyright 2014 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 <stdexcept>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
namespace Opm {
Box::Box(int nx , int ny , int nz) {
if (nx <= 0)
throw std::invalid_argument("The input nx value is invalid");
if (ny <= 0)
throw std::invalid_argument("The input ny value is invalid");
if (nz <= 0)
throw std::invalid_argument("The input nz value is invalid");
m_dims[0] = (size_t) nx;
m_dims[1] = (size_t) ny;
m_dims[2] = (size_t) nz;
m_offset[0] = 0;
m_offset[1] = 0;
m_offset[2] = 0;
m_stride[0] = 1;
m_stride[1] = m_dims[0];
m_stride[2] = m_dims[0] * m_dims[1];
m_isGlobal = true;
initIndexList();
}
Box::Box(const Box& globalBox , int i1 , int i2 , int j1 , int j2 , int k1 , int k2) {
assertDims(globalBox , 0 , i1 , i2);
assertDims(globalBox , 1 , j1 , j2);
assertDims(globalBox , 2 , k1 , k2);
m_dims[0] = (size_t) (i2 - i1 + 1);
m_dims[1] = (size_t) (j2 - j1 + 1);
m_dims[2] = (size_t) (k2 - k1 + 1);
m_offset[0] = (size_t) i1;
m_offset[1] = (size_t) j1;
m_offset[2] = (size_t) k1;
m_stride[0] = 1;
m_stride[1] = globalBox.getDim(0);
m_stride[2] = globalBox.getDim(0) * globalBox.getDim(1);
if (size() == globalBox.size())
m_isGlobal = true;
else
m_isGlobal = false;
initIndexList();
}
void Box::assertDims(const Box& globalBox, size_t idim , int l1 , int l2) {
if ((l1 < 0) || (l2 < 0) || (l1 > l2))
throw std::invalid_argument("Invalid index values for sub box");
if ((size_t) l2 >= globalBox.getDim(idim))
throw std::invalid_argument("Invalid index values for sub box");
}
size_t Box::size() const {
return m_dims[0] * m_dims[1] * m_dims[2];
}
bool Box::isGlobal() const {
return m_isGlobal;
}
size_t Box::getDim(size_t idim) const {
if (idim >= 3)
throw std::invalid_argument("The input dimension value is invalid");
return m_dims[idim];
}
const std::vector<size_t>& Box::getIndexList() const {
return m_indexList;
}
void Box::initIndexList() {
m_indexList.resize( size() );
size_t ii,ij,ik;
size_t l = 0;
for (ik=0; ik < m_dims[2]; ik++) {
size_t k = ik + m_offset[2];
for (ij=0; ij < m_dims[1]; ij++) {
size_t j = ij + m_offset[1];
for (ii=0; ii < m_dims[0]; ii++) {
size_t i = ii + m_offset[0];
size_t g = i * m_stride[0] + j*m_stride[1] + k*m_stride[2];
m_indexList[l] = g;
l++;
}
}
}
}
bool Box::equal(const Box& other) const {
if (size() != other.size())
return false;
{
for (size_t idim = 0; idim < 3; idim++) {
if (m_dims[idim] != other.m_dims[idim])
return false;
if (m_stride[idim] != other.m_stride[idim])
return false;
if (m_offset[idim] != other.m_offset[idim])
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,53 @@
/*
Copyright 2014 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/>.
*/
#ifndef BOX_HPP_
#define BOX_HPP_
#include <vector>
#include <cstddef>
namespace Opm {
class Box {
public:
Box(int nx , int ny , int nz);
Box(const Box& globalBox , int i1 , int i2 , int j1 , int j2 , int k1 , int k2); // Zero offset coordinates.
size_t size() const;
bool isGlobal() const;
size_t getDim(size_t idim) const;
const std::vector<size_t>& getIndexList() const;
bool equal(const Box& other) const;
private:
void initIndexList();
static void assertDims(const Box& globalBox, size_t idim , int l1 , int l2);
size_t m_dims[3];
size_t m_offset[3];
size_t m_stride[3];
bool m_isGlobal;
std::vector<size_t> m_indexList;
};
}
#endif

View File

@@ -0,0 +1,80 @@
/*
Copyright 2014 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 <stdexcept>
#include <opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp>
namespace Opm {
BoxManager::BoxManager(int nx , int ny , int nz) {
m_globalBox = std::make_shared<const Box>(nx,ny,nz);
}
std::shared_ptr<const Box> BoxManager::getGlobalBox() const {
return m_globalBox;
}
std::shared_ptr<const Box> BoxManager::getInputBox() const {
return m_inputBox;
}
std::shared_ptr<const Box> BoxManager::getKeywordBox() const {
return m_keywordBox;
}
std::shared_ptr<const Box> BoxManager::getActiveBox() const {
if (m_keywordBox)
return m_keywordBox;
if (m_inputBox)
return m_inputBox;
return m_globalBox;
}
void BoxManager::setInputBox( int i1,int i2 , int j1 , int j2 , int k1 , int k2) {
m_inputBox.reset( new Box( *m_globalBox , i1,i2,j1,j2,k1,k2) );
}
void BoxManager::endInputBox() {
if (m_keywordBox)
throw std::invalid_argument("Hmmm - this seems like an internal error - the SECTION is terminated with an active keyword box");
m_inputBox.reset( );
}
void BoxManager::endSection() {
endInputBox();
}
void BoxManager::setKeywordBox( int i1,int i2 , int j1 , int j2 , int k1 , int k2) {
m_keywordBox.reset( new Box( *m_globalBox , i1,i2,j1,j2,k1,k2) );
}
void BoxManager::endKeyword() {
m_keywordBox.reset( );
}
}

View File

@@ -0,0 +1,78 @@
/*
Copyright 2014 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/>.
*/
#ifndef BOXMANAGER_HPP_
#define BOXMANAGER_HPP_
#include <vector>
#include <memory>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
/*
This class implements a simple book keeping system for the current
input box. In general there are three different input boxes which
are relevant:
1. The global box give by the complete dimensions of the grid.
2. The input box given explicitly by the BOX keyword. That BOX will
apply to all following FIELD properties, and it will continue
to apply until either:
- ENDBOX
- A new BOX
- End of current section
is encountered.
3. Some keywords allow for a Box which applies only to the elements
of that keyword.
*/
namespace Opm {
class BoxManager {
public:
BoxManager(int nx , int ny , int nz);
void setInputBox( int i1,int i2 , int j1 , int j2 , int k1 , int k2);
void setKeywordBox( int i1,int i2 , int j1 , int j2 , int k1 , int k2);
void endSection();
void endInputBox();
void endKeyword();
std::shared_ptr<const Box> getActiveBox() const;
std::shared_ptr<const Box> getGlobalBox() const;
std::shared_ptr<const Box> getInputBox() const;
std::shared_ptr<const Box> getKeywordBox() const;
private:
std::shared_ptr<const Box> m_globalBox;
std::shared_ptr<const Box> m_inputBox;
std::shared_ptr<const Box> m_keywordBox;
};
}
#endif

View File

@@ -0,0 +1,730 @@
/*
Copyright 2014 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 <iostream>
#include <tuple>
#include <cmath>
#include <boost/lexical_cast.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/A.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/Z.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <ert/ecl/ecl_grid.h>
namespace Opm {
/**
Will create an EclipseGrid instance based on an existing
GRID/EGRID file.
*/
EclipseGrid::EclipseGrid(const std::string& filename )
: m_minpvValue(0),
m_minpvMode(MinpvMode::ModeEnum::Inactive),
m_pinch("PINCH"),
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
m_multzMode(PinchMode::ModeEnum::TOP)
{
ecl_grid_type * new_ptr = ecl_grid_load_case( filename.c_str() );
if (new_ptr)
m_grid.reset( new_ptr );
else
throw std::invalid_argument("Could not load grid from binary file: " + filename);
m_nx = static_cast<size_t>( ecl_grid_get_nx( c_ptr() ));
m_ny = static_cast<size_t>( ecl_grid_get_ny( c_ptr() ));
m_nz = static_cast<size_t>( ecl_grid_get_nz( c_ptr() ));
}
EclipseGrid::EclipseGrid(const ecl_grid_type * src_ptr)
: m_minpvValue(0),
m_minpvMode(MinpvMode::ModeEnum::Inactive),
m_pinch("PINCH"),
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
m_multzMode(PinchMode::ModeEnum::TOP)
{
m_grid.reset( ecl_grid_alloc_copy( src_ptr ) );
m_nx = static_cast<size_t>( ecl_grid_get_nx( c_ptr() ));
m_ny = static_cast<size_t>( ecl_grid_get_ny( c_ptr() ));
m_nz = static_cast<size_t>( ecl_grid_get_nz( c_ptr() ));
}
/*
This creates a grid which only has dimension, and no pointer to
a true grid structure. This grid will answer false to
hasCellInfo() - but can be used in all situations where the grid
dependency is really only on the dimensions.
*/
EclipseGrid::EclipseGrid(size_t nx, size_t ny , size_t nz,
double dx, double dy, double dz)
: m_minpvValue(0),
m_minpvMode(MinpvMode::ModeEnum::Inactive),
m_pinch("PINCH"),
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
m_multzMode(PinchMode::ModeEnum::TOP)
{
m_nx = nx;
m_ny = ny;
m_nz = nz;
m_grid.reset(ecl_grid_alloc_rectangular(nx, ny, nz, dx, dy, dz, NULL));
}
// keyword must be DIMENS or SPECGRID
static std::vector<int> getDims( const DeckKeyword& keyword ) {
const auto& record = keyword.getRecord(0);
std::vector<int> dims = {record.getItem("NX").get< int >(0) ,
record.getItem("NY").get< int >(0) ,
record.getItem("NZ").get< int >(0) };
return dims;
}
EclipseGrid::EclipseGrid(const std::shared_ptr<const Deck>& deckptr, const int * actnum)
:
EclipseGrid(*deckptr, actnum)
{}
EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
: m_minpvValue(0),
m_minpvMode(MinpvMode::ModeEnum::Inactive),
m_pinch("PINCH"),
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
m_multzMode(PinchMode::ModeEnum::TOP)
{
const bool hasRUNSPEC = Section::hasRUNSPEC(deck);
const bool hasGRID = Section::hasGRID(deck);
if (hasRUNSPEC && hasGRID) {
// Equivalent to first constructor.
RUNSPECSection runspecSection( deck );
if( runspecSection.hasKeyword<ParserKeywords::DIMENS>() ) {
const auto& dimens = runspecSection.getKeyword<ParserKeywords::DIMENS>();
std::vector<int> dims = getDims(dimens);
initGrid(dims, deck);
} else {
const std::string msg = "The RUNSPEC section must have the DIMENS keyword with logically Cartesian grid dimensions.";
m_messages.error(msg);
throw std::invalid_argument(msg);
}
} else if (hasGRID) {
// Look for SPECGRID instead of DIMENS.
if (deck.hasKeyword<ParserKeywords::SPECGRID>()) {
const auto& specgrid = deck.getKeyword<ParserKeywords::SPECGRID>();
std::vector<int> dims = getDims(specgrid);
initGrid(dims, deck);
} else {
const std::string msg = "With no RUNSPEC section, the GRID section must specify the grid dimensions using the SPECGRID keyword.";
m_messages.error(msg);
throw std::invalid_argument(msg);
}
} else {
// The deck contains no relevant section, so it is probably a sectionless GRDECL file.
// Either SPECGRID or DIMENS is OK.
if (deck.hasKeyword("SPECGRID")) {
const auto& specgrid = deck.getKeyword<ParserKeywords::SPECGRID>();
std::vector<int> dims = getDims(specgrid);
initGrid(dims, deck);
} else if (deck.hasKeyword<ParserKeywords::DIMENS>()) {
const auto& dimens = deck.getKeyword<ParserKeywords::DIMENS>();
std::vector<int> dims = getDims(dimens);
initGrid(dims, deck);
} else {
const std::string msg = "The deck must specify grid dimensions using either DIMENS or SPECGRID.";
m_messages.error(msg);
throw std::invalid_argument(msg);
}
}
if (actnum != nullptr)
resetACTNUM(actnum);
}
void EclipseGrid::initGrid( const std::vector<int>& dims, const Deck& deck) {
m_nx = static_cast<size_t>(dims[0]);
m_ny = static_cast<size_t>(dims[1]);
m_nz = static_cast<size_t>(dims[2]);
if (hasCornerPointKeywords(deck)) {
initCornerPointGrid(dims , deck);
} else if (hasCartesianKeywords(deck)) {
initCartesianGrid(dims , deck);
}
if (deck.hasKeyword<ParserKeywords::PINCH>()) {
const auto& record = deck.getKeyword<ParserKeywords::PINCH>( ).getRecord(0);
const auto& item = record.getItem<ParserKeywords::PINCH::THRESHOLD_THICKNESS>( );
m_pinch.setValue( item.getSIDouble(0) );
auto pinchoutString = record.getItem<ParserKeywords::PINCH::PINCHOUT_OPTION>().get< std::string >(0);
m_pinchoutMode = PinchMode::PinchModeFromString(pinchoutString);
auto multzString = record.getItem<ParserKeywords::PINCH::MULTZ_OPTION>().get< std::string >(0);
m_multzMode = PinchMode::PinchModeFromString(multzString);
}
if (deck.hasKeyword<ParserKeywords::MINPV>() && deck.hasKeyword<ParserKeywords::MINPVFIL>()) {
throw std::invalid_argument("Can not have both MINPV and MINPVFIL in deck.");
}
if (deck.hasKeyword<ParserKeywords::MINPV>()) {
const auto& record = deck.getKeyword<ParserKeywords::MINPV>( ).getRecord(0);
const auto& item = record.getItem<ParserKeywords::MINPV::VALUE>( );
m_minpvValue = item.getSIDouble(0);
m_minpvMode = MinpvMode::ModeEnum::EclSTD;
}
if (deck.hasKeyword<ParserKeywords::MINPVFIL>()) {
const auto& record = deck.getKeyword<ParserKeywords::MINPVFIL>( ).getRecord(0);
const auto& item = record.getItem<ParserKeywords::MINPVFIL::VALUE>( );
m_minpvValue = item.getSIDouble(0);
m_minpvMode = MinpvMode::ModeEnum::OpmFIL;
}
}
size_t EclipseGrid::getNX( ) const {
return m_nx;
}
size_t EclipseGrid::getNY( ) const {
return m_ny;
}
size_t EclipseGrid::getNZ( ) const {
return m_nz;
}
size_t EclipseGrid::getCartesianSize( ) const {
return m_nx * m_ny * m_nz;
}
bool EclipseGrid::isPinchActive( ) const {
return m_pinch.hasValue();
}
double EclipseGrid::getPinchThresholdThickness( ) const {
return m_pinch.getValue();
}
PinchMode::ModeEnum EclipseGrid::getPinchOption( ) const {
return m_pinchoutMode;
}
PinchMode::ModeEnum EclipseGrid::getMultzOption( ) const {
return m_multzMode;
}
MinpvMode::ModeEnum EclipseGrid::getMinpvMode() const {
return m_minpvMode;
}
double EclipseGrid::getMinpvValue( ) const {
return m_minpvValue;
}
size_t EclipseGrid::getGlobalIndex(size_t i, size_t j, size_t k) const {
return (i + j * getNX() + k * getNX() * getNY());
}
std::array<int, 3> EclipseGrid::getIJK(size_t globalIndex) const {
std::array<int, 3> r = {{ 0, 0, 0 }};
int k = globalIndex / (getNX() * getNY()); globalIndex -= k * (getNX() * getNY());
int j = globalIndex / getNX(); globalIndex -= j * getNX();
int i = globalIndex;
r[0] = i;
r[1] = j;
r[2] = k;
return r;
}
void EclipseGrid::assertGlobalIndex(size_t globalIndex) const {
if (globalIndex >= getCartesianSize())
throw std::invalid_argument("input index above valid range");
}
void EclipseGrid::assertIJK(size_t i , size_t j , size_t k) const {
if (i >= getNX() || j >= getNY() || k >= getNZ())
throw std::invalid_argument("input index above valid range");
}
void EclipseGrid::initCartesianGrid(const std::vector<int>& dims , const Deck& deck) {
if (hasDVDEPTHZKeywords( deck ))
initDVDEPTHZGrid( dims , deck );
else if (hasDTOPSKeywords(deck))
initDTOPSGrid( dims ,deck );
else
throw std::invalid_argument("Tried to initialize cartesian grid without all required keywords");
}
void EclipseGrid::initDVDEPTHZGrid(const std::vector<int>& dims, const Deck& deck) {
const std::vector<double>& DXV = deck.getKeyword<ParserKeywords::DXV>().getSIDoubleData();
const std::vector<double>& DYV = deck.getKeyword<ParserKeywords::DYV>().getSIDoubleData();
const std::vector<double>& DZV = deck.getKeyword<ParserKeywords::DZV>().getSIDoubleData();
const std::vector<double>& DEPTHZ = deck.getKeyword<ParserKeywords::DEPTHZ>().getSIDoubleData();
assertVectorSize( DEPTHZ , static_cast<size_t>( (dims[0] + 1)*(dims[1] +1 )) , "DEPTHZ");
assertVectorSize( DXV , static_cast<size_t>( dims[0] ) , "DXV");
assertVectorSize( DYV , static_cast<size_t>( dims[1] ) , "DYV");
assertVectorSize( DZV , static_cast<size_t>( dims[2] ) , "DZV");
m_grid.reset( ecl_grid_alloc_dxv_dyv_dzv_depthz( dims[0] , dims[1] , dims[2] , DXV.data() , DYV.data() , DZV.data() , DEPTHZ.data() , nullptr ) );
}
void EclipseGrid::initDTOPSGrid(const std::vector<int>& dims , const Deck& deck) {
std::vector<double> DX = createDVector( dims , 0 , "DX" , "DXV" , deck);
std::vector<double> DY = createDVector( dims , 1 , "DY" , "DYV" , deck);
std::vector<double> DZ = createDVector( dims , 2 , "DZ" , "DZV" , deck);
std::vector<double> TOPS = createTOPSVector( dims , DZ , deck );
m_grid.reset( ecl_grid_alloc_dx_dy_dz_tops( dims[0] , dims[1] , dims[2] , DX.data() , DY.data() , DZ.data() , TOPS.data() , nullptr ) );
}
void EclipseGrid::initCornerPointGrid(const std::vector<int>& dims, const Deck& deck) {
assertCornerPointKeywords( dims , deck);
{
const auto& ZCORNKeyWord = deck.getKeyword<ParserKeywords::ZCORN>();
const auto& COORDKeyWord = deck.getKeyword<ParserKeywords::COORD>();
const std::vector<double>& zcorn = ZCORNKeyWord.getSIDoubleData();
const std::vector<double>& coord = COORDKeyWord.getSIDoubleData();
double * mapaxes = NULL;
if (deck.hasKeyword<ParserKeywords::MAPAXES>()) {
const auto& mapaxesKeyword = deck.getKeyword<ParserKeywords::MAPAXES>();
const auto& record = mapaxesKeyword.getRecord(0);
mapaxes = new double[6];
for (size_t i = 0; i < 6; i++) {
mapaxes[i] = record.getItem( i ).getSIDouble( 0 );
}
}
{
const std::vector<float> zcorn_float( zcorn.begin() , zcorn.end() );
const std::vector<float> coord_float( coord.begin() , coord.end() );
float * mapaxes_float = NULL;
if (mapaxes) {
mapaxes_float = new float[6];
for (size_t i=0; i < 6; i++)
mapaxes_float[i] = mapaxes[i];
}
m_grid.reset( ecl_grid_alloc_GRDECL_data(dims[0] , dims[1] , dims[2] , zcorn_float.data() , coord_float.data() , nullptr , mapaxes_float) );
if (mapaxes) {
delete[] mapaxes_float;
delete[] mapaxes;
}
}
}
}
bool EclipseGrid::hasCornerPointKeywords(const Deck& deck) {
if (deck.hasKeyword<ParserKeywords::ZCORN>() && deck.hasKeyword<ParserKeywords::COORD>())
return true;
else
return false;
}
void EclipseGrid::assertCornerPointKeywords( const std::vector<int>& dims , const Deck& deck)
{
const int nx = dims[0];
const int ny = dims[1];
const int nz = dims[2];
{
const auto& ZCORNKeyWord = deck.getKeyword<ParserKeywords::ZCORN>();
if (ZCORNKeyWord.getDataSize() != static_cast<size_t>(8*nx*ny*nz)) {
const std::string msg =
"Wrong size of the ZCORN keyword: Expected 8*x*ny*nz = "
+ std::to_string(static_cast<long long>(8*nx*ny*nz)) + " is "
+ std::to_string(static_cast<long long>(ZCORNKeyWord.getDataSize()));
m_messages.error(msg);
throw std::invalid_argument(msg);
}
}
{
const auto& COORDKeyWord = deck.getKeyword<ParserKeywords::COORD>();
if (COORDKeyWord.getDataSize() != static_cast<size_t>(6*(nx + 1)*(ny + 1))) {
const std::string msg =
"Wrong size of the COORD keyword: Expected 6*(nx + 1)*(ny + 1) = "
+ std::to_string(static_cast<long long>(6*(nx + 1)*(ny + 1))) + " is "
+ std::to_string(static_cast<long long>(COORDKeyWord.getDataSize()));
m_messages.error(msg);
throw std::invalid_argument(msg);
}
}
}
bool EclipseGrid::hasCartesianKeywords(const Deck& deck) {
if (hasDVDEPTHZKeywords( deck ))
return true;
else
return hasDTOPSKeywords(deck);
}
bool EclipseGrid::hasDVDEPTHZKeywords(const Deck& deck) {
if (deck.hasKeyword<ParserKeywords::DXV>() &&
deck.hasKeyword<ParserKeywords::DYV>() &&
deck.hasKeyword<ParserKeywords::DZV>() &&
deck.hasKeyword<ParserKeywords::DEPTHZ>())
return true;
else
return false;
}
bool EclipseGrid::hasDTOPSKeywords(const Deck& deck) {
if ((deck.hasKeyword<ParserKeywords::DX>() || deck.hasKeyword<ParserKeywords::DXV>()) &&
(deck.hasKeyword<ParserKeywords::DY>() || deck.hasKeyword<ParserKeywords::DYV>()) &&
(deck.hasKeyword<ParserKeywords::DZ>() || deck.hasKeyword<ParserKeywords::DZV>()) &&
deck.hasKeyword<ParserKeywords::TOPS>())
return true;
else
return false;
}
void EclipseGrid::assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& vectorName) {
if (vector.size() != expectedSize)
throw std::invalid_argument("Wrong size for keyword: " + vectorName + ". Expected: " + boost::lexical_cast<std::string>(expectedSize) + " got: " + boost::lexical_cast<std::string>(vector.size()));
}
/*
The body of the for loop in this method looks slightly
peculiar. The situation is as follows:
1. The EclipseGrid class will assemble the necessary keywords
and create an ert ecl_grid instance.
2. The ecl_grid instance will export ZCORN, COORD and ACTNUM
data which will be used by the UnstructureGrid constructor
in opm-core. If the ecl_grid is created with ZCORN as an
input keyword that data is retained in the ecl_grid
structure, otherwise the ZCORN data is created based on the
internal cell geometries.
3. When constructing the UnstructuredGrid structure strict
numerical comparisons of ZCORN values are used to detect
cells in contact, if all the elements the elements in the
TOPS vector are specified[1] we will typically not get
bitwise equality between the bottom of one cell and the top
of the next.
To remedy this we enforce bitwise equality with the
construction:
if (std::abs(nextValue - TOPS[targetIndex]) < z_tolerance)
TOPS[targetIndex] = nextValue;
[1]: This is of course assuming the intention is to construct a
fully connected space covering grid - if that is indeed
not the case the barriers must be thicker than 1e-6m to be
retained.
*/
std::vector<double> EclipseGrid::createTOPSVector(const std::vector<int>& dims,
const std::vector<double>& DZ, const Deck& deck)
{
double z_tolerance = 1e-6;
size_t volume = dims[0] * dims[1] * dims[2];
size_t area = dims[0] * dims[1];
const auto& TOPSKeyWord = deck.getKeyword<ParserKeywords::TOPS>();
std::vector<double> TOPS = TOPSKeyWord.getSIDoubleData();
if (TOPS.size() >= area) {
size_t initialTOPSize = TOPS.size();
TOPS.resize( volume );
for (size_t targetIndex = area; targetIndex < volume; targetIndex++) {
size_t sourceIndex = targetIndex - area;
double nextValue = TOPS[sourceIndex] + DZ[sourceIndex];
if (targetIndex >= initialTOPSize)
TOPS[targetIndex] = nextValue;
else {
if (std::abs(nextValue - TOPS[targetIndex]) < z_tolerance)
TOPS[targetIndex] = nextValue;
}
}
}
if (TOPS.size() != volume)
throw std::invalid_argument("TOPS size mismatch");
return TOPS;
}
std::vector<double> EclipseGrid::createDVector(const std::vector<int>& dims, size_t dim, const std::string& DKey,
const std::string& DVKey, const Deck& deck)
{
size_t volume = dims[0] * dims[1] * dims[2];
size_t area = dims[0] * dims[1];
std::vector<double> D;
if (deck.hasKeyword(DKey)) {
D = deck.getKeyword( DKey ).getSIDoubleData();
if (D.size() >= area && D.size() < volume) {
/*
Only the top layer is required; for layers below the
top layer the value from the layer above is used.
*/
size_t initialDSize = D.size();
D.resize( volume );
for (size_t targetIndex = initialDSize; targetIndex < volume; targetIndex++) {
size_t sourceIndex = targetIndex - area;
D[targetIndex] = D[sourceIndex];
}
}
if (D.size() != volume)
throw std::invalid_argument(DKey + " size mismatch");
} else {
const auto& DVKeyWord = deck.getKeyword(DVKey);
const std::vector<double>& DV = DVKeyWord.getSIDoubleData();
if (DV.size() != (size_t) dims[dim])
throw std::invalid_argument(DVKey + " size mismatch");
D.resize( volume );
scatterDim( dims , dim , DV , D );
}
return D;
}
void EclipseGrid::scatterDim(const std::vector<int>& dims , size_t dim , const std::vector<double>& DV , std::vector<double>& D) {
int index[3];
for (index[2] = 0; index[2] < dims[2]; index[2]++) {
for (index[1] = 0; index[1] < dims[1]; index[1]++) {
for (index[0] = 0; index[0] < dims[0]; index[0]++) {
size_t globalIndex = index[2] * dims[1] * dims[0] + index[1] * dims[0] + index[0];
D[globalIndex] = DV[ index[dim] ];
}
}
}
}
/*
This function checks if the grid has a pointer to an underlying
ecl_grid_type; which must be used to read cell info as
size/depth/active of individual cells.
*/
bool EclipseGrid::hasCellInfo() const {
return static_cast<bool>( m_grid );
}
void EclipseGrid::assertCellInfo() const {
if (!hasCellInfo())
throw std::invalid_argument("Tried to access cell information in a grid with only dimensions");
}
const ecl_grid_type * EclipseGrid::c_ptr() const {
assertCellInfo();
return m_grid.get();
}
const MessageContainer& EclipseGrid::getMessageContainer() const {
return m_messages;
}
MessageContainer& EclipseGrid::getMessageContainer() {
return m_messages;
}
bool EclipseGrid::equal(const EclipseGrid& other) const {
bool status = (m_pinch.equal( other.m_pinch ) && (ecl_grid_compare( c_ptr() , other.c_ptr() , true , false , false )) && (m_minpvMode == other.getMinpvMode()));
if(m_minpvMode!=MinpvMode::ModeEnum::Inactive){
status = status && (m_minpvValue == other.getMinpvValue());
}
return status;
}
size_t EclipseGrid::getNumActive( ) const {
return static_cast<size_t>(ecl_grid_get_nactive( c_ptr() ));
}
bool EclipseGrid::cellActive( size_t globalIndex ) const {
assertGlobalIndex( globalIndex );
return ecl_grid_cell_active1( c_ptr() , static_cast<int>(globalIndex));
}
bool EclipseGrid::cellActive( size_t i , size_t j , size_t k ) const {
assertIJK(i,j,k);
return ecl_grid_cell_active3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
}
double EclipseGrid::getCellVolume(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
return ecl_grid_get_cell_volume1( c_ptr() , static_cast<int>(globalIndex));
}
double EclipseGrid::getCellVolume(size_t i , size_t j , size_t k) const {
assertIJK(i,j,k);
return ecl_grid_get_cell_volume3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
}
double EclipseGrid::getCellThicknes(size_t i , size_t j , size_t k) const {
assertIJK(i,j,k);
return ecl_grid_get_cell_thickness3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
}
double EclipseGrid::getCellThicknes(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
return ecl_grid_get_cell_thickness1( c_ptr() , static_cast<int>(globalIndex));
}
std::array<double, 3> EclipseGrid::getCellDims(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
{
double dx = ecl_grid_get_cell_dx1( c_ptr() , globalIndex);
double dy = ecl_grid_get_cell_dy1( c_ptr() , globalIndex);
double dz = ecl_grid_get_cell_thickness1( c_ptr() , globalIndex);
return std::array<double,3>{ {dx , dy , dz }};
}
}
std::array<double, 3> EclipseGrid::getCellDims(size_t i , size_t j , size_t k) const {
assertIJK(i,j,k);
{
size_t globalIndex = getGlobalIndex( i,j,k );
double dx = ecl_grid_get_cell_dx1( c_ptr() , globalIndex);
double dy = ecl_grid_get_cell_dy1( c_ptr() , globalIndex);
double dz = ecl_grid_get_cell_thickness1( c_ptr() , globalIndex);
return std::array<double,3>{ {dx , dy , dz }};
}
}
std::array<double, 3> EclipseGrid::getCellCenter(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
{
double x,y,z;
ecl_grid_get_xyz1( c_ptr() , static_cast<int>(globalIndex) , &x , &y , &z);
return std::array<double, 3>{{x,y,z}};
}
}
std::array<double, 3> EclipseGrid::getCellCenter(size_t i,size_t j, size_t k) const {
assertIJK(i,j,k);
{
double x,y,z;
ecl_grid_get_xyz3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k), &x , &y , &z);
return std::array<double, 3>{{x,y,z}};
}
}
double EclipseGrid::getCellDepth(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
return ecl_grid_get_cdepth1( c_ptr() , static_cast<int>(globalIndex));
}
double EclipseGrid::getCellDepth(size_t i,size_t j, size_t k) const {
assertIJK(i,j,k);
return ecl_grid_get_cdepth3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
}
void EclipseGrid::exportACTNUM( std::vector<int>& actnum) const {
size_t volume = getNX() * getNY() * getNZ();
if (getNumActive() == volume)
actnum.resize(0);
else {
actnum.resize( volume );
ecl_grid_init_actnum_data( c_ptr() , actnum.data() );
}
}
void EclipseGrid::exportMAPAXES( std::vector<double>& mapaxes) const {
if (ecl_grid_use_mapaxes( c_ptr())) {
mapaxes.resize(6);
ecl_grid_init_mapaxes_data_double( c_ptr() , mapaxes.data() );
} else {
mapaxes.resize(0);
}
}
void EclipseGrid::exportCOORD( std::vector<double>& coord) const {
coord.resize( ecl_grid_get_coord_size( c_ptr() ));
ecl_grid_init_coord_data_double( c_ptr() , coord.data() );
}
void EclipseGrid::exportZCORN( std::vector<double>& zcorn) const {
zcorn.resize( ecl_grid_get_zcorn_size( c_ptr() ));
ecl_grid_init_zcorn_data_double( c_ptr() , zcorn.data() );
}
void EclipseGrid::resetACTNUM( const int * actnum) {
assertCellInfo();
ecl_grid_reset_actnum( m_grid.get() , actnum );
}
void EclipseGrid::fwriteEGRID( const std::string& filename, bool output_metric ) const {
assertCellInfo();
ecl_grid_fwrite_EGRID( m_grid.get() , filename.c_str(), output_metric );
}
}

View File

@@ -0,0 +1,167 @@
/*
Copyright 2014 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/>.
*/
#ifndef ECLIPSE_GRID_HPP_
#define ECLIPSE_GRID_HPP_
#include <opm/parser/eclipse/EclipseState/Util/Value.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
#include <ert/ecl/ecl_grid.h>
#include <ert/util/ert_unique_ptr.hpp>
#include <array>
#include <memory>
#include <vector>
namespace Opm {
class Deck;
/**
About cell information and dimension: The actual grid
information is held in a pointer to an ERT ecl_grid_type
instance. This pointer must be used for access to all cell
related properties, including:
- Size of cells
- Real world position of cells
- Active/inactive status of cells
However in may cases the only required information is the
dimension of the grid. To facilitate simpler use, in particular
in testing, the grid dimensions are internalized separate from
the ecl_grid_type pointer. This means that in many cases a grid
without the underlying ecl_grid_type pointer is sufficient. To
create such a 'naked' grid you can parse a deck with only
DIMENS / SPECGRID and no further grid related keywords, or
alternatively use the:
EclipseGrid::EclipseGrid(nx,ny,nz)
constructor.
To query a grid instance if it has proper underlying grid
support use the method:
bool EclipseGrid::hasCellInfo();
*/
class EclipseGrid {
public:
explicit EclipseGrid(const std::string& filename);
explicit EclipseGrid(const ecl_grid_type * src_ptr);
explicit EclipseGrid(size_t nx, size_t ny, size_t nz,
double dx = 1.0, double dy = 1.0, double dz = 1.0);
/// EclipseGrid ignores ACTNUM in Deck, and therefore needs ACTNUM
/// explicitly. If a null pointer is passed, every cell is active.
explicit EclipseGrid(const Deck& deck, const int * actnum = nullptr);
/// [deprecated]
explicit EclipseGrid(const std::shared_ptr<const Deck>& deck, const int * actnum = nullptr);
static bool hasCornerPointKeywords(const Deck&);
static bool hasCartesianKeywords(const Deck&);
size_t getNumActive( ) const;
size_t getNX( ) const;
size_t getNY( ) const;
size_t getNZ( ) const;
size_t getCartesianSize( ) const;
bool isPinchActive( ) const;
double getPinchThresholdThickness( ) const;
PinchMode::ModeEnum getPinchOption( ) const;
PinchMode::ModeEnum getMultzOption( ) const;
MinpvMode::ModeEnum getMinpvMode() const;
double getMinpvValue( ) const;
bool hasCellInfo() const;
size_t getGlobalIndex(size_t i, size_t j, size_t k) const;
std::array<int, 3> getIJK(size_t globalIndex) const;
void assertGlobalIndex(size_t globalIndex) const;
void assertIJK(size_t i , size_t j , size_t k) const;
std::array<double, 3> getCellCenter(size_t i,size_t j, size_t k) const;
std::array<double, 3> getCellCenter(size_t globalIndex) const;
double getCellVolume(size_t globalIndex) const;
double getCellVolume(size_t i , size_t j , size_t k) const;
double getCellThicknes(size_t globalIndex) const;
double getCellThicknes(size_t i , size_t j , size_t k) const;
std::array<double, 3> getCellDims(size_t i,size_t j, size_t k) const;
std::array<double, 3> getCellDims(size_t globalIndex) const;
bool cellActive( size_t globalIndex ) const;
bool cellActive( size_t i , size_t j, size_t k ) const;
double getCellDepth(size_t i,size_t j, size_t k) const;
double getCellDepth(size_t globalIndex) const;
void exportMAPAXES( std::vector<double>& mapaxes) const;
void exportCOORD( std::vector<double>& coord) const;
void exportZCORN( std::vector<double>& zcorn) const;
void exportACTNUM( std::vector<int>& actnum) const;
void resetACTNUM( const int * actnum);
bool equal(const EclipseGrid& other) const;
void fwriteEGRID( const std::string& filename, bool output_metric ) const;
const ecl_grid_type * c_ptr() const;
const MessageContainer& getMessageContainer() const;
MessageContainer& getMessageContainer();
private:
ERT::ert_unique_ptr<ecl_grid_type , ecl_grid_free> m_grid;
double m_minpvValue;
MinpvMode::ModeEnum m_minpvMode;
Value<double> m_pinch;
PinchMode::ModeEnum m_pinchoutMode;
PinchMode::ModeEnum m_multzMode;
size_t m_nx;
size_t m_ny;
size_t m_nz;
MessageContainer m_messages;
void assertCellInfo() const;
void initCartesianGrid(const std::vector<int>& dims, const Deck&);
void initCornerPointGrid(const std::vector<int>& dims, const Deck&);
void initDTOPSGrid(const std::vector<int>& dims, const Deck&);
void initDVDEPTHZGrid(const std::vector<int>& dims, const Deck& deck);
void initGrid(const std::vector<int>& dims, const Deck&);
void assertCornerPointKeywords(const std::vector<int>& dims, const Deck&);
static bool hasDVDEPTHZKeywords(const Deck&);
static bool hasDTOPSKeywords(const Deck&);
static void assertVectorSize(const std::vector<double>& vector, size_t expectedSize, const std::string& msg);
static std::vector<double> createTOPSVector(const std::vector<int>& dims, const std::vector<double>& DZ,
const Deck&);
static std::vector<double> createDVector(const std::vector<int>& dims, size_t dim, const std::string& DKey,
const std::string& DVKey, const Deck&);
static void scatterDim(const std::vector<int>& dims , size_t dim , const std::vector<double>& DV , std::vector<double>& D);
};
typedef std::shared_ptr<EclipseGrid> EclipseGridPtr;
typedef std::shared_ptr<const EclipseGrid> EclipseGridConstPtr;
}
#endif

View File

@@ -0,0 +1,77 @@
/*
Copyright 2014 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 <stdexcept>
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
namespace Opm {
namespace FaceDir {
DirEnum FromString(const std::string& stringValue) {
if ((stringValue == "X") || (stringValue == "I"))
return XPlus;
if ((stringValue == "X-") || (stringValue == "I-"))
return XMinus;
if ((stringValue == "Y") || (stringValue == "J"))
return YPlus;
if ((stringValue == "Y-") || (stringValue == "J-"))
return YMinus;
if ((stringValue == "Z") || (stringValue == "K"))
return ZPlus;
if ((stringValue == "Z-") || (stringValue == "K-"))
return ZMinus;
throw std::invalid_argument("The string value " + stringValue + " could not be converted to a FaceDir enum value");
}
int FromMULTREGTString(const std::string& stringValue) {
if (stringValue == "X")
return XPlus + XMinus;
if (stringValue == "Y")
return YPlus + YMinus;
if (stringValue == "Z")
return ZPlus + ZMinus;
if (stringValue == "XY")
return XPlus + YPlus + XMinus + YMinus;
if (stringValue == "XZ")
return XPlus + ZPlus + XMinus + ZMinus;
if (stringValue == "YZ")
return YPlus + ZPlus + YMinus + ZMinus;
if (stringValue == "XYZ")
return XPlus + YPlus + ZPlus + XMinus + YMinus + ZMinus;
throw std::invalid_argument("The string " + stringValue + " is not a valid MULTREGT direction value");
}
}
}

View File

@@ -0,0 +1,49 @@
/*
Copyright 2014 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/>.
*/
#ifndef OPM_FACEDIR_HPP
#define OPM_FACEDIR_HPP
#include <string>
namespace Opm {
namespace FaceDir {
enum DirEnum {
XPlus = 1,
XMinus = 2,
YPlus = 4,
YMinus = 8,
ZPlus = 16,
ZMinus = 32
};
/**
The MULTREGTScanner will use these values as bitmaps;
i.e. it is essential they form a 2^n sequence.
*/
DirEnum FromString(const std::string& stringValue);
int FromMULTREGTString(const std::string& stringValue);
}
}
#endif

View File

@@ -0,0 +1,59 @@
/*
Copyright 2014 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 <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
namespace Opm {
Fault::Fault(const std::string& faultName) :
m_name( faultName ),
m_transMult( 1 )
{
}
const std::string& Fault::getName() const {
return m_name;
}
double Fault::getTransMult() const {
return m_transMult;
}
void Fault::setTransMult(double transMult) {
m_transMult = transMult;
}
void Fault::addFace(std::shared_ptr<const FaultFace> face) {
m_faceList.push_back( face );
}
std::vector<std::shared_ptr<const FaultFace> >::const_iterator Fault::begin() const {
return m_faceList.begin();
}
std::vector<std::shared_ptr<const FaultFace> >::const_iterator Fault::end() const {
return m_faceList.end();
}
}

Some files were not shown because too many files have changed in this diff Show More