diff --git a/src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp b/src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp index 595382dfa..c53674e60 100644 --- a/src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp +++ b/src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp @@ -490,6 +490,32 @@ FieldProps::FieldProps(const Deck& deck, const Phases& phases, const EclipseGrid } +// Special constructor ONLY used to get the correct ACTNUM. +// The grid argument should have all active cells. +FieldProps::FieldProps(const Deck& deck, const EclipseGrid& grid) : + active_size(grid.getNumActive()), + global_size(grid.getCartesianSize()), + unit_system(deck.getActiveUnitSystem()), + nx(grid.getNX()), + ny(grid.getNY()), + nz(grid.getNZ()), + m_phases(), + m_satfuncctrl(deck), + m_actnum(1, global_size), // NB! activates all at start! + cell_volume(), // NB! empty for this purpose. + cell_depth(), // NB! empty for this purpose. + m_default_region(default_region_keyword(deck)), + grid_ptr(&grid), + tables() // NB! empty for this purpose. +{ + if (this->active_size != this->global_size) { + throw std::logic_error("Programmer error: FieldProps special case processing for ACTNUM called with grid object that already had deactivated cells."); + } + if (DeckSection::hasGRID(deck)) + this->scanGRIDSectionOnlyACTNUM(GRIDSection(deck)); +} + + void FieldProps::reset_actnum(const std::vector& new_actnum) { if (this->global_size != new_actnum.size()) @@ -1168,6 +1194,21 @@ void FieldProps::scanGRIDSection(const GRIDSection& grid_section) { } } +void FieldProps::scanGRIDSectionOnlyACTNUM(const GRIDSection& grid_section) { + Box box(*this->grid_ptr); + + for (const auto& keyword : grid_section) { + const std::string& name = keyword.name(); + if (name == "ACTNUM") { + this->handle_int_keyword(Fieldprops::keywords::GRID::int_keywords.at(name), keyword, box); + } else if (name == "BOX" || name == "ENDBOX" || name == "EQUALS") { + this->handle_keyword(keyword, box); + } + } + const auto& processed_actnum_fielddata = this->int_data.at("ACTNUM"); + this->reset_actnum(processed_actnum_fielddata.data); +} + void FieldProps::scanEDITSection(const EDITSection& edit_section) { Box box(*this->grid_ptr); for (const auto& keyword : edit_section) { diff --git a/src/opm/input/eclipse/EclipseState/Grid/FieldProps.hpp b/src/opm/input/eclipse/EclipseState/Grid/FieldProps.hpp index 28a825b3e..36c8ce20a 100644 --- a/src/opm/input/eclipse/EclipseState/Grid/FieldProps.hpp +++ b/src/opm/input/eclipse/EclipseState/Grid/FieldProps.hpp @@ -377,8 +377,11 @@ public: - + /// Normal constructor for FieldProps. FieldProps(const Deck& deck, const Phases& phases, const EclipseGrid& grid, const TableManager& table_arg); + /// Special case constructor used to process ACTNUM only. + FieldProps(const Deck& deck, const EclipseGrid& grid); + void reset_actnum(const std::vector& actnum); void apply_numerical_aquifers(const NumericalAquifers& numerical_aquifers); @@ -504,6 +507,7 @@ public: static bool rst_cmp(const FieldProps& full_arg, const FieldProps& rst_arg); private: void scanGRIDSection(const GRIDSection& grid_section); + void scanGRIDSectionOnlyACTNUM(const GRIDSection& grid_section); void scanEDITSection(const EDITSection& edit_section); void scanPROPSSection(const PROPSSection& props_section); void scanREGIONSSection(const REGIONSSection& regions_section);