This commit reimplements the SummaryNode class in order not to use the ecl::smspec_node class from LibECL. Consequently, we remove class SummaryConfig's binding to LibECL. Class SummaryNode maintains the same information as before. We also implement a "named constructor" strategy to assign data members that only make sense for a subset of the node categories. The previous member function 'type' is renamed to 'category' to identify the attachment category (e.g., Well, Group, Field, Block, Region). In turn, we introduce a new 'type' member function to identify the parameter kind (e.g, pressure, rate, cumulative total, well count) represented by a given node. We furthermore capture whether or not the node is a user defined quantity (i.e., a UDQ). We reimplement the keyword classifier operations that are currently needed as free functions named 'is_*()' in SummaryConfig.cpp. Note that in addition to the renamed member functions of class SummaryNode, this commit also switches the summary key strategy for block parameters. Rather than capturing the 'ijk' values individually as "BOSAT:3,3,6", we now store the equivalent global (Cartesian) index (i.e., as "BOSAT:523"). Code that directly constructs block parameter keys must be updated accordingly. Chase the API change in the 'Summary' constructor and update unit tests as needed.
179 lines
5.6 KiB
C++
179 lines
5.6 KiB
C++
/*
|
|
Copyright 2015 Statoil 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/>.
|
|
*/
|
|
|
|
#ifndef OPM_SUMMARY_CONFIG_HPP
|
|
#define OPM_SUMMARY_CONFIG_HPP
|
|
|
|
#include <array>
|
|
#include <limits>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Opm {
|
|
|
|
/*
|
|
Very small utility class to get value semantics on the smspec_node
|
|
pointers. This should die as soon as the smspec_node class proper gets
|
|
value semantics.
|
|
*/
|
|
|
|
class SummaryNode {
|
|
public:
|
|
enum class Category {
|
|
Well, Group, Field,
|
|
Region, Block,
|
|
Connection, Segment,
|
|
Miscellaneous,
|
|
};
|
|
|
|
enum class Type {
|
|
Rate, Total, Ratio, Pressure, Count,
|
|
Undefined,
|
|
};
|
|
|
|
explicit SummaryNode(std::string keyword, const Category cat);
|
|
|
|
SummaryNode& parameterType(const Type type);
|
|
SummaryNode& namedEntity(std::string name);
|
|
SummaryNode& number(const int num);
|
|
SummaryNode& isUserDefined(const bool userDefined);
|
|
|
|
const std::string& keyword() const { return this->keyword_; }
|
|
Category category() const { return this->category_; }
|
|
Type type() const { return this->type_; }
|
|
const std::string& namedEntity() const { return this->name_; }
|
|
int number() const { return this->number_; }
|
|
bool isUserDefined() const { return this->userDefined_; }
|
|
|
|
std::string uniqueNodeKey() const;
|
|
|
|
private:
|
|
std::string keyword_;
|
|
Category category_;
|
|
Type type_{ Type::Undefined };
|
|
std::string name_{};
|
|
int number_{std::numeric_limits<int>::min()};
|
|
bool userDefined_{false};
|
|
};
|
|
|
|
bool operator==(const SummaryNode& lhs, const SummaryNode& rhs);
|
|
bool operator<(const SummaryNode& lhs, const SummaryNode& rhs);
|
|
|
|
inline bool operator!=(const SummaryNode& lhs, const SummaryNode& rhs)
|
|
{
|
|
return ! (lhs == rhs);
|
|
}
|
|
|
|
inline bool operator<=(const SummaryNode& lhs, const SummaryNode& rhs)
|
|
{
|
|
return ! (rhs < lhs);
|
|
}
|
|
|
|
inline bool operator>(const SummaryNode& lhs, const SummaryNode& rhs)
|
|
{
|
|
return rhs < lhs;
|
|
}
|
|
|
|
inline bool operator>=(const SummaryNode& lhs, const SummaryNode& rhs)
|
|
{
|
|
return ! (lhs < rhs);
|
|
}
|
|
|
|
class Deck;
|
|
class TableManager;
|
|
class EclipseState;
|
|
class ParserKeyword;
|
|
class Schedule;
|
|
class ErrorGuard;
|
|
class ParseContext;
|
|
class GridDims;
|
|
|
|
class SummaryConfig {
|
|
public:
|
|
typedef SummaryNode keyword_type;
|
|
typedef std::vector< keyword_type > keyword_list;
|
|
typedef keyword_list::const_iterator const_iterator;
|
|
|
|
SummaryConfig( const Deck&,
|
|
const Schedule&,
|
|
const TableManager&,
|
|
const ParseContext&,
|
|
ErrorGuard&);
|
|
|
|
template <typename T>
|
|
SummaryConfig( const Deck&,
|
|
const Schedule&,
|
|
const TableManager&,
|
|
const ParseContext&,
|
|
T&&);
|
|
|
|
SummaryConfig( const Deck&,
|
|
const Schedule&,
|
|
const TableManager&);
|
|
|
|
|
|
|
|
const_iterator begin() const;
|
|
const_iterator end() const;
|
|
size_t size() const;
|
|
SummaryConfig& merge( const SummaryConfig& );
|
|
SummaryConfig& merge( SummaryConfig&& );
|
|
|
|
/*
|
|
The hasKeyword() method will consult the internal set
|
|
'short_keywords', i.e. the query should be based on pure
|
|
keywords like 'WWCT' and 'BPR' - and *not* fully
|
|
identifiers like 'WWCT:OPX' and 'BPR:10,12,3'.
|
|
*/
|
|
bool hasKeyword( const std::string& keyword ) const;
|
|
|
|
/*
|
|
The hasSummaryKey() method will look for fully
|
|
qualified keys like 'RPR:3' and 'BPR:10,15,20.
|
|
*/
|
|
bool hasSummaryKey(const std::string& keyword ) const;
|
|
/*
|
|
Can be used to query if a certain 3D field, e.g. PRESSURE,
|
|
is required to calculate the summary variables.
|
|
*/
|
|
bool require3DField( const std::string& keyword) const;
|
|
bool requireFIPNUM( ) const;
|
|
private:
|
|
SummaryConfig( const Deck& deck,
|
|
const Schedule& schedule,
|
|
const TableManager& tables,
|
|
const ParseContext& parseContext,
|
|
ErrorGuard& errors,
|
|
const GridDims& dims);
|
|
|
|
/*
|
|
The short_keywords set contains only the pure keyword
|
|
part, e.g. "WWCT", and not the qualification with
|
|
well/group name or a numerical value.
|
|
*/
|
|
keyword_list keywords;
|
|
std::set<std::string> short_keywords;
|
|
std::set<std::string> summary_keywords;
|
|
};
|
|
|
|
} //namespace Opm
|
|
|
|
#endif
|