mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5457 Bubble Plot : Guard null pointer access
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseView.h"
|
#include "RimEclipseView.h"
|
||||||
#include "RimExtrudedCurveIntersection.h"
|
#include "RimExtrudedCurveIntersection.h"
|
||||||
|
#include "RimGridSummaryCase.h"
|
||||||
#include "RimIntersectionCollection.h"
|
#include "RimIntersectionCollection.h"
|
||||||
#include "RimPropertyFilterCollection.h"
|
#include "RimPropertyFilterCollection.h"
|
||||||
#include "RimSimWellFracture.h"
|
#include "RimSimWellFracture.h"
|
||||||
@@ -646,11 +647,24 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
|
|||||||
currentDate = caseTimeSteps.back();
|
currentDate = caseTimeSteps.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RifSummaryReaderInterface* summaryReader = nullptr;
|
||||||
|
{
|
||||||
RimGridSummaryCase* gridSummaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( this );
|
RimGridSummaryCase* gridSummaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( this );
|
||||||
|
if ( gridSummaryCase )
|
||||||
|
{
|
||||||
|
summaryReader = gridSummaryCase->summaryReader();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !summaryReader )
|
||||||
|
{
|
||||||
|
m_isValidDisk = false;
|
||||||
|
return -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( wellDiskConfig.isSingleProperty() )
|
if ( wellDiskConfig.isSingleProperty() )
|
||||||
{
|
{
|
||||||
double singleProperty = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
|
double singleProperty = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
|
||||||
name(),
|
name(),
|
||||||
wellDiskConfig.getSingleProperty(),
|
wellDiskConfig.getSingleProperty(),
|
||||||
currentDate,
|
currentDate,
|
||||||
@@ -667,7 +681,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
|
|||||||
{
|
{
|
||||||
m_isInjector = RimSimWellInViewTools::gridSummaryCaseForWell( this );
|
m_isInjector = RimSimWellInViewTools::gridSummaryCaseForWell( this );
|
||||||
|
|
||||||
double oil = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
|
double oil = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
|
||||||
name(),
|
name(),
|
||||||
wellDiskConfig.getOilProperty(),
|
wellDiskConfig.getOilProperty(),
|
||||||
currentDate,
|
currentDate,
|
||||||
@@ -678,7 +692,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
|
|||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double gas = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
|
double gas = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
|
||||||
name(),
|
name(),
|
||||||
wellDiskConfig.getGasProperty(),
|
wellDiskConfig.getGasProperty(),
|
||||||
currentDate,
|
currentDate,
|
||||||
@@ -690,7 +704,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
|
|||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double water = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
|
double water = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
|
||||||
name(),
|
name(),
|
||||||
wellDiskConfig.getWaterProperty(),
|
wellDiskConfig.getWaterProperty(),
|
||||||
currentDate,
|
currentDate,
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ QList<caf::PdmOptionItemInfo>
|
|||||||
RimGridSummaryCase* summaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( wells[0] );
|
RimGridSummaryCase* summaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( wells[0] );
|
||||||
|
|
||||||
std::set<std::string> summaries;
|
std::set<std::string> summaries;
|
||||||
if ( summaryCase )
|
if ( summaryCase && summaryCase->summaryReader() )
|
||||||
{
|
{
|
||||||
auto addresses = summaryCase->summaryReader()->allResultAddresses();
|
auto addresses = summaryCase->summaryReader()->allResultAddresses();
|
||||||
for ( auto addr : addresses )
|
for ( auto addr : addresses )
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "RimSimWellInViewCollection.h"
|
#include "RimSimWellInViewCollection.h"
|
||||||
#include "RimSummaryCaseMainCollection.h"
|
#include "RimSummaryCaseMainCollection.h"
|
||||||
|
|
||||||
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -96,13 +98,15 @@ bool RimSimWellInViewTools::isInjector( RimSimWellInView* well )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridSummaryCase,
|
double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface* summaryReader,
|
||||||
const QString& wellName,
|
const QString& wellName,
|
||||||
const std::string& vectorName,
|
const std::string& vectorName,
|
||||||
const QDateTime& currentDate,
|
const QDateTime& currentDate,
|
||||||
bool* isOk )
|
bool* isOk )
|
||||||
|
|
||||||
{
|
{
|
||||||
|
CVF_ASSERT( summaryReader );
|
||||||
|
|
||||||
if ( vectorName.empty() )
|
if ( vectorName.empty() )
|
||||||
{
|
{
|
||||||
*isOk = true;
|
*isOk = true;
|
||||||
@@ -124,8 +128,7 @@ double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridS
|
|||||||
false,
|
false,
|
||||||
-1 );
|
-1 );
|
||||||
|
|
||||||
RifSummaryReaderInterface* reader = gridSummaryCase->summaryReader();
|
if ( !summaryReader->hasAddress( addr ) )
|
||||||
if ( !gridSummaryCase->summaryReader()->hasAddress( addr ) )
|
|
||||||
{
|
{
|
||||||
// TODO: better error handling
|
// TODO: better error handling
|
||||||
std::cerr << "ERROR: no address found for well " << wellName.toStdString() << " " << vectorName << std::endl;
|
std::cerr << "ERROR: no address found for well " << wellName.toStdString() << " " << vectorName << std::endl;
|
||||||
@@ -134,8 +137,8 @@ double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridS
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> values;
|
std::vector<double> values;
|
||||||
reader->values( addr, &values );
|
summaryReader->values( addr, &values );
|
||||||
std::vector<time_t> timeSteps = reader->timeSteps( addr );
|
std::vector<time_t> timeSteps = summaryReader->timeSteps( addr );
|
||||||
|
|
||||||
RiaTimeHistoryCurveResampler resampler;
|
RiaTimeHistoryCurveResampler resampler;
|
||||||
resampler.setCurveData( values, timeSteps );
|
resampler.setCurveData( values, timeSteps );
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class QDateTime;
|
|||||||
|
|
||||||
class RimSimWellInView;
|
class RimSimWellInView;
|
||||||
class RimGridSummaryCase;
|
class RimGridSummaryCase;
|
||||||
|
class RifSummaryReaderInterface;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@@ -36,7 +37,7 @@ public:
|
|||||||
static RimGridSummaryCase* gridSummaryCaseForWell( RimSimWellInView* well );
|
static RimGridSummaryCase* gridSummaryCaseForWell( RimSimWellInView* well );
|
||||||
static bool isInjector( RimSimWellInView* well );
|
static bool isInjector( RimSimWellInView* well );
|
||||||
|
|
||||||
static double extractValueForTimeStep( RimGridSummaryCase* gridSummaryCase,
|
static double extractValueForTimeStep( RifSummaryReaderInterface* summaryReader,
|
||||||
const QString& wellName,
|
const QString& wellName,
|
||||||
const std::string& vectorName,
|
const std::string& vectorName,
|
||||||
const QDateTime& currentDate,
|
const QDateTime& currentDate,
|
||||||
|
|||||||
Reference in New Issue
Block a user