Added double properties for e.g. PERM and PORO to the EclipseState

This commit is contained in:
Joakim Hove
2014-06-02 09:07:16 +02:00
committed by Andreas Lauser
parent 7269924543
commit 5e56f16369
7 changed files with 177 additions and 39 deletions

View File

@@ -93,13 +93,17 @@ namespace Opm {
}
bool EclipseState::supportsGridProperty(const std::string& keyword) const {
return m_intGridProperties->supportsKeyword( keyword );
return (m_intGridProperties->supportsKeyword( keyword ) || m_doubleGridProperties->supportsKeyword( keyword ));
}
bool EclipseState::hasIntGridProperty(const std::string& keyword) const {
return m_intGridProperties->hasKeyword( keyword );
}
bool EclipseState::hasDoubleGridProperty(const std::string& keyword) const {
return m_doubleGridProperties->hasKeyword( keyword );
}
/*
Observe that this will autocreate a property if it has not been explicitly added.
*/
@@ -107,13 +111,23 @@ namespace Opm {
return m_intGridProperties->getKeyword( keyword );
}
std::shared_ptr<GridProperty<double> > EclipseState::getDoubleProperty( const std::string& keyword ) {
return m_doubleGridProperties->getKeyword( keyword );
}
void EclipseState::loadGridPropertyFromDeckKeyword(std::shared_ptr<const Box> inputBox , DeckKeywordConstPtr deckKeyword) {
const std::string& keyword = deckKeyword->name();
auto gridProperty = m_intGridProperties->getKeyword( keyword );
gridProperty->loadFromDeckKeyword( inputBox , deckKeyword );
if (m_intGridProperties->supportsKeyword( keyword )) {
auto gridProperty = m_intGridProperties->getKeyword( keyword );
gridProperty->loadFromDeckKeyword( inputBox , deckKeyword );
} else if (m_doubleGridProperties->supportsKeyword( keyword )) {
auto gridProperty = m_doubleGridProperties->getKeyword( keyword );
gridProperty->loadFromDeckKeyword( inputBox , deckKeyword );
}
}
void EclipseState::initProperties(DeckConstPtr deck) {
@@ -122,40 +136,79 @@ namespace Opm {
{ "PVTNUM" , 0 },
{ "EQLNUM" , 0 },
{ "FIPNUM" , 0 }};
m_intGridProperties = std::make_shared<GridProperties<int> >(m_eclipseGrid->getNX() , m_eclipseGrid->getNY() , m_eclipseGrid->getNZ() , supportedIntKeywords);
std::vector<std::pair<std::string , double> > supportedDoubleKeywords = {{ "PORO" , 0 },
{ "PERMX" , 0 },
{ "PERMY" , 0 },
{ "PERMZ" , 0 }};
m_intGridProperties = std::make_shared<GridProperties<int> >(m_eclipseGrid->getNX() , m_eclipseGrid->getNY() , m_eclipseGrid->getNZ() , supportedIntKeywords);
m_doubleGridProperties = std::make_shared<GridProperties<double> >(m_eclipseGrid->getNX() , m_eclipseGrid->getNY() , m_eclipseGrid->getNZ() , supportedDoubleKeywords);
if (Section::hasGRID(deck)) {
std::shared_ptr<Opm::GRIDSection> gridSection(new Opm::GRIDSection(deck) );
scanSection( gridSection , boxManager );
}
if (Section::hasEDIT(deck)) {
std::shared_ptr<Opm::EDITSection> editSection(new Opm::EDITSection(deck) );
scanSection( editSection , boxManager );
}
if (Section::hasPROPS(deck)) {
std::shared_ptr<Opm::PROPSSection> propsSection(new Opm::PROPSSection(deck) );
scanSection( propsSection , boxManager );
}
if (Section::hasREGIONS(deck)) {
std::shared_ptr<Opm::REGIONSSection> regionsSection(new Opm::REGIONSSection(deck) );
for (auto iter = regionsSection->begin(); iter != regionsSection->end(); ++iter) {
DeckKeywordConstPtr deckKeyword = *iter;
if (supportsGridProperty( deckKeyword->name()) )
loadGridPropertyFromDeckKeyword( boxManager.getActiveBox() , deckKeyword );
scanSection( regionsSection , boxManager );
}
if (deckKeyword->name() == "ADD")
handleADDKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "BOX")
handleBOXKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "COPY")
handleCOPYKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "EQUALS")
handleEQUALSKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "ENDBOX")
handleENDBOXKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "MULTIPLY")
handleMULTIPLYKeyword(deckKeyword , boxManager);
std::cout << "Looking at kw: " << deckKeyword->name() << std::endl;
boxManager.endKeyword();
}
if (Section::hasSOLUTION(deck)) {
std::shared_ptr<Opm::SOLUTIONSection> solutionSection(new Opm::SOLUTIONSection(deck) );
scanSection( solutionSection , boxManager );
}
}
void EclipseState::scanSection(std::shared_ptr<Opm::Section> section , BoxManager& boxManager) {
for (auto iter = section->begin(); iter != section->end(); ++iter) {
DeckKeywordConstPtr deckKeyword = *iter;
if (supportsGridProperty( deckKeyword->name()) )
loadGridPropertyFromDeckKeyword( boxManager.getActiveBox() , deckKeyword );
if (deckKeyword->name() == "ADD")
handleADDKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "BOX")
handleBOXKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "COPY")
handleCOPYKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "EQUALS")
handleEQUALSKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "ENDBOX")
handleENDBOXKeyword(deckKeyword , boxManager);
if (deckKeyword->name() == "MULTIPLY")
handleMULTIPLYKeyword(deckKeyword , boxManager);
boxManager.endKeyword();
}
boxManager.endSection();
}
void EclipseState::handleBOXKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager) {
@@ -189,8 +242,12 @@ namespace Opm {
std::shared_ptr<GridProperty<int> > property = m_intGridProperties->getKeyword( field );
property->scale( intFactor , boxManager.getActiveBox() );
} else if (m_doubleGridProperties->hasKeyword( field )) {
std::shared_ptr<GridProperty<double> > property = m_doubleGridProperties->getKeyword( field );
property->scale( scaleFactor , boxManager.getActiveBox() );
} else
throw std::invalid_argument("Fatal error processing MULTIPLY keyword. Tried to multiply not defined keyword" + field);
throw std::invalid_argument("Fatal error processing MULTIPLY keyword. Tried to multiply not defined keyword " + field);
}
}
@@ -215,8 +272,12 @@ namespace Opm {
std::shared_ptr<GridProperty<int> > property = m_intGridProperties->getKeyword( field );
property->add( intShift , boxManager.getActiveBox() );
} else if (m_intGridProperties->hasKeyword( field )) {
std::shared_ptr<GridProperty<double> > property = m_doubleGridProperties->getKeyword( field );
property->add( shiftValue , boxManager.getActiveBox() );
} else
throw std::invalid_argument("Fatal error processing ADD keyword. Tried to multiply not defined keyword" + field);
throw std::invalid_argument("Fatal error processing ADD keyword. Tried to multiply not defined keyword " + field);
}
}
@@ -235,8 +296,12 @@ namespace Opm {
std::shared_ptr<GridProperty<int> > property = m_intGridProperties->getKeyword( field );
property->setScalar( intValue , boxManager.getActiveBox() );
} else if (m_doubleGridProperties->supportsKeyword( field )) {
std::shared_ptr<GridProperty<double> > property = m_doubleGridProperties->getKeyword( field );
property->setScalar( value , boxManager.getActiveBox() );
} else
throw std::invalid_argument("Fatal error processing EQUALS keyword. Tried to set not defined keyword" + field);
throw std::invalid_argument("Fatal error processing EQUALS keyword. Tried to set not defined keyword " + field);
}
}
@@ -253,8 +318,10 @@ namespace Opm {
if (m_intGridProperties->hasKeyword( srcField ))
copyIntKeyword( srcField , targetField , boxManager.getActiveBox());
else if (m_doubleGridProperties->hasKeyword( srcField ))
copyDoubleKeyword( srcField , targetField , boxManager.getActiveBox());
else
throw std::invalid_argument("Fatal error processing COPY keyword. Tried to copy from not defined keyword" + srcField);
throw std::invalid_argument("Fatal error processing COPY keyword. Tried to copy from not defined keyword " + srcField);
}
}
@@ -263,6 +330,14 @@ namespace Opm {
void EclipseState::copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox) {
std::shared_ptr<const GridProperty<int> > src = m_intGridProperties->getKeyword( srcField );
std::shared_ptr<GridProperty<int> > target = m_intGridProperties->getKeyword( targetField );
target->copyFrom( *src , inputBox );
}
void EclipseState::copyDoubleKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox) {
std::shared_ptr<const GridProperty<double> > src = m_doubleGridProperties->getKeyword( srcField );
std::shared_ptr<GridProperty<double> > target = m_doubleGridProperties->getKeyword( targetField );
target->copyFrom( *src , inputBox );
}

