#755 First simple version of the proposed GUI. Type and Quantity name filter working.

This commit is contained in:
Jacob Støren 2016-06-09 10:55:48 +02:00
parent c2e62c60ba
commit e21ddfe74a
7 changed files with 581 additions and 377 deletions

View File

@ -18,269 +18,252 @@
#include "RifEclipseSummaryAddress.h"
#include <vector>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress::RifEclipseSummaryAddress(const std::string& ertSummaryVarId)
: m_ertSummaryVarId(ertSummaryVarId)
RifEclipseSummaryAddress RifEclipseSummaryAddress::fieldVarAddress(const std::string& fieldVarName)
{
fromErtSummaryVarId(m_ertSummaryVarId, &m_variableCategory, &m_simulationItemName, &m_quantityName);
RifEclipseSummaryAddress fieldAddr;
fieldAddr.m_variableCategory = SUMMARY_FIELD;
fieldAddr.m_quantityName = fieldVarName;
return fieldAddr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress::RifEclipseSummaryAddress(SummaryVarCategory category, const std::string& simulationItemName, const std::string& quantityName)
: m_variableCategory(category),
m_simulationItemName(simulationItemName),
m_quantityName(quantityName)
std::string RifEclipseSummaryAddress::uiText() const
{
m_ertSummaryVarId = toErtSummaryVarId(m_variableCategory, m_simulationItemName, m_quantityName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::category() const
{
return m_variableCategory;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::simulationItemName() const
{
return m_simulationItemName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::quantityName() const
{
return m_quantityName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::ertSummaryVarId() const
{
return m_ertSummaryVarId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::categoryName(SummaryVarCategory category)
{
std::string name;
switch (category)
std::string text;
text += m_quantityName;
switch(this->category())
{
case RifEclipseSummaryAddress::SUMMARY_WELL:
name = "Well";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
name = "Completion";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
name = "Group";
break;
case RifEclipseSummaryAddress::SUMMARY_FIELD:
name = "Field";
break;
case RifEclipseSummaryAddress::SUMMARY_REGION:
name = "Region";
break;
case RifEclipseSummaryAddress::SUMMARY_MISC:
name = "Misc";
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
name = "Block";
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
name = "LGR Block";
break;
case RifEclipseSummaryAddress::SUMMARY_AQUIFER:
name = "Aquifier";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
name = "Segment";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT_RIVER:
name = "Segment River";
break;
default:
break;
}
return name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::toErtSummaryVarId(SummaryVarCategory category, const std::string& simulationItemName, const std::string& quantityName)
{
std::string ertSummaryVarId;
ertSummaryVarId += prefixForCategory(category);
ertSummaryVarId += quantityName;
if (simulationItemName.size() != 0)
{
ertSummaryVarId += ":";
ertSummaryVarId += simulationItemName;
}
return ertSummaryVarId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> split(const std::string &text, char sep) {
std::vector<std::string> tokens;
std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) {
tokens.push_back(text.substr(start, end - start));
start = end + 1;
}
tokens.push_back(text.substr(start));
return tokens;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseSummaryAddress::fromErtSummaryVarId(const std::string& ertSummaryVarId, SummaryVarCategory* type, std::string* simulationItemName, std::string* quantityName)
{
*type = categoryFromErtSummaryVarId(ertSummaryVarId);
std::string prefix = prefixForCategory(*type);
std::string addressNoPrefix = ertSummaryVarId.substr(prefix.size());
std::vector<std::string> tokens = split(addressNoPrefix, ':');
if (tokens.size() > 0)
{
*quantityName = tokens[0];
}
if (tokens.size() > 1)
{
*simulationItemName = tokens[1];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifEclipseSummaryAddress::prefixForCategory(SummaryVarCategory category)
{
std::string prefix;
switch (category)
{
case RifEclipseSummaryAddress::SUMMARY_WELL:
prefix = "W";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
prefix = "C";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
prefix = "G";
break;
case RifEclipseSummaryAddress::SUMMARY_FIELD:
prefix = "F";
break;
case RifEclipseSummaryAddress::SUMMARY_REGION:
prefix = "R";
break;
case RifEclipseSummaryAddress::SUMMARY_MISC:
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
prefix = "B";
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
prefix = "LB";
break;
case RifEclipseSummaryAddress::SUMMARY_AQUIFER:
prefix = "A";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
prefix = "S";
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT_RIVER:
prefix = "SR";
break;
default:
break;
}
return prefix;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::categoryFromErtSummaryVarId(const std::string& resultAddress)
{
SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_MISC;
if (resultAddress.size() > 1)
{
std::string twoFirstChars = resultAddress.substr(0, 2);
if (twoFirstChars == "SR")
case RifEclipseSummaryAddress::SUMMARY_REGION:
{
category = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT_RIVER;
text += ", R: " + std::to_string(this->regionNumber());
}
else if (twoFirstChars == "LB")
break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION:
{
category = RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR;
text += ", R1: " + std::to_string(this->regionNumber());
text += ", R2: " + std::to_string(this->regionNumber2());
}
else
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
{
char firstChar = resultAddress[0];
switch (firstChar)
{
case 'W':
category = RifEclipseSummaryAddress::SUMMARY_WELL;
break;
case 'C':
category = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION;
break;
case 'G':
category = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP;
break;
case 'F':
category = RifEclipseSummaryAddress::SUMMARY_FIELD;
break;
case 'R':
category = RifEclipseSummaryAddress::SUMMARY_REGION;
break;
case 'B':
category = RifEclipseSummaryAddress::SUMMARY_BLOCK;
break;
case 'A':
category = RifEclipseSummaryAddress::SUMMARY_AQUIFER;
break;
case 'S':
category = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT;
break;
default:
break;
}
text += ", G:" + this->wellGroupName();
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL:
{
text += ", W:" + this->wellName();
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
{
text += ", W:" + this->wellName();
text += ", IJK: " + std::to_string(this->cellI()) + ", "
+ std::to_string(this->cellJ()) + ", "
+ std::to_string(this->cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR:
{
text += ", W:" + this->wellName();
text += ", LGR:" + this->lgrName();
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR:
{
text += ", W:" + this->wellName();
text += ", LGR:" + this->lgrName();
text += ", IJK: " + std::to_string(this->cellI()) + ", "
+ std::to_string(this->cellJ()) + ", "
+ std::to_string(this->cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
{
text += ", W:" + this->wellName();
text += ", S: " + std::to_string(this->wellSegmentNumber());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
{
text += ", IJK: " + std::to_string(this->cellI()) + ", "
+ std::to_string(this->cellJ()) + ", "
+ std::to_string(this->cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
{
text += ", LGR:" + this->lgrName();
text += ", IJK: " + std::to_string(this->cellI()) + ", "
+ std::to_string(this->cellJ()) + ", "
+ std::to_string(this->cellK());
}
break;
}
return category;
return text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second)
{
if(first.category() != second.category()) return false;
if(first.quantityName() != second.quantityName()) return false;
switch(first.category())
{
case RifEclipseSummaryAddress::SUMMARY_REGION:
{
if(first.regionNumber() != second.regionNumber()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION:
{
if(first.regionNumber() != second.regionNumber()) return false;
if(first.regionNumber2() != second.regionNumber2()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
{
if(first.wellGroupName() != second.wellGroupName()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL:
{
if(first.wellName() != second.wellName()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
{
if(first.wellName() != second.wellName()) return false;
if(first.cellI() != second.cellI()) return false;
if(first.cellJ() != second.cellJ()) return false;
if(first.cellK() != second.cellK()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR:
{
if(first.wellName() != second.wellName()) return false;
if(first.lgrName() != second.lgrName()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR:
{
if(first.wellName() != second.wellName()) return false;
if(first.lgrName() != second.lgrName()) return false;
if(first.cellI() != second.cellI()) return false;
if(first.cellJ() != second.cellJ()) return false;
if(first.cellK() != second.cellK()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
{
if(first.wellName() != second.wellName()) return false;
if(first.wellSegmentNumber() != second.wellSegmentNumber()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
{
if(first.cellI() != second.cellI()) return false;
if(first.cellJ() != second.cellJ()) return false;
if(first.cellK() != second.cellK()) return false;
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
{
if(first.lgrName() != second.lgrName()) return false;
if(first.cellI() != second.cellI()) return false;
if(first.cellJ() != second.cellJ()) return false;
if(first.cellK() != second.cellK()) return false;
}
break;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second)
{
if(first.category() != second.category()) return first.category() < second.category();
if(first.quantityName() != second.quantityName()) return first.quantityName() < second.quantityName();
switch(first.category())
{
case RifEclipseSummaryAddress::SUMMARY_REGION:
{
if(first.regionNumber() != second.regionNumber()) return first.regionNumber() < second.regionNumber();
}
break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION:
{
if(first.regionNumber() != second.regionNumber()) return first.regionNumber() < second.regionNumber();
if(first.regionNumber2() != second.regionNumber2()) return first.regionNumber2() < second.regionNumber2();
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
{
if(first.wellGroupName() != second.wellGroupName()) return first.wellGroupName() < second.wellGroupName();
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL:
{
if(first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
{
if(first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
if(first.cellI() != second.cellI()) return (first.cellI() < second.cellI());
if(first.cellJ() != second.cellJ()) return (first.cellJ() < second.cellJ());
if(first.cellK() != second.cellK()) return (first.cellK() < second.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR:
{
if(first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
if(first.lgrName() != second.lgrName()) return (first.lgrName() < second.lgrName());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR:
{
if(first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
if(first.lgrName() != second.lgrName()) return (first.lgrName() < second.lgrName());
if(first.cellI() != second.cellI()) return (first.cellI() < second.cellI());
if(first.cellJ() != second.cellJ()) return (first.cellJ() < second.cellJ());
if(first.cellK() != second.cellK()) return (first.cellK() < second.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
{
if(first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
if(first.wellSegmentNumber() != second.wellSegmentNumber()) return (first.wellSegmentNumber() < second.wellSegmentNumber());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
{
if(first.cellI() != second.cellI()) return (first.cellI() < second.cellI());
if(first.cellJ() != second.cellJ()) return (first.cellJ() < second.cellJ());
if(first.cellK() != second.cellK()) return (first.cellK() < second.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
{
if(first.lgrName() != second.lgrName()) return (first.lgrName() < second.lgrName());
if(first.cellI() != second.cellI()) return (first.cellI() < second.cellI());
if(first.cellJ() != second.cellJ()) return (first.cellJ() < second.cellJ());
if(first.cellK() != second.cellK()) return (first.cellK() < second.cellK());
}
break;
}
return false;
}

View File

@ -15,12 +15,10 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
//==================================================================================================
//
//
@ -32,6 +30,7 @@ public:
// Based on list in ecl_smspec.c and list of types taken from Eclipse Reference Manual ecl_rm_2011.1.pdf
enum SummaryVarCategory
{
SUMMARY_INVALID,
SUMMARY_FIELD,
SUMMARY_AQUIFER,
SUMMARY_NETWORK,
@ -44,36 +43,73 @@ public:
SUMMARY_WELL_LGR,
SUMMARY_WELL_COMPLETION_LGR,
SUMMARY_WELL_SEGMENT,
SUMMARY_WELL_SEGMENT_RIVER,
SUMMARY_BLOCK,
SUMMARY_BLOCK_LGR,
};
public:
RifEclipseSummaryAddress(const std::string& ertSummaryVarId);
RifEclipseSummaryAddress(SummaryVarCategory category, const std::string& simulationItemName, const std::string& quantityName);
SummaryVarCategory category() const;
std::string simulationItemName() const;
std::string quantityName() const;
RifEclipseSummaryAddress():
m_variableCategory(RifEclipseSummaryAddress::SUMMARY_INVALID),
m_regionNumber(-1),
m_regionNumber2(-1),
m_wellSegmentNumber(-1),
m_cellI(-1),
m_cellJ(-1),
m_cellK(-1)
{
}
std::string ertSummaryVarId() const;
static std::string categoryName(SummaryVarCategory category);
RifEclipseSummaryAddress(SummaryVarCategory category,
const std::string& quantityName,
int regionNumber,
int regionNumber2,
const std::string& wellGroupName,
const std::string& wellName,
int wellSegmentNumber,
const std::string& lgrName,
int cellI,
int cellJ,
int cellK):
m_variableCategory(category),
m_quantityName(quantityName),
m_regionNumber(regionNumber),
m_regionNumber2(regionNumber2),
m_wellGroupName(wellGroupName),
m_wellName(wellName),
m_wellSegmentNumber(wellSegmentNumber),
m_lgrName(lgrName),
m_cellI(cellI),
m_cellJ(cellJ),
m_cellK(cellK)
{
}
// Static specialized creation methods
static RifEclipseSummaryAddress fieldVarAddress(const std::string& fieldVarName);
// Access methods
SummaryVarCategory category() const { return m_variableCategory; }
const std::string& quantityName() const { return m_quantityName; }
int regionNumber() const { return m_regionNumber; }
int regionNumber2() const { return m_regionNumber2; }
const std::string& wellGroupName() const { return m_wellGroupName; }
const std::string& wellName() const { return m_wellName; }
int wellSegmentNumber() const { return m_wellSegmentNumber; }
const std::string& lgrName() const { return m_lgrName; }
int cellI() const { return m_cellI; }
int cellJ() const { return m_cellJ; }
int cellK() const { return m_cellK; }
// Derived properties
std::string uiText() const;
private:
static std::string toErtSummaryVarId(SummaryVarCategory category, const std::string& simulationItemName, const std::string& quantityName);
static void fromErtSummaryVarId(const std::string& ertSummaryVarId, SummaryVarCategory* category, std::string* simulationItemName, std::string* quantityName);
static std::string prefixForCategory(SummaryVarCategory category);
static SummaryVarCategory categoryFromErtSummaryVarId(const std::string& ertSummaryVarId);
private:
std::string m_ertSummaryVarId;
std::string m_simulationItemName;
SummaryVarCategory m_variableCategory;
std::string m_quantityName;
@ -87,3 +123,7 @@ private:
int m_cellJ;
int m_cellK;
};
bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second);
bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second);

View File

@ -23,6 +23,7 @@
#include "ert/ecl/ecl_util.h"
#include <iostream>
#include "cafAppEnum.h"
@ -128,7 +129,7 @@ void RifEclipseSummaryTools::dumpMetaData(RifReaderEclipseSummary* readerEclipse
{
std::vector<RifEclipseSummaryAddress> addresses = readerEclipseSummary->allResultAddresses();
for (int category = 0; category < RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT_RIVER; category++)
for (int category = 0; category < RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR; category++)
{
RifEclipseSummaryAddress::SummaryVarCategory categoryEnum = RifEclipseSummaryAddress::SummaryVarCategory(category);
@ -136,11 +137,20 @@ void RifEclipseSummaryTools::dumpMetaData(RifReaderEclipseSummary* readerEclipse
if (catAddresses.size() > 0)
{
std::cout << RifEclipseSummaryAddress::categoryName(categoryEnum) << " count : " << catAddresses.size() << std::endl;
std::cout << caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::uiText(categoryEnum).toStdString() << " count : " << catAddresses.size() << std::endl;
for (size_t i = 0; i < catAddresses.size(); i++)
{
std::cout << catAddresses[i].ertSummaryVarId() << " " << catAddresses[i].simulationItemName() << " " << catAddresses[i].quantityName() << std::endl;
std::cout << catAddresses[i].quantityName() << " "
<< catAddresses[i].regionNumber() << " "
<< catAddresses[i].regionNumber2() << " "
<< catAddresses[i].wellGroupName() << " "
<< catAddresses[i].wellName() << " "
<< catAddresses[i].wellSegmentNumber() << " "
<< catAddresses[i].lgrName() << " "
<< catAddresses[i].cellI() << " "
<< catAddresses[i].cellJ() << " "
<< catAddresses[i].cellK() << std::endl;
}
std::cout << std::endl;

View File

@ -24,6 +24,7 @@
#include <assert.h>
#include <QDateTime>
#include "ert/ecl/smspec_node.h"
//--------------------------------------------------------------------------------------------------
///
@ -67,7 +68,8 @@ bool RifReaderEclipseSummary::open(const std::string& headerFileName, const std:
if (ecl_sum)
{
assert(ecl_sum_get_smspec(ecl_sum) != NULL);
eclSmSpec = ecl_sum_get_smspec(ecl_sum);
assert(eclSmSpec != NULL);
return true;
}
@ -87,23 +89,125 @@ void RifReaderEclipseSummary::close()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifReaderEclipseSummary::variableNames() const
RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type * ertSumVarNode)
{
assert(ecl_sum != NULL);
if (smspec_node_get_var_type(ertSumVarNode) == ECL_SMSPEC_INVALID_VAR) return RifEclipseSummaryAddress();
// Get all possible variable names from file
stringlist_type* keys = ecl_sum_alloc_matching_general_var_list(ecl_sum, NULL);
stringlist_sort(keys, NULL);
std::vector<std::string> names;
RifReaderEclipseSummary::populateVectorFromStringList(keys, &names);
RifEclipseSummaryAddress::SummaryVarCategory sumCategory(RifEclipseSummaryAddress::SUMMARY_INVALID);
std::string quantityName;
int regionNumber(-1);
int regionNumber2(-1);
std::string wellGroupName;
std::string wellName;
int wellSegmentNumber(-1);
std::string lgrName;
int cellI(-1);
int cellJ(-1);
int cellK(-1);
stringlist_free(keys);
quantityName = smspec_node_get_keyword(ertSumVarNode);
return names;
switch (smspec_node_get_var_type(ertSumVarNode))
{
case ECL_SMSPEC_AQUIFER_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_AQUIFER;
}
break;
case ECL_SMSPEC_WELL_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL;
wellName = smspec_node_get_wgname(ertSumVarNode);
}
break;
case ECL_SMSPEC_REGION_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION;
regionNumber = smspec_node_get_num(ertSumVarNode);
}
break;
case ECL_SMSPEC_FIELD_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_FIELD;
}
break;
case ECL_SMSPEC_GROUP_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP;
wellGroupName = smspec_node_get_wgname(ertSumVarNode);
}
break;
case ECL_SMSPEC_BLOCK_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK;
// Todo: Get IJK values
}
break;
case ECL_SMSPEC_COMPLETION_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION;
wellName = smspec_node_get_wgname(ertSumVarNode);
// Todo: Get IJK values
}
break;
case ECL_SMSPEC_LOCAL_BLOCK_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR;
// Todo: GetLGR name
// Todo: Get IJK values
}
break;
case ECL_SMSPEC_LOCAL_COMPLETION_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR;
wellName = smspec_node_get_wgname(ertSumVarNode);
// Todo: GetLGR name
// Todo: Get IJK values
}
break;
case ECL_SMSPEC_LOCAL_WELL_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_LGR;
wellName = smspec_node_get_wgname(ertSumVarNode);
// Todo: GetLGR name
}
break;
case ECL_SMSPEC_NETWORK_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_NETWORK;
}
break;
case ECL_SMSPEC_REGION_2_REGION_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION;
// Todo: Get R1 R2 values
}
break;
case ECL_SMSPEC_SEGMENT_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT;
wellSegmentNumber = smspec_node_get_num(ertSumVarNode);
}
break;
case ECL_SMSPEC_MISC_VAR:
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_MISC;
}
break;
default:
CVF_ASSERT(false);
break;
}
return RifEclipseSummaryAddress(sumCategory,
quantityName,
regionNumber,
regionNumber2,
wellGroupName,
wellName,
wellSegmentNumber,
lgrName,
cellI, cellJ, cellK);
}
//--------------------------------------------------------------------------------------------------
@ -113,10 +217,12 @@ const std::vector<RifEclipseSummaryAddress>& RifReaderEclipseSummary::allResultA
{
if (m_allResultAddresses.size() == 0)
{
std::vector<std::string> fileVariableNames = variableNames();
for(size_t i = 0; i < fileVariableNames.size(); i++)
int varCount = ecl_smspec_num_nodes( eclSmSpec);
for(int i = 0; i < varCount; i++)
{
m_allResultAddresses.push_back(RifEclipseSummaryAddress(fileVariableNames[i]));
const smspec_node_type * ertSumVarNode = ecl_smspec_iget_node(eclSmSpec, i);
m_allResultAddresses.push_back(addressFromErtSmSpecNode(ertSumVarNode));
}
}
@ -126,42 +232,29 @@ const std::vector<RifEclipseSummaryAddress>& RifReaderEclipseSummary::allResultA
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::values(const std::string& variableName, std::vector<double>* values)
bool RifReaderEclipseSummary::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values)
{
assert(ecl_sum != NULL);
values->clear();
int tsCount = timeStepCount();
values->reserve(timeStepCount());
int variableIndex = variableIndexFromVariableName(variableName);
if (variableIndex < 0) return false;
int variableIndex = indexFromAddress(resultAddress);
for (int time_index = 0; time_index < timeStepCount(); time_index++)
if(variableIndex < 0) return false;
const smspec_node_type * ertSumVarNode = ecl_smspec_iget_node(eclSmSpec, variableIndex);
int paramsIndex = smspec_node_get_params_index(ertSumVarNode);
for(int time_index = 0; time_index < tsCount; time_index++)
{
double value = ecl_sum_iget(ecl_sum, time_index, variableIndex);
double value = ecl_sum_iget(ecl_sum, time_index, paramsIndex);
values->push_back(value);
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values)
{
std::string var = resultAddress.ertSummaryVarId();
return this->values(var, values);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseSummary::variableIndexFromVariableName(const std::string& keyword) const
{
assert(ecl_sum != NULL);
return ecl_sum_get_general_var_params_index(ecl_sum, keyword.data());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -205,6 +298,23 @@ std::vector<QDateTime> RifReaderEclipseSummary::fromTimeT(const std::vector<time
return a;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseSummary::indexFromAddress(const RifEclipseSummaryAddress& resultAddress)
{
// For now, a slow linear search
int resIndex = -1;
int addrCount = static_cast<int>(this->allResultAddresses().size());
for (int idx = 0; idx < addrCount; ++idx)
{
if (m_allResultAddresses[idx] == resultAddress) return idx;
}
return -1;
}
#if 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -218,3 +328,4 @@ void RifReaderEclipseSummary::populateVectorFromStringList(stringlist_type* stri
}
}
#endif

View File

@ -39,33 +39,30 @@ public:
RifReaderEclipseSummary();
~RifReaderEclipseSummary();
bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames);
void close();
bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames);
void close();
std::vector<std::string> variableNames() const;
const std::vector<RifEclipseSummaryAddress>& allResultAddresses();
std::vector<time_t> timeSteps() const;
std::vector<time_t> timeSteps() const;
bool values(const std::string& variableName, std::vector<double>* values);
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values);
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values);
// TODO: Move this to a tools class with static members
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
private:
int variableIndexFromVariableName(const std::string& variableName) const;
int timeStepCount() const;
// Taken from stringlist.h
typedef struct stringlist_struct stringlist_type;
static void populateVectorFromStringList(stringlist_type* stringList, std::vector<std::string>* strings);
int timeStepCount() const;
int indexFromAddress(const RifEclipseSummaryAddress& resultAddress);
private:
// Taken from ecl_sum.h
typedef struct ecl_sum_struct ecl_sum_type;
ecl_sum_type* ecl_sum;
typedef struct ecl_sum_struct ecl_sum_type;
typedef struct ecl_smspec_struct ecl_smspec_type;
ecl_sum_type* ecl_sum;
const ecl_smspec_type * eclSmSpec;
std::vector<RifEclipseSummaryAddress> m_allResultAddresses;
};

View File

@ -43,6 +43,20 @@ CAF_PDM_SOURCE_INIT(RimSummaryAddress, "SummaryAddress");
RimSummaryAddress::RimSummaryAddress()
{
CAF_PDM_InitFieldNoDefault(&m_category, "SummaryVarType", "Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_quantityName, "SummaryQuantityName", "Quantity", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_regionNumber, "SummaryRegion", "Region", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_regionNumber2, "SummaryRegion2", "Region2", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellGroupName, "SummaryWellGroup", "Group", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellName, "SummaryWell", "Well", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellSegmentNumber, "SummaryWellSegment", "Well Segment", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_lgrName, "SummaryLgr", "Grid", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellI, "SummaryCellI", "I", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellJ, "SummaryCellJ", "J", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellK, "SummaryCellK", "K", "", "", "");
m_category = RifEclipseSummaryAddress::SUMMARY_INVALID;
m_regionNumber = m_regionNumber2 = m_wellSegmentNumber = m_cellI = m_cellJ = m_cellK = -1;
}
//--------------------------------------------------------------------------------------------------
@ -58,7 +72,16 @@ RimSummaryAddress::~RimSummaryAddress()
//--------------------------------------------------------------------------------------------------
void RimSummaryAddress::setAddress(const RifEclipseSummaryAddress& addr)
{
m_category = addr.category();
m_quantityName = addr.quantityName().c_str();
m_regionNumber = addr.regionNumber();
m_regionNumber2 = addr.regionNumber2();
m_wellGroupName = addr.wellGroupName().c_str();
m_wellName = addr.wellName().c_str();
m_wellSegmentNumber = addr.wellSegmentNumber();
m_lgrName = addr.lgrName().c_str();
m_cellI = addr.cellI(); m_cellJ = addr.cellJ(); m_cellK = addr.cellK();
}
//--------------------------------------------------------------------------------------------------
@ -66,7 +89,15 @@ void RimSummaryAddress::setAddress(const RifEclipseSummaryAddress& addr)
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress RimSummaryAddress::address()
{
return RifEclipseSummaryAddress("");
return RifEclipseSummaryAddress( m_category(),
m_quantityName().toStdString(),
m_regionNumber(),
m_regionNumber2(),
m_wellGroupName().toStdString(),
m_wellName().toStdString(),
m_wellSegmentNumber(),
m_lgrName().toStdString(),
m_cellI(), m_cellJ(), m_cellK());
}
namespace caf
@ -87,7 +118,6 @@ void caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::setUp()
addItem(RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR, "SUMMARY_WELL_COMPLETION_LGR", "Lgr-Completion");
addItem(RifEclipseSummaryAddress::SUMMARY_WELL_LGR, "SUMMARY_WELL_LGR", "Lgr-Well");
addItem(RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT, "SUMMARY_SEGMENT", "Segment");
addItem(RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT_RIVER, "SUMMARY_SEGMENT_RIVER", "Segment River");
addItem(RifEclipseSummaryAddress::SUMMARY_BLOCK, "SUMMARY_BLOCK", "Block");
addItem(RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR, "SUMMARY_BLOCK_LGR", "Lgr-Block");
setDefault(RifEclipseSummaryAddress::SUMMARY_FIELD);
@ -138,9 +168,6 @@ RimSummaryCurve::RimSummaryCurve()
// TODO: Implement setUiTreeHidden
//m_eclipseCase.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_variableName, "SummaryVariableName", "Variable Name", "", "", "");
m_variableName.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_filterType,"SummaryVarCategory","Category","","","");
m_filterType.xmlCapability()->setIOWritable(false);
m_filterType.xmlCapability()->setIOReadable(false);
@ -177,9 +204,12 @@ RimSummaryCurve::RimSummaryCurve()
m_cellIJKFilter.xmlCapability()->setIOReadable(false);
m_uiFilterResultSelection.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_uiFilterResultSelection.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_uiFilterResultSelection.uiCapability()->setAutoAddingOptionFromValue(false);
CAF_PDM_InitFieldNoDefault(&m_curveVariable, "SummaryAddress", "SummaryAddress", "", "", "");
m_curveVariable.uiCapability()->setUiHidden(true);
m_curveVariable.uiCapability()->setUiChildrenHidden(true);
m_curveVariable = new RimSummaryAddress;
updateOptionSensitivity();
@ -206,7 +236,7 @@ void RimSummaryCurve::setSummaryCase(RimSummaryCase* sumCase)
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::setVariable(QString varName)
{
m_variableName = varName;
m_curveVariable->setAddress(RifEclipseSummaryAddress::fieldVarAddress(varName.toStdString()));
}
//--------------------------------------------------------------------------------------------------
@ -217,30 +247,8 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
QList<caf::PdmOptionItemInfo> optionList = this->RimPlotCurve::calculateValueOptions(fieldNeedingOptions,useOptionsOnly);
if (!optionList.isEmpty()) return optionList;
if (fieldNeedingOptions == &m_variableName)
{
if (m_summaryCase)
{
RifReaderEclipseSummary* reader = summaryReader();
if (reader)
{
std::vector<std::string> varNames = reader->variableNames();
for (size_t i = 0; i < varNames.size(); i++)
{
std::string name = varNames[i];
QString s = QString::fromStdString(name);
optionList.push_back(caf::PdmOptionItemInfo(s, s));
}
}
optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), RimDefines::undefinedResultName()));
if (useOptionsOnly) *useOptionsOnly = true;
}
}
else if (fieldNeedingOptions == &m_summaryCase)
if (fieldNeedingOptions == &m_summaryCase)
{
RimProject* proj = RiaApplication::instance()->project();
std::vector<RimSummaryCase*> cases;
@ -264,20 +272,27 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
if(m_summaryCase)
{
RifReaderEclipseSummary* reader = summaryReader();
int addressCount = 0;
if(reader)
{
std::vector<std::string> varNames = reader->variableNames();
for(size_t i = 0; i < varNames.size(); i++)
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
addressCount = static_cast<int>(allAddresses.size());
std::map<RifEclipseSummaryAddress, int> addrToIdxMap;
for(int i = 0; i <addressCount; i++)
{
std::string name = varNames[i];
if (!isIncludedByFilter(allAddresses[i] )) continue;
addrToIdxMap[allAddresses[i]] = i;
}
for (const auto& addrIntPair: addrToIdxMap)
{
std::string name = addrIntPair.first.uiText();
QString s = QString::fromStdString(name);
optionList.push_back(caf::PdmOptionItemInfo(s, i));
optionList.push_back(caf::PdmOptionItemInfo(s, addrIntPair.second));
}
}
optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), -1));
optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), addressCount));
if(useOptionsOnly) *useOptionsOnly = true;
}
@ -291,7 +306,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
//--------------------------------------------------------------------------------------------------
QString RimSummaryCurve::createCurveAutoName()
{
return m_variableName();
return QString::fromStdString( m_curveVariable->address().uiText());
}
//--------------------------------------------------------------------------------------------------
@ -426,6 +441,51 @@ void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.setForgetRemainingFields(true); // For now.
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCurve::isIncludedByFilter(const RifEclipseSummaryAddress& addr)
{
if (!isSumVarTypeMatchingFilterType(m_filterType(), addr.category())) return false;
if (!m_filterQuantityName().isEmpty())
{
QRegExp searcher(m_filterQuantityName(), Qt::CaseInsensitive, QRegExp::WildcardUnix);
QString addrQuant = QString::fromStdString(addr.quantityName());
if (!searcher.exactMatch(addrQuant)) return false ;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCurve::isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType)
{
if (sumVarType == RifEclipseSummaryAddress::SUMMARY_INVALID) return false;
if (sumFilterType == SUM_FILTER_ANY) return true;
switch(sumVarType)
{
case RifEclipseSummaryAddress::SUMMARY_FIELD: { return (sumFilterType == SUM_FILTER_FIELD); } break;
case RifEclipseSummaryAddress::SUMMARY_AQUIFER: { return (sumFilterType == SUM_FILTER_AQUIFER); } break;
case RifEclipseSummaryAddress::SUMMARY_NETWORK: { return (sumFilterType == SUM_FILTER_NETWORK); } break;
case RifEclipseSummaryAddress::SUMMARY_MISC: { return (sumFilterType == SUM_FILTER_MISC); } break;
case RifEclipseSummaryAddress::SUMMARY_REGION: { return (sumFilterType == SUM_FILTER_REGION); } break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: { return (sumFilterType == SUM_FILTER_REGION_2_REGION); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: { return (sumFilterType == SUM_FILTER_WELL_GROUP); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL: { return (sumFilterType == SUM_FILTER_WELL); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: { return (sumFilterType == SUM_FILTER_WELL_COMPLETION); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: { return (sumFilterType == SUM_FILTER_WELL_LGR); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: { return (sumFilterType == SUM_FILTER_FIELD); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: { return (sumFilterType == SUM_FILTER_WELL_SEGMENT); } break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK: { return (sumFilterType == SUM_FILTER_BLOCK); } break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: { return (sumFilterType == SUM_FILTER_BLOCK_LGR); } break;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -433,12 +493,17 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
{
this->RimPlotCurve::fieldChangedByUi(changedField,oldValue,newValue);
if (changedField == &m_variableName)
{
this->loadDataAndUpdate();
}
else if (changedField = &m_summaryCase)
if(changedField = &m_uiFilterResultSelection)
{
if (0 <= m_uiFilterResultSelection() && m_uiFilterResultSelection() < summaryReader()->allResultAddresses().size())
{
m_curveVariable->setAddress(summaryReader()->allResultAddresses()[m_uiFilterResultSelection()]);
}
else
{
m_curveVariable->setAddress(RifEclipseSummaryAddress());
}
this->loadDataAndUpdate();
}
}
@ -480,8 +545,8 @@ void RimSummaryCurve::curveData(std::vector<QDateTime>* timeSteps, std::vector<d
if (values)
{
std::string keyword = m_variableName().toStdString();
reader->values(keyword, values);
RifEclipseSummaryAddress addr = m_curveVariable()->address();
reader->values(addr, values);
}
}

View File

@ -113,10 +113,12 @@ private:
// Fields
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
caf::PdmField<QString> m_variableName; // Obsolete
caf::PdmChildField<RimSummaryAddress*> m_curveVariable;
// Filter fields
bool isIncludedByFilter(const RifEclipseSummaryAddress& addr);
bool isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType);
caf::PdmField<caf::AppEnum<SummaryFilterType> >
m_filterType;
caf::PdmField<QString> m_filterQuantityName;
@ -129,8 +131,4 @@ private:
caf::PdmField<QString> m_cellIJKFilter;
caf::PdmField<int> m_uiFilterResultSelection;
caf::PdmChildField<RimSummaryAddress*> m_curveVariable;
};