mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6423 Use directory instead of file path for FRK export.
This commit is contained in:
parent
df0a985e14
commit
a2f6a28248
@ -23,6 +23,8 @@
|
||||
#include "RimFractureModel.h"
|
||||
#include "RimFractureModelPlot.h"
|
||||
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include "RifFractureModelPlotExporter.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
@ -53,21 +55,17 @@ void RicExportFractureModelPlotToFileFeature::onActionTriggered( bool isChecked
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "FRACTURE_MODEL_PLOT" );
|
||||
|
||||
QString fileNameCandidate = "Geological";
|
||||
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename( fileNameCandidate ) + ".frk";
|
||||
QString fileName = QFileDialog::getSaveFileName( nullptr,
|
||||
"Select File for Fracture Model Plot Export",
|
||||
defaultFileName,
|
||||
"Geologic Model File(*.frk);;All files(*.*)" );
|
||||
QString directoryPath =
|
||||
RiuFileDialogTools::getExistingDirectory( nullptr, "Select Directory for Fracture Model Plot Export", defaultDir );
|
||||
|
||||
if ( fileName.isEmpty() ) return;
|
||||
if ( directoryPath.isEmpty() ) return;
|
||||
|
||||
RifFractureModelPlotExporter::writeToFile( fractureModelPlot,
|
||||
fractureModelPlot->fractureModel()->useDetailedFluidLoss(),
|
||||
fileName );
|
||||
RifFractureModelPlotExporter::writeToDirectory( fractureModelPlot,
|
||||
fractureModelPlot->fractureModel()->useDetailedFluidLoss(),
|
||||
directoryPath );
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "FRACTURE_MODEL_PLOT", QFileInfo( fileName ).absolutePath() );
|
||||
app->setLastUsedDialogDirectory( "FRACTURE_MODEL_PLOT", directoryPath );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -116,6 +116,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifElasticPropertiesReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFractureModelPlotExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFractureModelGeologicalFrkExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.cpp
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
|
@ -0,0 +1,162 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor 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 "RifFractureModelGeologicalFrkExporter.h"
|
||||
|
||||
#include "RimFractureModelPlot.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifFractureModelGeologicalFrkExporter::writeToFile( RimFractureModelPlot* plot,
|
||||
bool useDetailedLoss,
|
||||
const QString& filepath )
|
||||
{
|
||||
std::vector<QString> labels;
|
||||
// TVD depth of top of zone (ft)
|
||||
labels.push_back( "dpthlyr" );
|
||||
|
||||
// Stress at top of zone (psi)
|
||||
labels.push_back( "strs" );
|
||||
|
||||
// Stress gradient (psi/ft)
|
||||
labels.push_back( "strsg" );
|
||||
|
||||
// Young's modulus (MMpsi)
|
||||
labels.push_back( "elyr" );
|
||||
|
||||
// Poisson's Ratio
|
||||
labels.push_back( "poissonr" );
|
||||
|
||||
// K-Ic (psi*sqrt(in)
|
||||
labels.push_back( "tuflyr" );
|
||||
|
||||
// Fluid Loss Coefficient
|
||||
labels.push_back( "clyrc" );
|
||||
|
||||
// Spurt loss (gal/100f^2)
|
||||
labels.push_back( "clyrs" );
|
||||
|
||||
// Proppand Embedmeent (lb/ft^2)
|
||||
labels.push_back( "pembed" );
|
||||
|
||||
if ( useDetailedLoss )
|
||||
{
|
||||
// B2 Detailed Loss
|
||||
// Reservoir Pressure (psi)
|
||||
labels.push_back( "zoneResPres" );
|
||||
|
||||
// Immobile Fluid Saturation (fraction)
|
||||
labels.push_back( "zoneWaterSat" );
|
||||
|
||||
// Porosity (fraction)
|
||||
labels.push_back( "zonePorosity" );
|
||||
|
||||
// Horizontal Perm (md)
|
||||
labels.push_back( "zoneHorizPerm" );
|
||||
|
||||
// Vertical Perm (md)
|
||||
labels.push_back( "zoneVertPerm" );
|
||||
|
||||
// Temperature (F)
|
||||
labels.push_back( "zoneTemp" );
|
||||
|
||||
// Relative permeability
|
||||
labels.push_back( "zoneRelPerm" );
|
||||
|
||||
// Poro-Elastic constant
|
||||
labels.push_back( "zonePoroElas" );
|
||||
|
||||
// Thermal Epansion Coefficient (1/F)
|
||||
labels.push_back( "zoneThermalExp" );
|
||||
}
|
||||
|
||||
std::map<QString, std::vector<double>> values;
|
||||
values["dpthlyr"] = plot->calculateTrueVerticalDepth();
|
||||
values["strs"] = plot->calculateStress();
|
||||
values["strsg"] = plot->calculateStressGradient();
|
||||
values["elyr"] = plot->calculateYoungsModulus();
|
||||
values["poissonr"] = plot->calculatePoissonsRatio();
|
||||
values["tuflyr"] = plot->calculateKIc();
|
||||
values["clyrc"] = plot->calculateFluidLossCoefficient();
|
||||
values["clyrs"] = plot->calculateSpurtLoss();
|
||||
values["pembed"] = plot->calculateProppandEmbedment();
|
||||
values["zoneResPres"] = plot->calculateReservoirPressure();
|
||||
values["zoneWaterSat"] = plot->calculateImmobileFluidSaturation();
|
||||
values["zonePorosity"] = plot->calculatePorosity();
|
||||
values["zoneHorizPerm"] = plot->calculateHorizontalPermeability();
|
||||
values["zoneVertPerm"] = plot->calculateVerticalPermeability();
|
||||
values["zoneTemp"] = plot->calculateTemperature();
|
||||
values["zoneRelPerm"] = plot->calculateRelativePermeabilityFactor();
|
||||
values["zonePoroElas"] = plot->calculatePoroElasticConstant();
|
||||
values["zoneThermalExp"] = plot->calculateThermalExpansionCoefficient();
|
||||
|
||||
QFile data( filepath );
|
||||
if ( !data.open( QFile::WriteOnly | QFile::Truncate ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream( &data );
|
||||
appendHeaderToStream( stream );
|
||||
|
||||
for ( QString label : labels )
|
||||
{
|
||||
appendToStream( stream, label, values[label] );
|
||||
}
|
||||
|
||||
appendFooterToStream( stream );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RifFractureModelGeologicalFrkExporter::appendHeaderToStream( QTextStream& stream )
|
||||
{
|
||||
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl << "<geologic>" << endl;
|
||||
}
|
||||
|
||||
void RifFractureModelGeologicalFrkExporter::appendToStream( QTextStream& stream,
|
||||
const QString& label,
|
||||
const std::vector<double>& values )
|
||||
{
|
||||
stream << "<cNamedSet>" << endl
|
||||
<< "<name>" << endl
|
||||
<< label << endl
|
||||
<< "</name>" << endl
|
||||
<< "<dimCount>" << endl
|
||||
<< 1 << endl
|
||||
<< "</dimCount>" << endl
|
||||
<< "<sizes>" << endl
|
||||
<< values.size() << endl
|
||||
<< "</sizes>" << endl
|
||||
<< "<data>" << endl;
|
||||
for ( auto val : values )
|
||||
{
|
||||
stream << val << endl;
|
||||
}
|
||||
|
||||
stream << "</data>" << endl << "</cNamedSet>" << endl;
|
||||
}
|
||||
|
||||
void RifFractureModelGeologicalFrkExporter::appendFooterToStream( QTextStream& stream )
|
||||
{
|
||||
stream << "</geologic>" << endl;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor 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 <vector>
|
||||
|
||||
class RimFractureModelPlot;
|
||||
class QString;
|
||||
class QTextStream;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifFractureModelGeologicalFrkExporter
|
||||
{
|
||||
public:
|
||||
static bool writeToFile( RimFractureModelPlot* plot, bool useDetailedFluidLoss, const QString& filepath );
|
||||
|
||||
private:
|
||||
static void appendHeaderToStream( QTextStream& stream );
|
||||
static void appendToStream( QTextStream& stream, const QString& label, const std::vector<double>& values );
|
||||
static void appendFooterToStream( QTextStream& stream );
|
||||
};
|
@ -18,141 +18,16 @@
|
||||
|
||||
#include "RifFractureModelPlotExporter.h"
|
||||
|
||||
#include "RimFractureModelPlot.h"
|
||||
#include "RifFractureModelGeologicalFrkExporter.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include "RimFractureModelPlot.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifFractureModelPlotExporter::writeToFile( RimFractureModelPlot* plot, bool useDetailedLoss, const QString& filepath )
|
||||
bool RifFractureModelPlotExporter::writeToDirectory( RimFractureModelPlot* plot,
|
||||
bool useDetailedFluidLoss,
|
||||
const QString& directoryPath )
|
||||
{
|
||||
std::vector<QString> labels;
|
||||
// TVD depth of top of zone (ft)
|
||||
labels.push_back( "dpthlyr" );
|
||||
|
||||
// Stress at top of zone (psi)
|
||||
labels.push_back( "strs" );
|
||||
|
||||
// Stress gradient (psi/ft)
|
||||
labels.push_back( "strsg" );
|
||||
|
||||
// Young's modulus (MMpsi)
|
||||
labels.push_back( "elyr" );
|
||||
|
||||
// Poisson's Ratio
|
||||
labels.push_back( "poissonr" );
|
||||
|
||||
// K-Ic (psi*sqrt(in)
|
||||
labels.push_back( "tuflyr" );
|
||||
|
||||
// Fluid Loss Coefficient
|
||||
labels.push_back( "clyrc" );
|
||||
|
||||
// Spurt loss (gal/100f^2)
|
||||
labels.push_back( "clyrs" );
|
||||
|
||||
// Proppand Embedmeent (lb/ft^2)
|
||||
labels.push_back( "pembed" );
|
||||
|
||||
if ( useDetailedLoss )
|
||||
{
|
||||
// B2 Detailed Loss
|
||||
// Reservoir Pressure (psi)
|
||||
labels.push_back( "zoneResPres" );
|
||||
|
||||
// Immobile Fluid Saturation (fraction)
|
||||
labels.push_back( "zoneWaterSat" );
|
||||
|
||||
// Porosity (fraction)
|
||||
labels.push_back( "zonePorosity" );
|
||||
|
||||
// Horizontal Perm (md)
|
||||
labels.push_back( "zoneHorizPerm" );
|
||||
|
||||
// Vertical Perm (md)
|
||||
labels.push_back( "zoneVertPerm" );
|
||||
|
||||
// Temperature (F)
|
||||
labels.push_back( "zoneTemp" );
|
||||
|
||||
// Relative permeability
|
||||
labels.push_back( "zoneRelPerm" );
|
||||
|
||||
// Poro-Elastic constant
|
||||
labels.push_back( "zonePoroElas" );
|
||||
|
||||
// Thermal Epansion Coefficient (1/F)
|
||||
labels.push_back( "zoneThermalExp" );
|
||||
}
|
||||
|
||||
std::map<QString, std::vector<double>> values;
|
||||
values["dpthlyr"] = plot->calculateTrueVerticalDepth();
|
||||
values["strs"] = plot->calculateStress();
|
||||
values["strsg"] = plot->calculateStressGradient();
|
||||
values["elyr"] = plot->calculateYoungsModulus();
|
||||
values["poissonr"] = plot->calculatePoissonsRatio();
|
||||
values["tuflyr"] = plot->calculateKIc();
|
||||
values["clyrc"] = plot->calculateFluidLossCoefficient();
|
||||
values["clyrs"] = plot->calculateSpurtLoss();
|
||||
values["pembed"] = plot->calculateProppandEmbedment();
|
||||
values["zoneResPres"] = plot->calculateReservoirPressure();
|
||||
values["zoneWaterSat"] = plot->calculateImmobileFluidSaturation();
|
||||
values["zonePorosity"] = plot->calculatePorosity();
|
||||
values["zoneHorizPerm"] = plot->calculateHorizontalPermeability();
|
||||
values["zoneVertPerm"] = plot->calculateVerticalPermeability();
|
||||
values["zoneTemp"] = plot->calculateTemperature();
|
||||
values["zoneRelPerm"] = plot->calculateRelativePermeabilityFactor();
|
||||
values["zonePoroElas"] = plot->calculatePoroElasticConstant();
|
||||
values["zoneThermalExp"] = plot->calculateThermalExpansionCoefficient();
|
||||
|
||||
QFile data( filepath );
|
||||
if ( !data.open( QFile::WriteOnly | QFile::Truncate ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream( &data );
|
||||
appendHeaderToStream( stream );
|
||||
|
||||
for ( QString label : labels )
|
||||
{
|
||||
appendToStream( stream, label, values[label] );
|
||||
}
|
||||
|
||||
appendFooterToStream( stream );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RifFractureModelPlotExporter::appendHeaderToStream( QTextStream& stream )
|
||||
{
|
||||
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl << "<geologic>" << endl;
|
||||
}
|
||||
|
||||
void RifFractureModelPlotExporter::appendToStream( QTextStream& stream, const QString& label, const std::vector<double>& values )
|
||||
{
|
||||
stream << "<cNamedSet>" << endl
|
||||
<< "<name>" << endl
|
||||
<< label << endl
|
||||
<< "</name>" << endl
|
||||
<< "<dimCount>" << endl
|
||||
<< 1 << endl
|
||||
<< "</dimCount>" << endl
|
||||
<< "<sizes>" << endl
|
||||
<< values.size() << endl
|
||||
<< "</sizes>" << endl
|
||||
<< "<data>" << endl;
|
||||
for ( auto val : values )
|
||||
{
|
||||
stream << val << endl;
|
||||
}
|
||||
|
||||
stream << "</data>" << endl << "</cNamedSet>" << endl;
|
||||
}
|
||||
|
||||
void RifFractureModelPlotExporter::appendFooterToStream( QTextStream& stream )
|
||||
{
|
||||
stream << "</geologic>" << endl;
|
||||
return RifFractureModelGeologicalFrkExporter::writeToFile( plot, useDetailedFluidLoss, directoryPath + "/Geological.frk" );
|
||||
}
|
||||
|
@ -30,10 +30,5 @@ class QTextStream;
|
||||
class RifFractureModelPlotExporter
|
||||
{
|
||||
public:
|
||||
static bool writeToFile( RimFractureModelPlot* plot, bool useDetailedFluidLoss, const QString& filepath );
|
||||
|
||||
private:
|
||||
static void appendHeaderToStream( QTextStream& stream );
|
||||
static void appendToStream( QTextStream& stream, const QString& label, const std::vector<double>& values );
|
||||
static void appendFooterToStream( QTextStream& stream );
|
||||
static bool writeToDirectory( RimFractureModelPlot* plot, bool useDetailedFluidLoss, const QString& directoryPath );
|
||||
};
|
||||
|
@ -36,9 +36,8 @@ time_step = time_steps[len(time_steps) - 1]
|
||||
fracture_model_plot_collection = project.descendants(rips.FractureModelPlotCollection)[0]
|
||||
fracture_model_plot = fracture_model_plot_collection.new_fracture_model_plot(eclipse_case=case, fracture_model=fracture_model, time_step=time_step)
|
||||
|
||||
file_path = "/tmp/Geological.frk"
|
||||
fracture_model_plot.export_to_file(file_path=file_path)
|
||||
|
||||
|
||||
export_folder = "/tmp/"
|
||||
|
||||
fracture_model_plot.export_to_file(directory_path=export_folder)
|
||||
|
||||
fracture_model_plot.export_snapshot(export_folder=export_folder)
|
||||
|
@ -34,7 +34,7 @@ RimcFractureModelPlot_exportToFile::RimcFractureModelPlot_exportToFile( caf::Pdm
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Export Fracture Model Plot", "", "", "Export Fracture Model Plot to File" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_directoryPath, "DirectoryPath", "", "", "", "Directory Path" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -44,9 +44,9 @@ caf::PdmObjectHandle* RimcFractureModelPlot_exportToFile::execute()
|
||||
{
|
||||
RimFractureModelPlot* fractureModelPlot = self<RimFractureModelPlot>();
|
||||
|
||||
RifFractureModelPlotExporter::writeToFile( fractureModelPlot,
|
||||
fractureModelPlot->fractureModel()->useDetailedFluidLoss(),
|
||||
m_filePath() );
|
||||
RifFractureModelPlotExporter::writeToDirectory( fractureModelPlot,
|
||||
fractureModelPlot->fractureModel()->useDetailedFluidLoss(),
|
||||
m_directoryPath() );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -47,5 +47,5 @@ public:
|
||||
bool isNullptrValidResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_filePath;
|
||||
caf::PdmField<QString> m_directoryPath;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user