Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,8 @@ void FieldProps::handle_OPERATE(const DeckKeyword& keyword, Box box)

void FieldProps::handle_operation(const Section section,
const DeckKeyword& keyword,
Box box)
Box box,
const bool onlyACTNUM)
{
// Keyword handler for ADD, EQUALS, MAXVALUE, MINVALUE, and MULTIPLY.
//
Expand Down Expand Up @@ -1655,6 +1656,10 @@ void FieldProps::handle_operation(const Section section,
const auto target_kw = Fieldprops::keywords::
get_keyword_from_alias(record.getItem(0).getTrimmedString(0));

if (onlyACTNUM && target_kw != "ACTNUM") {
continue;
}
Comment on lines +1659 to +1661
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to make this optimisation, then the continue statement should at least be after box.update(). We absolutely need to account for those updates because they give the default box bounds for the next record.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily agree. My interpretation is that within Equals the box information only is used per target keyword. I can very well be wrong here.

You do have a point though: For the first occurrence of the target keyword the default box is the one specified by the last BOX/ENDBOX declaration. Which means that master also neglects this...

Summoning @gdfldm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interpretation is that within Equals the box information only is used per target keyword

If we have something like

EQUALS
  'PERMX' 100  3 9  3 9  3 9 /
  'PERMY' 100 /
  'PERMZ'  10  2*   5 7  4 /
/

then the PERMX box is {3..9, 3..9, 3..9}, the PERMY box is also {3..9, 3..9, 3..9} while the PERMZ box is {3..9, 5..7, 4..9}. That's why it's essential that we capture those box settings.

For the first occurrence of the target keyword the default box is the one specified by the last BOX/ENDBOX declaration.

For the most part, yes. However, the input box is reset to the default global dimensions of {1..NX, 1..NY, 1..NZ} at the end of each section (i.e., GRID/EDIT/PROPS &c).

Which means that master also neglects this...

I believe the current master souces do the right thing. Handle_keyword() takes a reference to the current input box and updates it when encountering a BOX (or ENDBOX) keyword. That box is then copied into handle_operation() and updated according to whatever box specification is provided in the operation keyword records. On the other hand, those updates do not propagate back out of the operation keyword.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, all of the box definitions need to be parsed to keep track of the current default box.


box.update(record);

if (auto tran_iter = this->tran.find(target_kw);
Expand Down Expand Up @@ -1829,12 +1834,13 @@ void FieldProps::handle_COPY(const DeckKeyword& keyword,

void FieldProps::handle_keyword(const Section section,
const DeckKeyword& keyword,
Box& box)
Box& box,
const bool onlyACTNUM)
{
const auto& name = keyword.name();

if (Fieldprops::keywords::oper_keywords.count(name) == 1) {
this->handle_operation(section, keyword, box);
this->handle_operation(section, keyword, box, onlyACTNUM);
}

else if (name == ParserKeywords::OPERATE::keywordName) {
Expand Down Expand Up @@ -2070,7 +2076,7 @@ void FieldProps::scanGRIDSectionOnlyACTNUM(const GRIDSection& grid_section)
this->handle_int_keyword(Fieldprops::keywords::GRID::int_keywords.at(name), keyword, box);
}
else if ((name == "EQUALS") || (Fieldprops::keywords::box_keywords.count(name) == 1)) {
this->handle_keyword(Section::GRID, keyword, box);
this->handle_keyword(Section::GRID, keyword, box, true);
}
}

Expand Down
6 changes: 4 additions & 2 deletions opm/input/eclipse/EclipseState/Grid/FieldProps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ class FieldProps {
region_index(const std::string& region_name, int region_value);

void handle_OPERATE(const DeckKeyword& keyword, Box box);
void handle_operation(Section section, const DeckKeyword& keyword, Box box);
void handle_operation(Section section, const DeckKeyword& keyword, Box box,
const bool onlyACTNUM = false);
void handle_operateR(const DeckKeyword& keyword);
void handle_region_operation(const DeckKeyword& keyword);
void handle_COPY(const DeckKeyword& keyword, Box box, bool region);
Expand All @@ -779,7 +780,8 @@ class FieldProps {
double get_beta(const std::string& func_name, const std::string& target_array, double raw_beta);
double get_alpha(const std::string& func_name, const std::string& target_array, double raw_alpha);

void handle_keyword(Section section, const DeckKeyword& keyword, Box& box);
void handle_keyword(Section section, const DeckKeyword& keyword, Box& box,
const bool onlyACTNUM = false);
void handle_double_keyword(Section section,
const Fieldprops::keywords::keyword_info<double>& kw_info,
const DeckKeyword& keyword,
Expand Down