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