mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
The depth-related geometry results (DEPTH/DX/DY/DZ/TOPS/BOTTOM) are derived purely from the shared grid geometry and were computed independently for the matrix and fracture porosity models. For dual-porosity cases this recomputed the identical per-cell geometry twice. Replace the per-model computeDepthRelatedResults() with a single static routine that traverses the shared main grid once, computing each cell's geometry a single time and writing it to every porosity model in which the cell is active. The per-property already-computed guards and the temporary-grid recompute path are preserved, so the stored values are unchanged. All six matrix+fracture call sites now go through a thin RigEclipseCaseData::computeDepthRelatedResults() wrapper.
236 lines
8.4 KiB
C++
236 lines
8.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2017 Statoil ASA
|
|
//
|
|
// 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.
|
|
//
|
|
// 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.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RigReservoirGridTools.h"
|
|
|
|
#include "RiaGuiApplication.h"
|
|
|
|
#include "RifReaderInterface.h"
|
|
|
|
#include "RigActiveCellInfo.h"
|
|
#include "RigCaseCellResultsData.h"
|
|
#include "RigEclipseCaseData.h"
|
|
#include "RigFemPartCollection.h"
|
|
#include "RigFemPartGrid.h"
|
|
#include "RigGeoMechCaseData.h"
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseResultCase.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimGeoMechCase.h"
|
|
#include "RimGridCollection.h"
|
|
#include "RimMainPlotCollection.h"
|
|
#include "RimWellLogPlotCollection.h"
|
|
|
|
#include <QString>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
int RigReservoirGridTools::gridCount( RimCase* rimCase )
|
|
{
|
|
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid( rimCase );
|
|
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection( rimCase );
|
|
|
|
if ( eclipseMainGrid )
|
|
{
|
|
return static_cast<int>( eclipseMainGrid->gridCount() );
|
|
}
|
|
else if ( geoMechPartCollection )
|
|
{
|
|
return geoMechPartCollection->partCount();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const cvf::StructGridInterface* RigReservoirGridTools::mainGrid( RimCase* rimCase )
|
|
{
|
|
return gridByIndex( rimCase, 0 );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const cvf::StructGridInterface* RigReservoirGridTools::gridByIndex( RimCase* rimCase, int gridIndex )
|
|
{
|
|
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid( rimCase );
|
|
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection( rimCase );
|
|
|
|
if ( eclipseMainGrid )
|
|
{
|
|
return eclipseMainGrid->gridByIndex( gridIndex );
|
|
}
|
|
else if ( geoMechPartCollection )
|
|
{
|
|
return geoMechPartCollection->part( gridIndex )->getOrCreateStructGrid();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RigReservoirGridTools::gridName( RimCase* rimCase, int gridIndex )
|
|
{
|
|
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid( rimCase );
|
|
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection( rimCase );
|
|
|
|
if ( eclipseMainGrid )
|
|
{
|
|
return eclipseMainGrid->gridByIndex( gridIndex )->gridName().c_str();
|
|
}
|
|
else if ( geoMechPartCollection )
|
|
{
|
|
return QString::number( gridIndex );
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RigActiveCellInfo* RigReservoirGridTools::activeCellInfo( Rim3dView* rimView )
|
|
{
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( rimView );
|
|
if ( eclipseView )
|
|
{
|
|
return eclipseView->currentActiveCellInfo();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigReservoirGridTools::refreshEclipseCaseDataAndViews( RimEclipseCase* eclipseCase )
|
|
{
|
|
RiaGuiApplication* guiApp = nullptr;
|
|
if ( RiaGuiApplication::isRunning() )
|
|
{
|
|
guiApp = RiaGuiApplication::instance();
|
|
}
|
|
|
|
if ( guiApp ) RiaGuiApplication::clearAllSelections();
|
|
|
|
deleteAllCachedData( eclipseCase );
|
|
RimMainPlotCollection::current()->deleteAllCachedData();
|
|
computeCachedData( eclipseCase );
|
|
|
|
for ( auto view : eclipseCase->reservoirViews() )
|
|
{
|
|
if ( view && view->gridCollection() )
|
|
{
|
|
view->gridCollection()->syncFromMainEclipseGrid();
|
|
}
|
|
}
|
|
|
|
RimMainPlotCollection::current()->wellLogPlotCollection()->loadDataAndUpdateAllPlots();
|
|
|
|
if ( guiApp ) eclipseCase->createDisplayModelAndUpdateAllViews();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigMainGrid* RigReservoirGridTools::eclipseMainGrid( RimCase* rimCase )
|
|
{
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase );
|
|
if ( eclipseCase && eclipseCase->eclipseCaseData() )
|
|
{
|
|
return eclipseCase->eclipseCaseData()->mainGrid();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigFemPartCollection* RigReservoirGridTools::geoMechPartCollection( RimCase* rimCase )
|
|
{
|
|
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>( rimCase );
|
|
if ( geoMechCase && geoMechCase->geoMechData() )
|
|
{
|
|
return geoMechCase->geoMechData()->femParts();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigReservoirGridTools::computeCachedData( RimEclipseCase* eclipseCase )
|
|
{
|
|
if ( !eclipseCase ) return;
|
|
|
|
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL );
|
|
|
|
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
|
|
if ( eclipseCaseData )
|
|
{
|
|
eclipseCaseData->mainGrid()->computeCachedData();
|
|
eclipseCase->computeActiveCellsBoundingBox();
|
|
}
|
|
|
|
RigCaseCellResultsData::computeDepthRelatedResults( cellResultsDataMatrix, cellResultsDataFracture );
|
|
|
|
if ( cellResultsDataMatrix )
|
|
{
|
|
cellResultsDataMatrix->computeCellVolumes();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigReservoirGridTools::deleteAllCachedData( RimEclipseCase* eclipseCase )
|
|
{
|
|
if ( !eclipseCase ) return;
|
|
|
|
std::vector<RiaDefines::ResultCatType> categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
|
|
|
|
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
if ( cellResultsDataMatrix )
|
|
{
|
|
cellResultsDataMatrix->freeAllocatedResultsData( categoriesToExclude, std::nullopt );
|
|
}
|
|
|
|
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL );
|
|
if ( cellResultsDataFracture )
|
|
{
|
|
cellResultsDataFracture->freeAllocatedResultsData( categoriesToExclude, std::nullopt );
|
|
}
|
|
|
|
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
|
|
if ( eclipseCaseData )
|
|
{
|
|
eclipseCaseData->clearWellCellsInGridCache();
|
|
eclipseCaseData->setVirtualPerforationTransmissibilities( nullptr );
|
|
}
|
|
}
|