View File

@@ -41,8 +41,12 @@ namespace Opm {
bool hasPhase(enum Phase::PhaseEnum phase) const;
std::string getTitle() const;
bool supportsGridProperty(const std::string& keyword) const;
std::shared_ptr<GridProperty<int> > getIntProperty( const std::string& keyword );
std::shared_ptr<GridProperty<double> > getDoubleProperty( const std::string& keyword );
bool hasIntGridProperty(const std::string& keyword) const;
bool hasDoubleGridProperty(const std::string& keyword) const;
void loadGridPropertyFromDeckKeyword(std::shared_ptr<const Box> inputBox , DeckKeywordConstPtr deckKeyword);
private:
@@ -52,6 +56,7 @@ namespace Opm {
void initTitle(DeckConstPtr deck);
void initProperties(DeckConstPtr deck);
void scanSection(std::shared_ptr<Opm::Section> section , BoxManager& boxManager);
void handleADDKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
void handleBOXKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
void handleCOPYKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
@@ -60,13 +65,16 @@ namespace Opm {
void handleMULTIPLYKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
void setKeywordBox(DeckRecordConstPtr deckRecord , BoxManager& boxManager);
void copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox);
void copyDoubleKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox);
EclipseGridConstPtr m_eclipseGrid;
ScheduleConstPtr schedule;
std::set<enum Phase::PhaseEnum> phases;
std::string m_title;
std::shared_ptr<GridProperties<int> > m_intGridProperties;
std::shared_ptr<GridProperties<double> > m_doubleGridProperties;
};
typedef std::shared_ptr<EclipseState> EclipseStatePtr;

