Whitespace

This commit is contained in:
Magne Sjaastad 2018-10-24 13:13:45 +02:00
parent 71d9f742d9
commit 45531865ba
3 changed files with 117 additions and 131 deletions

View File

@ -35,29 +35,29 @@
#include "RimDialogData.h" #include "RimDialogData.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimWellPath.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathCompletions.h" #include "RimWellPathCompletions.h"
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RimPerforationInterval.h"
#include "RimFracture.h"
#include "RimFishbonesMultipleSubs.h" #include "RimFishbonesMultipleSubs.h"
#include "RimFracture.h"
#include "RimPerforationInterval.h"
#include <QAction> #include <QAction>
#include <QFileInfo>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
#include <QTextStream>
#include <cafPdmUiPropertyViewDialog.h> #include <cafPdmUiPropertyViewDialog.h>
#include <cafSelectionManager.h> #include <cafSelectionManager.h>
#include <cafSelectionManagerTools.h> #include <cafSelectionManagerTools.h>
#include <cafVecIjk.h>
#include <cafUtils.h> #include <cafUtils.h>
#include <cafVecIjk.h>
#include <limits> #include <limits>
@ -66,12 +66,12 @@
CAF_CMD_SOURCE_INIT(RicExportLgrFeature, "RicExportLgrFeature"); CAF_CMD_SOURCE_INIT(RicExportLgrFeature, "RicExportLgrFeature");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RicExportLgrUi* RicExportLgrFeature::openDialog(const QString& dialogTitle, RimEclipseCase* defaultCase, int defaultTimeStep) RicExportLgrUi* RicExportLgrFeature::openDialog(const QString& dialogTitle, RimEclipseCase* defaultCase, int defaultTimeStep)
{ {
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project(); RimProject* proj = app->project();
QString startPath = app->lastUsedDialogDirectory("LGR_EXPORT_DIR"); QString startPath = app->lastUsedDialogDirectory("LGR_EXPORT_DIR");
if (startPath.isEmpty()) if (startPath.isEmpty())
@ -103,7 +103,8 @@ RicExportLgrUi* RicExportLgrFeature::openDialog(const QString& dialogTitle, RimE
if (defaultCase) featureUi->setCase(defaultCase); if (defaultCase) featureUi->setCase(defaultCase);
featureUi->setTimeStep(defaultTimeStep); 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)); propertyDialog.resize(QSize(600, 230));
if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty()) if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty())
@ -123,11 +124,10 @@ bool RicExportLgrFeature::openFileForExport(const QString& folderName, const QSt
if (!exportFolder.exists()) if (!exportFolder.exists())
{ {
bool createdPath = exportFolder.mkpath("."); bool createdPath = exportFolder.mkpath(".");
if (createdPath) if (createdPath) RiaLogging::info("Created export folder " + folderName);
RiaLogging::info("Created export folder " + folderName);
} }
QString filePath = exportFolder.filePath(fileName); QString filePath = exportFolder.filePath(fileName);
exportFile->setFileName(filePath); exportFile->setFileName(filePath);
if (!exportFile->open(QIODevice::WriteOnly | QIODevice::Text)) 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<LgrInfo>& lgrInfos) void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos)
{ {
@ -151,20 +151,16 @@ void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrI
{ {
RifEclipseDataTableFormatter formatter(stream); RifEclipseDataTableFormatter formatter(stream);
formatter.keyword("CARFIN"); formatter.keyword("CARFIN");
formatter.header( formatter.header({RifEclipseOutputTableColumn("Name"),
{ RifEclipseOutputTableColumn("I1"),
RifEclipseOutputTableColumn("Name"), RifEclipseOutputTableColumn("I2"),
RifEclipseOutputTableColumn("I1"), RifEclipseOutputTableColumn("J1"),
RifEclipseOutputTableColumn("I2"), RifEclipseOutputTableColumn("J2"),
RifEclipseOutputTableColumn("J1"), RifEclipseOutputTableColumn("K1"),
RifEclipseOutputTableColumn("J2"), RifEclipseOutputTableColumn("K2"),
RifEclipseOutputTableColumn("K1"), RifEclipseOutputTableColumn("NX"),
RifEclipseOutputTableColumn("K2"), RifEclipseOutputTableColumn("NY"),
RifEclipseOutputTableColumn("NX"), RifEclipseOutputTableColumn("NZ")});
RifEclipseOutputTableColumn("NY"),
RifEclipseOutputTableColumn("NZ")
}
);
formatter.add(lgrInfo.name); formatter.add(lgrInfo.name);
formatter.addOneBasedCellIndex(lgrInfo.mainGridStartCell.i()); formatter.addOneBasedCellIndex(lgrInfo.mainGridStartCell.i());
@ -191,22 +187,18 @@ void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrI
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicExportLgrFeature::exportLgrsForWellPath(const QString& exportFolder, void RicExportLgrFeature::exportLgrsForWellPath(const QString& exportFolder,
RimWellPath* wellPath, RimWellPath* wellPath,
RimEclipseCase* eclipseCase, RimEclipseCase* eclipseCase,
size_t timeStep, size_t timeStep,
caf::VecIjk lgrCellCounts, caf::VecIjk lgrCellCounts,
RicExportLgrUi::SplitType splitType) RicExportLgrUi::SplitType splitType)
{ {
std::vector<LgrInfo> lgrs; std::vector<LgrInfo> lgrs;
try try
{ {
lgrs = buildLgrsForWellPath(wellPath, lgrs = buildLgrsForWellPath(wellPath, eclipseCase, timeStep, lgrCellCounts, splitType);
eclipseCase,
timeStep,
lgrCellCounts,
splitType);
// Export // Export
QFile file; QFile file;
@ -227,14 +219,14 @@ void RicExportLgrFeature::exportLgrsForWellPath(const QString& exportFolder,
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<LgrInfo> RicExportLgrFeature::buildLgrsForWellPath(RimWellPath* wellPath, std::vector<LgrInfo> RicExportLgrFeature::buildLgrsForWellPath(RimWellPath* wellPath,
RimEclipseCase* eclipseCase, RimEclipseCase* eclipseCase,
size_t timeStep, size_t timeStep,
caf::VecIjk lgrCellCounts, caf::VecIjk lgrCellCounts,
RicExportLgrUi::SplitType splitType) RicExportLgrUi::SplitType splitType)
{ {
std::vector<LgrInfo> lgrs; std::vector<LgrInfo> lgrs;
bool intersectsWithExistingLgr = false; bool intersectsWithExistingLgr = false;
if (splitType == RicExportLgrUi::LGR_PER_CELL) if (splitType == RicExportLgrUi::LGR_PER_CELL)
{ {
@ -285,18 +277,18 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsForWellPath(RimWellPath*
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* eclipseCase, std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* eclipseCase,
const std::vector<RigCompletionDataGridCell>& intersectingCells, const std::vector<RigCompletionDataGridCell>& intersectingCells,
const caf::VecIjk& lgrSizes) const caf::VecIjk& lgrSizes)
{ {
std::vector<LgrInfo> lgrs; std::vector<LgrInfo> lgrs;
int lgrId = firstAvailableLgrId(eclipseCase->mainGrid()); int lgrId = firstAvailableLgrId(eclipseCase->mainGrid());
for (auto intersectionCell : intersectingCells) for (auto intersectionCell : intersectingCells)
{ {
lgrs.push_back(buildLgr(lgrId++, eclipseCase, { intersectionCell }, lgrSizes)); lgrs.push_back(buildLgr(lgrId++, eclipseCase, {intersectionCell}, lgrSizes));
} }
return lgrs; return lgrs;
} }
@ -304,12 +296,13 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase* e
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerCompletion(RimEclipseCase* eclipseCase, std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerCompletion(
const std::map<CompletionInfo, std::vector<RigCompletionDataGridCell>>& intersectingCells, RimEclipseCase* eclipseCase,
const caf::VecIjk& lgrSizesPerMainGridCell) const std::map<CompletionInfo, std::vector<RigCompletionDataGridCell>>& intersectingCells,
const caf::VecIjk& lgrSizesPerMainGridCell)
{ {
std::vector<LgrInfo> lgrs; std::vector<LgrInfo> lgrs;
int lgrId = firstAvailableLgrId(eclipseCase->mainGrid()); int lgrId = firstAvailableLgrId(eclipseCase->mainGrid());
for (auto intersectionInfo : intersectingCells) for (auto intersectionInfo : intersectingCells)
{ {
@ -319,12 +312,12 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerCompletion(RimEclipseCase*
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
LgrInfo RicExportLgrFeature::buildLgr(int lgrId, LgrInfo RicExportLgrFeature::buildLgr(int lgrId,
RimEclipseCase* eclipseCase, RimEclipseCase* eclipseCase,
const std::vector<RigCompletionDataGridCell>& intersectingCells, const std::vector<RigCompletionDataGridCell>& intersectingCells,
const caf::VecIjk& lgrSizesPerMainGridCell) const caf::VecIjk& lgrSizesPerMainGridCell)
{ {
std::vector<LgrInfo> lgrs; std::vector<LgrInfo> lgrs;
@ -335,11 +328,11 @@ LgrInfo RicExportLgrFeature::buildLgr(int lgrId,
for (auto cell : intersectingCells) 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); 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); 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); kRange.second = std::max(cell.localCellIndexK(), kRange.second);
} }
@ -353,12 +346,10 @@ LgrInfo RicExportLgrFeature::buildLgr(int lgrId,
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RigCompletionDataGridCell> std::vector<RigCompletionDataGridCell>
RicExportLgrFeature::cellsIntersectingCompletions(RimEclipseCase* eclipseCase, RicExportLgrFeature::cellsIntersectingCompletions(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, size_t timeStep)
const RimWellPath* wellPath,
size_t timeStep)
{ {
std::vector<RigCompletionDataGridCell> cells; std::vector<RigCompletionDataGridCell> cells;
@ -434,32 +425,33 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked)
std::vector<RimWellPath*> wellPaths = selectedWellPaths(); std::vector<RimWellPath*> wellPaths = selectedWellPaths();
CVF_ASSERT(wellPaths.size() > 0); CVF_ASSERT(wellPaths.size() > 0);
QString dialogTitle = "LGR Export"; QString dialogTitle = "LGR Export";
RimEclipseCase* defaultEclipseCase = nullptr; RimEclipseCase* defaultEclipseCase = nullptr;
int defaultTimeStep = 0; int defaultTimeStep = 0;
auto activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeGridView()); auto activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeGridView());
if (activeView) if (activeView)
{ {
defaultEclipseCase = activeView->eclipseCase(); defaultEclipseCase = activeView->eclipseCase();
defaultTimeStep = activeView->currentTimeStep(); defaultTimeStep = activeView->currentTimeStep();
} }
auto dialogData = openDialog("LGR Export", defaultEclipseCase, defaultTimeStep); auto dialogData = openDialog("LGR Export", defaultEclipseCase, defaultTimeStep);
if (dialogData) if (dialogData)
{ {
auto eclipseCase = dialogData->caseToApply(); auto eclipseCase = dialogData->caseToApply();
auto lgrCellCounts = dialogData->lgrCellCount(); auto lgrCellCounts = dialogData->lgrCellCount();
size_t timeStep = dialogData->timeStep(); size_t timeStep = dialogData->timeStep();
bool intersectsExistingLgr = false; bool intersectsExistingLgr = false;
for (const auto& wellPath : wellPaths) for (const auto& wellPath : wellPaths)
{ {
try 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; intersectsExistingLgr = true;
} }
@ -467,7 +459,9 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked)
if (intersectsExistingLgr) 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<RimWellPath*> RicExportLgrFeature::selectedWellPaths() std::vector<RimWellPath*> RicExportLgrFeature::selectedWellPaths()
{ {
std::vector<RimWellPathCompletions*> selectedCompletions = caf::selectedObjectsByTypeStrict<RimWellPathCompletions*>(); std::vector<RimWellPathCompletions*> selectedCompletions = caf::selectedObjectsByTypeStrict<RimWellPathCompletions*>();
std::vector<RimWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
for (auto completion : selectedCompletions) for (auto completion : selectedCompletions)
{ {
@ -512,22 +506,21 @@ bool RicExportLgrFeature::containsAnyNonMainGridCells(
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicExportLgrFeature::containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells) bool RicExportLgrFeature::containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells)
{ {
return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) {
{ return !cell.isMainGridCell();
return !cell.isMainGridCell(); }) != cells.end();
}) != cells.end();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RicExportLgrFeature::firstAvailableLgrId(const RigMainGrid* mainGrid) int RicExportLgrFeature::firstAvailableLgrId(const RigMainGrid* mainGrid)
{ {
int gridCount = (int)mainGrid->gridCount(); int gridCount = (int)mainGrid->gridCount();
int lastUsedId = 0; int lastUsedId = 0;
for (int i = 0; i < gridCount; i++) for (int i = 0; i < gridCount; i++)
{ {

View File

@ -18,15 +18,16 @@
#pragma once #pragma once
#include "RigCompletionDataGridCell.h"
#include "RigCompletionData.h" #include "RigCompletionData.h"
#include "RigCompletionDataGridCell.h"
#include "RicExportLgrUi.h" #include "RicExportLgrUi.h"
#include "cafCmdFeature.h" #include "cafCmdFeature.h"
#include <cafVecIjk.h> #include "cafVecIjk.h"
#include <memory>
#include <limits> #include <limits>
#include <memory>
class RimEclipseCase; class RimEclipseCase;
class RimSimWellInView; class RimSimWellInView;

View File

@ -23,51 +23,50 @@
#include "RiaLogging.h" #include "RiaLogging.h"
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" #include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h"
#include "ExportCommands/RicExportLgrUi.h"
#include "ExportCommands/RicExportLgrFeature.h" #include "ExportCommands/RicExportLgrFeature.h"
#include "ExportCommands/RicExportLgrUi.h"
#include "RifEclipseDataTableFormatter.h" #include "RifEclipseDataTableFormatter.h"
#include "RigActiveCellInfo.h" #include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h" #include "RigCaseCellResultsData.h"
#include "RigCellGeometryTools.h"
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "RigResultAccessor.h" #include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h" #include "RigResultAccessorFactory.h"
#include "RigVirtualPerforationTransmissibilities.h" #include "RigVirtualPerforationTransmissibilities.h"
#include "RigCellGeometryTools.h"
#include "RimDialogData.h" #include "RimDialogData.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimWellPath.h" #include "RimMainPlotCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathCompletions.h" #include "RimWellPathCompletions.h"
#include "RimMainPlotCollection.h"
#include "RimWellLogPlotCollection.h"
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include <QAction> #include <QAction>
#include <QFileInfo>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
#include <QTextStream>
#include <cafPdmUiPropertyViewDialog.h> #include <cafPdmUiPropertyViewDialog.h>
#include <cafSelectionManager.h> #include <cafSelectionManager.h>
#include <cafSelectionManagerTools.h> #include <cafSelectionManagerTools.h>
#include <cafVecIjk.h>
#include <cafUtils.h> #include <cafUtils.h>
#include <cafVecIjk.h>
#include <limits>
#include <algorithm> #include <algorithm>
#include <limits>
CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature"); CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -90,24 +89,24 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked)
QString dialogTitle = "Create Temporary LGR"; QString dialogTitle = "Create Temporary LGR";
RimEclipseCase* defaultEclipseCase = nullptr; RimEclipseCase* defaultEclipseCase = nullptr;
int defaultTimeStep = 0; int defaultTimeStep = 0;
auto activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeGridView()); auto activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeGridView());
if (activeView) if (activeView)
{ {
defaultEclipseCase = activeView->eclipseCase(); defaultEclipseCase = activeView->eclipseCase();
defaultTimeStep = activeView->currentTimeStep(); defaultTimeStep = activeView->currentTimeStep();
} }
auto dialogData = RicExportLgrFeature::openDialog(dialogTitle, defaultEclipseCase, defaultTimeStep); auto dialogData = RicExportLgrFeature::openDialog(dialogTitle, defaultEclipseCase, defaultTimeStep);
if (dialogData) if (dialogData)
{ {
auto eclipseCase = dialogData->caseToApply(); auto eclipseCase = dialogData->caseToApply();
auto lgrCellCounts = dialogData->lgrCellCount(); auto lgrCellCounts = dialogData->lgrCellCount();
size_t timeStep = dialogData->timeStep(); size_t timeStep = dialogData->timeStep();
auto splitType = dialogData->splitType(); auto splitType = dialogData->splitType();
auto eclipseCaseData = eclipseCase->eclipseCaseData(); auto eclipseCaseData = eclipseCase->eclipseCaseData();
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL); RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL);
bool intersectsExistingLgr = false; bool intersectsExistingLgr = false;
@ -117,11 +116,7 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked)
try try
{ {
lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath, lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath, eclipseCase, timeStep, lgrCellCounts, splitType);
eclipseCase,
timeStep,
lgrCellCounts,
splitType);
auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid();
@ -172,13 +167,13 @@ void RicCreateTemporaryLgrFeature::setupActionLook(QAction* actionToSetup)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* mainGrid) void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* mainGrid)
{ {
auto app = RiaApplication::instance(); auto app = RiaApplication::instance();
auto eclipseView = dynamic_cast<RimEclipseView*>(app->activeReservoirView()); auto eclipseView = dynamic_cast<RimEclipseView*>(app->activeReservoirView());
if (!eclipseView) return; if (!eclipseView) return;
int lgrId = lgrInfo.id; int lgrId = lgrInfo.id;
size_t totalCellCount = mainGrid->globalCellArray().size(); size_t totalCellCount = mainGrid->globalCellArray().size();
size_t lgrCellCount = lgrInfo.cellCount(); size_t lgrCellCount = lgrInfo.cellCount();
// Create local grid and set properties // Create local grid and set properties
RigLocalGrid* localGrid = new RigLocalGrid(mainGrid); 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)); mainGrid->nodes().resize(nodeStartIndex + lgrCellCount * 8, cvf::Vec3d(0, 0, 0));
} }
auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell(); auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell();
size_t gridLocalCellIndex = 0; size_t gridLocalCellIndex = 0;
// Loop through all new LGR cells // Loop through all new LGR cells
@ -230,16 +225,15 @@ void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* main
mainGrid->cellCornerVertices(mainCellIndex, vertices.data()); mainGrid->cellCornerVertices(mainCellIndex, vertices.data());
auto cellCounts = lgrInfo.sizesPerMainGridCell(); auto cellCounts = lgrInfo.sizesPerMainGridCell();
auto lgrCoords = RigCellGeometryTools::createHexCornerCoords(vertices, auto lgrCoords =
cellCounts.i(), RigCellGeometryTools::createHexCornerCoords(vertices, cellCounts.i(), cellCounts.j(), cellCounts.k());
cellCounts.j(),
cellCounts.k());
size_t subI = lgrI % lgrSizePerMainCell.i(); size_t subI = lgrI % lgrSizePerMainCell.i();
size_t subJ = lgrJ % lgrSizePerMainCell.j(); size_t subJ = lgrJ % lgrSizePerMainCell.j();
size_t subK = lgrK % lgrSizePerMainCell.k(); 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)
{ {
@ -256,7 +250,7 @@ void RicCreateTemporaryLgrFeature::createLgr(LgrInfo& lgrInfo, RigMainGrid* main
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCase) void RicCreateTemporaryLgrFeature::deleteAllCachedData(RimEclipseCase* eclipseCase)
{ {
@ -283,13 +277,13 @@ 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* cellResultsDataMatrix = eclipseCase->results(RiaDefines::MATRIX_MODEL);
RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results(RiaDefines::FRACTURE_MODEL); RigCaseCellResultsData* cellResultsDataFracture = eclipseCase->results(RiaDefines::FRACTURE_MODEL);
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
@ -309,16 +303,15 @@ void RicCreateTemporaryLgrFeature::computeCachedData(RimEclipseCase* eclipseCase
cellResultsDataFracture->computeDepthRelatedResults(); cellResultsDataFracture->computeDepthRelatedResults();
} }
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RicCreateTemporaryLgrFeature::selectedWellPaths() std::vector<RimWellPath*> RicCreateTemporaryLgrFeature::selectedWellPaths()
{ {
std::vector<RimWellPathCompletions*> selectedCompletions = caf::selectedObjectsByTypeStrict<RimWellPathCompletions*>(); std::vector<RimWellPathCompletions*> selectedCompletions = caf::selectedObjectsByTypeStrict<RimWellPathCompletions*>();
std::vector<RimWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
for (auto completion : selectedCompletions) for (auto completion : selectedCompletions)
{ {
@ -331,12 +324,11 @@ std::vector<RimWellPath*> RicCreateTemporaryLgrFeature::selectedWellPaths()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicCreateTemporaryLgrFeature::containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells) bool RicCreateTemporaryLgrFeature::containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells)
{ {
return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) return std::find_if(cells.begin(), cells.end(), [](const RigCompletionDataGridCell& cell) {
{ return !cell.isMainGridCell();
return !cell.isMainGridCell(); }) != cells.end();
}) != cells.end();
} }