EclipseState: make the grid properties returned by get*GridProperty() constant
that's because they are not supposed to be modified outside of the
EclipseState. (if they are, why? I'd consider that *very* bad style
since it is also possible to copy these objects and modify the copy
and also this was used nowhere within the OPM project.)
also, the has*Property() is now working as expected: if e.g.,
```c++
bool hasSatnum = eclipseState->hasIntProperty("SATNUM");
eclipseState->getIntProperty("SATNUM");
assert(hasSatnum == eclipseState->hasIntProperty("SATNUM"));
```
will now work for decks which does not explicitly specify
SATNUM. (before the getIntProperty() method silently created the
SATNUM property which caused hasIntProperty() to change its
opinion. With this patch, the property will still be silently created,
but has*Property() ignores it, i.e., that method could be renamed to
hasExplicit*Property() which -- as far as I understand this -- was its
intention from start.)
This commit is contained in:
@@ -80,7 +80,7 @@ namespace Opm {
|
||||
{ }
|
||||
|
||||
|
||||
void apply(std::vector<double>& ) const {
|
||||
void apply(std::vector<double>& values) const {
|
||||
EclipseGridConstPtr grid = m_eclipseState.getEclipseGrid();
|
||||
/*
|
||||
Observe that this apply method does not alter the
|
||||
@@ -93,21 +93,24 @@ namespace Opm {
|
||||
auto ntg = m_eclipseState.getDoubleGridProperty("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(porv->iget(globalIndex))) {
|
||||
double cell_poro = poro->iget(globalIndex);
|
||||
if (std::isnan(values[globalIndex])) {
|
||||
double cell_poro = poroData[globalIndex];
|
||||
double cell_ntg = ntg->iget(globalIndex);
|
||||
double cell_volume = grid->getCellVolume(globalIndex);
|
||||
porv->iset( globalIndex , cell_poro * cell_volume * cell_ntg);
|
||||
values[globalIndex] = cell_poro * cell_volume * cell_ntg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_eclipseState.hasDoubleGridProperty("MULTPV")) {
|
||||
auto multpv = m_eclipseState.getDoubleGridProperty("MULTPV");
|
||||
porv->multiplyWith( *multpv );
|
||||
auto multpvData = m_eclipseState.getDoubleGridProperty("MULTPV")->getData();
|
||||
for (size_t globalIndex = 0; globalIndex < porv->getCartesianSize(); globalIndex++) {
|
||||
values[globalIndex] *= multpvData[globalIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,11 +455,11 @@ namespace Opm {
|
||||
been explicitly added.
|
||||
*/
|
||||
|
||||
std::shared_ptr<GridProperty<int> > EclipseState::getIntGridProperty( const std::string& keyword ) const {
|
||||
std::shared_ptr<const GridProperty<int> > EclipseState::getIntGridProperty( const std::string& keyword ) const {
|
||||
return m_intGridProperties->getKeyword( keyword );
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<double> > EclipseState::getDoubleGridProperty( const std::string& keyword ) const {
|
||||
std::shared_ptr<const GridProperty<double> > EclipseState::getDoubleGridProperty( const std::string& keyword ) const {
|
||||
auto gridProperty = m_doubleGridProperties->getKeyword( keyword );
|
||||
if (gridProperty->postProcessorRunRequired())
|
||||
gridProperty->runPostProcessor();
|
||||
@@ -464,11 +467,11 @@ namespace Opm {
|
||||
return gridProperty;
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<int> > EclipseState::getDefaultRegion() const {
|
||||
return m_intGridProperties->getInitializedKeyword( m_defaultRegion );
|
||||
std::shared_ptr<const GridProperty<int> > EclipseState::getDefaultRegion() const {
|
||||
return m_intGridProperties->getKeyword( m_defaultRegion );
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<int> > EclipseState::getRegion( const DeckItem& regionItem ) const {
|
||||
std::shared_ptr<const GridProperty<int> > EclipseState::getRegion( const DeckItem& regionItem ) const {
|
||||
if (regionItem.defaultApplied(0))
|
||||
return getDefaultRegion();
|
||||
else {
|
||||
@@ -493,12 +496,12 @@ namespace Opm {
|
||||
const std::string& keyword = deckKeyword.name();
|
||||
if (m_intGridProperties->supportsKeyword( keyword )) {
|
||||
if (enabledTypes & IntProperties) {
|
||||
auto gridProperty = m_intGridProperties->getKeyword( keyword );
|
||||
auto gridProperty = getOrCreateIntProperty_( keyword );
|
||||
gridProperty->loadFromDeckKeyword( inputBox , deckKeyword );
|
||||
}
|
||||
} else if (m_doubleGridProperties->supportsKeyword( keyword )) {
|
||||
if (enabledTypes & DoubleProperties) {
|
||||
auto gridProperty = m_doubleGridProperties->getKeyword( keyword );
|
||||
auto gridProperty = getOrCreateDoubleProperty_( keyword );
|
||||
gridProperty->loadFromDeckKeyword( inputBox , deckKeyword );
|
||||
}
|
||||
} else {
|
||||
@@ -1014,36 +1017,34 @@ namespace Opm {
|
||||
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
|
||||
throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray);
|
||||
|
||||
if (supportsGridProperty( targetArray , enabledTypes)) {
|
||||
double doubleValue = record.getItem("VALUE").get< double >(0);
|
||||
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
|
||||
std::shared_ptr<Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::vector<bool> mask;
|
||||
double doubleValue = record.getItem("VALUE").template get<double>(0);
|
||||
int regionValue = record.getItem("REGION_NUMBER").template get<int>(0);
|
||||
std::shared_ptr<const Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::vector<bool> mask;
|
||||
|
||||
regionProperty->initMask( regionValue , mask);
|
||||
regionProperty->initMask( regionValue , mask);
|
||||
|
||||
if (m_intGridProperties->supportsKeyword( targetArray )) {
|
||||
if (enabledTypes & IntProperties) {
|
||||
if (isInt( doubleValue )) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = m_intGridProperties->getKeyword(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);
|
||||
}
|
||||
if (m_intGridProperties->supportsKeyword( targetArray )) {
|
||||
if (enabledTypes & IntProperties) {
|
||||
if (isInt( doubleValue )) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = getOrCreateIntProperty_(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) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = m_doubleGridProperties->getKeyword(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);
|
||||
}
|
||||
else if (m_doubleGridProperties->supportsKeyword( targetArray )) {
|
||||
if (enabledTypes & DoubleProperties) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = getOrCreateDoubleProperty_(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1059,7 +1060,7 @@ namespace Opm {
|
||||
if (supportsGridProperty( targetArray , enabledTypes)) {
|
||||
double doubleValue = record.getItem("SHIFT").get< double >(0);
|
||||
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
|
||||
std::shared_ptr<Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::shared_ptr<const Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::vector<bool> mask;
|
||||
|
||||
regionProperty->initMask( regionValue , mask);
|
||||
@@ -1103,29 +1104,22 @@ namespace Opm {
|
||||
if (supportsGridProperty( targetArray , enabledTypes)) {
|
||||
double doubleValue = record.getItem("FACTOR").get< double >(0);
|
||||
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
|
||||
std::shared_ptr<Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::shared_ptr<const Opm::GridProperty<int> > 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 )) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = m_intGridProperties->getKeyword( 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 & IntProperties) {
|
||||
if (isInt( doubleValue )) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = getOrCreateIntProperty_( 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);
|
||||
}
|
||||
else if (m_doubleGridProperties->hasKeyword( targetArray )) {
|
||||
if (enabledTypes & DoubleProperties) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = m_doubleGridProperties->getKeyword(targetArray);
|
||||
targetProperty->maskedMultiply( doubleValue , mask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray);
|
||||
if (enabledTypes & DoubleProperties) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = getOrCreateDoubleProperty_(targetArray);
|
||||
targetProperty->maskedMultiply( doubleValue , mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1146,22 +1140,22 @@ namespace Opm {
|
||||
|
||||
if (supportsGridProperty( srcArray , enabledTypes)) {
|
||||
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
|
||||
std::shared_ptr<Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::shared_ptr<const Opm::GridProperty<int> > regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
std::vector<bool> mask;
|
||||
|
||||
regionProperty->initMask( regionValue , mask );
|
||||
|
||||
if (m_intGridProperties->hasKeyword( srcArray )) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > srcProperty = m_intGridProperties->getInitializedKeyword( srcArray );
|
||||
std::shared_ptr<const Opm::GridProperty<int> > srcProperty = m_intGridProperties->getInitializedKeyword( srcArray );
|
||||
if (supportsGridProperty( targetArray , IntProperties)) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = m_intGridProperties->getKeyword( targetArray );
|
||||
std::shared_ptr<Opm::GridProperty<int> > targetProperty = getOrCreateIntProperty_( targetArray );
|
||||
targetProperty->maskedCopy( *srcProperty , mask );
|
||||
} else
|
||||
throw std::invalid_argument("Fatal error processing COPYREG keyword.");
|
||||
} else if (m_doubleGridProperties->hasKeyword( srcArray )) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > srcProperty = m_doubleGridProperties->getInitializedKeyword( srcArray );
|
||||
std::shared_ptr<const Opm::GridProperty<double> > srcProperty = m_doubleGridProperties->getInitializedKeyword( srcArray );
|
||||
if (supportsGridProperty( targetArray , DoubleProperties)) {
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = m_doubleGridProperties->getKeyword( targetArray );
|
||||
std::shared_ptr<Opm::GridProperty<double> > targetProperty = getOrCreateDoubleProperty_( targetArray );
|
||||
targetProperty->maskedCopy( *srcProperty , mask );
|
||||
}
|
||||
}
|
||||
@@ -1245,14 +1239,14 @@ namespace Opm {
|
||||
if (m_intGridProperties->supportsKeyword( field )) {
|
||||
if (enabledTypes & IntProperties) {
|
||||
int intValue = static_cast<int>(value);
|
||||
std::shared_ptr<GridProperty<int> > property = m_intGridProperties->getKeyword( field );
|
||||
std::shared_ptr<GridProperty<int> > property = getOrCreateIntProperty_( field );
|
||||
|
||||
property->setScalar( intValue , boxManager.getActiveBox() );
|
||||
}
|
||||
} else if (m_doubleGridProperties->supportsKeyword( field )) {
|
||||
|
||||
if (enabledTypes & DoubleProperties) {
|
||||
std::shared_ptr<GridProperty<double> > property = m_doubleGridProperties->getKeyword( field );
|
||||
std::shared_ptr<GridProperty<double> > property = getOrCreateDoubleProperty_( field );
|
||||
|
||||
double siValue = value * getSIScaling(property->getKeywordInfo().getDimensionString());
|
||||
property->setScalar( siValue , boxManager.getActiveBox() );
|
||||
@@ -1289,7 +1283,7 @@ 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 );
|
||||
std::shared_ptr<GridProperty<int> > target = getOrCreateIntProperty_( targetField );
|
||||
|
||||
target->copyFrom( *src , inputBox );
|
||||
}
|
||||
@@ -1297,7 +1291,7 @@ namespace Opm {
|
||||
|
||||
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 );
|
||||
std::shared_ptr<GridProperty<double> > target = getOrCreateDoubleProperty_( targetField );
|
||||
|
||||
target->copyFrom( *src , inputBox );
|
||||
}
|
||||
@@ -1397,4 +1391,21 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<int> > EclipseState::getOrCreateIntProperty_(const std::string name)
|
||||
{
|
||||
if (!m_intGridProperties->hasKeyword(name)) {
|
||||
m_intGridProperties->addKeyword(name);
|
||||
}
|
||||
return m_intGridProperties->getKeyword(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<double> > EclipseState::getOrCreateDoubleProperty_(const std::string name)
|
||||
{
|
||||
if (!m_doubleGridProperties->hasKeyword(name)) {
|
||||
m_doubleGridProperties->addKeyword(name);
|
||||
}
|
||||
return m_doubleGridProperties->getKeyword(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef OPM_ECLIPSE_STATE_HPP
|
||||
#define OPM_ECLIPSE_STATE_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
@@ -73,10 +74,10 @@ namespace Opm {
|
||||
std::string getTitle() const;
|
||||
bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const;
|
||||
|
||||
std::shared_ptr<GridProperty<int> > getRegion( const DeckItem& regionItem ) const;
|
||||
std::shared_ptr<GridProperty<int> > getDefaultRegion() const;
|
||||
std::shared_ptr<GridProperty<int> > getIntGridProperty( const std::string& keyword ) const;
|
||||
std::shared_ptr<GridProperty<double> > getDoubleGridProperty( const std::string& keyword ) const;
|
||||
std::shared_ptr<const GridProperty<int> > getRegion( const DeckItem& regionItem ) const;
|
||||
std::shared_ptr<const GridProperty<int> > getDefaultRegion() const;
|
||||
std::shared_ptr<const GridProperty<int> > getIntGridProperty( const std::string& keyword ) const;
|
||||
std::shared_ptr<const GridProperty<double> > getDoubleGridProperty( const std::string& keyword ) const;
|
||||
bool hasIntGridProperty(const std::string& keyword) const;
|
||||
bool hasDoubleGridProperty(const std::string& keyword) const;
|
||||
|
||||
@@ -142,6 +143,9 @@ namespace Opm {
|
||||
|
||||
void complainAboutAmbiguousKeyword(std::shared_ptr< const Deck > deck, const std::string& keywordName) const;
|
||||
|
||||
std::shared_ptr<GridProperty<int> > getOrCreateIntProperty_(const std::string name);
|
||||
std::shared_ptr<GridProperty<double> > getOrCreateDoubleProperty_(const std::string name);
|
||||
|
||||
std::shared_ptr< const EclipseGrid > m_eclipseGrid;
|
||||
std::shared_ptr< IOConfig > m_ioConfig;
|
||||
std::shared_ptr< const InitConfig > m_initConfig;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef ECLIPSE_GRIDPROPERTIES_HPP_
|
||||
#define ECLIPSE_GRIDPROPERTIES_HPP_
|
||||
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
@@ -65,22 +65,21 @@ public:
|
||||
}
|
||||
|
||||
bool hasKeyword(const std::string& keyword) const {
|
||||
return m_properties.count( keyword ) > 0;
|
||||
return m_properties.count( keyword ) > 0 && !isAutoGenerated_(keyword);
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return m_property_list.size();
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<GridProperty<T> > getKeyword(const std::string& keyword) {
|
||||
std::shared_ptr<GridProperty<T> > getKeyword(const std::string& keyword) const {
|
||||
if (!hasKeyword(keyword))
|
||||
addKeyword(keyword);
|
||||
addAutoGeneratedKeyword_(keyword);
|
||||
|
||||
return m_properties.at( keyword );
|
||||
}
|
||||
|
||||
std::shared_ptr<GridProperty<T> > getKeyword(size_t index) {
|
||||
std::shared_ptr<GridProperty<T> > getKeyword(size_t index) const {
|
||||
if (index < size())
|
||||
return m_property_list[index];
|
||||
else
|
||||
@@ -107,6 +106,13 @@ public:
|
||||
if (hasKeyword(keywordName))
|
||||
return false;
|
||||
else {
|
||||
// if the property was already added auto generated, we just need to make it
|
||||
// non-auto generated
|
||||
if (m_autoGeneratedProperties_.count(keywordName)) {
|
||||
m_autoGeneratedProperties_.erase(m_autoGeneratedProperties_.find(keywordName));
|
||||
return true;
|
||||
}
|
||||
|
||||
auto supportedKeyword = m_supportedKeywords.at( keywordName );
|
||||
int nx = m_eclipseGrid->getNX();
|
||||
int ny = m_eclipseGrid->getNY();
|
||||
@@ -126,7 +132,7 @@ public:
|
||||
}
|
||||
|
||||
template <class Keyword>
|
||||
std::shared_ptr<GridProperty<T> > getKeyword() {
|
||||
std::shared_ptr<GridProperty<T> > getKeyword() const {
|
||||
return getKeyword( Keyword::keywordName );
|
||||
}
|
||||
|
||||
@@ -138,10 +144,36 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
bool addAutoGeneratedKeyword_(const std::string& keywordName) const {
|
||||
if (!supportsKeyword( keywordName ))
|
||||
throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container");
|
||||
|
||||
if (m_properties.count( keywordName ) > 0)
|
||||
return false; // property already exists (if it is auto generated or not doesn't matter)
|
||||
else {
|
||||
auto supportedKeyword = m_supportedKeywords.at( keywordName );
|
||||
int nx = m_eclipseGrid->getNX();
|
||||
int ny = m_eclipseGrid->getNY();
|
||||
int nz = m_eclipseGrid->getNZ();
|
||||
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(nx , ny , nz , supportedKeyword));
|
||||
|
||||
m_autoGeneratedProperties_.insert(keywordName);
|
||||
|
||||
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( keywordName , newProperty ));
|
||||
m_property_list.push_back( newProperty );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isAutoGenerated_(const std::string& keyword) const {
|
||||
return m_autoGeneratedProperties_.count(keyword);
|
||||
}
|
||||
|
||||
std::shared_ptr<const EclipseGrid> m_eclipseGrid;
|
||||
std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
|
||||
std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties;
|
||||
std::vector<std::shared_ptr<GridProperty<T> > > m_property_list;
|
||||
mutable std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties;
|
||||
mutable std::set<std::string> m_autoGeneratedProperties_;
|
||||
mutable std::vector<std::shared_ptr<GridProperty<T> > > m_property_list;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
|
||||
|
||||
|
||||
void initMask(T value, std::vector<bool>& mask) {
|
||||
void initMask(T value, std::vector<bool>& mask) const {
|
||||
mask.resize(getCartesianSize());
|
||||
for (size_t g = 0; g < getCartesianSize(); g++) {
|
||||
if (m_data[g] == value)
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace Opm {
|
||||
double MULTREGTScanner::getRegionMultiplier(size_t globalIndex1 , size_t globalIndex2, FaceDir::DirEnum faceDir) const {
|
||||
|
||||
for (auto iter = m_searchMap.begin(); iter != m_searchMap.end(); iter++) {
|
||||
std::shared_ptr<Opm::GridProperty<int> > region = m_cellRegionNumbers->getKeyword( (*iter).first );
|
||||
std::shared_ptr<const Opm::GridProperty<int> > region = m_cellRegionNumbers->getKeyword( (*iter).first );
|
||||
MULTREGTSearchMap map = (*iter).second;
|
||||
|
||||
int regionId1 = region->iget(globalIndex1);
|
||||
|
||||
@@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
|
||||
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
Opm::DeckPtr deck = createValidIntDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode());
|
||||
std::shared_ptr<Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
for (size_t j=0; j< 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
if (i < 2)
|
||||
@@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) {
|
||||
Opm::DeckPtr deck = createValidPERMXDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode());
|
||||
std::shared_ptr<Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
|
||||
std::shared_ptr<const Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
|
||||
|
||||
for (size_t j=0; j< 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
|
||||
@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(TypeMismatchThrows) {
|
||||
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
Opm::DeckPtr deck = createValidIntDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode() );
|
||||
std::shared_ptr<Opm::GridProperty<int> > property = state.getIntGridProperty( "FLUXNUM");
|
||||
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "FLUXNUM");
|
||||
for (size_t j=0; j< 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
if (i < 2)
|
||||
|
||||
@@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
|
||||
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
Opm::DeckPtr deck = createValidIntDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode());
|
||||
std::shared_ptr<Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
for (size_t j=0; j< 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
if (i < 2)
|
||||
@@ -233,9 +233,9 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) {
|
||||
Opm::DeckPtr deck = createValidPERMXDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode());
|
||||
std::shared_ptr<Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
|
||||
std::shared_ptr<Opm::GridProperty<double> > permy = state.getDoubleGridProperty( "PERMY");
|
||||
std::shared_ptr<Opm::GridProperty<double> > permz = state.getDoubleGridProperty( "PERMZ");
|
||||
std::shared_ptr<const Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
|
||||
std::shared_ptr<const Opm::GridProperty<double> > permy = state.getDoubleGridProperty( "PERMY");
|
||||
std::shared_ptr<const Opm::GridProperty<double> > permz = state.getDoubleGridProperty( "PERMZ");
|
||||
for (size_t g=0; g< 25; g++) {
|
||||
BOOST_CHECK_EQUAL( permz->iget(g), permx->iget(g));
|
||||
BOOST_CHECK_EQUAL( permy->iget(g), permx->iget(g));
|
||||
|
||||
@@ -76,6 +76,20 @@ BOOST_AUTO_TEST_CASE(addKeyword) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(hasKeyword) {
|
||||
typedef Opm::GridProperties<int>::SupportedKeywordInfo SupportedKeywordInfo;
|
||||
std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{
|
||||
SupportedKeywordInfo("SATNUM" , 0, "1")
|
||||
});
|
||||
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
|
||||
Opm::GridProperties<int> gridProperties( grid , supportedKeywords);
|
||||
|
||||
// calling getKeyword() should not change the semantics of hasKeyword()!
|
||||
BOOST_CHECK(!gridProperties.hasKeyword("SATNUM"));
|
||||
gridProperties.getKeyword("SATNUM");
|
||||
BOOST_CHECK(!gridProperties.hasKeyword("SATNUM"));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(getKeyword) {
|
||||
typedef Opm::GridProperties<int>::SupportedKeywordInfo SupportedKeywordInfo;
|
||||
|
||||
@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
|
||||
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
|
||||
Opm::DeckPtr deck = createValidIntDeck();
|
||||
Opm::EclipseState state(deck , Opm::ParseMode());
|
||||
std::shared_ptr<Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
|
||||
for (size_t j=0; j< 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
if (i < 2)
|
||||
|
||||
@@ -100,8 +100,8 @@ BOOST_AUTO_TEST_CASE(GetPOROTOPBased) {
|
||||
DeckPtr deck = createDeckTOP();
|
||||
EclipseState state(deck , ParseMode());
|
||||
|
||||
std::shared_ptr<GridProperty<double> > poro = state.getDoubleGridProperty( "PORO" );
|
||||
std::shared_ptr<GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX" );
|
||||
std::shared_ptr<const GridProperty<double> > poro = state.getDoubleGridProperty( "PORO" );
|
||||
std::shared_ptr<const GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX" );
|
||||
|
||||
BOOST_CHECK_EQUAL(1000U , poro->getCartesianSize() );
|
||||
BOOST_CHECK_EQUAL(1000U , permx->getCartesianSize() );
|
||||
@@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(GetProperty) {
|
||||
DeckPtr deck = createDeck();
|
||||
EclipseState state(deck, ParseMode());
|
||||
|
||||
std::shared_ptr<GridProperty<int> > satNUM = state.getIntGridProperty( "SATNUM" );
|
||||
std::shared_ptr<const GridProperty<int> > satNUM = state.getIntGridProperty( "SATNUM" );
|
||||
|
||||
BOOST_CHECK_EQUAL(1000U , satNUM->getCartesianSize() );
|
||||
for (size_t i=0; i < satNUM->getCartesianSize(); i++)
|
||||
|
||||
@@ -51,9 +51,9 @@ EclipseState makeState(const std::string& fileName) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PERMX ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1" );
|
||||
std::shared_ptr<GridProperty<double> > permx = state.getDoubleGridProperty("PERMX");
|
||||
std::shared_ptr<GridProperty<double> > permy = state.getDoubleGridProperty("PERMY");
|
||||
std::shared_ptr<GridProperty<double> > permz = state.getDoubleGridProperty("PERMZ");
|
||||
std::shared_ptr<const GridProperty<double> > permx = state.getDoubleGridProperty("PERMX");
|
||||
std::shared_ptr<const GridProperty<double> > permy = state.getDoubleGridProperty("PERMY");
|
||||
std::shared_ptr<const GridProperty<double> > permz = state.getDoubleGridProperty("PERMZ");
|
||||
size_t i,j,k;
|
||||
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
|
||||
|
||||
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE( PERMX ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
|
||||
std::shared_ptr<GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
|
||||
std::shared_ptr<const GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
|
||||
{
|
||||
size_t i,j,k;
|
||||
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
|
||||
@@ -97,8 +97,8 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
|
||||
std::shared_ptr<GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
|
||||
std::shared_ptr<GridProperty<int> > fipnum = state.getIntGridProperty("FIPNUM");
|
||||
std::shared_ptr<const GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
|
||||
std::shared_ptr<const GridProperty<int> > fipnum = state.getIntGridProperty("FIPNUM");
|
||||
size_t i,j,k;
|
||||
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
|
||||
|
||||
@@ -128,9 +128,9 @@ BOOST_AUTO_TEST_CASE( KEYWORD_BOX_TOO_SMALL) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( EQUAL ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
|
||||
std::shared_ptr<GridProperty<int> > pvtnum = state.getIntGridProperty("PVTNUM");
|
||||
std::shared_ptr<GridProperty<int> > eqlnum = state.getIntGridProperty("EQLNUM");
|
||||
std::shared_ptr<GridProperty<double> > poro = state.getDoubleGridProperty("PORO");
|
||||
std::shared_ptr<const GridProperty<int> > pvtnum = state.getIntGridProperty("PVTNUM");
|
||||
std::shared_ptr<const GridProperty<int> > eqlnum = state.getIntGridProperty("EQLNUM");
|
||||
std::shared_ptr<const GridProperty<double> > poro = state.getDoubleGridProperty("PORO");
|
||||
size_t i,j,k;
|
||||
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user