2018-01-12 04:31:01 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-01-09 08:15:34 -06:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2018-01-16 04:09:03 -06:00
|
|
|
//
|
2018-01-12 04:31:01 -06:00
|
|
|
// 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.
|
2018-01-16 04:09:03 -06:00
|
|
|
//
|
2018-01-12 04:31:01 -06:00
|
|
|
// 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.
|
2018-01-16 04:09:03 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-01-12 04:31:01 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RiaCompletionTypeCalculationScheduler.h"
|
2018-04-20 06:20:46 -05:00
|
|
|
|
2018-01-16 04:09:03 -06:00
|
|
|
#include "RiaApplication.h"
|
2023-05-11 01:37:58 -05:00
|
|
|
#include "RiaResultNames.h"
|
2018-04-20 06:20:46 -05:00
|
|
|
|
2018-05-09 01:39:36 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RigEclipseCaseData.h"
|
2018-05-08 07:21:16 -05:00
|
|
|
|
2018-01-12 04:31:01 -06:00
|
|
|
#include "RimEclipseCase.h"
|
2018-05-09 01:39:36 -05:00
|
|
|
#include "RimEclipseView.h"
|
2018-01-12 04:31:01 -06:00
|
|
|
#include "RimProject.h"
|
2018-04-20 06:20:46 -05:00
|
|
|
|
2018-01-12 04:31:01 -06:00
|
|
|
#include "RiuMainWindow.h"
|
2018-01-16 04:09:03 -06:00
|
|
|
#include "RiuViewer.h"
|
|
|
|
|
2018-01-12 04:31:01 -06:00
|
|
|
#include "cafPdmUiTreeView.h"
|
2021-01-26 13:34:31 -06:00
|
|
|
#include "cafProgressState.h"
|
2018-01-16 04:09:03 -06:00
|
|
|
|
|
|
|
#include <QTimer>
|
2018-01-12 04:31:01 -06:00
|
|
|
#include <QTreeView>
|
2018-01-16 04:09:03 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include <set>
|
2018-01-12 04:31:01 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::instance()
|
|
|
|
{
|
2018-01-16 04:09:03 -06:00
|
|
|
static RiaCompletionTypeCalculationScheduler theInstance;
|
|
|
|
|
2018-01-12 04:31:01 -06:00
|
|
|
return &theInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews()
|
|
|
|
{
|
2022-11-18 05:50:04 -06:00
|
|
|
auto eclipseCases = RimProject::current()->eclipseCases();
|
2018-05-08 07:21:16 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
scheduleRecalculateCompletionTypeAndRedrawAllViews( eclipseCases );
|
2018-05-08 07:21:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews( const std::vector<RimEclipseCase*>& eclipseCases )
|
2018-05-08 07:21:16 -05:00
|
|
|
{
|
2022-05-05 04:29:07 -05:00
|
|
|
clearCompletionTypeResults( eclipseCases );
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseCase* eclipseCase : eclipseCases )
|
2018-05-08 07:21:16 -05:00
|
|
|
{
|
2022-05-05 04:29:07 -05:00
|
|
|
if ( eclipseCase ) m_eclipseCasesToRecalculate.emplace_back( eclipseCase );
|
|
|
|
}
|
2018-05-09 01:39:36 -05:00
|
|
|
|
2022-05-05 04:29:07 -05:00
|
|
|
startTimer( 0 );
|
|
|
|
}
|
2018-05-08 07:21:16 -05:00
|
|
|
|
2022-05-05 04:29:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaCompletionTypeCalculationScheduler::clearCompletionTypeResultsInAllCases()
|
|
|
|
{
|
2022-11-18 05:50:04 -06:00
|
|
|
auto eclipseCases = RimProject::current()->eclipseCases();
|
2018-01-12 04:31:01 -06:00
|
|
|
|
2022-05-05 04:29:07 -05:00
|
|
|
clearCompletionTypeResults( eclipseCases );
|
2022-11-18 05:50:04 -06:00
|
|
|
|
|
|
|
// Clear geometry cache in views to recreate potential property filter geometry
|
|
|
|
for ( auto eclipseCase : eclipseCases )
|
|
|
|
{
|
|
|
|
if ( !eclipseCase ) continue;
|
|
|
|
|
|
|
|
for ( auto view : eclipseCase->views() )
|
|
|
|
{
|
|
|
|
if ( auto eclipseView = dynamic_cast<RimEclipseView*>( view ) )
|
|
|
|
{
|
|
|
|
eclipseView->scheduleReservoirGridGeometryRegen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-12 04:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-05-05 04:29:07 -05:00
|
|
|
void RiaCompletionTypeCalculationScheduler::clearCompletionTypeResults( const std::vector<RimEclipseCase*>& eclipseCases )
|
2018-01-12 04:31:01 -06:00
|
|
|
{
|
2022-05-05 04:29:07 -05:00
|
|
|
for ( RimEclipseCase* eclipseCase : eclipseCases )
|
2018-05-21 16:46:35 -05:00
|
|
|
{
|
2022-05-05 04:29:07 -05:00
|
|
|
if ( !eclipseCase || !eclipseCase->eclipseCaseData() ) continue;
|
|
|
|
|
|
|
|
eclipseCase->eclipseCaseData()
|
|
|
|
->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
|
|
|
|
->clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::completionTypeResultName() );
|
|
|
|
|
|
|
|
// Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type
|
|
|
|
eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities( nullptr );
|
2018-05-21 16:46:35 -05:00
|
|
|
}
|
2022-05-05 04:29:07 -05:00
|
|
|
}
|
2018-05-21 16:46:35 -05:00
|
|
|
|
2022-05-05 04:29:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaCompletionTypeCalculationScheduler::performScheduledUpdates()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::set<RimEclipseCase*> uniqueCases( m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end() );
|
2018-01-12 04:31:01 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseCase* eclipseCase : uniqueCases )
|
2018-01-12 04:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( eclipseCase )
|
2018-05-09 01:39:36 -05:00
|
|
|
{
|
2022-11-18 05:50:04 -06:00
|
|
|
for ( auto view : eclipseCase->views() )
|
2018-05-09 01:39:36 -05:00
|
|
|
{
|
2022-11-18 05:50:04 -06:00
|
|
|
if ( auto eclipseView = dynamic_cast<RimEclipseView*>( view ) )
|
2018-06-27 07:21:08 -05:00
|
|
|
{
|
2022-11-18 05:50:04 -06:00
|
|
|
eclipseView->calculateCompletionTypeAndRedrawIfRequired();
|
2018-06-27 07:21:08 -05:00
|
|
|
}
|
2018-05-09 01:39:36 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-12 04:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
m_eclipseCasesToRecalculate.clear();
|
|
|
|
|
|
|
|
// Recalculation of completion type causes active view to be set to potentially a different view
|
|
|
|
// Also current index in project tree is changed. Restore both to initial state.
|
|
|
|
|
2022-11-18 05:50:04 -06:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( activeView && activeView->viewer() )
|
2018-01-12 04:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication::instance()->setActiveReservoirView( activeView );
|
2021-01-26 13:34:31 -06:00
|
|
|
if ( RiuMainWindow::instance() )
|
|
|
|
{
|
|
|
|
RiuMainWindow::instance()->setActiveViewer( activeView->viewer()->layoutWidget() );
|
|
|
|
}
|
2018-01-12 04:31:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler()
|
|
|
|
{
|
|
|
|
}
|
2018-04-20 06:20:46 -05:00
|
|
|
|
2021-01-26 13:34:31 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiaCompletionTypeCalculationScheduler::RiaCompletionTypeCalculationScheduler()
|
|
|
|
{
|
|
|
|
}
|