mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#165 Use original days since simulation start when plotting time history curves
This commit is contained in:
parent
2c8358e9e9
commit
ad4657d610
@ -294,7 +294,6 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate()
|
|||||||
|
|
||||||
if (isCurveVisible())
|
if (isCurveVisible())
|
||||||
{
|
{
|
||||||
std::vector<time_t> dateTimes;
|
|
||||||
std::vector<double> values;
|
std::vector<double> values;
|
||||||
|
|
||||||
RimEclipseGeometrySelectionItem* eclTopItem = eclipseGeomSelectionItem();
|
RimEclipseGeometrySelectionItem* eclTopItem = eclipseGeomSelectionItem();
|
||||||
@ -309,40 +308,44 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate()
|
|||||||
m_geoMechResultDefinition->loadResult();
|
m_geoMechResultDefinition->loadResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
dateTimes = timeStepValues();
|
|
||||||
values = yValues();
|
values = yValues();
|
||||||
|
|
||||||
RimSummaryPlot* plot = nullptr;
|
RimSummaryPlot* plot = nullptr;
|
||||||
firstAncestorOrThisOfType(plot);
|
firstAncestorOrThisOfType(plot);
|
||||||
bool isLogCurve = plot->isLogarithmicScaleEnabled(this->yAxis());
|
bool isLogCurve = plot->isLogarithmicScaleEnabled(this->yAxis());
|
||||||
|
|
||||||
if (dateTimes.size() > 0 && dateTimes.size() == values.size())
|
|
||||||
{
|
|
||||||
if (plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE)
|
if (plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE)
|
||||||
|
{
|
||||||
|
std::vector<time_t> dateTimes = timeStepValues();
|
||||||
|
if (dateTimes.size() > 0 && dateTimes.size() == values.size())
|
||||||
{
|
{
|
||||||
m_qwtPlotCurve->setSamplesFromTimeTAndValues(dateTimes, values, isLogCurve);
|
m_qwtPlotCurve->setSamplesFromTimeTAndValues(dateTimes, values, isLogCurve);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double timeScale = plot->timeAxisProperties()->fromTimeTToDisplayUnitScale();
|
m_qwtPlotCurve->setSamplesFromTimeTAndValues(std::vector<time_t>(), std::vector<double>(), isLogCurve);
|
||||||
|
|
||||||
std::vector<double> times;
|
|
||||||
if (dateTimes.size())
|
|
||||||
{
|
|
||||||
time_t startDate = dateTimes[0];
|
|
||||||
for (time_t& date : dateTimes)
|
|
||||||
{
|
|
||||||
times.push_back(timeScale*(date - startDate));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_qwtPlotCurve->setSamplesFromTimeAndValues(times, values, isLogCurve);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::vector<double> days = daysSinceSimulationStart();
|
||||||
|
if (days.size() > 0 && days.size() == values.size())
|
||||||
|
{
|
||||||
|
double timeScale = plot->timeAxisProperties()->fromDaysToDisplayUnitScale();
|
||||||
|
|
||||||
|
std::vector<double> times;
|
||||||
|
for (double day : days)
|
||||||
|
{
|
||||||
|
times.push_back(timeScale * day);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_qwtPlotCurve->setSamplesFromTimeAndValues(times, values, isLogCurve);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_qwtPlotCurve->setSamplesFromTimeTAndValues(std::vector<time_t>(), std::vector<double>(), isLogCurve);
|
m_qwtPlotCurve->setSamplesFromTimeTAndValues(std::vector<time_t>(), std::vector<double>(), isLogCurve);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateZoomInParentPlot();
|
updateZoomInParentPlot();
|
||||||
|
|
||||||
@ -404,6 +407,56 @@ std::vector<time_t> RimGridTimeHistoryCurve::timeStepValues() const
|
|||||||
return dateTimes;
|
return dateTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<double> RimGridTimeHistoryCurve::daysSinceSimulationStart() const
|
||||||
|
{
|
||||||
|
std::vector<double> daysSinceSimulationStart;
|
||||||
|
RimEclipseGeometrySelectionItem* eclTopItem = eclipseGeomSelectionItem();
|
||||||
|
if (eclTopItem && eclTopItem->eclipseCase())
|
||||||
|
{
|
||||||
|
RimReservoirCellResultsStorage* cellResStorage = m_eclipseResultDefinition->currentGridCellResults();
|
||||||
|
RigCaseCellResultsData* cellResultsData = cellResStorage->cellResults();
|
||||||
|
|
||||||
|
daysSinceSimulationStart = cellResultsData->daysSinceSimulationStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
RimGeoMechGeometrySelectionItem* geoMechTopItem = geoMechGeomSelectionItem();
|
||||||
|
if (geoMechTopItem && geoMechTopItem->geoMechCase())
|
||||||
|
{
|
||||||
|
std::unique_ptr<RiuFemTimeHistoryResultAccessor> timeHistResultAccessor = femTimeHistoryResultAccessor();
|
||||||
|
if (timeHistResultAccessor)
|
||||||
|
{
|
||||||
|
std::vector<double> values = timeHistResultAccessor->timeHistoryValues();
|
||||||
|
|
||||||
|
QStringList stepNames = geoMechTopItem->geoMechCase()->timeStepStrings();
|
||||||
|
std::vector<QDateTime> dates = RimGeoMechCase::dateTimeVectorFromTimeStepStrings(stepNames);
|
||||||
|
if (dates.size() == values.size())
|
||||||
|
{
|
||||||
|
if (!dates.empty()) {
|
||||||
|
time_t startDate = dates[0].toTime_t();
|
||||||
|
double secondsToDaysConversion = (24.0 * 60.0 * 60.0);
|
||||||
|
for (QDateTime dt : dates)
|
||||||
|
{
|
||||||
|
double timeDifference = static_cast<double>(dt.toTime_t() - startDate);
|
||||||
|
daysSinceSimulationStart.push_back(timeDifference / secondsToDaysConversion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < values.size(); i++)
|
||||||
|
{
|
||||||
|
daysSinceSimulationStart.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return daysSinceSimulationStart;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
std::vector<double> yValues() const;
|
std::vector<double> yValues() const;
|
||||||
std::vector<time_t> timeStepValues() const;
|
std::vector<time_t> timeStepValues() const;
|
||||||
|
std::vector<double> daysSinceSimulationStart() const;
|
||||||
|
|
||||||
QString quantityName() const;
|
QString quantityName() const;
|
||||||
QString caseName() const;
|
QString caseName() const;
|
||||||
|
@ -278,6 +278,36 @@ double RimSummaryTimeAxisProperties::fromTimeTToDisplayUnitScale()
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double RimSummaryTimeAxisProperties::fromDaysToDisplayUnitScale()
|
||||||
|
{
|
||||||
|
double scale = 1.0;
|
||||||
|
switch (m_timeUnit())
|
||||||
|
{
|
||||||
|
case SECONDS:
|
||||||
|
scale = 60.0 * 60.0 * 24.0;
|
||||||
|
break;
|
||||||
|
case MINUTES:
|
||||||
|
scale = 60.0 * 24.0;
|
||||||
|
break;
|
||||||
|
case HOURS:
|
||||||
|
scale = 24.0;
|
||||||
|
break;
|
||||||
|
case DAYS:
|
||||||
|
break;
|
||||||
|
case YEARS:
|
||||||
|
scale = 1.0/365.2425;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CVF_ASSERT(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -69,6 +69,7 @@ public:
|
|||||||
TimeModeType timeMode() const { return m_timeMode(); }
|
TimeModeType timeMode() const { return m_timeMode(); }
|
||||||
void setTimeMode(TimeModeType val) { m_timeMode = val; }
|
void setTimeMode(TimeModeType val) { m_timeMode = val; }
|
||||||
double fromTimeTToDisplayUnitScale();
|
double fromTimeTToDisplayUnitScale();
|
||||||
|
double fromDaysToDisplayUnitScale();
|
||||||
|
|
||||||
double visibleRangeMin() const;
|
double visibleRangeMin() const;
|
||||||
double visibleRangeMax() const;
|
double visibleRangeMax() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user