Move getRegions into 3DProperties
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!");
|
||||
|
||||
@@ -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...
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user