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"
|
2023-04-14 04:00:45 -05:00
|
|
|
#include "RigWellResultFrame.h"
|
2020-02-03 05:20:35 -06:00
|
|
|
|
|
|
|
#include "Rim3dView.h"
|
|
|
|
#include "RimEclipseResultCase.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
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-03-03 08:28:34 -06:00
|
|
|
RimSummaryCase* RimSimWellInViewTools::summaryCaseForWell( RimSimWellInView* well )
|
2020-02-03 05:20:35 -06:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( !project ) return nullptr;
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr;
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( !sumCaseColl ) return nullptr;
|
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
auto eclCase = well->firstAncestorOrThisOfType<RimEclipseResultCase>();
|
2020-02-03 05:20:35 -06:00
|
|
|
if ( eclCase )
|
|
|
|
{
|
2023-03-03 08:28:34 -06:00
|
|
|
return sumCaseColl->findSummaryCaseFromEclipseResultCase( eclCase );
|
2020-02-03 05:20:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2023-02-26 03:48:40 -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 )
|
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto rimView = well->firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
2020-02-03 05:20:35 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-04-14 04:00:45 -05:00
|
|
|
if ( RiaDefines::isInjector( wrf->productionType() ) )
|
2020-02-03 05:20:35 -06:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-03-31 03:04:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSimWellInViewTools::isProducer( RimSimWellInView* well )
|
|
|
|
{
|
|
|
|
RigSimWellData* wRes = well->simWellData();
|
|
|
|
if ( wRes )
|
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto rimView = well->firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
2023-03-31 03:04:17 -05:00
|
|
|
|
|
|
|
int currentTimeStep = rimView->currentTimeStep();
|
|
|
|
|
|
|
|
if ( wRes->hasWellResult( currentTimeStep ) )
|
|
|
|
{
|
|
|
|
const RigWellResultFrame* wrf = wRes->wellResultFrame( currentTimeStep );
|
|
|
|
|
2023-04-14 04:00:45 -05:00
|
|
|
if ( RiaDefines::WellProductionType::PRODUCER == wrf->productionType() )
|
2023-03-31 03:04:17 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-03 05:20:35 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-14 04:18:10 -05:00
|
|
|
auto addr = RifEclipseSummaryAddress::wellAddress( vectorName, wellName.toStdString(), -1 );
|
2020-02-03 05:20:35 -06:00
|
|
|
|
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;
|
|
|
|
}
|