/*
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 .
*/
#ifndef OPM_ECLIPSE_STATE_HPP
#define OPM_ECLIPSE_STATE_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace Opm {
class EclipseState {
public:
enum EnabledTypes {
IntProperties = 0x01,
DoubleProperties = 0x02,
AllProperties = IntProperties | DoubleProperties
};
EclipseState(DeckConstPtr deck, LoggerPtr logger = std::make_shared(&std::cout));
ScheduleConstPtr getSchedule() const;
EclipseGridConstPtr getEclipseGrid() const;
EclipseGridPtr getEclipseGridCopy() const;
bool hasPhase(enum Phase::PhaseEnum phase) const;
std::string getTitle() const;
bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const;
std::shared_ptr > getIntGridProperty( const std::string& keyword ) const;
std::shared_ptr > getDoubleGridProperty( const std::string& keyword ) const;
bool hasIntGridProperty(const std::string& keyword) const;
bool hasDoubleGridProperty(const std::string& keyword) const;
void loadGridPropertyFromDeckKeyword(std::shared_ptr inputBox,
DeckKeywordConstPtr deckKeyword,
LoggerPtr logger,
int enabledTypes = AllProperties);
std::shared_ptr getFaults() const;
std::shared_ptr getTransMult() const;
// the tables used by the deck. If the tables had some defaulted data in the
// deck, the objects returned here exhibit the correct values. If the table is
// not present in the deck, the corresponding vector is of size zero.
const std::vector& getEnkrvdTables() const;
const std::vector& getEnptvdTables() const;
const std::vector& getImkrvdTables() const;
const std::vector& getImptvdTables() const;
const std::vector& getPlyadsTables() const;
const std::vector& getPlymaxTables() const;
const std::vector& getPlyrockTables() const;
const std::vector& getPlyviscTables() const;
const std::vector& getPvdgTables() const;
const std::vector& getPvdoTables() const;
const std::vector& getPvtgTables() const;
const std::vector& getPvtoTables() const;
const std::vector& getRocktabTables() const;
const std::vector& getRsvdTables() const;
const std::vector& getRvvdTables() const;
const std::vector& getRtempvdTables() const;
const std::vector& getSgofTables() const;
const std::vector& getSof2Tables() const;
const std::vector& getSwofTables() const;
const std::vector& getSwfnTables() 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...
std::shared_ptr getDeckUnitSystem() const;
private:
void initTables(DeckConstPtr deck, LoggerPtr logger);
void initSchedule(DeckConstPtr deck, LoggerPtr logger);
void initEclipseGrid(DeckConstPtr deck, LoggerPtr logger);
void initPhases(DeckConstPtr deck, LoggerPtr logger);
void initTitle(DeckConstPtr deck, LoggerPtr logger);
void initProperties(DeckConstPtr deck, LoggerPtr logger);
void initTransMult(LoggerPtr logger);
void initFaults(DeckConstPtr deck, LoggerPtr logger);
template
void initSimpleTables(DeckConstPtr deck,
LoggerPtr logger,
const std::string& keywordName,
std::vector& tableVector) {
if (!deck->hasKeyword(keywordName))
return; // the table is not featured by the deck...
if (deck->numKeywords(keywordName) > 1) {
complainAboutAmbiguousKeyword(deck, logger, keywordName);
return;
}
const auto& tableKeyword = deck->getKeyword(keywordName);
for (size_t tableIdx = 0; tableIdx < tableKeyword->size(); ++tableIdx) {
if (tableKeyword->getRecord(tableIdx)->getItem(0)->size() == 0) {
// for simple tables, an empty record indicates that the previous table
// should be copied...
if (tableIdx == 0) {
logger->addError(tableKeyword->getFileName(),
tableKeyword->getLineNumber(),
"The first table for keyword "+keywordName+
" must be explicitly defined! Ignoring keyword");
return;
}
tableVector.push_back(tableVector.back());
continue;
}
tableVector.push_back(TableType());
tableVector[tableIdx].init(tableKeyword, tableIdx);
}
}
template
void initFullTables(DeckConstPtr deck,
LoggerPtr logger,
const std::string& keywordName,
std::vector& tableVector) {
if (!deck->hasKeyword(keywordName))
return; // the table is not featured by the deck...
if (deck->numKeywords(keywordName) > 1) {
complainAboutAmbiguousKeyword(deck, logger, keywordName);
return;
}
const auto& tableKeyword = deck->getKeyword(keywordName);
int numTables = TableType::numTables(tableKeyword);
for (int tableIdx = 0; tableIdx < numTables; ++tableIdx) {
tableVector.push_back(TableType());
tableVector[tableIdx].init(tableKeyword, tableIdx);
}
}
void initRocktabTables(DeckConstPtr deck, LoggerPtr logger);
void setMULTFLT(std::shared_ptr section, LoggerPtr logger) const;
void initMULTREGT(DeckConstPtr deck, LoggerPtr logger);
double getSIScaling(const std::string &dimensionString) const;
void processGridProperties(Opm::DeckConstPtr deck, LoggerPtr logger, int enabledTypes);
void scanSection(std::shared_ptr section, LoggerPtr logger, int enabledTypes);
void handleADDKeyword(DeckKeywordConstPtr deckKeyword , LoggerPtr logger, BoxManager& boxManager, int enabledTypes);
void handleBOXKeyword(DeckKeywordConstPtr deckKeyword , LoggerPtr logger, BoxManager& boxManager);
void handleCOPYKeyword(DeckKeywordConstPtr deckKeyword , LoggerPtr logger, BoxManager& boxManager, int enabledTypes);
void handleENDBOXKeyword(BoxManager& boxManager);
void handleEQUALSKeyword(DeckKeywordConstPtr deckKeyword , LoggerPtr logger, BoxManager& boxManager, int enabledTypes);
void handleMULTIPLYKeyword(DeckKeywordConstPtr deckKeyword , LoggerPtr logger, BoxManager& boxManager, int enabledTypes);
void setKeywordBox(DeckKeywordConstPtr deckKeyword, size_t recordIdx, LoggerPtr logger, BoxManager& boxManager);
void copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr inputBox);
void copyDoubleKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr inputBox);
void complainAboutAmbiguousKeyword(DeckConstPtr deck, LoggerPtr logger, const std::string& keywordName) const;
EclipseGridConstPtr m_eclipseGrid;
ScheduleConstPtr schedule;
std::vector m_enkrvdTables;
std::vector m_enptvdTables;
std::vector m_imkrvdTables;
std::vector m_imptvdTables;
std::vector m_plyadsTables;
std::vector m_plymaxTables;
std::vector m_plyrockTables;
std::vector m_plyviscTables;
std::vector m_pvdgTables;
std::vector m_pvdoTables;
std::vector m_pvtgTables;
std::vector m_pvtoTables;
std::vector m_rocktabTables;
std::vector m_rsvdTables;
std::vector m_rvvdTables;
std::vector m_rtempvdTables;
std::vector m_sgofTables;
std::vector m_sof2Tables;
std::vector m_swofTables;
std::vector m_swfnTables;
std::set phases;
std::string m_title;
std::shared_ptr m_deckUnitSystem;
std::shared_ptr > m_intGridProperties;
std::shared_ptr > m_doubleGridProperties;
std::shared_ptr m_transMult;
std::shared_ptr m_faults;
};
typedef std::shared_ptr EclipseStatePtr;
typedef std::shared_ptr EclipseStateConstPtr;
}
#endif