2020-02-03 05:20:35 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimSimWellInViewTools.h"
|
|
|
|
|
2020-04-06 06:04:53 -05:00
|
|
|
#include "RiaLogging.h"
|
2020-02-03 05:20:35 -06:00
|
|
|
#include "RiaSummaryTools.h"
|
|
|
|
|
|
|
|
#include "RifEclipseSummaryAddress.h"
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
|
|
|
|
|
|
#include "RigSimWellData.h"
|
2021-05-26 04:31:47 -05:00
|
|
|
#include "RigWellResultPoint.h"
|
2020-02-03 05:20:35 -06:00
|
|
|
|
|
|
|
#include "Rim3dView.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimGridSummaryCase.h"
|
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSimWellInView.h"
|
|
|
|
#include "RimSimWellInViewCollection.h"
|
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
|
|
|
|
2020-02-03 06:44:45 -06:00
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridSummaryCase* RimSimWellInViewTools::gridSummaryCaseForWell( RimSimWellInView* well )
|
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( !project ) return nullptr;
|
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
RimSummaryCaseMainCollection* sumCaseColl =
|
|
|
|
project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr;
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( !sumCaseColl ) return nullptr;
|
|
|
|
|
|
|
|
RimEclipseResultCase* eclCase = nullptr;
|
|
|
|
well->firstAncestorOrThisOfType( eclCase );
|
|
|
|
if ( eclCase )
|
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
RimGridSummaryCase* gridSummaryCase =
|
|
|
|
dynamic_cast<RimGridSummaryCase*>( sumCaseColl->findSummaryCaseFromEclipseResultCase( eclCase ) );
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( gridSummaryCase )
|
|
|
|
{
|
|
|
|
return gridSummaryCase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-02-10 00:13:04 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryCase*> RimSimWellInViewTools::summaryCases()
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryCase*> cases;
|
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2020-02-10 00:13:04 -06:00
|
|
|
if ( project )
|
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
RimSummaryCaseMainCollection* sumCaseColl =
|
|
|
|
project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr;
|
2020-02-10 00:13:04 -06:00
|
|
|
if ( sumCaseColl )
|
|
|
|
{
|
|
|
|
cases = sumCaseColl->allSummaryCases();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cases;
|
|
|
|
}
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSimWellInViewTools::isInjector( RimSimWellInView* well )
|
|
|
|
{
|
|
|
|
RigSimWellData* wRes = well->simWellData();
|
|
|
|
if ( wRes )
|
|
|
|
{
|
|
|
|
Rim3dView* rimView = nullptr;
|
|
|
|
well->firstAncestorOrThisOfTypeAsserted( rimView );
|
|
|
|
|
|
|
|
int currentTimeStep = rimView->currentTimeStep();
|
|
|
|
|
|
|
|
if ( wRes->hasWellResult( currentTimeStep ) )
|
|
|
|
{
|
2021-05-26 04:31:47 -05:00
|
|
|
const RigWellResultFrame* wrf = wRes->wellResultFrame( currentTimeStep );
|
2020-02-03 05:20:35 -06:00
|
|
|
|
2021-05-26 05:35:20 -05:00
|
|
|
if ( RiaDefines::isInjector( wrf->m_productionType ) )
|
2020-02-03 05:20:35 -06:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-03 06:44:45 -06:00
|
|
|
double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface* summaryReader,
|
|
|
|
const QString& wellName,
|
|
|
|
const std::string& vectorName,
|
|
|
|
const QDateTime& currentDate,
|
|
|
|
bool* isOk )
|
2020-02-03 05:20:35 -06:00
|
|
|
|
|
|
|
{
|
2020-02-03 06:44:45 -06:00
|
|
|
CVF_ASSERT( summaryReader );
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( vectorName.empty() )
|
|
|
|
{
|
|
|
|
*isOk = true;
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RifEclipseSummaryAddress addr( RifEclipseSummaryAddress::SUMMARY_WELL,
|
|
|
|
vectorName,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
"",
|
|
|
|
wellName.toStdString(),
|
|
|
|
-1,
|
|
|
|
"",
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
false,
|
|
|
|
-1 );
|
|
|
|
|
2020-02-03 06:44:45 -06:00
|
|
|
if ( !summaryReader->hasAddress( addr ) )
|
2020-02-03 05:20:35 -06:00
|
|
|
{
|
2020-04-06 06:04:53 -05:00
|
|
|
QString message = "ERROR: no address found for well " + wellName + " " + QString::fromStdString( vectorName );
|
|
|
|
RiaLogging::warning( message );
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
*isOk = false;
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<double> values;
|
2020-02-03 06:44:45 -06:00
|
|
|
summaryReader->values( addr, &values );
|
|
|
|
std::vector<time_t> timeSteps = summaryReader->timeSteps( addr );
|
2020-02-12 07:24:23 -06:00
|
|
|
if ( values.empty() || timeSteps.empty() )
|
|
|
|
{
|
2020-04-06 06:04:53 -05:00
|
|
|
QString message = "ERROR: no data found for well " + wellName + " " + QString::fromStdString( vectorName );
|
|
|
|
RiaLogging::warning( message );
|
|
|
|
|
2020-02-12 07:24:23 -06:00
|
|
|
*isOk = false;
|
|
|
|
return 0.0;
|
|
|
|
}
|
2020-02-03 05:20:35 -06:00
|
|
|
|
2021-02-12 03:50:58 -06:00
|
|
|
auto [resampledTimeSteps, resampledValues] =
|
2022-03-14 03:18:48 -05:00
|
|
|
RiaSummaryTools::resampledValuesForPeriod( addr, timeSteps, values, RiaDefines::DateTimePeriod::DAY );
|
2020-04-30 00:27:56 -05:00
|
|
|
|
2021-02-22 00:55:37 -06:00
|
|
|
time_t currentTime_t = currentDate.toSecsSinceEpoch();
|
2020-04-30 00:27:56 -05:00
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
for ( unsigned int i = 0; i < resampledTimeSteps.size(); i++ )
|
|
|
|
{
|
2020-04-30 00:27:56 -05:00
|
|
|
if ( resampledTimeSteps[i] > currentTime_t )
|
2020-02-03 05:20:35 -06:00
|
|
|
{
|
|
|
|
*isOk = true;
|
|
|
|
return resampledValues[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-06 06:04:53 -05:00
|
|
|
QString message = "ERROR: no resampled values found for well " + wellName + " " + QString::fromStdString( vectorName );
|
|
|
|
RiaLogging::warning( message );
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
*isOk = false;
|
|
|
|
return -1;
|
|
|
|
}
|