#1092 - pre-proto - Added feature for exporting fracture data to file. File is written, but not with any useful information yet.

This commit is contained in:
astridkbjorke 2017-01-10 09:30:39 +01:00
parent 6dd3db4d97
commit 9bba00999e
10 changed files with 406 additions and 0 deletions

View File

@ -46,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RicFractureDefinitionsDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicFracturesDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathFracturesDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFractureWellCompletionFeature.h
# General delete of any object in a child array field
@ -95,6 +96,8 @@ ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.cpp
${CEE_CURRENT_LIST_DIR}RicFractureDefinitionsDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathFracturesDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFractureWellCompletionFeature.cpp

View File

@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicExportFractureWellCompletionFeature.h"
#include "RiaApplication.h"
#include "RifEclipseExportTools.h"
#include "RifEclipseExportTools.h"
#include "RimBinaryExportSettings.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEclipseWellCollection.h"
#include "RimFractureExportSettings.h"
#include "RiuMainWindow.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include <QMessageBox>
#include <QString>
CAF_CMD_SOURCE_INIT(RicExportFractureWellCompletionFeature, "RicExportFractureWellCompletionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFractureWellCompletionFeature::onActionTriggered(bool isChecked)
{
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
if (!pdmUiItem) return;
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (!objHandle) return;
RimEclipseWellCollection* eclipseWellColl = nullptr;
objHandle->firstAncestorOrThisOfType(eclipseWellColl);
RimEclipseView* eclipseWiew = nullptr;
objHandle->firstAncestorOrThisOfType(eclipseWiew);
RimFractureExportSettings exportSettings;
RiaApplication* app = RiaApplication::instance();
QString projectFolder = app->currentProjectPath();
if (projectFolder.isEmpty())
{
projectFolder = eclipseWiew->eclipseCase()->locationOnDisc();
}
QString outputFileName = projectFolder + "/Fractures";
exportSettings.fileName = outputFileName;
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Fracture Well Completion Data", "");
if (propertyDialog.exec() == QDialog::Accepted)
{
bool isOk = RifEclipseExportTools::writeFracturesToTextFile(exportSettings.fileName, eclipseWellColl);
if (!isOk)
{
QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFractureWellCompletionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/FractureTemplate16x16.png"));
actionToSetup->setText("Export Fracture Well Completion Data");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportFractureWellCompletionFeature::isCommandEnabled()
{
return true;
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RicExportFractureWellCompletionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
};

View File

@ -21,6 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderSettings.h
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h
${CEE_CURRENT_LIST_DIR}RifReaderOpmParserInput.h
${CEE_CURRENT_LIST_DIR}RifEclipseWellCompletionExporter.h
${CEE_CURRENT_LIST_DIR}RifEclipseExportTools.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -40,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp
${CEE_CURRENT_LIST_DIR}RifReaderOpmParserInput.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseWellCompletionExporter.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseExportTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,96 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifEclipseExportTools.h"
#include "RimFracture.h"
#include "RimEclipseWellCollection.h"
#include "RimEclipseView.h"
#include "cafProgressInfo.h"
#include <QTextStream>
#include <QFile>
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseExportTools::RifEclipseExportTools()
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifEclipseExportTools::~RifEclipseExportTools()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseExportTools::writeFracturesToTextFile(const QString& fileName, RimEclipseWellCollection* wellColl)
{
std::vector<RimFracture*> fractures;
wellColl->descendantsIncludingThisOfType(fractures);
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
return false;
}
writeFractureDataToTextFile(&file, fractures);
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseExportTools::writeFractureDataToTextFile(QFile* file, const std::vector<RimFracture*>& fractures)
{
QTextStream out(file);
out << "\n";
out << "-- Exported from ResInsight" << "\n";
out << "COMPDAT" << "\n" << right << qSetFieldWidth(16);
caf::ProgressInfo pi(fractures.size(), QString("Writing data to file %1").arg(file->fileName()));
size_t progressSteps = fractures.size() / 20;
size_t i;
for (i = 0; i < fractures.size(); i++)
{
out << fractures.at(i);
out << "\n";
pi.setProgress(i);
}
out << "\n" << "/" << "\n";
}

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "cvfObject.h"
#include "cvfLibCore.h"
#include "ert/ecl/ecl_kw.h"
#include <map>
#include <QString>
class RimEclipseWellCollection;
class RimFracture;
class QFile;
//==================================================================================================
//
// Class for access to Eclipse "keyword" files using libecl
//
//==================================================================================================
class RifEclipseExportTools
{
public:
RifEclipseExportTools();
virtual ~RifEclipseExportTools();
static bool writeFracturesToTextFile(const QString& fileName, RimEclipseWellCollection* wellColl);
private:
static void writeFractureDataToTextFile(QFile* file, const std::vector<RimFracture*>& fractures);
};

View File

@ -91,6 +91,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.h
${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.h
${CEE_CURRENT_LIST_DIR}RimSimWellFracture.h
${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.h
${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.h
)
@ -181,6 +182,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.cpp
${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.cpp
${CEE_CURRENT_LIST_DIR}RimSimWellFracture.cpp
${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.cpp
${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -33,6 +33,7 @@
#include "RimEclipseStatisticsCase.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimFault.h"
#include "RimFormationNames.h"
#include "RimFormationNamesCollection.h"
@ -341,6 +342,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
{
commandIds << "RicNewSimWellIntersectionFeature";
}
else if (dynamic_cast<RimEclipseWellCollection*>(uiItem))
{
commandIds << "RicExportFractureWellCompletionFeature";
}
else if(dynamic_cast<RimFormationNames*>(uiItem))
{
commandIds << "RicImportFormationNamesFeature";

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimFractureExportSettings.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimFractureExportSettings, "RimFractureExportSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFractureExportSettings::RimFractureExportSettings()
{
CAF_PDM_InitObject("RimFractureExportSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export filename", "", "", "");
fileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
// CAF_PDM_InitFieldNoDefault(&eclipseKeyword, "EclipseKeyword", "Eclipse Keyword", "", "", "");
// CAF_PDM_InitField(&undefinedValue, "UndefinedValue", 0.0, "Undefined value", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureExportSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (field == &fileName)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -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 "cafPdmField.h"
#include "cafPdmObject.h"
//==================================================================================================
///
///
//==================================================================================================
class RimFractureExportSettings : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimFractureExportSettings();
caf::PdmField<QString> fileName;
// caf::PdmField<QString> eclipseKeyword;
// caf::PdmField<double> undefinedValue;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};