mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1697 Export of visible cells to FLUXNUM / MULTNUM .GRDECL file
This commit is contained in:
parent
279080fc4a
commit
1c483c7420
@ -13,6 +13,8 @@ ${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h
|
||||
@ -31,6 +33,8 @@ ${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp
|
||||
|
@ -0,0 +1,126 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicSaveEclipseInputVisibleCellsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RicExportFeatureImpl.h"
|
||||
|
||||
#include "RicSaveEclipseInputVisibleCellsUi.h"
|
||||
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
|
||||
#include "RimView.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSaveEclipseInputVisibleCellsFeature, "RicSaveEclipseInputVisibleCellsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSaveEclipseInputVisibleCellsFeature::isCommandEnabled()
|
||||
{
|
||||
return getSelectedEclipseView() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEclipseView* view = getEclipseActiveView();
|
||||
|
||||
RicSaveEclipseInputVisibleCellsUi exportSettings;
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export FLUXNUM/MULTNUM", "");
|
||||
RicExportFeatureImpl::configureForExport(&propertyDialog);
|
||||
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
std::vector<double> values;
|
||||
cvf::UByteArray visibleCells;
|
||||
view->calculateCurrentTotalCellVisibility(&visibleCells, view->currentTimeStep());
|
||||
RigActiveCellInfo* activeCellInfo = view->eclipseCase()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
|
||||
values.resize(visibleCells.size());
|
||||
for (size_t i = 0; i < visibleCells.size(); ++i)
|
||||
{
|
||||
if (activeCellInfo->isActive(i))
|
||||
{
|
||||
if (visibleCells[i])
|
||||
{
|
||||
values[i] = static_cast<double>(exportSettings.visibleActiveCellsValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = static_cast<double>(exportSettings.hiddenActiveCellsValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = static_cast<double>(exportSettings.inactiveCellsValue);
|
||||
}
|
||||
}
|
||||
QFile exportFile(exportSettings.exportFilename);
|
||||
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
RiaLogging::error(QString("saveEclipseInputVisibleCells: Unable to open file '%1' for writing.").arg(exportSettings.exportFilename));
|
||||
return;
|
||||
}
|
||||
RifEclipseInputFileTools::writeDataToTextFile(&exportFile, exportSettings.exportKeyword().text(), values);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveEclipseInputVisibleCellsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Export Visible Cells as FLUXNUM/MULTNUM");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RicSaveEclipseInputVisibleCellsFeature::getEclipseActiveView()
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
|
||||
return dynamic_cast<RimEclipseView*>(activeView);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView * RicSaveEclipseInputVisibleCellsFeature::getSelectedEclipseView()
|
||||
{
|
||||
return dynamic_cast<RimEclipseView*>(caf::SelectionManager::instance()->selectedItem());
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimEclipseInputProperty;
|
||||
class RimEclipseView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSaveEclipseInputVisibleCellsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimEclipseView* getEclipseActiveView();
|
||||
RimEclipseView* getSelectedEclipseView();
|
||||
};
|
@ -0,0 +1,117 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicSaveEclipseInputVisibleCellsUi.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
namespace caf {
|
||||
|
||||
template<>
|
||||
void RicSaveEclipseInputVisibleCellsUi::ExportKeywordEnum::setUp()
|
||||
{
|
||||
addItem(RicSaveEclipseInputVisibleCellsUi::FLUXNUM, "FLUXNUM", "FLUXNUM");
|
||||
addItem(RicSaveEclipseInputVisibleCellsUi::MULTNUM, "MULTNUM", "MULTNUM");
|
||||
setDefault(RicSaveEclipseInputVisibleCellsUi::FLUXNUM);
|
||||
}
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicSaveEclipseInputVisibleCellsUi, "RicSaveEclipseInputVisibleCellsUi");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSaveEclipseInputVisibleCellsUi::RicSaveEclipseInputVisibleCellsUi(void) : exportFilenameManuallyChanged(false)
|
||||
{
|
||||
CAF_PDM_InitObject("Export Visible Cells FLUXNUM/MULTNUM", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&exportFilename, "ExportFilename", QString(), "Export Filename", "", "", "");
|
||||
exportFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitFieldNoDefault(&exportKeyword, "ExportKeyword", "Export Keyword", "", "", "");
|
||||
CAF_PDM_InitField(&visibleActiveCellsValue, "VisibleActiveCellsValue", 1, "Visible Active Cells Value", "", "", "");
|
||||
CAF_PDM_InitField(&hiddenActiveCellsValue, "HiddenActiveCellsValue", 0, "Hidden Active Cells Value", "", "", "");
|
||||
CAF_PDM_InitField(&inactiveCellsValue, "InactiveCellsValue", 0, "Inactive Cells Value", "", "", "");
|
||||
|
||||
exportFilename = getDefaultExportPath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSaveEclipseInputVisibleCellsUi::~RicSaveEclipseInputVisibleCellsUi()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveEclipseInputVisibleCellsUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||
{
|
||||
if (field == &exportFilename)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
myAttr->m_selectSaveFileName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveEclipseInputVisibleCellsUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&exportFilename);
|
||||
uiOrdering.add(&exportKeyword);
|
||||
uiOrdering.add(&visibleActiveCellsValue);
|
||||
uiOrdering.add(&hiddenActiveCellsValue);
|
||||
uiOrdering.add(&inactiveCellsValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveEclipseInputVisibleCellsUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &exportFilename)
|
||||
{
|
||||
exportFilenameManuallyChanged = true;
|
||||
}
|
||||
else if (changedField == &exportKeyword)
|
||||
{
|
||||
if (!exportFilenameManuallyChanged)
|
||||
{
|
||||
exportFilename = getDefaultExportPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSaveEclipseInputVisibleCellsUi::getDefaultExportPath() const
|
||||
{
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
return baseDir.absoluteFilePath(QString("%1.grdecl").arg(exportKeyword().text()));
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSaveEclipseInputVisibleCellsUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum ExportKeyword
|
||||
{
|
||||
FLUXNUM,
|
||||
MULTNUM,
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<ExportKeyword> ExportKeywordEnum;
|
||||
|
||||
public:
|
||||
RicSaveEclipseInputVisibleCellsUi(void);
|
||||
~RicSaveEclipseInputVisibleCellsUi();
|
||||
|
||||
caf::PdmField<QString> exportFilename;
|
||||
caf::PdmField<ExportKeywordEnum> exportKeyword;
|
||||
caf::PdmField<int> visibleActiveCellsValue;
|
||||
caf::PdmField<int> hiddenActiveCellsValue;
|
||||
caf::PdmField<int> inactiveCellsValue;
|
||||
|
||||
protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
QString getDefaultExportPath() const;
|
||||
|
||||
private:
|
||||
bool exportFilenameManuallyChanged;
|
||||
};
|
@ -88,10 +88,10 @@ public:
|
||||
const QString& faultIncludeFileAbsolutePathPrefix);
|
||||
|
||||
static cvf::StructGridInterface::FaceEnum faceEnumFromText(const QString& faceString);
|
||||
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);
|
||||
|
||||
private:
|
||||
static bool readDataFromKeyword(ecl_kw_type* eclipseKeywordData, RigEclipseCaseData* caseData, const QString& resultName);
|
||||
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);
|
||||
static void findGridKeywordPositions(const std::vector< RifKeywordAndFilePos >& keywords, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos);
|
||||
|
||||
static size_t findFaultByName(const cvf::Collection<RigFault>& faults, const QString& name);
|
||||
|
@ -125,6 +125,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
commandIds << "RicSaveEclipseInputVisibleCellsFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimCaseCollection*>(uiItem))
|
||||
{
|
||||
|
@ -353,6 +353,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicNewGridTimeHistoryCurveFeature";
|
||||
commandIds << "RicShowFlowCharacteristicsPlotFeature";
|
||||
commandIds << "RicSaveEclipseInputVisibleCellsFeature";
|
||||
|
||||
|
||||
RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
|
||||
|
Loading…
Reference in New Issue
Block a user