Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
402f28f
Adds Opm::EclIO::SummaryNode::Type::Mode.
wito Mar 20, 2020
3af0bbf
Removes extraneous names.
wito Mar 19, 2020
e5e0a49
Adds conversion operator SummaryConfigNode => SummaryNode.
wito Mar 19, 2020
e317b96
Removes extraneous type.
wito Mar 19, 2020
90a2eeb
Reworks to unified initialisation.
wito Mar 19, 2020
0265b7f
Renames variables for clarity.
wito Mar 19, 2020
861c098
Implements Opm::EclIO::SummaryNode::unique_key().
wito Mar 19, 2020
dbf17af
Minor formatting tweaks.
wito Mar 19, 2020
c3de96b
Makes fallthrough explicit.
wito Mar 19, 2020
d9e1d39
Fixes order of accumulation for key parts.
wito Mar 19, 2020
4bb453d
Adds a test for Opm::EclIO::SummaryNode::unique_key()
wito Mar 19, 2020
84c57ff
Review Action: Renames Opm::EclIO::SummaryNode::name => wgname
wito Mar 19, 2020
001877d
Simplifies namespace declaration.
wito Mar 19, 2020
b940d81
Rewrites ::need_wells() for Opm::EclIO::SummaryNode.
wito Mar 19, 2020
cb0f27c
Reworks ::updateValue for Opm::EclIO::SummaryNode.
wito Mar 19, 2020
b12397c
Minor formatting tweak.
wito Mar 19, 2020
e500fbb
Reworks ::find_wells for Opm::EclIO::SummaryNode.
wito Mar 19, 2020
855b23a
Minor formatting tweak.
wito Mar 19, 2020
bb114b6
Renames enum access name.
wito Mar 19, 2020
701175c
Makes fallthrough explicit.
wito Mar 19, 2020
6970158
Makes the return value of Opm::Group::flow_group/::control_group opti…
wito Mar 19, 2020
0174a16
Reworks EfficiencyFactor::setFactors for Opm::EclIO::SummaryNode.
wito Mar 19, 2020
fda69e9
Review action: Reverts a number of changes at the request of @bska.
wito Mar 20, 2020
318ca70
Uses the correct names for enum values.
wito Mar 20, 2020
a6a144a
Review action: Removes default: cases.
wito Mar 20, 2020
21e9c1b
Implements the change to SummaryNode in ::Evaluator.
wito Mar 20, 2020
35afdd5
Reworks ::requiredSegmentVectors() for Opm::EclIO::SummaryNode.
wito Mar 20, 2020
99375eb
Reworks requiredRestartVectors for Opm::EclIO::SummaryNode.
wito Mar 20, 2020
62983db
Removes use of default:
wito Mar 20, 2020
327fe79
Adds Opm::EclIO::SummaryNode::is_user_defined().
wito Mar 20, 2020
89fe3c3
Reworks Evaluator::Factory for Opm::EclIO::SummaryNode.
wito Mar 20, 2020
eba0f3d
Relocates new test in CMakeLists_files.cmake.
wito Mar 20, 2020
06eeae8
Reworks mode vectors for Opm::EclIO::SummaryNode.
wito Mar 20, 2020
f884c90
Refactors out duplicated code.
wito Mar 20, 2020
fb4f026
Uses correct name in reference to enum value.
wito Mar 20, 2020
ab71b43
Fixes minor formatting glitch in the SummaryNode copyright statement.
wito Mar 20, 2020
2c74b09
Removes various minor edits.
wito Mar 20, 2020
06d317d
Review Actions: Un-consts SummaryNode members and un-statics some dat…
wito Mar 26, 2020
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
10 changes: 10 additions & 0 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ list (APPEND MAIN_SOURCE_FILES
)
if(ENABLE_ECL_INPUT)
list(APPEND MAIN_SOURCE_FILES
src/opm/io/eclipse/SummaryNode.cpp
src/opm/json/JsonObject.cpp
src/opm/parser/eclipse/Deck/Deck.cpp
src/opm/parser/eclipse/Deck/DeckItem.cpp
Expand Down Expand Up @@ -239,6 +240,7 @@ if(ENABLE_ECL_OUTPUT)
src/opm/io/eclipse/ERst.cpp
src/opm/io/eclipse/ESmry.cpp
src/opm/io/eclipse/OutputStream.cpp
src/opm/io/eclipse/SummaryNode.cpp
src/opm/io/eclipse/rst/connection.cpp
src/opm/io/eclipse/rst/group.cpp
src/opm/io/eclipse/rst/header.cpp
Expand Down Expand Up @@ -500,6 +502,7 @@ list( APPEND PUBLIC_HEADER_FILES
)
if(ENABLE_ECL_INPUT)
list(APPEND PUBLIC_HEADER_FILES
opm/io/eclipse/SummaryNode.hpp
opm/json/JsonObject.hpp
opm/parser/eclipse/Utility/Stringview.hpp
opm/parser/eclipse/Utility/Functional.hpp
Expand Down Expand Up @@ -719,6 +722,7 @@ if(ENABLE_ECL_OUTPUT)
opm/io/eclipse/ESmry.hpp
opm/io/eclipse/PaddedOutputString.hpp
opm/io/eclipse/OutputStream.hpp
opm/io/eclipse/SummaryNode.hpp
opm/io/eclipse/rst/connection.hpp
opm/io/eclipse/rst/group.hpp
opm/io/eclipse/rst/header.hpp
Expand Down Expand Up @@ -763,3 +767,9 @@ if(ENABLE_ECL_OUTPUT)
opm/output/OutputWriter.hpp
)
endif()

if(ENABLE_ECL_INPUT OR ENABLE_ECL_OUTPUT)
list(APPEND TEST_SOURCE_FILES
tests/test_SummaryNode.cpp
)
endif()
58 changes: 58 additions & 0 deletions opm/io/eclipse/SummaryNode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2020 Equinor ASA.

This file is part of the Open Porous Media project (OPM).

OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string>

namespace Opm::EclIO {

struct SummaryNode {
enum class Category {
Well,
Group,
Field,
Region,
Block,
Connection,
Segment,
Miscellaneous,
};

enum class Type {
Rate,
Total,
Ratio,
Pressure,
Count,
Mode,
Undefined,
};

const std::string keyword;
const Category category;
const Type type;
const std::string wgname;
const int number;

constexpr static int default_number { std::numeric_limits<int>::min() };

std::string unique_key() const;
bool is_user_defined() const;
};

} // namespace Opm::EclIO
7 changes: 4 additions & 3 deletions opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#define GROUP2_HPP


#include <string>
#include <map>
#include <optional>
#include <string>

#include <opm/parser/eclipse/Deck/UDAValue.hpp>
#include <opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp>
Expand Down Expand Up @@ -221,8 +222,8 @@ struct ProductionControls {

// [[deprecated("use Group::control_group() or Group::flow_group()")]]
const std::string& parent() const;
const std::string& control_group() const;
const std::string& flow_group() const;
std::optional<std::string> control_group() const;
std::optional<std::string> flow_group() const;

bool updateParent(const std::string& parent);
bool updateInjection(const GroupInjectionProperties& injection);
Expand Down
18 changes: 7 additions & 11 deletions opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <string>
#include <vector>

#include <opm/io/eclipse/SummaryNode.hpp>
#include <opm/common/OpmLog/Location.hpp>

namespace Opm {
Expand All @@ -38,17 +39,8 @@ namespace Opm {

class SummaryConfigNode {
public:
enum class Category {
Well, Group, Field,
Region, Block,
Connection, Segment,
Miscellaneous,
};

enum class Type {
Rate, Total, Ratio, Pressure, Count, Mode,
Undefined,
};
using Category = Opm::EclIO::SummaryNode::Category;
using Type = Opm::EclIO::SummaryNode::Type;

SummaryConfigNode() = default;
explicit SummaryConfigNode(std::string keyword, const Category cat, Location loc_arg);
Expand All @@ -68,6 +60,10 @@ namespace Opm {
std::string uniqueNodeKey() const;
const Location& location( ) const { return this->loc; }

operator Opm::EclIO::SummaryNode() const {
return { keyword_, category_, type_, name_, number_ };
}

template<class Serializer>
void serializeOp(Serializer& serializer)
{
Expand Down
113 changes: 113 additions & 0 deletions src/opm/io/eclipse/SummaryNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
Copyright 2020 Equinor ASA.

This file is part of the Open Porous Media project (OPM).

OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <numeric>
#include <regex>
#include <string>
#include <unordered_set>
#include <vector>

#include <opm/io/eclipse/SummaryNode.hpp>

namespace {

constexpr bool use_number(Opm::EclIO::SummaryNode::Category category) {
switch (category) {
case Opm::EclIO::SummaryNode::Category::Block: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Connection: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Region: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Segment:
return true;
case Opm::EclIO::SummaryNode::Category::Field: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Group: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Miscellaneous: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Well:
return false;
}
}

constexpr bool use_name(Opm::EclIO::SummaryNode::Category category) {
switch (category) {
case Opm::EclIO::SummaryNode::Category::Connection: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Group: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Segment: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Well:
return true;
case Opm::EclIO::SummaryNode::Category::Block: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Field: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Miscellaneous: [[fallthrough]];
case Opm::EclIO::SummaryNode::Category::Region:
return false;
}
}

};

std::string Opm::EclIO::SummaryNode::unique_key() const {
std::vector<std::string> key_parts { keyword } ;

if (use_name(category))
key_parts.emplace_back(wgname);

if (use_number(category))
key_parts.emplace_back(std::to_string(number));

auto compose_key = [](std::string& key, const std::string& key_part) -> std::string {
constexpr auto delimiter { ':' } ;
return key.empty() ? key_part : key + delimiter + key_part;
};

return std::accumulate(std::begin(key_parts), std::end(key_parts), std::string(), compose_key);
}

bool Opm::EclIO::SummaryNode::is_user_defined() const {
static const std::unordered_set<std::string> udq_blacklist {
"AUTOCOAR",
"AUTOREF",
"FULLIMP",
"GUIDECAL",
"GUIDERAT",
"GUPFREQ",
"RUNSPEC",
"RUNSUM",
"SUMMARY",
"SUMTHIN",
"SURF",
"SURFACT",
"SURFACTW",
"SURFADDW",
"SURFADS",
"SURFCAPD",
"SURFESAL",
"SURFNUM",
"SURFOPTS",
"SURFROCK",
"SURFST",
"SURFSTES",
"SURFVISC",
"SURFWNUM",
} ;

static const std::regex user_defined_regex { "[ABCFGRSW]U[A-Z]+" } ;

const bool matched { std::regex_match(keyword, user_defined_regex) } ;
const bool blacklisted { udq_blacklist.find(keyword) != udq_blacklist.end() } ;

return matched && !blacklisted;
Copy link
Member

Choose a reason for hiding this comment

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

Did you consider writing this as

return !blacklisted && std::regex_match(keyword, user_defined_regex);

? That way, you don't incur the cost of regular expression matching for blacklisted keywords.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, in this case, if that's worth it, given the domain of the function and the relative simplicity of the regular expression.

}
Loading