mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-04 13:16:56 -06:00
This commit is contained in:
1 parent
6b2231478c
commit
1808745ea0
6 files changed
+251
-389
No files matched your search
@@ -40,6 +40,7 @@
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include <regex>
|
||||
#include "RimTools.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -691,3 +692,226 @@ bool RimWellPlotTools::tryMatchChannelName(const std::set<QString>& channelNames
|
||||
});
|
||||
return itr != channelNames.end();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName,
|
||||
const std::vector<QDateTime>& selectedTimeSteps,
|
||||
const std::set<RifEclipseRftAddress::RftWellLogChannelType>& interestingRFTResults,
|
||||
const std::vector<RifDataSourceForRftPlt>& selectedSourcesExpanded)
|
||||
{
|
||||
std::set<RiaRftPltCurveDefinition> curveDefs;
|
||||
|
||||
std::set<QDateTime> selectedTimeStepSet(selectedTimeSteps.begin(), selectedTimeSteps.end());
|
||||
|
||||
for ( const RifDataSourceForRftPlt& addr : selectedSourcesExpanded )
|
||||
{
|
||||
if ( addr.rftReader() )
|
||||
{
|
||||
std::set<QDateTime> rftTimes = addr.rftReader()->availableTimeSteps(simWellName, { RifEclipseRftAddress::ORAT,
|
||||
RifEclipseRftAddress::WRAT,
|
||||
RifEclipseRftAddress::GRAT });
|
||||
for ( const QDateTime& time : rftTimes )
|
||||
{
|
||||
if ( selectedTimeStepSet.count(time) )
|
||||
{
|
||||
curveDefs.insert(RiaRftPltCurveDefinition(addr, time));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase() )
|
||||
{
|
||||
std::set<QDateTime> timeSteps = RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName);
|
||||
|
||||
for ( const QDateTime& time : timeSteps )
|
||||
{
|
||||
if ( selectedTimeStepSet.count(time) )
|
||||
{
|
||||
curveDefs.insert(RiaRftPltCurveDefinition(addr, time));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( addr.sourceType() == RifDataSourceForRftPlt::OBSERVED )
|
||||
{
|
||||
if ( addr.wellLogFile() )
|
||||
{
|
||||
if ( selectedTimeStepSet.count(addr.wellLogFile()->date()) )
|
||||
{
|
||||
curveDefs.insert(RiaRftPltCurveDefinition(addr, addr.wellLogFile()->date()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return curveDefs;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellName,
|
||||
const std::vector<RifDataSourceForRftPlt>& selSources,
|
||||
const std::set<RifEclipseRftAddress::RftWellLogChannelType>& interestingRFTResults,
|
||||
QList<caf::PdmOptionItemInfo>& options)
|
||||
{
|
||||
//std::vector<RifDataSourceForRftPlt> selSources = selectedSourcesExpanded();
|
||||
bool hasObservedData = false;
|
||||
bool hasRftData = false;
|
||||
bool hasGridData = false;
|
||||
|
||||
for (const auto& source : selSources )
|
||||
{
|
||||
switch (source.sourceType())
|
||||
{
|
||||
case RifDataSourceForRftPlt::RFT:
|
||||
hasRftData = true;
|
||||
break;
|
||||
case RifDataSourceForRftPlt::GRID:
|
||||
hasGridData = true;
|
||||
break;
|
||||
case RifDataSourceForRftPlt::OBSERVED:
|
||||
hasObservedData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<QDateTime, std::set<RifDataSourceForRftPlt> > observedTimeStepsWithSources;
|
||||
std::map<QDateTime, std::set<RifDataSourceForRftPlt> > rftTimeStepsWithSources;
|
||||
std::map<QDateTime, std::set<RifDataSourceForRftPlt> > gridTimestepsWithSources;
|
||||
|
||||
|
||||
|
||||
if (hasObservedData)
|
||||
{
|
||||
for (const auto& source : selSources )
|
||||
{
|
||||
if (source.sourceType() == RifDataSourceForRftPlt::OBSERVED && source.wellLogFile())
|
||||
{
|
||||
observedTimeStepsWithSources[source.wellLogFile()->date()].insert(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasRftData)
|
||||
{
|
||||
for (const auto& source : selSources )
|
||||
{
|
||||
if (source.sourceType() == RifDataSourceForRftPlt::RFT && source.rftReader())
|
||||
{
|
||||
std::set<QDateTime> rftTimes = source.rftReader()->availableTimeSteps(simWellName, interestingRFTResults );
|
||||
for ( const QDateTime& date: rftTimes)
|
||||
{
|
||||
rftTimeStepsWithSources[date].insert(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasGridData )
|
||||
{
|
||||
for ( const auto& source : selSources )
|
||||
{
|
||||
if ( source.sourceType() == RifDataSourceForRftPlt::GRID && source.eclCase() )
|
||||
{
|
||||
std::set<QDateTime> wellTimeSteps = RimWellPlotTools::availableSimWellTimesteps(source.eclCase(), simWellName);
|
||||
|
||||
for ( const QDateTime& date: wellTimeSteps)
|
||||
{
|
||||
gridTimestepsWithSources[date].insert(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a time baseline add the equal or adjacent grid timesteps
|
||||
|
||||
std::map<QDateTime, std::set<RifDataSourceForRftPlt> > timestepsToShowWithSources;
|
||||
std::map<QDateTime, std::set<RifDataSourceForRftPlt> >* timeBaseline = nullptr;
|
||||
|
||||
if (hasObservedData)
|
||||
{
|
||||
timeBaseline = &observedTimeStepsWithSources;
|
||||
}
|
||||
else if (hasRftData)
|
||||
{
|
||||
timeBaseline = &rftTimeStepsWithSources;
|
||||
}
|
||||
|
||||
if (timeBaseline)
|
||||
{
|
||||
std::set<QDateTime> baseTimeSteps;
|
||||
for (const auto& dateSourceSetPair: *timeBaseline) baseTimeSteps.insert(dateSourceSetPair.first);
|
||||
std::set<QDateTime> rftTimeSteps;
|
||||
for (const auto& dateSourceSetPair: rftTimeStepsWithSources) rftTimeSteps.insert(dateSourceSetPair.first);
|
||||
std::set<QDateTime> gridTimeSteps;
|
||||
for (const auto& dateSourceSetPair: gridTimestepsWithSources) gridTimeSteps.insert(dateSourceSetPair.first);
|
||||
|
||||
std::set<QDateTime> filteredRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, rftTimeSteps);
|
||||
std::set<QDateTime> filteredGridTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps);
|
||||
|
||||
// Fill final map
|
||||
timestepsToShowWithSources = observedTimeStepsWithSources;
|
||||
|
||||
std::set<QDateTime>& allFilteredTimesteps = filteredRftTimeSteps;
|
||||
allFilteredTimesteps.insert(filteredGridTimeSteps.begin(), filteredGridTimeSteps.end());
|
||||
|
||||
for (const QDateTime& time: allFilteredTimesteps)
|
||||
{
|
||||
auto rftTimeSourceSetIt = rftTimeStepsWithSources.find(time);
|
||||
if ( rftTimeSourceSetIt != rftTimeStepsWithSources.end() )
|
||||
{
|
||||
std::set<RifDataSourceForRftPlt>& sourceSet = rftTimeSourceSetIt->second;
|
||||
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
|
||||
}
|
||||
|
||||
auto gridTimeSourceSetIt = gridTimestepsWithSources.find(time);
|
||||
if ( gridTimeSourceSetIt != gridTimestepsWithSources.end() )
|
||||
{
|
||||
std::set<RifDataSourceForRftPlt>& sourceSet = gridTimeSourceSetIt->second;
|
||||
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timestepsToShowWithSources = gridTimestepsWithSources;
|
||||
}
|
||||
|
||||
// Create formatted options of all the timesteps
|
||||
|
||||
std::vector<QDateTime> allTimeSteps;
|
||||
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
|
||||
{
|
||||
allTimeSteps.push_back(timeStepPair.first);
|
||||
}
|
||||
const QString dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
|
||||
|
||||
|
||||
for (const std::pair<QDateTime, std::set<RifDataSourceForRftPlt>>& timeStepPair : timestepsToShowWithSources)
|
||||
{
|
||||
QString optionText = timeStepPair.first.toString(dateFormatString);
|
||||
bool hasObs = false;
|
||||
bool hasRft = false;
|
||||
bool hasGrid = false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
optionText += " \t[ ";
|
||||
|
||||
if (hasObs) optionText += "O ";
|
||||
if (hasRft) optionText += "R ";
|
||||
if (hasGrid) optionText += "G";
|
||||
optionText += " ]";
|
||||
options.push_back(caf::PdmOptionItemInfo(optionText, timeStepPair.first));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user