#4248 Add option for making invisible cells inactive in Export Sector Model

This commit is contained in:
Gaute Lindkvist 2019-03-29 14:26:49 +01:00
parent 0df03e4886
commit 3b8daa4939
6 changed files with 40 additions and 20 deletions

View File

@ -88,12 +88,23 @@ void RicExportEclipseSectorModelFeature::executeCommand(RimEclipseView* view,
CVF_ASSERT(refinement.x() > 0u && refinement.y() > 0u && refinement.z() > 0u); CVF_ASSERT(refinement.x() > 0u && refinement.y() > 0u && refinement.z() > 0u);
cvf::UByteArray cellVisibility;
view->calculateCurrentTotalCellVisibility(&cellVisibility, view->currentTimeStep());
cvf::Vec3st min, max; cvf::Vec3st min, max;
std::tie(min, max) = getVisibleCellRange(view); std::tie(min, max) = getVisibleCellRange(view, cellVisibility);
if (exportSettings.exportGrid()) if (exportSettings.exportGrid())
{ {
const cvf::UByteArray* cellVisibilityForActnum = exportSettings.makeInvisibleCellsInactive() ? &cellVisibility : nullptr;
auto task = progress.task("Export Grid", gridProgressPercentage); auto task = progress.task("Export Grid", gridProgressPercentage);
bool worked = RifEclipseInputFileTools::exportGrid(exportSettings.exportGridFilename(), view->eclipseCase()->eclipseCaseData(), min, max, refinement);
bool worked = RifEclipseInputFileTools::exportGrid(exportSettings.exportGridFilename(),
view->eclipseCase()->eclipseCaseData(),
cellVisibilityForActnum,
min,
max,
refinement);
if (!worked) if (!worked)
{ {
RiaLogging::error( RiaLogging::error(
@ -203,10 +214,8 @@ void RicExportEclipseSectorModelFeature::executeCommand(RimEclipseView* view,
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::pair<cvf::Vec3st, cvf::Vec3st> RicExportEclipseSectorModelFeature::getVisibleCellRange(RimEclipseView* view) std::pair<cvf::Vec3st, cvf::Vec3st> RicExportEclipseSectorModelFeature::getVisibleCellRange(RimEclipseView* view, const cvf::UByteArray& cellVisibillity)
{ {
cvf::UByteArray visibleCells;
view->calculateCurrentTotalCellVisibility(&visibleCells, view->currentTimeStep());
const RigMainGrid* mainGrid = view->eclipseCase()->mainGrid(); const RigMainGrid* mainGrid = view->eclipseCase()->mainGrid();
cvf::Vec3st max = cvf::Vec3st::ZERO; cvf::Vec3st max = cvf::Vec3st::ZERO;
@ -217,7 +226,7 @@ std::pair<cvf::Vec3st, cvf::Vec3st> RicExportEclipseSectorModelFeature::getVisib
size_t cellCount = mainGrid->cellCount(); size_t cellCount = mainGrid->cellCount();
for (size_t index = 0; index < cellCount; ++index) for (size_t index = 0; index < cellCount; ++index)
{ {
if (visibleCells[index]) if (cellVisibillity[index])
{ {
cvf::Vec3st ijk; cvf::Vec3st ijk;
mainGrid->ijkFromCellIndex(index, &ijk[0], &ijk[1], &ijk[2]); mainGrid->ijkFromCellIndex(index, &ijk[0], &ijk[1], &ijk[2]);

View File

@ -39,7 +39,7 @@ public :
const RicExportEclipseSectorModelUi& exportSettings, const RicExportEclipseSectorModelUi& exportSettings,
const QString& logPrefix); const QString& logPrefix);
static std::pair<cvf::Vec3st, cvf::Vec3st> getVisibleCellRange(RimEclipseView* view); static std::pair<cvf::Vec3st, cvf::Vec3st> getVisibleCellRange(RimEclipseView* view, const cvf::UByteArray& cellVisibility);
protected: protected:
bool isCommandEnabled() override; bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override; void onActionTriggered(bool isChecked) override;

View File

@ -50,6 +50,7 @@ void RicExportEclipseSectorModelUi::ResultExportOptionsEnum::setUp()
setDefault(RicExportEclipseSectorModelUi::EXPORT_TO_SEPARATE_FILE_PER_RESULT); setDefault(RicExportEclipseSectorModelUi::EXPORT_TO_SEPARATE_FILE_PER_RESULT);
} }
} // namespace caf } // namespace caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -64,6 +65,8 @@ RicExportEclipseSectorModelUi::RicExportEclipseSectorModelUi(RigEclipseCaseData*
CAF_PDM_InitField(&exportGridFilename, "ExportGridFilename", QString(), "Grid File Name", "", "", ""); CAF_PDM_InitField(&exportGridFilename, "ExportGridFilename", QString(), "Grid File Name", "", "", "");
exportGridFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); exportGridFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&makeInvisibleCellsInactive, "InvisibleCellActnum", false, "Make Invisible Cells Inactive", "", "", "");
CAF_PDM_InitFieldNoDefault(&exportFaults, "ExportFaults", "Export Faults", "", "", ""); CAF_PDM_InitFieldNoDefault(&exportFaults, "ExportFaults", "Export Faults", "", "", "");
exportFaults = EXPORT_TO_SINGLE_SEPARATE_FILE; exportFaults = EXPORT_TO_SINGLE_SEPARATE_FILE;
@ -151,6 +154,7 @@ void RicExportEclipseSectorModelUi::defineUiOrdering(QString uiConfigName, caf::
gridGroup->add(&exportGrid); gridGroup->add(&exportGrid);
gridGroup->add(&exportGridFilename); gridGroup->add(&exportGridFilename);
exportGridFilename.uiCapability()->setUiReadOnly(!exportGrid()); exportGridFilename.uiCapability()->setUiReadOnly(!exportGrid());
gridGroup->add(&makeInvisibleCellsInactive);
gridGroup->add(&exportFaults); gridGroup->add(&exportFaults);
if (exportFaults() != EXPORT_NO_RESULTS) if (exportFaults() != EXPORT_NO_RESULTS)

View File

@ -45,7 +45,6 @@ class RicExportEclipseSectorModelUi : public caf::PdmObject
EXPORT_TO_SINGLE_SEPARATE_FILE, EXPORT_TO_SINGLE_SEPARATE_FILE,
EXPORT_TO_SEPARATE_FILE_PER_RESULT EXPORT_TO_SEPARATE_FILE_PER_RESULT
}; };
typedef caf::AppEnum<ResultExportOptions> ResultExportOptionsEnum; typedef caf::AppEnum<ResultExportOptions> ResultExportOptionsEnum;
public: public:
@ -57,6 +56,8 @@ public:
caf::PdmField<bool> exportGrid; caf::PdmField<bool> exportGrid;
caf::PdmField<QString> exportGridFilename; caf::PdmField<QString> exportGridFilename;
caf::PdmField<bool> makeInvisibleCellsInactive;
caf::PdmField<ResultExportOptionsEnum> exportFaults; caf::PdmField<ResultExportOptionsEnum> exportFaults;
caf::PdmField<QString> exportFaultsFilename; caf::PdmField<QString> exportFaultsFilename;

View File

@ -231,11 +231,12 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName,
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::exportGrid(const QString& fileName, bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
RigEclipseCaseData* eclipseCase, RigEclipseCaseData* eclipseCase,
const cvf::Vec3st& min, const cvf::UByteArray* cellVisibilityOverrideForActnum,
const cvf::Vec3st& maxIn, const cvf::Vec3st& min,
const cvf::Vec3st& refinement) const cvf::Vec3st& maxIn,
const cvf::Vec3st& refinement)
{ {
if (!eclipseCase) if (!eclipseCase)
{ {
@ -289,6 +290,10 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
size_t mainIndex = mainGrid->cellIndexFromIJK(mainI, mainJ, mainK); size_t mainIndex = mainGrid->cellIndexFromIJK(mainI, mainJ, mainK);
int active = activeCellInfo->isActive(mainIndex) ? 1 : 0; int active = activeCellInfo->isActive(mainIndex) ? 1 : 0;
if (active && cellVisibilityOverrideForActnum)
{
active = (*cellVisibilityOverrideForActnum)[mainIndex];
}
int* ecl_cell_coords = new int[5]; int* ecl_cell_coords = new int[5];
ecl_cell_coords[0] = (int)(i0 + 1); ecl_cell_coords[0] = (int)(i0 + 1);
@ -322,7 +327,7 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
} }
if (incrementalIndex % cellProgressInterval == 0) if (incrementalIndex % cellProgressInterval == 0)
{ {
progress.setProgress(incrementalIndex); progress.setProgress(incrementalIndex / cellsPerOriginal);
} }
} }

View File

@ -60,12 +60,13 @@ public:
~RifEclipseInputFileTools() override; ~RifEclipseInputFileTools() override;
static bool openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData, QString* errorMessages); static bool openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData, QString* errorMessages);
static bool exportGrid(const QString& gridFileName, static bool exportGrid(const QString& gridFileName,
RigEclipseCaseData* eclipseCase, RigEclipseCaseData* eclipseCase,
const cvf::Vec3st& min = cvf::Vec3st::ZERO, const cvf::UByteArray* cellVisibilityOverrideForActnum = nullptr,
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED, const cvf::Vec3st& min = cvf::Vec3st::ZERO,
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1)); const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
static bool exportKeywords(const QString& resultFileName, static bool exportKeywords(const QString& resultFileName,
RigEclipseCaseData* eclipseCase, RigEclipseCaseData* eclipseCase,