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"
|
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"
|
|
|
|
#include "RimEclipseCaseCollection.h"
|
2018-05-09 01:39:36 -05:00
|
|
|
#include "RimEclipseView.h"
|
2018-01-12 04:31:01 -06:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#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()
|
|
|
|
{
|
2018-05-08 07:21:16 -05:00
|
|
|
std::vector<RimEclipseCase*> eclipseCases =
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject::current()->activeOilField()->analysisModels->cases().childObjects();
|
2018-01-12 04:31:01 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
scheduleRecalculateCompletionTypeAndRedrawAllViews( eclipseCases );
|
2018-01-12 04:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews( RimEclipseCase* eclipseCase )
|
2018-01-12 04:31:01 -06:00
|
|
|
{
|
2018-05-08 07:21:16 -05:00
|
|
|
std::vector<RimEclipseCase*> eclipseCases;
|
2019-09-06 03:40:57 -05:00
|
|
|
eclipseCases.push_back( eclipseCase );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-05-09 01:39:36 -05:00
|
|
|
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews(
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<RimEclipseCase*>& eclipseCases )
|
2018-05-08 07:21:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseCase* eclipseCase : eclipseCases )
|
2018-05-08 07:21:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( eclipseCase );
|
2018-05-08 07:21:16 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( eclipseCase->eclipseCaseData() )
|
2018-05-08 07:21:16 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
eclipseCase->eclipseCaseData()
|
2020-04-23 23:53:06 -05:00
|
|
|
->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
|
2021-01-21 05:58:46 -06:00
|
|
|
->clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
|
|
|
|
RiaResultNames::completionTypeResultName() );
|
2018-05-09 01:39:36 -05:00
|
|
|
|
|
|
|
// Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type
|
2019-09-06 03:40:57 -05:00
|
|
|
eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities( nullptr );
|
2018-05-08 07:21:16 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_eclipseCasesToRecalculate.push_back( eclipseCase );
|
2018-05-08 07:21:16 -05:00
|
|
|
}
|
2018-01-12 04:31:01 -06:00
|
|
|
|
2018-04-20 06:20:46 -05:00
|
|
|
startTimer();
|
2018-01-12 04:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-16 04:09:03 -06:00
|
|
|
///
|
2018-01-12 04:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType()
|
|
|
|
{
|
2018-05-21 16:46:35 -05:00
|
|
|
if ( caf::ProgressState::isActive() )
|
|
|
|
{
|
|
|
|
startTimer();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-01-26 13:34:31 -06:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
|
|
|
|
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
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& w : eclipseCase->views() )
|
2018-05-09 01:39:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( w );
|
|
|
|
if ( eclView )
|
2018-06-27 07:21:08 -05:00
|
|
|
{
|
|
|
|
eclView->calculateCompletionTypeAndRedrawIfRequired();
|
|
|
|
}
|
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.
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
delete m_recalculateCompletionTypeTimer;
|
|
|
|
}
|
2018-04-20 06:20:46 -05:00
|
|
|
|
2021-01-26 13:34:31 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiaCompletionTypeCalculationScheduler::RiaCompletionTypeCalculationScheduler()
|
|
|
|
: m_recalculateCompletionTypeTimer( nullptr )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-04-20 06:20:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-05-08 07:21:16 -05:00
|
|
|
///
|
2018-04-20 06:20:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaCompletionTypeCalculationScheduler::startTimer()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_recalculateCompletionTypeTimer )
|
2018-04-20 06:20:46 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_recalculateCompletionTypeTimer = new QTimer( this );
|
|
|
|
m_recalculateCompletionTypeTimer->setSingleShot( true );
|
|
|
|
connect( m_recalculateCompletionTypeTimer, SIGNAL( timeout() ), this, SLOT( slotRecalculateCompletionType() ) );
|
2018-04-20 06:20:46 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_recalculateCompletionTypeTimer->start( 1500 );
|
2018-04-20 06:20:46 -05:00
|
|
|
}
|