#2119, #2072 Handle well flow condition and total flow

This commit is contained in:
Jacob Støren 2017-11-23 15:11:07 +01:00
parent 69a61a2cb8
commit eaefaf4980
4 changed files with 127 additions and 82 deletions

View File

@ -810,14 +810,15 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN
} }
// Create formatted options of all the timesteps // Create formatted options of all the timesteps
QString dateFormatString;
std::vector<QDateTime> allTimeSteps;
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
{ {
allTimeSteps.push_back(timeStepPair.first); std::vector<QDateTime> allTimeSteps;
for ( const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources )
{
allTimeSteps.push_back(timeStepPair.first);
}
dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
} }
const QString dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources) for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
{ {
@ -836,11 +837,11 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN
} }
optionText += " \t[ "; optionText += " \t[ ";
if (hasObs) optionText += "O "; if (hasObs) optionText += "O ";
if (hasRft) optionText += "R "; if (hasRft) optionText += "R ";
if (hasGrid) optionText += "G"; if (hasGrid) optionText += "G";
optionText += " ]"; optionText += " ]";
options.push_back(caf::PdmOptionItemInfo(optionText, timeStepPair.first)); options.push_back(caf::PdmOptionItemInfo(optionText, timeStepPair.first));
} }
} }

View File

