Skip to content

Commit

Permalink
Address PR Review Comments
Browse files Browse the repository at this point in the history
In particular,

  1. Replace if/else chain by switch
  2. Replace 'well formed' with 'fully defined' in documentation
  • Loading branch information
bska committed Aug 20, 2024
1 parent 90be095 commit eb23b95
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
24 changes: 15 additions & 9 deletions opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,25 +517,31 @@ void apply(const Fieldprops::ScalarOperation op,
const T scalar_value,
const std::vector<Box::cell_index>& index_list)
{
if (op == Fieldprops::ScalarOperation::EQUAL) {
switch (op) {
case Fieldprops::ScalarOperation::EQUAL:
assign_scalar(data, value_status, scalar_value, index_list);
}
return;

else if (op == Fieldprops::ScalarOperation::MUL) {
case Fieldprops::ScalarOperation::MUL:
multiply_scalar(loc, arrayName, data, value_status, scalar_value, index_list);
}
return;

else if (op == Fieldprops::ScalarOperation::ADD) {
case Fieldprops::ScalarOperation::ADD:
add_scalar(loc, arrayName, data, value_status, scalar_value, index_list);
}
return;

else if (op == Fieldprops::ScalarOperation::MIN) {
case Fieldprops::ScalarOperation::MIN:
min_value(loc, arrayName, data, value_status, scalar_value, index_list);
}
return;

else if (op == Fieldprops::ScalarOperation::MAX) {
case Fieldprops::ScalarOperation::MAX:
max_value(loc, arrayName, data, value_status, scalar_value, index_list);
return;
}

throw std::invalid_argument {
fmt::format("'{}' is not a known operation.", static_cast<int>(op))
};
}

std::string make_region_name(const std::string& deck_value)
Expand Down
12 changes: 6 additions & 6 deletions opm/input/eclipse/EclipseState/Grid/FieldProps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class FieldProps {

/// Property array existence status
enum class GetStatus {
/// Property exists and its property data is well formed.
/// Property exists and its property data is fully defined.
OK = 1,

/// Property array has not been fully initialised.
Expand Down Expand Up @@ -401,7 +401,7 @@ class FieldProps {
/// \code this->status \endcode is not \code GetStatus::OK \endcode.
/// Does nothing otherwise.
///
/// \param[in] Input keyword which prompted request
/// \param[in] Input keyword which prompted request.
///
/// \param[in] descr Textual description of context in which request
/// occurred.
Expand Down Expand Up @@ -462,7 +462,7 @@ class FieldProps {

/// Access underlying property data elements
///
/// Returns \c nullptr if property data is not well formed.
/// Returns \c nullptr if property data is not fully defined.
const std::vector<T>* ptr() const
{
return (this->data_ptr != nullptr)
Expand All @@ -473,7 +473,7 @@ class FieldProps {
/// Access underlying property data elements
///
/// Throws an exception as outlined in \c GetStatus if property data
/// is not well formed.
/// is not fully defined.
const std::vector<T>& data() const
{
this->verify_status();
Expand All @@ -483,7 +483,7 @@ class FieldProps {
/// Read-only access to contained FieldData object
///
/// Throws an exception as outlined in \c GetStatus if property data
/// is not well formed.
/// is not fully defined.
const Fieldprops::FieldData<T>& field_data() const
{
this->verify_status();
Expand All @@ -492,7 +492,7 @@ class FieldProps {

/// Property validity predicate.
///
/// Returns true if propery exists and has well defined data
/// Returns true if property exists and has fully defined data
/// elements. False otherwise.
bool valid() const
{
Expand Down

0 comments on commit eb23b95

Please sign in to comment.