mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-03 12:10:57 -06:00
#6773 Regression Test : Add more input validation due to missing files
Running regression tests without valid external files revealed several crashes. Add guarding and remove asserts to make sure regression tests can be executed without crash.
This commit is contained in:
parent
b4a879c637
commit
a6af4fbd00
@ -235,7 +235,7 @@ void RivGridBoxGenerator::updateFromCamera( const cvf::Camera* camera )
|
||||
{
|
||||
m_gridBoxModel->removeAllParts();
|
||||
|
||||
if ( m_gridBoxFaceParts.size() == 0 ) return;
|
||||
if ( m_gridBoxFaceParts.empty() ) return;
|
||||
|
||||
std::vector<bool> faceVisibility( 6, false );
|
||||
for ( size_t i = POS_X; i <= NEG_Z; i++ )
|
||||
@ -263,17 +263,20 @@ void RivGridBoxGenerator::updateFromCamera( const cvf::Camera* camera )
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<bool> edgeVisibility( 12, false );
|
||||
computeEdgeVisibility( faceVisibility, edgeVisibility );
|
||||
|
||||
CVF_ASSERT( m_gridBoxLegendParts.size() == ( NEG_X_NEG_Y + 1 ) * 2 );
|
||||
for ( size_t i = POS_Z_POS_X; i <= NEG_X_NEG_Y; i++ )
|
||||
if ( !m_gridBoxLegendParts.empty() )
|
||||
{
|
||||
if ( edgeVisibility[i] )
|
||||
std::vector<bool> edgeVisibility( 12, false );
|
||||
computeEdgeVisibility( faceVisibility, edgeVisibility );
|
||||
|
||||
CVF_ASSERT( m_gridBoxLegendParts.size() == ( NEG_X_NEG_Y + 1 ) * 2 );
|
||||
for ( size_t i = POS_Z_POS_X; i <= NEG_X_NEG_Y; i++ )
|
||||
{
|
||||
// We have two parts for each edge - line and text
|
||||
m_gridBoxModel->addPart( m_gridBoxLegendParts[2 * i].p() );
|
||||
m_gridBoxModel->addPart( m_gridBoxLegendParts[2 * i + 1].p() );
|
||||
if ( edgeVisibility[i] )
|
||||
{
|
||||
// We have two parts for each edge - line and text
|
||||
m_gridBoxModel->addPart( m_gridBoxLegendParts[2 * i].p() );
|
||||
m_gridBoxModel->addPart( m_gridBoxLegendParts[2 * i + 1].p() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,6 +495,11 @@ void RivGridBoxGenerator::createLegend( EdgeType edge, cvf::Collection<cvf::Part
|
||||
cvf::Vec3d min = m_displayCoordsBoundingBox.min();
|
||||
cvf::Vec3d max = m_displayCoordsBoundingBox.max();
|
||||
|
||||
if ( min == max )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AxisType axis = X_AXIS;
|
||||
|
||||
cvf::Vec3f tickMarkDir = cvf::Vec3f::X_AXIS;
|
||||
|
@ -721,6 +721,8 @@ std::set<time_t> RimAnalysisPlot::allAvailableTimeSteps()
|
||||
|
||||
for ( RimSummaryCase* sumCase : timestepDefiningSourceCases() )
|
||||
{
|
||||
if ( !sumCase || !sumCase->summaryReader() ) continue;
|
||||
|
||||
const std::vector<time_t>& timeSteps = sumCase->summaryReader()->timeSteps( RifEclipseSummaryAddress() );
|
||||
|
||||
for ( time_t t : timeSteps )
|
||||
|
@ -650,6 +650,7 @@ void RimFlowCharacteristicsPlot::onLoadDataAndUpdate()
|
||||
if ( m_flowDiagSolution && m_flowCharPlotWidget )
|
||||
{
|
||||
RigFlowDiagResults* flowResult = m_flowDiagSolution->flowDiagResults();
|
||||
if ( !flowResult ) return;
|
||||
|
||||
{
|
||||
std::vector<int> calculatedTimesteps = flowResult->calculatedTimeSteps( RigFlowDiagResultAddress::PHASE_ALL );
|
||||
|
@ -100,7 +100,10 @@ RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults()
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType( eclCase );
|
||||
|
||||
CVF_ASSERT( eclCase && eclCase->eclipseCaseData() );
|
||||
if ( !eclCase || !eclCase->eclipseCaseData() )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
timeStepCount =
|
||||
eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->maxTimeStepCount();
|
||||
|
@ -555,15 +555,18 @@ std::set<QDateTime> RimWellPlotTools::availableSimWellTimesteps( RimEclipseCase*
|
||||
{
|
||||
std::set<QDateTime> availebleTimeSteps;
|
||||
|
||||
std::vector<QDateTime> allTimeSteps =
|
||||
eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->timeStepDates();
|
||||
const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData( simWellName );
|
||||
|
||||
for ( size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx )
|
||||
if ( eclCase && eclCase->eclipseCaseData() )
|
||||
{
|
||||
if ( simWell->hasWellResult( tsIdx ) || ( addFirstReportTimestep && tsIdx == 0 ) )
|
||||
std::vector<QDateTime> allTimeSteps =
|
||||
eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->timeStepDates();
|
||||
const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData( simWellName );
|
||||
|
||||
for ( size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx )
|
||||
{
|
||||
availebleTimeSteps.insert( allTimeSteps[tsIdx] );
|
||||
if ( simWell->hasWellResult( tsIdx ) || ( addFirstReportTimestep && tsIdx == 0 ) )
|
||||
{
|
||||
availebleTimeSteps.insert( allTimeSteps[tsIdx] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,11 @@ void RimWellPltPlot::setPlotXAxisTitles( RimWellLogTrack* plotTrack )
|
||||
std::set<RiaEclipseUnitTools::UnitSystem> presentUnitSystems;
|
||||
for ( const RifDataSourceForRftPlt& source : m_selectedSources.v() )
|
||||
{
|
||||
if ( source.eclCase() ) presentUnitSystems.insert( source.eclCase()->eclipseCaseData()->unitsType() );
|
||||
if ( source.eclCase() && source.eclCase()->eclipseCaseData() )
|
||||
{
|
||||
presentUnitSystems.insert( source.eclCase()->eclipseCaseData()->unitsType() );
|
||||
}
|
||||
|
||||
if ( source.wellLogFile() )
|
||||
{
|
||||
if ( source.wellLogFile()->wellLogFileData() )
|
||||
|
@ -1075,7 +1075,7 @@ QString RimEclipseCase::timeStepName( int frameIdx ) const
|
||||
double RimEclipseCase::characteristicCellSize() const
|
||||
{
|
||||
const RigEclipseCaseData* rigEclipseCase = eclipseCaseData();
|
||||
if ( rigEclipseCase )
|
||||
if ( rigEclipseCase && rigEclipseCase->mainGrid() )
|
||||
{
|
||||
return rigEclipseCase->mainGrid()->characteristicIJCellSize();
|
||||
}
|
||||
|
@ -1884,15 +1884,12 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT( rimEclipseCase );
|
||||
if ( !rimEclipseCase ) return;
|
||||
|
||||
RigEclipseCaseData* eclipseCaseData = rimEclipseCase->eclipseCaseData();
|
||||
CVF_ASSERT( eclipseCaseData );
|
||||
if ( !eclipseCaseData ) return;
|
||||
|
||||
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( this->porosityModel() );
|
||||
CVF_ASSERT( cellResultsData );
|
||||
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
@ -2039,11 +2036,9 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
|
||||
|
||||
// Ternary legend update
|
||||
{
|
||||
CVF_ASSERT( rimEclipseCase );
|
||||
if ( !rimEclipseCase ) return;
|
||||
|
||||
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
|
||||
CVF_ASSERT( eclipseCase );
|
||||
if ( !eclipseCase ) return;
|
||||
|
||||
RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() );
|
||||
|
@ -210,9 +210,10 @@ cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterfac
|
||||
|
||||
RimEclipseView* eclipseView;
|
||||
this->firstAncestorOrThisOfType( eclipseView );
|
||||
if ( eclipseView )
|
||||
if ( eclipseView && eclipseView->mainGrid() )
|
||||
{
|
||||
RigMainGrid* grid = eclipseView->mainGrid();
|
||||
|
||||
return new RivEclipseIntersectionGrid( grid, eclipseView->currentActiveCellInfo(), this->isInactiveCellsVisible() );
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,11 @@ void RimSimWellInView::wellHeadTopBottomPosition( int frameIndex, cvf::Vec3d* to
|
||||
RimEclipseView* m_rimReservoirView;
|
||||
firstAncestorOrThisOfTypeAsserted( m_rimReservoirView );
|
||||
|
||||
if ( !m_rimReservoirView->eclipseCase() || !m_rimReservoirView->eclipseCase()->eclipseCaseData() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData();
|
||||
|
||||
const RigWellResultFrame* wellResultFramePtr = nullptr;
|
||||
|
@ -864,7 +864,7 @@ bool RimViewController::isRangeFilterMappingApplicable() const
|
||||
|
||||
if ( eclipseView && geomView )
|
||||
{
|
||||
if ( eclipseView->eclipseCase()->eclipseCaseData() && geomView->geoMechCase() &&
|
||||
if ( eclipseView->eclipseCase() && eclipseView->eclipseCase()->eclipseCaseData() && geomView->geoMechCase() &&
|
||||
geomView->geoMechCase()->geoMechData() )
|
||||
{
|
||||
RigMainGrid* eclGrid = eclipseView->mainGrid();
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
QString porosityModelName = args[4];
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( rimCase == nullptr )
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() )
|
||||
{
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID: \"%1\"" ).arg( caseId ) );
|
||||
|
Loading…
Reference in New Issue
Block a user