@ -87,6 +87,7 @@ void caf::AppEnum< FlowPhase>::setUp()
addItem(FLOW_PHASE_OIL, "PHASE_OIL", "Oil"); addItem(FLOW_PHASE_OIL, "PHASE_OIL", "Oil");
addItem(FLOW_PHASE_GAS, "PHASE_GAS", "Gas"); addItem(FLOW_PHASE_GAS, "PHASE_GAS", "Gas");
addItem(FLOW_PHASE_WATER, "PHASE_WATER", "Water"); addItem(FLOW_PHASE_WATER, "PHASE_WATER", "Water");
addItem(FLOW_PHASE_TOTAL, "PHASE_TOTAL", "Total");
} }
} }
@ -128,11 +129,13 @@ RimWellPltPlot::RimWellPltPlot()
m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue(false); m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue(false);
CAF_PDM_InitFieldNoDefault(&m_phaseSelectionMode, "PhaseSelectionMode", "Mode", "", "", ""); CAF_PDM_InitField(&m_useStandardConditionCurves, "showStandardConditionCurves", true, "Standard Volume", "", "", "");
CAF_PDM_InitField(&m_useReservoirConditionCurves, "showReservoirConditionCurves", true, "Reservoir Volume", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_phases, "Phases", "Phases", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_phases, "Phases", "Phases", "", "", "");
m_phases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); m_phases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
m_phases = std::vector<caf::AppEnum<FlowPhase>>({ FLOW_PHASE_OIL, FLOW_PHASE_GAS, FLOW_PHASE_WATER }); m_phases = std::vector<caf::AppEnum<FlowPhase>>({ FLOW_PHASE_OIL, FLOW_PHASE_GAS, FLOW_PHASE_WATER });
m_phases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
this->setAsPlotMdiWindow(); this->setAsPlotMdiWindow();
m_doInitAfterLoad = false; m_doInitAfterLoad = false;
@ -492,12 +495,20 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
RimProject* proj = RiaApplication::instance()->project(); RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = RimWellPlotTools::wellPathByWellPathNameOrSimWellName(m_wellPathName); RimWellPath* wellPath = RimWellPlotTools::wellPathByWellPathNameOrSimWellName(m_wellPathName);
QString dateFormatString;
{
std::vector<QDateTime> allTimeSteps;
for ( const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs )
{
allTimeSteps.push_back(curveDefToAdd.timeStep());
}
dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
}
// Add curves // Add curves
for (const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs) for (const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs)
{ {
std::set<FlowPhase> selectedPhases = m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT ? std::set<FlowPhase> selectedPhases = std::set<FlowPhase>(m_phases().begin(), m_phases().end()) ;
std::set<FlowPhase>(m_phases().begin(), m_phases().end()) :
std::set<FlowPhase>({ FLOW_PHASE_TOTAL });
RifDataSourceForRftPlt sourceDef = curveDefToAdd.address(); RifDataSourceForRftPlt sourceDef = curveDefToAdd.address();
QDateTime timeStep = curveDefToAdd.timeStep(); QDateTime timeStep = curveDefToAdd.timeStep();
@ -506,10 +517,10 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
QString curveName; QString curveName;
{ {
curveName += sourceDef.eclCase() ? sourceDef.eclCase()->caseUserDescription() : ""; curveName += sourceDef.eclCase() ? sourceDef.eclCase()->caseUserDescription() : "";
curveName += sourceDef.wellLogFile() ? sourceDef.wellLogFile()->name() : ""; curveName += sourceDef.wellLogFile() ? sourceDef.wellLogFile()->name() : "";
if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) curveName += ", RFT"; if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) curveName += ", RFT";
curveName += ", " + timeStep.toString(); curveName += ", " + timeStep.toString(dateFormatString);
} }
if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT )
@ -523,41 +534,64 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
resultPointCalc.reset(new RigSimWellResultPointCalculator(m_wellPathName, resultPointCalc.reset(new RigSimWellResultPointCalculator(m_wellPathName,
dynamic_cast<RimEclipseResultCase*>(sourceDef.eclCase()), dynamic_cast<RimEclipseResultCase*>(sourceDef.eclCase()),
timeStep)); timeStep));
} }
if (resultPointCalc != nullptr) if (resultPointCalc != nullptr)
{ {
if ( resultPointCalc->pipeBranchCLCoords().size() ) if ( resultPointCalc->pipeBranchCLCoords().size() )
{ {
if ( selectedPhases.count(FLOW_PHASE_TOTAL)
RigAccWellFlowCalculator wfAccumulator(resultPointCalc->pipeBranchCLCoords(), && m_useReservoirConditionCurves()
resultPointCalc->pipeBranchWellResultPoints(), && sourceDef.sourceType() == RifDataSourceForRftPlt::GRID )
resultPointCalc->pipeBranchMeasuredDepths(),
false); // m_phaseSelectionMode() != FLOW_TYPE_PHASE_SPLIT); The total flow is reservoir conditions must be careful
const std::vector<double>& depthValues = wfAccumulator.pseudoLengthFromTop(0);
std::vector<QString> tracerNames = wfAccumulator.tracerNames();
for ( const QString& tracerName: tracerNames )
{ {
auto color = tracerName == RIG_FLOW_OIL_NAME ? cvf::Color3f::DARK_GREEN : RigAccWellFlowCalculator wfTotalAccumulator(resultPointCalc->pipeBranchCLCoords(),
tracerName == RIG_FLOW_GAS_NAME ? cvf::Color3f::DARK_RED : resultPointCalc->pipeBranchWellResultPoints(),
tracerName == RIG_FLOW_WATER_NAME ? cvf::Color3f::BLUE : resultPointCalc->pipeBranchMeasuredDepths(),
cvf::Color3f::DARK_GRAY; true);
if ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count(FLOW_PHASE_OIL) const std::vector<double>& depthValues = wfTotalAccumulator.pseudoLengthFromTop(0);
|| tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count(FLOW_PHASE_GAS)
|| tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER) const std::vector<double> accFlow = wfTotalAccumulator.accumulatedTracerFlowPrPseudoLength(RIG_FLOW_TOTAL_NAME, 0);
|| tracerName == RIG_FLOW_TOTAL_NAME && selectedPhases.count(FLOW_PHASE_TOTAL) ) addStackedCurve(curveName + ", " + RIG_FLOW_TOTAL_NAME + " [R]",
depthValues,
accFlow,
plotTrack,
cvf::Color3f::DARK_GRAY,
curveGroupId,
false);
curveGroupId++;
}
if ( m_useStandardConditionCurves() )
{
RigAccWellFlowCalculator wfPhaseAccumulator(resultPointCalc->pipeBranchCLCoords(),
resultPointCalc->pipeBranchWellResultPoints(),
resultPointCalc->pipeBranchMeasuredDepths(),
false);
const std::vector<double>& depthValues = wfPhaseAccumulator.pseudoLengthFromTop(0);
std::vector<QString> tracerNames = wfPhaseAccumulator.tracerNames();
for ( const QString& tracerName: tracerNames )
{ {
const std::vector<double> accFlow = wfAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0); auto color = tracerName == RIG_FLOW_OIL_NAME ? cvf::Color3f::DARK_GREEN :
addStackedCurve(curveName + ", " + tracerName, tracerName == RIG_FLOW_GAS_NAME ? cvf::Color3f::DARK_RED :
depthValues, tracerName == RIG_FLOW_WATER_NAME ? cvf::Color3f::BLUE :
accFlow, cvf::Color3f::DARK_GRAY;
plotTrack,
color, if ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count(FLOW_PHASE_OIL)
curveGroupId, || tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count(FLOW_PHASE_GAS)
false); || tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER) )
{
const std::vector<double> accFlow = wfPhaseAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0);
addStackedCurve(curveName + ", " + tracerName + " [S]",
depthValues,
accFlow,
plotTrack,
color,
curveGroupId,
false);
}
} }
} }
} }
@ -565,47 +599,58 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::OBSERVED ) else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::OBSERVED )
{ {
RimWellLogFile* const wellLogFile = sourceDef.wellLogFile(); RimWellLogFile* const wellLogFile = sourceDef.wellLogFile();
if ( wellLogFile ) if ( sourceDef.wellLogFile() && sourceDef.wellLogFile()->wellLogFileData() )
{ {
RigWellLogFile* wellLogFileData = wellLogFile->wellLogFileData(); RimWellLogFile::WellFlowCondition flowCondition = sourceDef.wellLogFile()->wellFlowRateCondition();
if ( wellLogFileData ) if ( (m_useStandardConditionCurves() && flowCondition == RimWellLogFile::WELL_FLOW_COND_STANDARD)
|| (m_useReservoirConditionCurves() && flowCondition == RimWellLogFile::WELL_FLOW_COND_RESERVOIR) )
{ {
std::vector<RimWellLogFileChannel*> channels = RimWellPlotTools::getFlowChannelsFromWellFile(wellLogFile); using ChannelValNameIdxTuple = std::tuple<double, QString, int> ;
std::multiset<std::tuple<double, QString, size_t> > sortedChannels; RigWellLogFile* wellLogFileData = sourceDef.wellLogFile()->wellLogFileData();
QStringList channelNames = wellLogFileData->wellLogChannelNames();
std::multiset< ChannelValNameIdxTuple > sortedChannels;
std::vector<std::vector<double> > channelData; std::vector<std::vector<double> > channelData;
channelData.resize(channels.size()); channelData.resize(channelNames.size());
for (size_t chIdx = 0; chIdx < channels.size(); ++chIdx) for ( int chIdx = 0; chIdx < channelNames.size(); ++chIdx )
{ {
QString channelName = channels[chIdx]->name(); QString channelName = channelNames[chIdx];
channelData[chIdx] = wellLogFileData->values(channelName); channelData[chIdx] = wellLogFileData->values(channelName);
if (channelData[chIdx].size()) if ( channelData[chIdx].size() )
{ {
sortedChannels.insert(std::tuple<double, QString, size_t>(-fabs(channelData[chIdx].front()), channelName, chIdx) ); sortedChannels.insert(ChannelValNameIdxTuple(-fabs(channelData[chIdx].front()), channelName, chIdx));
} }
} }
std::vector<double> depthValues = wellLogFileData->depthValues(); std::vector<double> depthValues = wellLogFileData->depthValues();
QString conditionName = (flowCondition == RimWellLogFile::WELL_FLOW_COND_RESERVOIR) ? " [R]" : " [S]";
for ( const std::tuple<double, QString, size_t>& channelInfo: sortedChannels ) for ( const ChannelValNameIdxTuple& channelInfo: sortedChannels )
{ {
const auto& channelName = std::get<1>(channelInfo); const auto& channelName = std::get<1>(channelInfo);
if (selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0) if ( selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0 )
{ {
auto color = RimWellPlotTools::isOilFlowChannel(channelName) ? cvf::Color3f::DARK_GREEN : auto color = RimWellPlotTools::isOilFlowChannel(channelName) ? cvf::Color3f::DARK_GREEN :
RimWellPlotTools::isGasFlowChannel(channelName) ? cvf::Color3f::DARK_RED : RimWellPlotTools::isGasFlowChannel(channelName) ? cvf::Color3f::DARK_RED :
RimWellPlotTools::isWaterFlowChannel(channelName) ? cvf::Color3f::BLUE : RimWellPlotTools::isWaterFlowChannel(channelName) ? cvf::Color3f::BLUE :
cvf::Color3f::DARK_GRAY; cvf::Color3f::DARK_GRAY;
addStackedCurve(curveName + ", " + channelName,
addStackedCurve(curveName + ", " + channelName + conditionName,
depthValues, depthValues,
channelData[std::get<2>(channelInfo)], channelData[std::get<2>(channelInfo)],
plotTrack, plotTrack,
color, color,
curveGroupId, curveGroupId,
true); true);
// Total flow channel will end up first, so just increment the group
// idx to make the rest of the phases group together
if ( RimWellPlotTools::isTotalFlowChannel(channelName) ) curveGroupId++;
} }
} }
} }
@ -797,14 +842,12 @@ QList<caf::PdmOptionItemInfo> RimWellPltPlot::calculateValueOptions(const caf::P
options); options);
} }
if (fieldNeedingOptions == &m_phaseSelectionMode) if (fieldNeedingOptions == &m_phases)
{
}
else if (fieldNeedingOptions == &m_phases)
{ {
options.push_back(caf::PdmOptionItemInfo("Oil", FLOW_PHASE_OIL)); options.push_back(caf::PdmOptionItemInfo("Oil", FLOW_PHASE_OIL));
options.push_back(caf::PdmOptionItemInfo("Gas", FLOW_PHASE_GAS)); options.push_back(caf::PdmOptionItemInfo("Gas", FLOW_PHASE_GAS));
options.push_back(caf::PdmOptionItemInfo("Water", FLOW_PHASE_WATER)); options.push_back(caf::PdmOptionItemInfo("Water", FLOW_PHASE_WATER));
options.push_back(caf::PdmOptionItemInfo("Total", FLOW_PHASE_TOTAL));
} }
return options; return options;
@ -847,8 +890,9 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
//m_wellLogPlot->setShowDescription(m_showPlotTitle); //m_wellLogPlot->setShowDescription(m_showPlotTitle);
} }
if (changedField == &m_phaseSelectionMode || if ( changedField == &m_useStandardConditionCurves
changedField == &m_phases) || changedField == &m_useReservoirConditionCurves
|| changedField == &m_phases)
{ {
syncCurvesFromUiSelection(); syncCurvesFromUiSelection();
} }
@ -894,15 +938,11 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps"); caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
timeStepsGroup->add(&m_selectedTimeSteps); timeStepsGroup->add(&m_selectedTimeSteps);
caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Phase Selection", "PhaseSelection"); caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Curve Selection", "PhaseSelection");
flowGroup->add(&m_phaseSelectionMode); flowGroup->add(&m_useStandardConditionCurves);
flowGroup->add(&m_useReservoirConditionCurves);
if (m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT) flowGroup->add(&m_phases);
{
flowGroup->add(&m_phases);
}
//uiOrdering.add(&m_showPlotTitle);
if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0) if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0)
{ {

View File

@ -144,7 +144,8 @@ private:
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot; caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot;
caf::PdmField<caf::AppEnum<FlowType>> m_phaseSelectionMode; caf::PdmField<bool> m_useStandardConditionCurves;
caf::PdmField<bool> m_useReservoirConditionCurves;
caf::PdmField<std::vector<caf::AppEnum<FlowPhase>>> m_phases; caf::PdmField<std::vector<caf::AppEnum<FlowPhase>>> m_phases;
bool m_doInitAfterLoad; bool m_doInitAfterLoad;

View File

@ -42,12 +42,6 @@ class RimWellLogFile : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
enum WellFlowCondition
{
WELL_FLOW_COND_RESERVOIR,
WELL_FLOW_COND_STANDARD
};
const static QDateTime DEFAULT_DATE_TIME; const static QDateTime DEFAULT_DATE_TIME;
public: public:
@ -70,6 +64,14 @@ public:
bool hasFlowData() const; bool hasFlowData() const;
enum WellFlowCondition
{
WELL_FLOW_COND_RESERVOIR,
WELL_FLOW_COND_STANDARD
};
RimWellLogFile::WellFlowCondition wellFlowRateCondition() const { return m_wellFlowCondition(); }
private: private:
virtual void setupBeforeSave() override; virtual void setupBeforeSave() override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
@ -90,7 +92,8 @@ private:
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;
caf::PdmField<QDateTime> m_date; caf::PdmField<QDateTime> m_date;
bool m_lasFileHasValidDate; bool m_lasFileHasValidDate;
caf::PdmField<caf::AppEnum<WellFlowCondition>> m_wellFlowCondition; caf::PdmField<caf::AppEnum<WellFlowCondition>>
m_wellFlowCondition;
caf::PdmField<QString> m_invalidDateMessage; caf::PdmField<QString> m_invalidDateMessage;
}; };