mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3457 Export visible cells. New command file command
This commit is contained in:
parent
677914a338
commit
f23fa64235
@ -22,6 +22,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -47,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@ -35,6 +35,7 @@ namespace caf {
|
|||||||
addItem(RicfCommandFileExecutor::SNAPSHOTS, "SNAPSHOTS", "Snapshots");
|
addItem(RicfCommandFileExecutor::SNAPSHOTS, "SNAPSHOTS", "Snapshots");
|
||||||
addItem(RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics");
|
addItem(RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics");
|
||||||
addItem(RicfCommandFileExecutor::WELLPATHS, "WELLPATHS", "Well Path");
|
addItem(RicfCommandFileExecutor::WELLPATHS, "WELLPATHS", "Well Path");
|
||||||
|
addItem(RicfCommandFileExecutor::CELLS, "CELLS", "Cells");
|
||||||
setDefault(RicfCommandFileExecutor::COMPLETIONS);
|
setDefault(RicfCommandFileExecutor::COMPLETIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ public:
|
|||||||
SNAPSHOTS,
|
SNAPSHOTS,
|
||||||
PROPERTIES,
|
PROPERTIES,
|
||||||
STATISTICS,
|
STATISTICS,
|
||||||
WELLPATHS
|
WELLPATHS,
|
||||||
|
CELLS
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef caf::AppEnum<ExportType> ExportTypeEnum;
|
typedef caf::AppEnum<ExportType> ExportTypeEnum;
|
||||||
|
138
ApplicationCode/CommandFileInterface/RicfExportVisibleCells.cpp
Normal file
138
ApplicationCode/CommandFileInterface/RicfExportVisibleCells.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicfExportVisibleCells.h"
|
||||||
|
|
||||||
|
#include "RiaFilePathTools.h"
|
||||||
|
|
||||||
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
#include "ExportCommands/RicSaveEclipseInputVisibleCellsFeature.h"
|
||||||
|
#include "ExportCommands/RicSaveEclipseInputVisibleCellsUi.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimOilField.h"
|
||||||
|
#include "RimEclipseCaseCollection.h"
|
||||||
|
#include "RimEclipseCase.h"
|
||||||
|
#include "RimEclipseView.h"
|
||||||
|
#include "RimEclipseCellColors.h"
|
||||||
|
|
||||||
|
#include "RifEclipseInputFileTools.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <cafUtils.h>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT(RicfExportVisibleCells, "exportVisibleCells");
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
void AppEnum< RicfExportVisibleCells::ExportKeyword >::setUp()
|
||||||
|
{
|
||||||
|
addItem(RicfExportVisibleCells::FLUXNUM, "FLUXNUM", "FLUXNUM");
|
||||||
|
addItem(RicfExportVisibleCells::MULTNUM, "MULTNUM", "MULTNUM");
|
||||||
|
|
||||||
|
setDefault(RicfExportVisibleCells::FLUXNUM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RicfExportVisibleCells::RicfExportVisibleCells()
|
||||||
|
{
|
||||||
|
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||||
|
RICF_InitField(&m_viewName, "viewName", QString(), "View Name", "", "", "");
|
||||||
|
RICF_InitField(&m_exportKeyword, "exportKeyword", caf::AppEnum<RicfExportVisibleCells::ExportKeyword>(), "Export Keyword", "", "", "");
|
||||||
|
RICF_InitField(&m_visibleActiveCellsValue, "visibleActiveCellsValue", 1, "Visible Active Cells Value", "", "", "");
|
||||||
|
RICF_InitField(&m_hiddenActiveCellsValue, "hiddenActiveCellsValue", 0, "Hidden Active Cells Value", "", "", "");
|
||||||
|
RICF_InitField(&m_inactiveCellsValue, "inactiveCellsValue", 0, "Inactive Cells Value", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicfExportVisibleCells::execute()
|
||||||
|
{
|
||||||
|
if (m_caseId < 0 || m_viewName().isEmpty())
|
||||||
|
{
|
||||||
|
RiaLogging::error("exportVisibleCells: CaseId or view name not specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto eclipseView = viewFromCaseIdAndViewName(m_caseId, m_viewName);
|
||||||
|
if (!eclipseView)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportVisibleCells: Could not find view '%1' in case ID %2").arg(m_viewName).arg(m_caseId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::CELLS);
|
||||||
|
if (exportFolder.isNull())
|
||||||
|
{
|
||||||
|
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("visibleCells");
|
||||||
|
}
|
||||||
|
|
||||||
|
RicSaveEclipseInputVisibleCellsUi exportSettings;
|
||||||
|
buildExportSettings(exportFolder, &exportSettings);
|
||||||
|
RicSaveEclipseInputVisibleCellsFeature::executeCommand(eclipseView, exportSettings, "exportVisibleCells");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimEclipseView* RicfExportVisibleCells::viewFromCaseIdAndViewName(int caseId, const QString& viewName)
|
||||||
|
{
|
||||||
|
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
||||||
|
{
|
||||||
|
if (c->caseId() == caseId)
|
||||||
|
{
|
||||||
|
for (auto v : c->views())
|
||||||
|
{
|
||||||
|
auto eclipseView = dynamic_cast<RimEclipseView*>(v);
|
||||||
|
if (eclipseView && eclipseView->name().compare(viewName, Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
return eclipseView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicfExportVisibleCells::buildExportSettings(const QString& exportFolder, RicSaveEclipseInputVisibleCellsUi* exportSettings)
|
||||||
|
{
|
||||||
|
QDir baseDir(exportFolder);
|
||||||
|
exportSettings->exportFilename = baseDir.absoluteFilePath(QString("%1.grdecl").arg(m_exportKeyword().text()));
|
||||||
|
|
||||||
|
if (m_exportKeyword == ExportKeyword::FLUXNUM) exportSettings->exportKeyword = RicSaveEclipseInputVisibleCellsUi::FLUXNUM;
|
||||||
|
else if (m_exportKeyword == ExportKeyword::MULTNUM) exportSettings->exportKeyword = RicSaveEclipseInputVisibleCellsUi::MULTNUM;
|
||||||
|
|
||||||
|
exportSettings->visibleActiveCellsValue = m_visibleActiveCellsValue;
|
||||||
|
exportSettings->hiddenActiveCellsValue = m_hiddenActiveCellsValue;
|
||||||
|
exportSettings->inactiveCellsValue = m_inactiveCellsValue;
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RiaDefines.h"
|
||||||
|
|
||||||
|
#include "RicfCommandObject.h"
|
||||||
|
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
|
||||||
|
class RimEclipseView;
|
||||||
|
class RicSaveEclipseInputVisibleCellsUi;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class RicfExportVisibleCells : public RicfCommandObject
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
enum ExportKeyword {FLUXNUM, MULTNUM};
|
||||||
|
|
||||||
|
public:
|
||||||
|
RicfExportVisibleCells();
|
||||||
|
|
||||||
|
virtual void execute() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RimEclipseView* viewFromCaseIdAndViewName(int caseId, const QString& viewName);
|
||||||
|
void buildExportSettings(const QString& exportFolder, RicSaveEclipseInputVisibleCellsUi* exportSettings);
|
||||||
|
|
||||||
|
caf::PdmField<int> m_caseId;
|
||||||
|
caf::PdmField<QString> m_viewName;
|
||||||
|
caf::PdmField<caf::AppEnum<ExportKeyword>> m_exportKeyword;
|
||||||
|
caf::PdmField<int> m_visibleActiveCellsValue;
|
||||||
|
caf::PdmField<int> m_hiddenActiveCellsValue;
|
||||||
|
caf::PdmField<int> m_inactiveCellsValue;
|
||||||
|
};
|
@ -49,7 +49,7 @@ CAF_CMD_SOURCE_INIT(RicSaveEclipseInputActiveVisibleCellsFeature, "RicSaveEclips
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void executeCommand(RimEclipseView* view)
|
void RicSaveEclipseInputVisibleCellsFeature::openDialogAndExecuteCommand(RimEclipseView* view)
|
||||||
{
|
{
|
||||||
if (!view) return;
|
if (!view) return;
|
||||||
|
|
||||||
@ -58,6 +58,17 @@ void executeCommand(RimEclipseView* view)
|
|||||||
RicExportFeatureImpl::configureForExport(&propertyDialog);
|
RicExportFeatureImpl::configureForExport(&propertyDialog);
|
||||||
|
|
||||||
if (propertyDialog.exec() == QDialog::Accepted)
|
if (propertyDialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
executeCommand(view, exportSettings, "saveEclipseInputVisibleCells");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSaveEclipseInputVisibleCellsFeature::executeCommand(RimEclipseView* view,
|
||||||
|
const RicSaveEclipseInputVisibleCellsUi& exportSettings,
|
||||||
|
const QString& logPrefix)
|
||||||
{
|
{
|
||||||
std::vector<double> values;
|
std::vector<double> values;
|
||||||
cvf::UByteArray visibleCells;
|
cvf::UByteArray visibleCells;
|
||||||
@ -85,12 +96,11 @@ void executeCommand(RimEclipseView* view)
|
|||||||
QFile exportFile(exportSettings.exportFilename);
|
QFile exportFile(exportSettings.exportFilename);
|
||||||
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
RiaLogging::error(QString("saveEclipseInputVisibleCells: Unable to open file '%1' for writing.").arg(exportSettings.exportFilename));
|
RiaLogging::error(QString("%1: Unable to open file '%2' for writing.").arg(logPrefix).arg(exportSettings.exportFilename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RifEclipseInputFileTools::writeDataToTextFile(&exportFile, exportSettings.exportKeyword().text(), values);
|
RifEclipseInputFileTools::writeDataToTextFile(&exportFile, exportSettings.exportKeyword().text(), values);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -106,7 +116,7 @@ bool RicSaveEclipseInputVisibleCellsFeature::isCommandEnabled()
|
|||||||
void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked)
|
void RicSaveEclipseInputVisibleCellsFeature::onActionTriggered(bool isChecked)
|
||||||
{
|
{
|
||||||
RimEclipseView* view = RicSaveEclipseInputVisibleCellsFeature::selectedView();
|
RimEclipseView* view = RicSaveEclipseInputVisibleCellsFeature::selectedView();
|
||||||
executeCommand(view);
|
openDialogAndExecuteCommand(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -157,7 +167,7 @@ bool RicSaveEclipseInputActiveVisibleCellsFeature::isCommandEnabled()
|
|||||||
void RicSaveEclipseInputActiveVisibleCellsFeature::onActionTriggered(bool isChecked)
|
void RicSaveEclipseInputActiveVisibleCellsFeature::onActionTriggered(bool isChecked)
|
||||||
{
|
{
|
||||||
RimEclipseView* view = RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView();
|
RimEclipseView* view = RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView();
|
||||||
executeCommand(view);
|
RicSaveEclipseInputVisibleCellsFeature::openDialogAndExecuteCommand(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
class RimEclipseInputProperty;
|
|
||||||
class RimEclipseView;
|
class RimEclipseView;
|
||||||
|
class RicSaveEclipseInputVisibleCellsUi;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -30,6 +30,12 @@ class RicSaveEclipseInputVisibleCellsFeature : public caf::CmdFeature
|
|||||||
{
|
{
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public :
|
||||||
|
static void openDialogAndExecuteCommand(RimEclipseView* view);
|
||||||
|
static void executeCommand(RimEclipseView* view,
|
||||||
|
const RicSaveEclipseInputVisibleCellsUi& exportSettings,
|
||||||
|
const QString& logPrefix);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isCommandEnabled() override;
|
virtual bool isCommandEnabled() override;
|
||||||
virtual void onActionTriggered(bool isChecked) override;
|
virtual void onActionTriggered(bool isChecked) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user