diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp index 6bc4f73384..b5cbcfe1a2 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp @@ -35,29 +35,29 @@ #include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimWellPath.h" #include "RimProject.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathCompletions.h" #include "RiuPlotMainWindow.h" -#include "RimPerforationInterval.h" -#include "RimFracture.h" #include "RimFishbonesMultipleSubs.h" +#include "RimFracture.h" +#include "RimPerforationInterval.h" #include -#include #include #include -#include +#include #include +#include #include #include #include -#include #include +#include #include @@ -66,12 +66,12 @@ CAF_CMD_SOURCE_INIT(RicExportLgrFeature, "RicExportLgrFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RicExportLgrUi* RicExportLgrFeature::openDialog(const QString& dialogTitle, RimEclipseCase* defaultCase, int defaultTimeStep) { - RiaApplication* app = RiaApplication::instance(); - RimProject* proj = app->project(); + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); QString startPath = app->lastUsedDialogDirectory("LGR_EXPORT_DIR"); if (startPath.isEmpty()) @@ -103,7 +103,8 @@ RicExportLgrUi* RicExportLgrFeature::openDialog(const QString& dialogTitle, RimE if (defaultCase) featureUi->setCase(defaultCase); featureUi->setTimeStep(defaultTimeStep); - caf::PdmUiPropertyViewDialog propertyDialog(nullptr, featureUi, dialogTitle, "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + caf::PdmUiPropertyViewDialog propertyDialog( + nullptr, featureUi, dialogTitle, "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); propertyDialog.resize(QSize(600, 230)); if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty()) @@ -123,11 +124,10 @@ bool RicExportLgrFeature::openFileForExport(const QString& folderName, const QSt if (!exportFolder.exists()) { bool createdPath = exportFolder.mkpath("."); - if (createdPath) - RiaLogging::info("Created export folder " + folderName); + if (createdPath) RiaLogging::info("Created export folder " + folderName); } - QString filePath = exportFolder.filePath(fileName); + QString filePath = exportFolder.filePath(fileName); exportFile->setFileName(filePath); if (!exportFile->open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -139,7 +139,7 @@ bool RicExportLgrFeature::openFileForExport(const QString& folderName, const QSt } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector& lgrInfos) { @@ -151,20 +151,16 @@ void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector lgrs; - + try { - lgrs = buildLgrsForWellPath(wellPath, - eclipseCase, - timeStep, - lgrCellCounts, - splitType); + lgrs = buildLgrsForWellPath(wellPath, eclipseCase, timeStep, lgrCellCounts, splitType); // Export QFile file; @@ -227,14 +219,14 @@ void RicExportLgrFeature::exportLgrsForWellPath(const QString& exportFolder, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicExportLgrFeature::buildLgrsForWellPath(RimWellPath* wellPath, - RimEclipseCase* eclipseCase, - size_t timeStep, - caf::VecIjk lgrCellCounts, - RicExportLgrUi::SplitType splitType) +std::vector RicExportLgrFeature::buildLgrsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStep, + caf::VecIjk lgrCellCounts, + RicExportLgrUi::SplitType splitType) { std::vector lgrs; - bool intersectsWithExistingLgr = false; + bool intersectsWithExistingLgr = false; if (splitType == RicExportLgrUi::LGR_PER_CELL) { @@ -285,18 +277,18 @@ std::vector RicExportLgrFeature::buildLgrsForWellPath(RimWellPath* } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* eclipseCase, +std::vector RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* eclipseCase, const std::vector& intersectingCells, - const caf::VecIjk& lgrSizes) + const caf::VecIjk& lgrSizes) { std::vector lgrs; int lgrId = firstAvailableLgrId(eclipseCase->mainGrid()); for (auto intersectionCell : intersectingCells) { - lgrs.push_back(buildLgr(lgrId++, eclipseCase, { intersectionCell }, lgrSizes)); + lgrs.push_back(buildLgr(lgrId++, eclipseCase, {intersectionCell}, lgrSizes)); } return lgrs; } @@ -304,12 +296,13 @@ std::vector RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* e //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicExportLgrFeature::buildLgrsPerCompletion(RimEclipseCase* eclipseCase, - const std::map>& intersectingCells, - const caf::VecIjk& lgrSizesPerMainGridCell) +std::vector RicExportLgrFeature::buildLgrsPerCompletion( + RimEclipseCase* eclipseCase, + const std::map>& intersectingCells, + const caf::VecIjk& lgrSizesPerMainGridCell) { std::vector lgrs; - + int lgrId = firstAvailableLgrId(eclipseCase->mainGrid()); for (auto intersectionInfo : intersectingCells) { @@ -319,12 +312,12 @@ std::vector RicExportLgrFeature::buildLgrsPerCompletion(RimEclipseCase* } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -LgrInfo RicExportLgrFeature::buildLgr(int lgrId, - RimEclipseCase* eclipseCase, - const std::vector& intersectingCells, - const caf::VecIjk& lgrSizesPerMainGridCell) +LgrInfo RicExportLgrFeature::buildLgr(int lgrId, + RimEclipseCase* eclipseCase, + const std::vector& intersectingCells, + const caf::VecIjk& lgrSizesPerMainGridCell) { std::vector lgrs; @@ -335,11 +328,11 @@ LgrInfo RicExportLgrFeature::buildLgr(int lgrId, for (auto cell : intersectingCells) { - iRange.first = std::min(cell.localCellIndexI(), iRange.first); + iRange.first = std::min(cell.localCellIndexI(), iRange.first); iRange.second = std::max(cell.localCellIndexI(), iRange.second); - jRange.first = std::min(cell.localCellIndexJ(), jRange.first); + jRange.first = std::min(cell.localCellIndexJ(), jRange.first); jRange.second = std::max(cell.localCellIndexJ(), jRange.second); - kRange.first = std::min(cell.localCellIndexK(), kRange.first); + kRange.first = std::min(cell.localCellIndexK(), kRange.first); kRange.second = std::max(cell.localCellIndexK(), kRange.second); } @@ -353,12 +346,10 @@ LgrInfo RicExportLgrFeature::buildLgr(int lgrId, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector -RicExportLgrFeature::cellsIntersectingCompletions(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - size_t timeStep) + RicExportLgrFeature::cellsIntersectingCompletions(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, size_t timeStep) { std::vector cells; @@ -434,32 +425,33 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked) std::vector wellPaths = selectedWellPaths(); CVF_ASSERT(wellPaths.size() > 0); - QString dialogTitle = "LGR Export"; + QString dialogTitle = "LGR Export"; RimEclipseCase* defaultEclipseCase = nullptr; - int defaultTimeStep = 0; - auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); + int defaultTimeStep = 0; + auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); if (activeView) { defaultEclipseCase = activeView->eclipseCase(); - defaultTimeStep = activeView->currentTimeStep(); + defaultTimeStep = activeView->currentTimeStep(); } auto dialogData = openDialog("LGR Export", defaultEclipseCase, defaultTimeStep); if (dialogData) { - auto eclipseCase = dialogData->caseToApply(); - auto lgrCellCounts = dialogData->lgrCellCount(); - size_t timeStep = dialogData->timeStep(); + auto eclipseCase = dialogData->caseToApply(); + auto lgrCellCounts = dialogData->lgrCellCount(); + size_t timeStep = dialogData->timeStep(); bool intersectsExistingLgr = false; for (const auto& wellPath : wellPaths) { try { - exportLgrsForWellPath(dialogData->exportFolder(), wellPath, eclipseCase, timeStep, lgrCellCounts, dialogData->splitType()); + exportLgrsForWellPath( + dialogData->exportFolder(), wellPath, eclipseCase, timeStep, lgrCellCounts, dialogData->splitType()); } - catch(CreateLgrException e) + catch (CreateLgrException e) { intersectsExistingLgr = true; } @@ -467,7 +459,9 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked) if (intersectsExistingLgr) { - QMessageBox::warning(nullptr, "LGR cells intersected", "At least one completion intersects with an LGR. No output for those completions produced"); + QMessageBox::warning(nullptr, + "LGR cells intersected", + "At least one completion intersects with an LGR. No output for those completions produced"); } } } @@ -481,12 +475,12 @@ void RicExportLgrFeature::setupActionLook(QAction* actionToSetup) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicExportLgrFeature::selectedWellPaths() { std::vector selectedCompletions = caf::selectedObjectsByTypeStrict(); - std::vector wellPaths; + std::vector wellPaths; for (auto completion : selectedCompletions) { @@ -512,22 +506,21 @@ bool RicExportLgrFeature::containsAnyNonMainGridCells( } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicExportLgrFeature::containsAnyNonMainGridCells(const std::vector& cells) { - return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) - { - return !cell.isMainGridCell(); - }) != cells.end(); + return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) { + return !cell.isMainGridCell(); + }) != cells.end(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RicExportLgrFeature::firstAvailableLgrId(const RigMainGrid* mainGrid) { - int gridCount = (int)mainGrid->gridCount(); + int gridCount = (int)mainGrid->gridCount(); int lastUsedId = 0; for (int i = 0; i < gridCount; i++) { diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h index 4b41c35767..be904b2ab3 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h @@ -18,15 +18,16 @@ #pragma once -#include "RigCompletionDataGridCell.h" #include "RigCompletionData.h" +#include "RigCompletionDataGridCell.h" #include "RicExportLgrUi.h" #include "cafCmdFeature.h" -#include -#include +#include "cafVecIjk.h" + #include +#include class RimEclipseCase; class RimSimWellInView; diff --git a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp index 6cfb028458..3a77b41c23 100644 --- a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -23,51 +23,50 @@ #include "RiaLogging.h" #include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" -#include "ExportCommands/RicExportLgrUi.h" #include "ExportCommands/RicExportLgrFeature.h" +#include "ExportCommands/RicExportLgrUi.h" #include "RifEclipseDataTableFormatter.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" +#include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" #include "RigVirtualPerforationTransmissibilities.h" -#include "RigCellGeometryTools.h" #include "RimDialogData.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimWellPath.h" +#include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimWellLogPlotCollection.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathCompletions.h" -#include "RimMainPlotCollection.h" -#include "RimWellLogPlotCollection.h" #include "RiuPlotMainWindow.h" #include -#include #include #include -#include +#include #include +#include #include #include #include -#include #include +#include -#include #include +#include CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature"); - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -90,24 +89,24 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked) QString dialogTitle = "Create Temporary LGR"; RimEclipseCase* defaultEclipseCase = nullptr; - int defaultTimeStep = 0; - auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); + int defaultTimeStep = 0; + auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); if (activeView) { defaultEclipseCase = activeView->eclipseCase(); - defaultTimeStep = activeView->currentTimeStep(); + defaultTimeStep = activeView->currentTimeStep(); } auto dialogData = RicExportLgrFeature::openDialog(dialogTitle, defaultEclipseCase, defaultTimeStep); 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(); - auto eclipseCaseData = eclipseCase->eclipseCaseData(); - RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); + auto eclipseCaseData = eclipseCase->eclipseCaseData(); + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL); bool intersectsExistingLgr = false; @@ -117,11 +116,7 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked) try { - lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath, - eclipseCase, - timeStep, - lgrCellCounts, - splitType); + lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath, eclipseCase, timeStep, lgrCellCounts, splitType); auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); @@ -172,13 +167,13 @@ void RicCreateTemporaryLgrFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* mainGrid) { - auto app = RiaApplication::instance(); + auto app = RiaApplication::instance(); auto eclipseView = dynamic_cast(app->activeReservoirView()); if (!eclipseView) return; - int lgrId = lgrInfo.id; + int lgrId = lgrInfo.id; size_t totalCellCount = mainGrid->globalCellArray().size(); - size_t lgrCellCount = lgrInfo.cellCount(); + size_t lgrCellCount = lgrInfo.cellCount(); // Create local grid and set properties RigLocalGrid* localGrid = new RigLocalGrid(mainGrid); @@ -200,7 +195,7 @@ void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* main mainGrid->nodes().resize(nodeStartIndex + lgrCellCount * 8, cvf::Vec3d(0, 0, 0)); } - auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell(); + auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell(); size_t gridLocalCellIndex = 0; // Loop through all new LGR cells @@ -230,16 +225,15 @@ void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* main mainGrid->cellCornerVertices(mainCellIndex, vertices.data()); auto cellCounts = lgrInfo.sizesPerMainGridCell(); - auto lgrCoords = RigCellGeometryTools::createHexCornerCoords(vertices, - cellCounts.i(), - cellCounts.j(), - cellCounts.k()); + auto lgrCoords = + RigCellGeometryTools::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) { @@ -256,7 +250,7 @@ void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* main } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCase) { @@ -283,13 +277,13 @@ void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCa } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCreateTemporaryLgrFeature::computeCachedData(RimEclipseCase* eclipseCase) { if (eclipseCase) { - RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results(RiaDefines::MATRIX_MODEL); + RigCaseCellResultsData* cellResultsDataMatrix = eclipseCase->results(RiaDefines::MATRIX_MODEL); RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results(RiaDefines::FRACTURE_MODEL); RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); @@ -309,16 +303,15 @@ void RicCreateTemporaryLgrFeature::computeCachedData(RimEclipseCase* eclipseCase cellResultsDataFracture->computeDepthRelatedResults(); } } - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicCreateTemporaryLgrFeature::selectedWellPaths() { std::vector selectedCompletions = caf::selectedObjectsByTypeStrict(); - std::vector wellPaths; + std::vector wellPaths; for (auto completion : selectedCompletions) { @@ -331,12 +324,11 @@ std::vector RicCreateTemporaryLgrFeature::selectedWellPaths() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicCreateTemporaryLgrFeature::containsAnyNonMainGridCells(const std::vector& cells) { - return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) - { - return !cell.isMainGridCell(); - }) != cells.end(); + return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) { + return !cell.isMainGridCell(); + }) != cells.end(); }