#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;
};