mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -18,15 +18,15 @@
|
||||
|
||||
#include "RicCreateTemporaryLgrFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaCellDividingTools.h"
|
||||
#include "RiaCompletionTypeCalculationScheduler.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RicDeleteTemporaryLgrsFeature.h"
|
||||
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h"
|
||||
#include "ExportCommands/RicExportLgrFeature.h"
|
||||
#include "ExportCommands/RicExportLgrUi.h"
|
||||
#include "RicDeleteTemporaryLgrsFeature.h"
|
||||
|
||||
#include "RifEclipseDataTableFormatter.h"
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathCompletions.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "Riu3dSelectionManager.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
@@ -70,60 +70,64 @@
|
||||
#include <limits>
|
||||
#include <set>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::createLgrsForWellPaths(std::vector<RimWellPath*> wellPaths,
|
||||
RimEclipseCase* eclipseCase,
|
||||
size_t timeStep,
|
||||
caf::VecIjk lgrCellCounts,
|
||||
Lgr::SplitType splitType,
|
||||
const std::set<RigCompletionData::CompletionType>& completionTypes,
|
||||
QStringList* wellsIntersectingOtherLgrs)
|
||||
void RicCreateTemporaryLgrFeature::createLgrsForWellPaths( std::vector<RimWellPath*> wellPaths,
|
||||
RimEclipseCase* eclipseCase,
|
||||
size_t timeStep,
|
||||
caf::VecIjk lgrCellCounts,
|
||||
Lgr::SplitType splitType,
|
||||
const std::set<RigCompletionData::CompletionType>& completionTypes,
|
||||
QStringList* wellsIntersectingOtherLgrs )
|
||||
{
|
||||
auto eclipseCaseData = eclipseCase->eclipseCaseData();
|
||||
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
|
||||
RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL);
|
||||
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::MATRIX_MODEL );
|
||||
RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::FRACTURE_MODEL );
|
||||
|
||||
auto lgrs = RicExportLgrFeature::buildLgrsForWellPaths(
|
||||
wellPaths, eclipseCase, timeStep, lgrCellCounts, splitType, completionTypes, wellsIntersectingOtherLgrs);
|
||||
auto lgrs = RicExportLgrFeature::buildLgrsForWellPaths( wellPaths,
|
||||
eclipseCase,
|
||||
timeStep,
|
||||
lgrCellCounts,
|
||||
splitType,
|
||||
completionTypes,
|
||||
wellsIntersectingOtherLgrs );
|
||||
|
||||
for (const auto& lgr : lgrs)
|
||||
for ( const auto& lgr : lgrs )
|
||||
{
|
||||
createLgr(lgr, eclipseCase->eclipseCaseData()->mainGrid());
|
||||
createLgr( lgr, eclipseCase->eclipseCaseData()->mainGrid() );
|
||||
|
||||
size_t lgrCellCount = lgr.cellCount();
|
||||
|
||||
activeCellInfo->addLgr(lgrCellCount);
|
||||
if (fractureActiveCellInfo->reservoirActiveCellCount() > 0)
|
||||
activeCellInfo->addLgr( lgrCellCount );
|
||||
if ( fractureActiveCellInfo->reservoirActiveCellCount() > 0 )
|
||||
{
|
||||
fractureActiveCellInfo->addLgr(lgrCellCount);
|
||||
fractureActiveCellInfo->addLgr( lgrCellCount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::updateViews(RimEclipseCase* eclipseCase)
|
||||
void RicCreateTemporaryLgrFeature::updateViews( RimEclipseCase* eclipseCase )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
app->clearAllSelections();
|
||||
|
||||
deleteAllCachedData(eclipseCase);
|
||||
deleteAllCachedData( eclipseCase );
|
||||
RiaApplication::instance()->project()->mainPlotCollection()->deleteAllCachedData();
|
||||
computeCachedData(eclipseCase);
|
||||
computeCachedData( eclipseCase );
|
||||
|
||||
RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots();
|
||||
|
||||
for (const auto& v : eclipseCase->views())
|
||||
for ( const auto& v : eclipseCase->views() )
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(v);
|
||||
if (eclipseView)
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( v );
|
||||
if ( eclipseView )
|
||||
{
|
||||
eclipseView->scheduleReservoirGridGeometryRegen();
|
||||
}
|
||||
@@ -146,50 +150,51 @@ bool RicCreateTemporaryLgrFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked)
|
||||
void RicCreateTemporaryLgrFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellPath*> wellPaths = RicExportLgrFeature::selectedWellPaths();
|
||||
if (wellPaths.empty()) return;
|
||||
if ( wellPaths.empty() ) return;
|
||||
|
||||
QString dialogTitle = "Create Temporary LGR";
|
||||
|
||||
RimEclipseCase* defaultEclipseCase = nullptr;
|
||||
int defaultTimeStep = 0;
|
||||
auto activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeGridView());
|
||||
if (activeView)
|
||||
auto activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeGridView() );
|
||||
if ( activeView )
|
||||
{
|
||||
defaultEclipseCase = activeView->eclipseCase();
|
||||
defaultTimeStep = activeView->currentTimeStep();
|
||||
}
|
||||
|
||||
auto dialogData = RicExportLgrFeature::openDialog(dialogTitle, defaultEclipseCase, defaultTimeStep, true);
|
||||
if (dialogData)
|
||||
auto dialogData = RicExportLgrFeature::openDialog( dialogTitle, defaultEclipseCase, defaultTimeStep, true );
|
||||
if ( dialogData )
|
||||
{
|
||||
auto eclipseCase = dialogData->caseToApply();
|
||||
auto lgrCellCounts = dialogData->lgrCellCount();
|
||||
size_t timeStep = dialogData->timeStep();
|
||||
auto splitType = dialogData->splitType();
|
||||
auto eclipseCase = dialogData->caseToApply();
|
||||
auto lgrCellCounts = dialogData->lgrCellCount();
|
||||
size_t timeStep = dialogData->timeStep();
|
||||
auto splitType = dialogData->splitType();
|
||||
const auto completionTypes = dialogData->completionTypes();
|
||||
|
||||
RicDeleteTemporaryLgrsFeature::deleteAllTemporaryLgrs(eclipseCase);
|
||||
RicDeleteTemporaryLgrsFeature::deleteAllTemporaryLgrs( eclipseCase );
|
||||
|
||||
QStringList wellsIntersectingOtherLgrs;
|
||||
|
||||
createLgrsForWellPaths(wellPaths,
|
||||
createLgrsForWellPaths( wellPaths,
|
||||
eclipseCase,
|
||||
timeStep,
|
||||
lgrCellCounts,
|
||||
splitType,
|
||||
completionTypes,
|
||||
&wellsIntersectingOtherLgrs);
|
||||
&wellsIntersectingOtherLgrs );
|
||||
|
||||
updateViews(eclipseCase);
|
||||
updateViews( eclipseCase );
|
||||
|
||||
if (!wellsIntersectingOtherLgrs.empty())
|
||||
if ( !wellsIntersectingOtherLgrs.empty() )
|
||||
{
|
||||
QMessageBox::warning(nullptr,
|
||||
"LGR cells intersected",
|
||||
"At least one completion intersects with an LGR. No LGR(s) for those cells are produced");
|
||||
QMessageBox::
|
||||
warning( nullptr,
|
||||
"LGR cells intersected",
|
||||
"At least one completion intersects with an LGR. No LGR(s) for those cells are produced" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,30 +202,31 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicCreateTemporaryLgrFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Create Temporary LGR");
|
||||
actionToSetup->setIcon(QIcon(":/TempLGR16x16.png"));
|
||||
actionToSetup->setText( "Create Temporary LGR" );
|
||||
actionToSetup->setIcon( QIcon( ":/TempLGR16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Todo: Guarding, caching LGR corner nodes calculations
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::createLgr(const LgrInfo& lgrInfo, RigMainGrid* mainGrid)
|
||||
void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGrid* mainGrid )
|
||||
{
|
||||
int lgrId = lgrInfo.id;
|
||||
size_t totalCellCount = mainGrid->globalCellArray().size();
|
||||
size_t lgrCellCount = lgrInfo.cellCount();
|
||||
|
||||
// Create local grid and set properties
|
||||
RigLocalGrid* localGrid = new RigLocalGrid(mainGrid);
|
||||
localGrid->setAsTempGrid(true);
|
||||
localGrid->setAssociatedWellPathName(lgrInfo.associatedWellPathName.toStdString());
|
||||
localGrid->setGridId(lgrId);
|
||||
localGrid->setIndexToStartOfCells(totalCellCount);
|
||||
localGrid->setGridName(lgrInfo.name.toStdString());
|
||||
localGrid->setGridPointDimensions(cvf::Vec3st(lgrInfo.sizes.i() + 1, lgrInfo.sizes.j() + 1, lgrInfo.sizes.k() + 1));
|
||||
mainGrid->addLocalGrid(localGrid);
|
||||
RigLocalGrid* localGrid = new RigLocalGrid( mainGrid );
|
||||
localGrid->setAsTempGrid( true );
|
||||
localGrid->setAssociatedWellPathName( lgrInfo.associatedWellPathName.toStdString() );
|
||||
localGrid->setGridId( lgrId );
|
||||
localGrid->setIndexToStartOfCells( totalCellCount );
|
||||
localGrid->setGridName( lgrInfo.name.toStdString() );
|
||||
localGrid->setGridPointDimensions(
|
||||
cvf::Vec3st( lgrInfo.sizes.i() + 1, lgrInfo.sizes.j() + 1, lgrInfo.sizes.k() + 1 ) );
|
||||
mainGrid->addLocalGrid( localGrid );
|
||||
|
||||
size_t cellStartIndex = mainGrid->globalCellArray().size();
|
||||
size_t nodeStartIndex = mainGrid->nodes().size();
|
||||
@@ -228,56 +234,58 @@ void RicCreateTemporaryLgrFeature::createLgr(const LgrInfo& lgrInfo, RigMainGrid
|
||||
// Resize global cell and node arrays
|
||||
{
|
||||
RigCell defaultCell;
|
||||
defaultCell.setHostGrid(localGrid);
|
||||
mainGrid->globalCellArray().resize(cellStartIndex + lgrCellCount, defaultCell);
|
||||
mainGrid->nodes().resize(nodeStartIndex + lgrCellCount * 8, cvf::Vec3d(0, 0, 0));
|
||||
defaultCell.setHostGrid( localGrid );
|
||||
mainGrid->globalCellArray().resize( cellStartIndex + lgrCellCount, defaultCell );
|
||||
mainGrid->nodes().resize( nodeStartIndex + lgrCellCount * 8, cvf::Vec3d( 0, 0, 0 ) );
|
||||
}
|
||||
|
||||
auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell();
|
||||
size_t gridLocalCellIndex = 0;
|
||||
|
||||
// Loop through all new LGR cells
|
||||
for (size_t lgrK = 0; lgrK < lgrInfo.sizes.k(); lgrK++)
|
||||
for ( size_t lgrK = 0; lgrK < lgrInfo.sizes.k(); lgrK++ )
|
||||
{
|
||||
size_t mainK = lgrInfo.mainGridStartCell.k() + lgrK / lgrSizePerMainCell.k();
|
||||
|
||||
for (size_t lgrJ = 0; lgrJ < lgrInfo.sizes.j(); lgrJ++)
|
||||
for ( size_t lgrJ = 0; lgrJ < lgrInfo.sizes.j(); lgrJ++ )
|
||||
{
|
||||
size_t mainJ = lgrInfo.mainGridStartCell.j() + lgrJ / lgrSizePerMainCell.j();
|
||||
|
||||
for (size_t lgrI = 0; lgrI < lgrInfo.sizes.i(); lgrI++, gridLocalCellIndex++)
|
||||
for ( size_t lgrI = 0; lgrI < lgrInfo.sizes.i(); lgrI++, gridLocalCellIndex++ )
|
||||
{
|
||||
size_t mainI = lgrInfo.mainGridStartCell.i() + lgrI / lgrSizePerMainCell.i();
|
||||
|
||||
size_t mainCellIndex = mainGrid->cellIndexFromIJK(mainI, mainJ, mainK);
|
||||
auto& mainGridCell = mainGrid->globalCellArray()[mainCellIndex];
|
||||
mainGridCell.setSubGrid(localGrid);
|
||||
size_t mainCellIndex = mainGrid->cellIndexFromIJK( mainI, mainJ, mainK );
|
||||
auto& mainGridCell = mainGrid->globalCellArray()[mainCellIndex];
|
||||
mainGridCell.setSubGrid( localGrid );
|
||||
|
||||
RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex];
|
||||
cell.setGridLocalCellIndex(gridLocalCellIndex);
|
||||
cell.setParentCellIndex(mainCellIndex);
|
||||
cell.setGridLocalCellIndex( gridLocalCellIndex );
|
||||
cell.setParentCellIndex( mainCellIndex );
|
||||
|
||||
// Corner coordinates
|
||||
{
|
||||
size_t cIdx;
|
||||
std::array<cvf::Vec3d, 8> vertices;
|
||||
mainGrid->cellCornerVertices(mainCellIndex, vertices.data());
|
||||
mainGrid->cellCornerVertices( mainCellIndex, vertices.data() );
|
||||
|
||||
auto cellCounts = lgrInfo.sizesPerMainGridCell();
|
||||
auto lgrCoords =
|
||||
RiaCellDividingTools::createHexCornerCoords(vertices, cellCounts.i(), cellCounts.j(), cellCounts.k());
|
||||
auto lgrCoords = RiaCellDividingTools::createHexCornerCoords( vertices,
|
||||
cellCounts.i(),
|
||||
cellCounts.j(),
|
||||
cellCounts.k() );
|
||||
|
||||
size_t subI = lgrI % lgrSizePerMainCell.i();
|
||||
size_t subJ = lgrJ % lgrSizePerMainCell.j();
|
||||
size_t subK = lgrK % lgrSizePerMainCell.k();
|
||||
|
||||
size_t subIndex =
|
||||
subI + subJ * lgrSizePerMainCell.i() + subK * lgrSizePerMainCell.i() * lgrSizePerMainCell.j();
|
||||
size_t subIndex = subI + subJ * lgrSizePerMainCell.i() +
|
||||
subK * lgrSizePerMainCell.i() * lgrSizePerMainCell.j();
|
||||
|
||||
for (cIdx = 0; cIdx < 8; ++cIdx)
|
||||
for ( cIdx = 0; cIdx < 8; ++cIdx )
|
||||
{
|
||||
auto& node = mainGrid->nodes()[nodeStartIndex + gridLocalCellIndex * 8 + cIdx];
|
||||
node.set(lgrCoords[subIndex * 8 + cIdx]);
|
||||
node.set( lgrCoords[subIndex * 8 + cIdx] );
|
||||
cell.cornerIndices()[cIdx] = nodeStartIndex + gridLocalCellIndex * 8 + cIdx;
|
||||
}
|
||||
}
|
||||
@@ -285,33 +293,33 @@ void RicCreateTemporaryLgrFeature::createLgr(const LgrInfo& lgrInfo, RigMainGrid
|
||||
}
|
||||
}
|
||||
|
||||
localGrid->setParentGrid(mainGrid);
|
||||
localGrid->setParentGrid( mainGrid );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCase)
|
||||
void RicCreateTemporaryLgrFeature::deleteAllCachedData( RimEclipseCase* eclipseCase )
|
||||
{
|
||||
if (eclipseCase)
|
||||
if ( eclipseCase )
|
||||
{
|
||||
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results(RiaDefines::MATRIX_MODEL);
|
||||
if (cellResultsDataMatrix)
|
||||
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results( RiaDefines::MATRIX_MODEL );
|
||||
if ( cellResultsDataMatrix )
|
||||
{
|
||||
cellResultsDataMatrix->freeAllocatedResultsData();
|
||||
}
|
||||
|
||||
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results(RiaDefines::FRACTURE_MODEL);
|
||||
if (cellResultsDataFracture)
|
||||
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results( RiaDefines::FRACTURE_MODEL );
|
||||
if ( cellResultsDataFracture )
|
||||
{
|
||||
cellResultsDataFracture->freeAllocatedResultsData();
|
||||
}
|
||||
|
||||
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
|
||||
if (eclipseCaseData)
|
||||
if ( eclipseCaseData )
|
||||
{
|
||||
eclipseCaseData->clearWellCellsInGridCache();
|
||||
eclipseCaseData->setVirtualPerforationTransmissibilities(nullptr);
|
||||
eclipseCaseData->setVirtualPerforationTransmissibilities( nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,30 +327,29 @@ void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateTemporaryLgrFeature::computeCachedData(RimEclipseCase* eclipseCase)
|
||||
void RicCreateTemporaryLgrFeature::computeCachedData( RimEclipseCase* eclipseCase )
|
||||
{
|
||||
if (eclipseCase)
|
||||
if ( eclipseCase )
|
||||
{
|
||||
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results(RiaDefines::MATRIX_MODEL);
|
||||
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results(RiaDefines::FRACTURE_MODEL);
|
||||
RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results( RiaDefines::MATRIX_MODEL );
|
||||
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results( RiaDefines::FRACTURE_MODEL );
|
||||
|
||||
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
|
||||
if (eclipseCaseData)
|
||||
if ( eclipseCaseData )
|
||||
{
|
||||
eclipseCaseData->mainGrid()->computeCachedData();
|
||||
eclipseCaseData->computeActiveCellBoundingBoxes();
|
||||
}
|
||||
|
||||
if (cellResultsDataMatrix)
|
||||
if ( cellResultsDataMatrix )
|
||||
{
|
||||
cellResultsDataMatrix->computeDepthRelatedResults();
|
||||
cellResultsDataMatrix->computeCellVolumes();
|
||||
}
|
||||
|
||||
if (cellResultsDataFracture)
|
||||
if ( cellResultsDataFracture )
|
||||
{
|
||||
cellResultsDataFracture->computeDepthRelatedResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user