#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
QString dateFormatString;
{
std::vector<QDateTime> allTimeSteps;
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
for ( const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources )
{
allTimeSteps.push_back(timeStepPair.first);
}
const QString dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
}
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
{
@ -836,11 +837,11 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN
}
optionText += " \t[ ";
if (hasObs) optionText += "O ";
if (hasRft) optionText += "R ";
if (hasGrid) optionText += "G";
optionText += " ]";
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_GAS, "PHASE_GAS", "Gas");
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()->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", "", "", "");
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.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
this->setAsPlotMdiWindow();
m_doInitAfterLoad = false;
@ -492,12 +495,20 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
RimProject* proj = RiaApplication::instance()->project();
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
for (const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs)
{
std::set<FlowPhase> selectedPhases = m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT ?
std::set<FlowPhase>(m_phases().begin(), m_phases().end()) :
std::set<FlowPhase>({ FLOW_PHASE_TOTAL });
std::set<FlowPhase> selectedPhases = std::set<FlowPhase>(m_phases().begin(), m_phases().end()) ;
RifDataSourceForRftPlt sourceDef = curveDefToAdd.address();
QDateTime timeStep = curveDefToAdd.timeStep();
@ -509,7 +520,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
curveName += sourceDef.eclCase() ? sourceDef.eclCase()->caseUserDescription() : "";
curveName += sourceDef.wellLogFile() ? sourceDef.wellLogFile()->name() : "";
if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) curveName += ", RFT";
curveName += ", " + timeStep.toString();
curveName += ", " + timeStep.toString(dateFormatString);
}
if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT )
@ -523,21 +534,44 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
resultPointCalc.reset(new RigSimWellResultPointCalculator(m_wellPathName,
dynamic_cast<RimEclipseResultCase*>(sourceDef.eclCase()),
timeStep));
}
if (resultPointCalc != nullptr)
{
if ( resultPointCalc->pipeBranchCLCoords().size() )
{
RigAccWellFlowCalculator wfAccumulator(resultPointCalc->pipeBranchCLCoords(),
if ( selectedPhases.count(FLOW_PHASE_TOTAL)
&& m_useReservoirConditionCurves()
&& sourceDef.sourceType() == RifDataSourceForRftPlt::GRID )
{
RigAccWellFlowCalculator wfTotalAccumulator(resultPointCalc->pipeBranchCLCoords(),
resultPointCalc->pipeBranchWellResultPoints(),
resultPointCalc->pipeBranchMeasuredDepths(),
false); // m_phaseSelectionMode() != FLOW_TYPE_PHASE_SPLIT); The total flow is reservoir conditions must be careful
true);
const std::vector<double>& depthValues = wfAccumulator.pseudoLengthFromTop(0);
std::vector<QString> tracerNames = wfAccumulator.tracerNames();
const std::vector<double>& depthValues = wfTotalAccumulator.pseudoLengthFromTop(0);
const std::vector<double> accFlow = wfTotalAccumulator.accumulatedTracerFlowPrPseudoLength(RIG_FLOW_TOTAL_NAME, 0);
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 )
{
auto color = tracerName == RIG_FLOW_OIL_NAME ? cvf::Color3f::DARK_GREEN :
@ -547,11 +581,10 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
if ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count(FLOW_PHASE_OIL)
|| tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count(FLOW_PHASE_GAS)
|| tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER)
|| tracerName == RIG_FLOW_TOTAL_NAME && selectedPhases.count(FLOW_PHASE_TOTAL) )
|| tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER) )
{
const std::vector<double> accFlow = wfAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0);
addStackedCurve(curveName + ", " + tracerName,
const std::vector<double> accFlow = wfPhaseAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0);
addStackedCurve(curveName + ", " + tracerName + " [S]",
depthValues,
accFlow,
plotTrack,
@ -562,50 +595,62 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
}
}
}
}
else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::OBSERVED )
{
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;
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);
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();
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);
if (selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0)
if ( selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0 )
{
auto color = RimWellPlotTools::isOilFlowChannel(channelName) ? cvf::Color3f::DARK_GREEN :
RimWellPlotTools::isGasFlowChannel(channelName) ? cvf::Color3f::DARK_RED :
RimWellPlotTools::isWaterFlowChannel(channelName) ? cvf::Color3f::BLUE :
cvf::Color3f::DARK_GRAY;
addStackedCurve(curveName + ", " + channelName,
addStackedCurve(curveName + ", " + channelName + conditionName,
depthValues,
channelData[std::get<2>(channelInfo)],
plotTrack,
color,
curveGroupId,
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);
}
if (fieldNeedingOptions == &m_phaseSelectionMode)
{
}
else if (fieldNeedingOptions == &m_phases)
if (fieldNeedingOptions == &m_phases)
{
options.push_back(caf::PdmOptionItemInfo("Oil", FLOW_PHASE_OIL));
options.push_back(caf::PdmOptionItemInfo("Gas", FLOW_PHASE_GAS));
options.push_back(caf::PdmOptionItemInfo("Water", FLOW_PHASE_WATER));
options.push_back(caf::PdmOptionItemInfo("Total", FLOW_PHASE_TOTAL));
}
return options;
@ -847,8 +890,9 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
//m_wellLogPlot->setShowDescription(m_showPlotTitle);
}
if (changedField == &m_phaseSelectionMode ||
changedField == &m_phases)
if ( changedField == &m_useStandardConditionCurves
|| changedField == &m_useReservoirConditionCurves
|| changedField == &m_phases)
{
syncCurvesFromUiSelection();
}
@ -894,15 +938,11 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
timeStepsGroup->add(&m_selectedTimeSteps);
caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Phase Selection", "PhaseSelection");
flowGroup->add(&m_phaseSelectionMode);
caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Curve Selection", "PhaseSelection");
flowGroup->add(&m_useStandardConditionCurves);
flowGroup->add(&m_useReservoirConditionCurves);
if (m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT)
{
flowGroup->add(&m_phases);
}
//uiOrdering.add(&m_showPlotTitle);
if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0)
{

View File

@ -144,7 +144,8 @@ private:
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;
bool m_doInitAfterLoad;

View File

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