This commit is contained in:
Magne Sjaastad 2018-05-11 14:20:16 +02:00
parent bf2f524d34
commit b02bf07568

View File

@ -39,9 +39,8 @@
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include <regex>
#include "RimTools.h" #include "RimTools.h"
#include <regex>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -64,10 +63,14 @@ public:
StaticFieldsInitializer() StaticFieldsInitializer()
{ {
// Init static list // Init static list
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), RimWellPlotTools::OIL_CHANNEL_NAMES.end()); RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(),
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), RimWellPlotTools::GAS_CHANNEL_NAMES.end()); RimWellPlotTools::OIL_CHANNEL_NAMES.end());
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), RimWellPlotTools::WATER_CHANNEL_NAMES.end()); RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(),
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), RimWellPlotTools::TOTAL_CHANNEL_NAMES.end()); RimWellPlotTools::GAS_CHANNEL_NAMES.end());
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(),
RimWellPlotTools::WATER_CHANNEL_NAMES.end());
RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(),
RimWellPlotTools::TOTAL_CHANNEL_NAMES.end());
} }
} staticFieldsInitializer; } staticFieldsInitializer;
@ -107,8 +110,8 @@ std::pair<size_t, QString> RimWellPlotTools::pressureResultDataInfo(const RigEcl
{ {
for (const auto& pressureDataName : PRESSURE_DATA_NAMES) for (const auto& pressureDataName : PRESSURE_DATA_NAMES)
{ {
size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName); ->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName);
if (index != cvf::UNDEFINED_SIZE_T) if (index != cvf::UNDEFINED_SIZE_T)
{ {
return std::make_pair(index, pressureDataName); return std::make_pair(index, pressureDataName);
@ -224,8 +227,8 @@ bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase)
for (const QString& channelName : FLOW_DATA_NAMES) for (const QString& channelName : FLOW_DATA_NAMES)
{ {
size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> size_t resultIndex =
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName); eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName);
if (resultIndex != cvf::UNDEFINED_SIZE_T) return true; if (resultIndex != cvf::UNDEFINED_SIZE_T) return true;
} }
@ -244,7 +247,6 @@ FlowPhase RimWellPlotTools::flowPhaseFromChannelName(const QString& channelName)
return FLOW_PHASE_NONE; return FLOW_PHASE_NONE;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -272,8 +274,7 @@ std::vector<RimWellLogFile*> RimWellPlotTools::wellLogFilesContainingPressure(co
for (auto wellPath : wellPaths) for (auto wellPath : wellPaths)
{ {
if (!wellPathNameOrSimWellName.isEmpty() && if (!wellPathNameOrSimWellName.isEmpty() && (wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() ||
(wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() ||
wellPathNameOrSimWellName == wellPath->name())) wellPathNameOrSimWellName == wellPath->name()))
{ {
const std::vector<RimWellLogFile*> files = wellPath->wellLogFiles(); const std::vector<RimWellLogFile*> files = wellPath->wellLogFiles();
@ -344,7 +345,8 @@ RimWellPath* RimWellPlotTools::wellPathFromWellLogFile(const RimWellLogFile* wel
RimProject* const project = RiaApplication::instance()->project(); RimProject* const project = RiaApplication::instance()->project();
for (const auto& oilField : project->oilFields) for (const auto& oilField : project->oilFields)
{ {
auto wellPaths = std::vector<RimWellPath*>(oilField->wellPathCollection()->wellPaths.begin(), oilField->wellPathCollection()->wellPaths.end()); auto wellPaths = std::vector<RimWellPath*>(oilField->wellPathCollection()->wellPaths.begin(),
oilField->wellPathCollection()->wellPaths.end());
for (const auto& wellPath : wellPaths) for (const auto& wellPath : wellPaths)
{ {
@ -396,9 +398,7 @@ std::vector<RimEclipseResultCase*> RimWellPlotTools::rftCasesForWell(const QStri
{ {
RimEclipseResultCase* resultCase = dynamic_cast<RimEclipseResultCase*>(eclCase); RimEclipseResultCase* resultCase = dynamic_cast<RimEclipseResultCase*>(eclCase);
if (resultCase if (resultCase && resultCase->rftReader() && resultCase->rftReader()->wellNames().count(simWellName))
&& resultCase->rftReader()
&& resultCase->rftReader()->wellNames().count(simWellName))
{ {
cases.push_back(resultCase); cases.push_back(resultCase);
} }
@ -409,8 +409,7 @@ std::vector<RimEclipseResultCase*> RimWellPlotTools::rftCasesForWell(const QStri
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::set<QDateTime> RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, std::set<QDateTime> RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, const QString& simWellName)
const QString& simWellName)
{ {
std::set<QDateTime> timeSteps; std::set<QDateTime> timeSteps;
RifReaderEclipseRft* const reader = rftCase->rftReader(); RifReaderEclipseRft* const reader = rftCase->rftReader();
@ -488,8 +487,7 @@ std::set<QDateTime> RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std:
if (itToEqualOrLargerTime != availableTimeSteps.end()) if (itToEqualOrLargerTime != availableTimeSteps.end())
{ {
resultTimeSteps.insert(*itToEqualOrLargerTime); resultTimeSteps.insert(*itToEqualOrLargerTime);
if ( *itToEqualOrLargerTime != baseTimeStep if (*itToEqualOrLargerTime != baseTimeStep && itToEqualOrLargerTime != availableTimeSteps.begin())
&& itToEqualOrLargerTime != availableTimeSteps.begin() )
{ {
// Found a larger time, then add the timestep before it as the adjacent timestep before the base timestep // Found a larger time, then add the timestep before it as the adjacent timestep before the base timestep
itToEqualOrLargerTime--; itToEqualOrLargerTime--;
@ -512,9 +510,8 @@ std::set<QDateTime> RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::set<QDateTime> RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase * eclCase, std::set<QDateTime>
const QString& simWellName, RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimestep)
bool addFirstReportTimestep)
{ {
std::set<QDateTime> availebleTimeSteps; std::set<QDateTime> availebleTimeSteps;
@ -558,8 +555,8 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur
{ {
size_t timeStepIndex = gridCurve->currentTimeStep(); size_t timeStepIndex = gridCurve->currentTimeStep();
const std::map<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepsMap = timeStepsMapFromGridCase(gridCase); const std::map<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepsMap = timeStepsMapFromGridCase(gridCase);
auto timeStepsVector = std::vector<std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>>( auto timeStepsVector =
timeStepsMap.begin(), timeStepsMap.end()); std::vector<std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>>(timeStepsMap.begin(), timeStepsMap.end());
if (timeStepIndex < timeStepsMap.size()) if (timeStepIndex < timeStepsMap.size())
{ {
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase), return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase),
@ -610,8 +607,7 @@ QString RimWellPlotTools::simWellName(const QString& wellPathNameOrSimWellName)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimWellPlotTools::tryMatchChannelName(const std::set<QString>& channelNames, const QString& channelNameToMatch) bool RimWellPlotTools::tryMatchChannelName(const std::set<QString>& channelNames, const QString& channelNameToMatch)
{ {
auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) {
{
if (channelName.startsWith('^')) if (channelName.startsWith('^'))
{ {
std::regex pattern(channelName.toStdString()); std::regex pattern(channelName.toStdString());
@ -625,11 +621,11 @@ bool RimWellPlotTools::tryMatchChannelName(const std::set<QString>& channelNames
return itr != channelNames.end(); return itr != channelNames.end();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName, std::set<RiaRftPltCurveDefinition>
RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName,
const std::vector<QDateTime>& selectedTimeSteps, const std::vector<QDateTime>& selectedTimeSteps,
bool firstSimWellTimeStepIsValid, bool firstSimWellTimeStepIsValid,
const std::vector<RifDataSourceForRftPlt>& selectedSourcesExpanded) const std::vector<RifDataSourceForRftPlt>& selectedSourcesExpanded)
@ -642,9 +638,8 @@ std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(c
{ {
if (addr.rftReader()) if (addr.rftReader())
{ {
std::set<QDateTime> rftTimes = addr.rftReader()->availableTimeSteps(simWellName, { RifEclipseRftAddress::ORAT, std::set<QDateTime> rftTimes = addr.rftReader()->availableTimeSteps(
RifEclipseRftAddress::WRAT, simWellName, {RifEclipseRftAddress::ORAT, RifEclipseRftAddress::WRAT, RifEclipseRftAddress::GRAT});
RifEclipseRftAddress::GRAT });
for (const QDateTime& time : rftTimes) for (const QDateTime& time : rftTimes)
{ {
if (selectedTimeStepSet.count(time)) if (selectedTimeStepSet.count(time))
@ -655,7 +650,8 @@ std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(c
} }
else if (addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase()) else if (addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase())
{ {
std::set<QDateTime> timeSteps = RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid); std::set<QDateTime> timeSteps =
RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid);
for (const QDateTime& time : timeSteps) for (const QDateTime& time : timeSteps)
{ {
@ -680,7 +676,6 @@ std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(c
return curveDefs; return curveDefs;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -714,10 +709,17 @@ QString flowConditionReservoirUnitText(RiaEclipseUnitTools::UnitSystem unitSyste
switch (unitSystem) switch (unitSystem)
{ {
case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[m<sup>3</sup>/day]"; break; case RiaEclipseUnitTools::UNITS_METRIC:
case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Brl/day]"; break; unitText = "[m<sup>3</sup>/day]";
case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm<sup>3</sup>/hr]"; break; break;
default: break; case RiaEclipseUnitTools::UNITS_FIELD:
unitText = "[Brl/day]";
break;
case RiaEclipseUnitTools::UNITS_LAB:
unitText = "[cm<sup>3</sup>/hr]";
break;
default:
break;
} }
return unitText; return unitText;
@ -738,21 +740,29 @@ QString RimWellPlotTools::flowUnitText(RimWellLogFile::WellFlowCondition conditi
{ {
switch (unitSystem) switch (unitSystem)
{ {
case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[Liquid Sm<sup>3</sup>/day], [Gas kSm<sup>3</sup>/day]"; break; case RiaEclipseUnitTools::UNITS_METRIC:
case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; unitText = "[Liquid Sm<sup>3</sup>/day], [Gas kSm<sup>3</sup>/day]";
case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm<sup>3</sup>/hr]"; break; break;
default: break; case RiaEclipseUnitTools::UNITS_FIELD:
unitText = "[Liquid BBL/day], [Gas BOE/day]";
break;
case RiaEclipseUnitTools::UNITS_LAB:
unitText = "[cm<sup>3</sup>/hr]";
break;
default:
break;
} }
} }
return unitText; return unitText;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition, RiaEclipseUnitTools::UnitSystem unitSystem, FlowPhase flowPhase) QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition,
RiaEclipseUnitTools::UnitSystem unitSystem,
FlowPhase flowPhase)
{ {
QString unitText; QString unitText;
@ -767,24 +777,39 @@ QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condit
case RiaEclipseUnitTools::UNITS_METRIC: case RiaEclipseUnitTools::UNITS_METRIC:
switch (flowPhase) switch (flowPhase)
{ {
case FLOW_PHASE_GAS: unitText = "[kSm<sup>3</sup>/day]"; break; case FLOW_PHASE_GAS:
unitText = "[kSm<sup>3</sup>/day]";
break;
case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit
case FLOW_PHASE_OIL: unitText = "[Sm<sup>3</sup>/day]"; break; case FLOW_PHASE_OIL:
default: unitText = "[Liquid Sm<sup>3</sup>/day], [Gas kSm<sup>3</sup>/day]"; break; unitText = "[Sm<sup>3</sup>/day]";
break;
default:
unitText = "[Liquid Sm<sup>3</sup>/day], [Gas kSm<sup>3</sup>/day]";
break;
} }
break; break;
case RiaEclipseUnitTools::UNITS_FIELD: case RiaEclipseUnitTools::UNITS_FIELD:
switch (flowPhase) switch (flowPhase)
{ {
case FLOW_PHASE_GAS: unitText = "[BOE/day]"; break; case FLOW_PHASE_GAS:
unitText = "[BOE/day]";
break;
case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit
case FLOW_PHASE_OIL: unitText = "[BBL/day]"; break; case FLOW_PHASE_OIL:
default: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; unitText = "[BBL/day]";
break;
default:
unitText = "[Liquid BBL/day], [Gas BOE/day]";
break;
} }
break; break;
case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm<sup>3</sup>/hr]"; break; case RiaEclipseUnitTools::UNITS_LAB:
default: break; unitText = "[cm<sup>3</sup>/hr]";
break;
default:
break;
} }
} }
@ -940,12 +965,14 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& wellPathNameOrSimWellName, void RimWellPlotTools::calculateValueOptionsForTimeSteps(
const QString& wellPathNameOrSimWellName,
const std::vector<RifDataSourceForRftPlt>& selSources, const std::vector<RifDataSourceForRftPlt>& selSources,
const std::set<RifEclipseRftAddress::RftWellLogChannelType>& interestingRFTResults, const std::set<RifEclipseRftAddress::RftWellLogChannelType>& interestingRFTResults,
QList<caf::PdmOptionItemInfo>& options) QList<caf::PdmOptionItemInfo>& options)
{ {
auto timestepsToShowWithSources = calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults); auto timestepsToShowWithSources =
calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults);
// Create formatted options of all the time steps // Create formatted options of all the time steps
QString dateFormatString; QString dateFormatString;
@ -967,10 +994,17 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& wellPath
for (const auto& source : timeStepPair.second) for (const auto& source : timeStepPair.second)
{ {
switch (source.sourceType()){ switch (source.sourceType())
case RifDataSourceForRftPlt::OBSERVED: hasObs = true; break; {
case RifDataSourceForRftPlt::RFT : hasRft = true; break; case RifDataSourceForRftPlt::OBSERVED:
case RifDataSourceForRftPlt::GRID : hasGrid = true; break; hasObs = true;
break;
case RifDataSourceForRftPlt::RFT:
hasRft = true;
break;
case RifDataSourceForRftPlt::GRID:
hasGrid = true;
break;
} }
} }