Create LGR : Use all well cells if no completions are defined (#7285)

* #7274 Create LGR : Use all well cells if no completions are defined

* #7263  Create LGR : Not working in console mode 

Guard access to RiaApplication

* Add pytest for create_lgr_for_completion

* Add pytest for create_lgr_for_completion

* #7289 Script : Add execute of last used script

* #7291 Python : Guard access to RiaMainWindow
This commit is contained in:
Magne Sjaastad 2021-01-26 20:34:31 +01:00 committed by GitHub
parent f8aae6691d
commit 0ec612ae86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 101 additions and 20 deletions

View File

@ -33,11 +33,11 @@
#include "RiuViewer.h"
#include "cafPdmUiTreeView.h"
#include "cafProgressState.h"
#include <QTimer>
#include <QTreeView>
#include "cafProgressState.h"
#include <set>
//--------------------------------------------------------------------------------------------------
@ -112,8 +112,13 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType()
std::set<RimEclipseCase*> uniqueCases( m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end() );
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex();
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
QModelIndex mi;
if ( RiuMainWindow::instance() )
{
mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex();
}
for ( RimEclipseCase* eclipseCase : uniqueCases )
{
@ -138,10 +143,13 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType()
if ( activeView && activeView->viewer() )
{
RiaApplication::instance()->setActiveReservoirView( activeView );
RiuMainWindow::instance()->setActiveViewer( activeView->viewer()->layoutWidget() );
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->setActiveViewer( activeView->viewer()->layoutWidget() );
}
}
if ( mi.isValid() )
if ( mi.isValid() && RiuMainWindow::instance() )
{
RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex( mi );
}
@ -155,6 +163,14 @@ RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler()
delete m_recalculateCompletionTypeTimer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaCompletionTypeCalculationScheduler::RiaCompletionTypeCalculationScheduler()
: m_recalculateCompletionTypeTimer( nullptr )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,9 @@
class QTimer;
class RimEclipseCase;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaCompletionTypeCalculationScheduler : public QObject
{
Q_OBJECT;
@ -40,10 +43,7 @@ private slots:
void slotRecalculateCompletionType();
private:
RiaCompletionTypeCalculationScheduler()
: m_recalculateCompletionTypeTimer( nullptr )
{
}
RiaCompletionTypeCalculationScheduler();
~RiaCompletionTypeCalculationScheduler() override;
RiaCompletionTypeCalculationScheduler( const RiaCompletionTypeCalculationScheduler& o ) = delete;

View File

@ -476,6 +476,13 @@ std::vector<LgrInfo>
{
auto intersectingCells =
cellsIntersectingCompletions( eclipseCase, wellPath, timeStep, completionTypes, &isIntersectingOtherLgrs );
if ( intersectingCells.empty() )
{
// Find all grid cells intersected by well path
intersectingCells = allIntersectedCells( eclipseCase, wellPath );
}
auto newLgrs = buildLgrsPerMainCell( firstLgrId + (int)lgrs.size(),
eclipseCase,
wellPath,
@ -494,13 +501,15 @@ std::vector<LgrInfo>
timeStep,
completionTypes,
wellsIntersectingOtherLgrs );
auto newLgrs = buildLgrsPerCompletion( firstLgrId + (int)lgrs.size(),
eclipseCase,
intersectingCells,
lgrCellCounts,
lgrNameFactory );
lgrs.insert( lgrs.end(), newLgrs.begin(), newLgrs.end() );
if ( !intersectingCells.empty() )
{
auto newLgrs = buildLgrsPerCompletion( firstLgrId + (int)lgrs.size(),
eclipseCase,
intersectingCells,
lgrCellCounts,
lgrNameFactory );
lgrs.insert( lgrs.end(), newLgrs.begin(), newLgrs.end() );
}
}
else if ( splitType == Lgr::LGR_PER_WELL )
{
@ -511,11 +520,23 @@ std::vector<LgrInfo>
auto intersectingCells =
cellsIntersectingCompletions( eclipseCase, wellPath, timeStep, completionTypes, &isIntersectingOtherLgrs );
lgrs.push_back( buildLgr( lgrId, lgrName, eclipseCase, wellPath->name(), intersectingCells, lgrCellCounts ) );
if ( intersectingCells.empty() )
{
// Find all grid cells intersected by well path
intersectingCells = allIntersectedCells( eclipseCase, wellPath );
}
if ( !intersectingCells.empty() )
{
lgrs.push_back(
buildLgr( lgrId, lgrName, eclipseCase, wellPath->name(), intersectingCells, lgrCellCounts ) );
}
if ( isIntersectingOtherLgrs ) wellsIntersectingOtherLgrs->push_back( wellPath->name() );
}
}
return lgrs;
}
@ -745,6 +766,28 @@ std::map<CompletionInfo, std::vector<RigCompletionDataGridCell>>
return completionToCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigCompletionDataGridCell> RicExportLgrFeature::allIntersectedCells( RimEclipseCase* eclipseCase,
const RimWellPath* wellPath )
{
std::vector<RigCompletionDataGridCell> cells;
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
auto globalCellIndices =
RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( eclipseCase->eclipseCaseData(),
wellPath->wellPathGeometry()->wellPathPoints() );
for ( const auto& globalCellIndex : globalCellIndices )
{
cells.push_back( RigCompletionDataGridCell( globalCellIndex, mainGrid ) );
}
return cells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -228,6 +228,9 @@ private:
const std::set<RigCompletionData::CompletionType>& completionTypes,
QStringList* wellsIntersectingOtherLgrs );
static std::vector<RigCompletionDataGridCell> allIntersectedCells( RimEclipseCase* eclipseCase,
const RimWellPath* wellPath );
static int firstAvailableLgrId( const RigMainGrid* mainGrid );
static const RigGridBase* hostGrid( const RigMainGrid* mainGrid, size_t reservoirCellIndex );
};

