-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop Processing if COPYing From Undefined Source Array #4109
Conversation
Note: I am creating this PR in draft mode because it depends on, and contains, the earlier PR #4103. I will keep the PR in a draft state until it is ready for review and merging. |
ce5ee02
to
5d323c5
Compare
jenkins build this please |
3553c46
to
aebab88
Compare
4d7b24a
to
fced603
Compare
1699f86
to
67b9603
Compare
66ff822
to
bcf1e6a
Compare
jenkins build this please |
I have corrected the unexpected |
bcf1e6a
to
b18b142
Compare
jenkins build this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small suggestions that you may or may not take.
const T scalar_value, | ||
const std::vector<Box::cell_index>& index_list) | ||
{ | ||
if (op == Fieldprops::ScalarOperation::EQUAL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch?
const Fieldprops::FieldData<T>& field_data() const | ||
{ | ||
this->verify_status(); | ||
return *this->data_ptr; | ||
} | ||
|
||
/// Property validity predicate. | ||
/// | ||
/// Returns true if propery exists and has well defined data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: s/well/properly or the likes. the term 'well' is a bit reserved in the context. also 'property'
@@ -492,7 +492,7 @@ class FieldProps { | |||
|
|||
/// Property validity predicate. | |||
/// | |||
/// Returns true if propery exists and has well defined data | |||
/// Returns true if propery exists and has fully defined data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
properTy
f6398f0
to
b253f3f
Compare
Thanks a lot for looking at this. I've pushed an update to address your comments. I'm always a little on the fence when it comes to switching on enums because while the set of valid enumerators is fixed, and typically small, the possible enumeration values are of course all of the values allowed by the underlying arithmetic type. That said, I replaced the |
jenkins build this please |
b253f3f
to
d75d747
Compare
jenkins build this please |
1 similar comment
jenkins build this please |
This overload includes more context and enables generating more descriptive diagnostic messages.
This commit makes the backend implementations of ADD, MULTIPLY, &c capable of halting processing if we encounter any undefined source elements. We nevertheless maintain the definition of "defined" as value::has_value() (from the value_status.hpp header), at least for the time being, as changing the definition requires making more parts of the array processing aware of the currently active section. The new helper function reject_undefined_operation() will throw an OpmInputError exception with (hopefully) enough context that fixing the input will be easier. While here, make the apply() function private to the FieldProps.cpp implementation file. It was already marked 'static' and does not need access to any of the FieldProps data members.
This commit adds defined value checking to the source array from which we're copying in a COPY operation--either with the COPY or with the COPYREG keywords. We count the number of source array values which do not have the status of 'deck_value' and if this count is positive, then we throw an OpmInputError exception which halts further input processing. As an example of this behaviour, the (deliberately faulty) setup EQUALS -- SGL not defined prior to this point 'SGL' 0.0 2* 2* 1 5 / / COPY SGL SWL 2* 2* 4 7 / / will generate an "Error" of the form Error: Problem with keyword COPY In USER_ERR_COPY_BOX_PARTIALLY_UNDEF.DATA line 195 Copying from source array SGL in BOX (1-13, 1-22, 4-7) would generate an undefined result in 572 blocks of target array SWL. and stop input processing.
For operations other than assignment (EQUALS keyword), this commit ensures that the array being mutated already exists in the input. In particular, this means that a request of the form ADD SGU 0.123 / / will halt input processing and generate an "Error" of the form Error: Problem with keyword ADD In USER_ERR_ADD.DATA line 202 Target array SGU must already exist when operated upon in ADD. unless the 'SGU' array has already been assigned earlier. To this end, repurpose the second parameter to member function FieldProps::try_get<>() and make this a bitmask of flags instead of a single 'bool'. The currently supported flags are 'AllowUnsupported' and 'MustExist' with the former representing the original 'bool' parameter and the second requesting that the property array must already exist for the request to succeed.
In particular, 1. Replace if/else chain by switch 2. Replace 'well formed' with 'fully defined' in documentation
d75d747
to
eb23b95
Compare
jenkins build this please |
PR approved and build check is green. I'll merge into master. |
The existence checks introduced in commit 90be0956d0 (PR OPM#4109) turned out to be a little too restrictive. Recent experience suggests that we need to permit array operations like ADD or MULTIPLY on the MULT* arrays (MULT[XYZ] and MULT[XYZ]-) even if these arrays have not yet been explicitly defined in the input deck. This commit re-enables those array operations for property arrays whose 'multiplier' flag is 'true'.
The existence checks introduced in commit 90be095 (PR OPM#4109) turned out to be a little too restrictive. Recent experience suggests that we need to permit array operations like ADD or MULTIPLY on the MULT* arrays (MULT[XYZ] and MULT[XYZ]-) even if these arrays have not yet been explicitly defined in the input deck. This commit re-enables those array operations for property arrays whose 'multiplier' flag is 'true'.
This PR adds defined value checking to the source array from which we're copying in a
COPY
operation–either with theCOPY
or with theCOPYREG
keywords. We count the number of source array values which do not have the status ofdeck_value
and if this count is positive, then we throw anOpmInputError
exception which halts further input processing.As an example of this behaviour, the (deliberately faulty) setup
will generate an "Error" of the form
and stop input processing.
Similarly, For operations other than assignment (
EQUALS
keyword), this PR ensures that the array being mutated already exists in the input. In particular, this means that a request of the formwill halt input processing and generate an "Error" of the form
unless the
SGU
array has already been assigned earlier.To this end, repurpose the second parameter to member function
and make this a bitmask of flags instead of a single
bool
. The currently supported flags areAllowUnsupported
andMustExist
with the former representing the original 'bool' parameter and the second requesting that the property array must already exist for the request to succeed.