Provide External Access to Well-Order Sorting
This commit extracts the 'NameOrder' sorting operation to a new public member function, WellMatcher::sort(vector<string>). The immediate use-case for this function is to provide a stable sorting order for wells that are matched in an ACTIONX block. Well IDs often end up in various output arrays in the restart files--e.g., in the IUAP array the matching wells are used in a WCON* keyword that employs a user-defined argument as part of setting its targets or limits--and we should strive to keep those arrays as deterministic as possible.
This commit is contained in:
@@ -36,6 +36,7 @@ public:
|
||||
explicit WellMatcher(std::initializer_list<std::string> wells);
|
||||
explicit WellMatcher(const std::vector<std::string>& wells);
|
||||
WellMatcher(const NameOrder& well_order, const WListManager& wlm);
|
||||
std::vector<std::string> sort(std::vector<std::string> wells) const;
|
||||
std::vector<std::string> wells(const std::string& pattern) const;
|
||||
const std::vector<std::string>& wells() const;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellMatcher.hpp>
|
||||
@@ -45,6 +46,10 @@ WellMatcher::WellMatcher(const NameOrder& well_order, const WListManager &wlm) :
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::string> WellMatcher::sort(std::vector<std::string> wells) const {
|
||||
return this->m_well_order.sort(std::move(wells));
|
||||
}
|
||||
|
||||
const std::vector<std::string>& WellMatcher::wells() const {
|
||||
return this->m_well_order.names();
|
||||
}
|
||||
@@ -56,7 +61,7 @@ std::vector<std::string> WellMatcher::wells(const std::string& pattern) const {
|
||||
|
||||
// WLIST
|
||||
if (pattern[0] == '*' && pattern.size() > 1)
|
||||
return this->m_well_order.sort( this->m_wlm.wells(pattern) );
|
||||
return this->sort( this->m_wlm.wells(pattern) );
|
||||
|
||||
// Normal pattern matching
|
||||
auto star_pos = pattern.find('*');
|
||||
|
||||
Reference in New Issue
Block a user