From bb2ada26b9a9e55c31d4c4c344bd4ae81e58c11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 10 Oct 2018 11:56:27 +0200 Subject: [PATCH] LGR Export. Skip exporting PORO keyword if PORO result is missing from model --- .../ExportCommands/RicExportLgrFeature.cpp | 20 ++++++++++++------- .../ExportCommands/RicExportLgrFeature.h | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp index 889548d11d..e754f3128e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp @@ -55,6 +55,7 @@ #include #include +#include CAF_CMD_SOURCE_INIT(RicExportLgrFeature, "RicExportLgrFeature"); @@ -132,7 +133,7 @@ bool RicExportLgrFeature::openFileForExport(const QString& folderName, const QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportLgrFeature::exportLgr(QTextStream& stream, const std::vector& lgrInfos) +void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector& lgrInfos) { int count = 0; for (auto lgrInfo : lgrInfos) @@ -171,7 +172,10 @@ void RicExportLgrFeature::exportLgr(QTextStream& stream, const std::vector RicExportLgrFeature::buildOneLgrPerMainCell(RimEclipseCase* cvf::ref poroAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCase->eclipseCaseData(), 0, RiaDefines::MATRIX_MODEL, 0, "PORO"); + bool poroExists = !poroAccessObject.isNull(); for (const auto& intersectingCell : intersectingCells) { size_t globCellIndex = intersectingCell.globalCellIndex(); - double poro = poroAccessObject->cellScalarGlobIdx(globCellIndex); + double poro = poroExists ? poroAccessObject->cellScalarGlobIdx(globCellIndex) : std::numeric_limits::infinity(); std::vector lgrValues; @@ -221,7 +226,7 @@ std::vector RicExportLgrFeature::buildOneLgrPerMainCell(RimEclipseCase* intersectingCell.localCellIndexK()); LgrInfo lgrInfo(QString("LGR_%1").arg(++lgrCount), lgrSizes, mainGridFirstCell, mainGridEndCell); - lgrInfo.values = lgrValues; + if(poroExists) lgrInfo.values = lgrValues; lgrs.push_back(lgrInfo); } @@ -256,6 +261,7 @@ std::vector RicExportLgrFeature::buildSingleLgr(RimEclipseCase* eclipse kRange.second = std::max(cell.localCellIndexK(), kRange.second); } + bool poroExists = !poroAccessObject.isNull(); auto mainGrid = eclipseCase->mainGrid(); std::vector lgrValues; for (size_t mainK = kRange.first; mainK <= kRange.second; mainK++) @@ -266,7 +272,7 @@ std::vector RicExportLgrFeature::buildSingleLgr(RimEclipseCase* eclipse { size_t globCellIndex = mainGrid->cellIndexFromIJK(mainI, mainJ, mainK); - double poro = poroAccessObject->cellScalarGlobIdx(globCellIndex); + double poro = poroExists ? poroAccessObject->cellScalarGlobIdx(globCellIndex) : std::numeric_limits::infinity(); for (size_t k = 0; k < lgrSizes.k(); k++) { @@ -287,7 +293,7 @@ std::vector RicExportLgrFeature::buildSingleLgr(RimEclipseCase* eclipse caf::VecIjk mainGridEndCell(iRange.second, jRange.second, kRange.second); LgrInfo lgrInfo(QString("LGR_1"), lgrSizes, mainGridStartCell, mainGridEndCell); - lgrInfo.values = lgrValues; + if(poroExists) lgrInfo.values = lgrValues; lgrs.push_back(lgrInfo); return lgrs; @@ -369,7 +375,7 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked) QTextStream stream(&file); stream.setRealNumberNotation(QTextStream::FixedNotation); stream.setRealNumberPrecision(2); - exportLgr(stream, lgrs); + exportLgrs(stream, lgrs); file.close(); } diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h index f1728ff9b3..494f0f54e3 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h @@ -66,7 +66,7 @@ class RicExportLgrFeature : public caf::CmdFeature static RicExportLgrUi* openDialog(); static bool openFileForExport(const QString& folderName, const QString& fileName, QFile* exportFile); - static void exportLgr(QTextStream& stream, const std::vector& lgrInfos); + static void exportLgrs(QTextStream& stream, const std::vector& lgrInfos); static std::vector buildOneLgrPerMainCell(RimEclipseCase* eclipseCase, const std::vector& intersectingCells,