changed: store reference to FieldPropsManager as a pointer
default initialization required for serialization is not possible with a const ref member
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Opm {
|
||||
|
||||
public:
|
||||
MULTREGTScanner(const GridDims& grid,
|
||||
const FieldPropsManager& fp_arg,
|
||||
const FieldPropsManager* fp_arg,
|
||||
const std::vector< const DeckKeyword* >& keywords);
|
||||
double getRegionMultiplier(size_t globalCellIdx1, size_t globalCellIdx2, FaceDir::DirEnum faceDir) const;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Opm {
|
||||
void addKeyword( const DeckKeyword& deckKeyword, const std::string& defaultRegion);
|
||||
void assertKeywordSupported(const DeckKeyword& deckKeyword);
|
||||
std::size_t nx,ny,nz;
|
||||
const FieldPropsManager& fp;
|
||||
const FieldPropsManager* fp = nullptr;
|
||||
std::vector< MULTREGTRecord > m_records;
|
||||
std::map<std::string , MULTREGTSearchMap> m_searchMap;
|
||||
std::map<std::string, std::vector<int>> regions;
|
||||
|
||||
@@ -106,21 +106,21 @@ std::vector<int> unique(const std::vector<int> data) {
|
||||
interface with the wanted region values.
|
||||
*/
|
||||
MULTREGTScanner::MULTREGTScanner(const GridDims& grid,
|
||||
const FieldPropsManager& fp_arg,
|
||||
const FieldPropsManager* fp_arg,
|
||||
const std::vector< const DeckKeyword* >& keywords) :
|
||||
nx(grid.getNX()),
|
||||
ny(grid.getNY()),
|
||||
nz(grid.getNZ()),
|
||||
fp(fp_arg) {
|
||||
|
||||
this->default_region = this->fp.default_region();
|
||||
this->default_region = this->fp->default_region();
|
||||
for (size_t idx = 0; idx < keywords.size(); idx++)
|
||||
this->addKeyword(*keywords[idx] , this->default_region);
|
||||
|
||||
MULTREGTSearchMap searchPairs;
|
||||
for (std::vector<MULTREGTRecord>::const_iterator record = m_records.begin(); record != m_records.end(); ++record) {
|
||||
const std::string& region_name = record->region_name;
|
||||
if (this->fp.has<int>( region_name)) {
|
||||
if (this->fp->has<int>( region_name)) {
|
||||
int srcRegion = record->src_value;
|
||||
int targetRegion = record->target_value;
|
||||
|
||||
@@ -140,7 +140,7 @@ std::vector<int> unique(const std::vector<int> data) {
|
||||
+ " which is not in the deck");
|
||||
|
||||
if (this->regions.count(region_name) == 0)
|
||||
this->regions[region_name] = this->fp.get_global<int>(region_name);
|
||||
this->regions[region_name] = this->fp->get_global<int>(region_name);
|
||||
}
|
||||
|
||||
for (auto iter = searchPairs.begin(); iter != searchPairs.end(); ++iter) {
|
||||
@@ -195,12 +195,12 @@ std::vector<int> unique(const std::vector<int> data) {
|
||||
region_name = MULTREGT::RegionNameFromDeckValue( regionItem.get<std::string>(0) );
|
||||
|
||||
if (srcItem.defaultApplied(0) || srcItem.get<int>(0) < 0)
|
||||
src_regions = unique(this->fp.get<int>(region_name));
|
||||
src_regions = unique(this->fp->get<int>(region_name));
|
||||
else
|
||||
src_regions.push_back(srcItem.get<int>(0));
|
||||
|
||||
if (targetItem.defaultApplied(0) || targetItem.get<int>(0) < 0)
|
||||
target_regions = unique(fp.get<int>(region_name));
|
||||
target_regions = unique(fp->get<int>(region_name));
|
||||
else
|
||||
target_regions.push_back(targetItem.get<int>(0));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Opm {
|
||||
{ FaceDir::XMinus, "MULTX-" },
|
||||
{ FaceDir::YMinus, "MULTY-" },
|
||||
{ FaceDir::ZMinus, "MULTZ-" }}),
|
||||
m_multregtScanner( dims, fp, deck.getKeywordList( "MULTREGT" ))
|
||||
m_multregtScanner( dims, &fp, deck.getKeywordList( "MULTREGT" ))
|
||||
{
|
||||
EDITSection edit_section(deck);
|
||||
if (edit_section.hasKeyword("MULTREGT")) {
|
||||
|
||||
@@ -115,19 +115,19 @@ BOOST_AUTO_TEST_CASE(InvalidInput) {
|
||||
std::vector<const Opm::DeckKeyword*> keywords0;
|
||||
const auto& multregtKeyword0 = deck.getKeyword( "MULTREGT", 0 );
|
||||
keywords0.push_back( &multregtKeyword0 );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, fp, keywords0 ); , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, &fp, keywords0 ); , std::invalid_argument );
|
||||
|
||||
// Not supported region
|
||||
std::vector<const Opm::DeckKeyword*> keywords1;
|
||||
const auto& multregtKeyword1 = deck.getKeyword( "MULTREGT", 1 );
|
||||
keywords1.push_back( &multregtKeyword1 );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, fp, keywords1 ); , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, &fp, keywords1 ); , std::invalid_argument );
|
||||
|
||||
// The keyword is ok; but it refers to a region which is not in the deck.
|
||||
std::vector<const Opm::DeckKeyword*> keywords2;
|
||||
const auto& multregtKeyword2 = deck.getKeyword( "MULTREGT", 2 );
|
||||
keywords2.push_back( &multregtKeyword2 );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, fp, keywords2 ); , std::logic_error );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, &fp, keywords2 ); , std::logic_error );
|
||||
}
|
||||
|
||||
|
||||
@@ -182,13 +182,13 @@ BOOST_AUTO_TEST_CASE(NotSupported) {
|
||||
std::vector<const Opm::DeckKeyword*> keywords0;
|
||||
const auto& multregtKeyword0 = deck.getKeyword( "MULTREGT", 0 );
|
||||
keywords0.push_back( &multregtKeyword0 );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, fp, keywords0 ); , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, &fp, keywords0 ); , std::invalid_argument );
|
||||
|
||||
// srcValue == targetValue - not supported
|
||||
std::vector<const Opm::DeckKeyword*> keywords1;
|
||||
const Opm::DeckKeyword& multregtKeyword1 = deck.getKeyword( "MULTREGT", 1 );
|
||||
keywords1.push_back( &multregtKeyword1 );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, fp, keywords1 ); , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( grid, &fp, keywords1 ); , std::invalid_argument );
|
||||
}
|
||||
|
||||
static Opm::Deck createDefaultedRegions() {
|
||||
@@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(DefaultedRegions) {
|
||||
std::vector<const Opm::DeckKeyword*> keywords0;
|
||||
const auto& multregtKeyword0 = deck.getKeyword( "MULTREGT", 0 );
|
||||
keywords0.push_back( &multregtKeyword0 );
|
||||
Opm::MULTREGTScanner scanner0(grid, fp, keywords0);
|
||||
Opm::MULTREGTScanner scanner0(grid, &fp, keywords0);
|
||||
BOOST_CHECK_EQUAL( scanner0.getRegionMultiplier(grid.getGlobalIndex(0,0,1), grid.getGlobalIndex(1,0,1), Opm::FaceDir::XPlus ), 1.25);
|
||||
BOOST_CHECK_EQUAL( scanner0.getRegionMultiplier(grid.getGlobalIndex(1,0,0), grid.getGlobalIndex(2,0,0), Opm::FaceDir::XPlus ), 1.0);
|
||||
BOOST_CHECK_EQUAL( scanner0.getRegionMultiplier(grid.getGlobalIndex(2,0,1), grid.getGlobalIndex(2,0,0), Opm::FaceDir::ZMinus ), 0.0);
|
||||
@@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE(DefaultedRegions) {
|
||||
std::vector<const Opm::DeckKeyword*> keywords1;
|
||||
const Opm::DeckKeyword& multregtKeyword1 = deck.getKeyword( "MULTREGT", 1 );
|
||||
keywords1.push_back( &multregtKeyword1 );
|
||||
Opm::MULTREGTScanner scanner1(grid, fp, keywords1 );
|
||||
Opm::MULTREGTScanner scanner1(grid, &fp, keywords1 );
|
||||
BOOST_CHECK_EQUAL( scanner1.getRegionMultiplier(grid.getGlobalIndex(2,0,0), grid.getGlobalIndex(1,0,0), Opm::FaceDir::XMinus ), 0.75);
|
||||
BOOST_CHECK_EQUAL( scanner1.getRegionMultiplier(grid.getGlobalIndex(2,0,0), grid.getGlobalIndex(2,0,1), Opm::FaceDir::ZPlus), 0.75);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user