diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 4882e26f4d..96e0500451 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -55,6 +55,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.h ${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.h ${CMAKE_CURRENT_LIST_DIR}/RifElasticPropertiesReader.h ${CMAKE_CURRENT_LIST_DIR}/RifFractureModelPlotExporter.h +${CMAKE_CURRENT_LIST_DIR}/RifFractureModelGeologicalFrkExporter.h +${CMAKE_CURRENT_LIST_DIR}/RifFractureModelDeviationFrkExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.h @@ -117,6 +119,7 @@ ${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}/RifFractureModelDeviationFrkExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt diff --git a/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.cpp b/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.cpp new file mode 100644 index 0000000000..4de0c91b38 --- /dev/null +++ b/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.cpp @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifFractureModelDeviationFrkExporter.h" + +#include "RimFractureModel.h" +#include "RimFractureModelPlot.h" +#include "RimWellPath.h" + +#include "RigWellPathGeometryExporter.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifFractureModelDeviationFrkExporter::writeToFile( RimFractureModelPlot* plot, const QString& filepath ) +{ + RimFractureModel* fractureModel = plot->fractureModel(); + if ( !fractureModel ) + { + return false; + } + + RimWellPath* wellPath = fractureModel->wellPath(); + if ( !wellPath ) + { + return false; + } + + QFile data( filepath ); + if ( !data.open( QFile::WriteOnly | QFile::Truncate ) ) + { + return false; + } + + QTextStream stream( &data ); + appendHeaderToStream( stream ); + + bool useMdRkb = false; + double mdStepSize = 5.0; + std::vector xValues; + std::vector yValues; + std::vector tvdValues; + std::vector mdValues; + RigWellPathGeometryExporter::exportWellPathGeometry( wellPath, mdStepSize, xValues, yValues, tvdValues, mdValues, useMdRkb ); + + convertFromMeterToFeet( mdValues ); + convertFromMeterToFeet( tvdValues ); + + appendToStream( stream, "mdArray", mdValues ); + appendToStream( stream, "tvdArray", tvdValues ); + + appendFooterToStream( stream ); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifFractureModelDeviationFrkExporter::appendHeaderToStream( QTextStream& stream ) +{ + stream << "" << endl << "" << endl; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifFractureModelDeviationFrkExporter::appendToStream( QTextStream& stream, + const QString& label, + const std::vector& values ) +{ + stream << "" << endl + << "" << endl + << label << endl + << "" << endl + << "" << endl + << 1 << endl + << "" << endl + << "" << endl + << values.size() << endl + << "" << endl + << "" << endl; + for ( auto val : values ) + { + stream << val << endl; + } + + stream << "" << endl << "" << endl; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifFractureModelDeviationFrkExporter::appendFooterToStream( QTextStream& stream ) +{ + stream << "" << endl; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifFractureModelDeviationFrkExporter::convertFromMeterToFeet( std::vector& data ) +{ + for ( size_t i = 0; i < data.size(); i++ ) + { + data[i] = RiaEclipseUnitTools::meterToFeet( data[i] ); + } +} diff --git a/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.h b/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.h new file mode 100644 index 0000000000..2af9d62acd --- /dev/null +++ b/ApplicationCode/FileInterface/RifFractureModelDeviationFrkExporter.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RimFractureModelPlot; +class QString; +class QTextStream; + +//================================================================================================== +// +//================================================================================================== +class RifFractureModelDeviationFrkExporter +{ +public: + static bool writeToFile( RimFractureModelPlot* plot, const QString& filepath ); + +private: + static void appendHeaderToStream( QTextStream& stream ); + static void appendToStream( QTextStream& stream, const QString& label, const std::vector& values ); + static void appendFooterToStream( QTextStream& stream ); + static void convertFromMeterToFeet( std::vector& data ); +}; diff --git a/ApplicationCode/FileInterface/RifFractureModelPlotExporter.cpp b/ApplicationCode/FileInterface/RifFractureModelPlotExporter.cpp index cebb7fb2b1..6d68b77d12 100644 --- a/ApplicationCode/FileInterface/RifFractureModelPlotExporter.cpp +++ b/ApplicationCode/FileInterface/RifFractureModelPlotExporter.cpp @@ -18,6 +18,7 @@ #include "RifFractureModelPlotExporter.h" +#include "RifFractureModelDeviationFrkExporter.h" #include "RifFractureModelGeologicalFrkExporter.h" #include "RimFractureModelPlot.h" @@ -29,5 +30,6 @@ bool RifFractureModelPlotExporter::writeToDirectory( RimFractureModelPlot* plot, bool useDetailedFluidLoss, const QString& directoryPath ) { - return RifFractureModelGeologicalFrkExporter::writeToFile( plot, useDetailedFluidLoss, directoryPath + "/Geological.frk" ); + return RifFractureModelGeologicalFrkExporter::writeToFile( plot, useDetailedFluidLoss, directoryPath + "/Geological.frk" ) && + RifFractureModelDeviationFrkExporter::writeToFile( plot, directoryPath + "/Deviation.frk" ); }