View File

@@ -94,7 +94,7 @@ public:
else {
auto supportedKeyword = m_supportedKeywords.find( keyword );
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(m_nx , m_ny , m_nz , keyword , (*supportedKeyword).second));
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<int> > > ( keyword , newProperty ));
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( keyword , newProperty ));
return true;
}
}

View File

@@ -40,4 +40,24 @@ void GridProperty<int>::loadFromDeckKeyword(std::shared_ptr<const Box> inputBox
throw std::invalid_argument("Can only load from DATA keywords");
}
/*****************************************************************/
template<>
void GridProperty<double>::loadFromDeckKeyword(Opm::DeckKeywordConstPtr deckKeyword) {
if (deckKeyword->isDataKeyword()) {
const std::vector<double>& data = deckKeyword->getSIDoubleData();
setFromVector(data);
} else
throw std::invalid_argument("Can only load from DATA keywords");
}
template<>
void GridProperty<double>::loadFromDeckKeyword(std::shared_ptr<const Box> inputBox , Opm::DeckKeywordConstPtr deckKeyword) {
if (deckKeyword->isDataKeyword()) {
const std::vector<double>& data = deckKeyword->getSIDoubleData();
setFromVector(inputBox , data);
} else
throw std::invalid_argument("Can only load from DATA keywords");
}
}

View File

@@ -24,6 +24,7 @@
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/lexical_cast.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
@@ -150,7 +151,7 @@ private:
for (size_t i = 0; i < data.size(); i++)
m_data[i] = data[i];
} else
throw std::invalid_argument("Size mismatch");
throw std::invalid_argument("Size mismatch when setting data for:" + m_keyword + " keyword size: " + boost::lexical_cast<std::string>(m_data.size()) + " input size: " + boost::lexical_cast<std::string>(data.size()));
}
@@ -165,7 +166,7 @@ private:
m_data[targetIndex] = data[i];
}
} else
throw std::invalid_argument("Size mismatch");
throw std::invalid_argument("Size mismatch when setting data for:" + m_keyword + " box size: " + boost::lexical_cast<std::string>(inputBox->size()) + " input size: " + boost::lexical_cast<std::string>(data.size()));
}
}

View File

@@ -108,3 +108,25 @@ BOOST_AUTO_TEST_CASE( EQUAL ) {
}
}
}
BOOST_AUTO_TEST_CASE( PERMX ) {
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
std::shared_ptr<GridProperty<double> > permx = state.getDoubleProperty("PERMX");
std::shared_ptr<GridProperty<double> > permy = state.getDoubleProperty("PERMY");
std::shared_ptr<GridProperty<double> > permz = state.getDoubleProperty("PERMZ");
size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
for (k = 0; k < grid->getNZ(); k++) {
for (j = 0; j < grid->getNY(); j++) {
for (i = 0; i < grid->getNX(); i++) {
BOOST_CHECK_CLOSE( permx->iget(i,j,k) * 0.25 , permz->iget(i,j,k) , 0.001);
BOOST_CHECK_EQUAL( permx->iget(i,j,k) , permy->iget(i,j,k));
}
}
}
}

View File

@@ -17,6 +17,18 @@ DZ
TOPS
1000*0.25 /
PERMX
1000*100 /
COPY
PERMX PERMZ /
PERMX PERMY /
/
MULTIPLY
PERMZ 0.25 /
/
EDIT
OIL