Move getRegions into 3DProperties

This commit is contained in:
Jørgen Kvalsvik
2016-04-29 13:11:53 +02:00
parent 091dc196f3
commit 28ae15cf0f
6 changed files with 40 additions and 41 deletions

View File

@@ -449,6 +449,17 @@ namespace Opm {
}
}
std::vector< int > Eclipse3DProperties::getRegions( const std::string& kw ) const {
if( !this->hasDeckIntGridProperty( kw ) ) return {};
const auto& property = this->getIntGridProperty( kw );
std::set< int > regions( property.getData().begin(),
property.getData().end() );
return { regions.begin(), regions.end() };
}
/// 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

View File

@@ -61,6 +61,7 @@ namespace Opm {
const GridProperty<int>& getRegion(const DeckItem& regionItem) const;
std::vector< int > getRegions( const std::string& keyword ) const;
std::string getDefaultRegionKeyword() const;
const GridProperty<int>& getIntGridProperty ( const std::string& keyword ) const;

View File

@@ -261,17 +261,6 @@ namespace Opm {
}
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!");

View File

@@ -95,8 +95,6 @@ namespace Opm {
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...

View File

@@ -235,3 +235,31 @@ BOOST_AUTO_TEST_CASE(PermxUnitAppliedCorrectly) {
BOOST_CHECK_CLOSE(4 * Opm::Metric::Permeability, permx.iget(i, j, 0), 0.0001);
}
}
BOOST_AUTO_TEST_CASE(getRegions) {
const char* input =
"START -- 0 \n"
"10 MAI 2007 / \n"
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 2 2 1 /\n"
"GRID\n"
"DXV \n 2*400 /\n"
"DYV \n 2*400 /\n"
"DZV \n 1*400 /\n"
"REGIONS\n"
"FIPNUM\n"
"1 1 2 3 /\n";
auto deck = Opm::Parser().parseString(input, Opm::ParseContext());
Setup s( deck );
std::vector< int > ref = { 1, 2, 3 };
const auto regions = s.props.getRegions( "FIPNUM" );
BOOST_CHECK_EQUAL_COLLECTIONS( ref.begin(), ref.end(),
regions.begin(), regions.end() );
BOOST_CHECK( s.props.getRegions( "EQLNUM" ).empty() );
}

View File

@@ -584,31 +584,3 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTSOL) {
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(0));
}
}
BOOST_AUTO_TEST_CASE(getRegions) {
const char* input =
"START -- 0 \n"
"10 MAI 2007 / \n"
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 2 2 1 /\n"
"GRID\n"
"DXV \n 2*400 /\n"
"DYV \n 2*400 /\n"
"DZV \n 1*400 /\n"
"REGIONS\n"
"FIPNUM\n"
"1 1 2 3 /\n";
const auto deck = Parser().parseString(input, ParseContext());
EclipseState es( deck, ParseContext() );
std::vector< int > ref = { 1, 2, 3 };
const auto regions = es.getRegions( "FIPNUM" );
BOOST_CHECK_EQUAL_COLLECTIONS( ref.begin(), ref.end(),
regions.begin(), regions.end() );
BOOST_CHECK( es.getRegions( "EQLNUM" ).empty() );
}