View File

@ -114,9 +114,13 @@ void RicCreateTemporaryLgrFeature::createLgrsForWellPaths( std::vector<RimWellPa
//--------------------------------------------------------------------------------------------------
void RicCreateTemporaryLgrFeature::updateViews( RimEclipseCase* eclipseCase )
{
RiaGuiApplication* app = RiaGuiApplication::instance();
RiaGuiApplication* guiApp = nullptr;
if ( RiaGuiApplication::isRunning() )
{
guiApp = RiaGuiApplication::instance();
}
app->clearAllSelections();
if ( guiApp ) guiApp->clearAllSelections();
deleteAllCachedData( eclipseCase );
RimProject::current()->mainPlotCollection()->deleteAllCachedData();
@ -124,7 +128,7 @@ void RicCreateTemporaryLgrFeature::updateViews( RimEclipseCase* eclipseCase )
RimProject::current()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots();
eclipseCase->createDisplayModelAndUpdateAllViews();
if ( guiApp ) eclipseCase->createDisplayModelAndUpdateAllViews();
}
//--------------------------------------------------------------------------------------------------

View File

View File

@ -8,3 +8,18 @@ sys.path.insert(1, os.path.join(sys.path[0], '../../'))
import rips
import dataroot
def test_create_lgr_well(rips_instance, initialize_test):
case = rips_instance.project.load_case(
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
assert(case.name == "TEST10K_FLT_LGR_NNC")
assert(len(case.grids()) == 2)
well_files=[dataroot.PATH + "/TEST10K_FLT_LGR_NNC/wellpath_a.dev"]
rips_instance.project.import_well_paths(well_path_files=well_files)
time_step=5
well_path_names=["Well Path A"]
case.create_lgr_for_completion(time_step, well_path_names, refinement_i=2, refinement_j=3,refinement_k=1, split_type="LGR_PER_WELL")
assert(len(case.grids()) == 3)