Refactor well path geometry export to ".dev" file.

The code to generate the geometry data is extracted for easier reuse, and
differences between exporting visible and selected well paths removed.
This commit is contained in:
Kristian Bendiksen 2020-09-04 13:46:53 +02:00
parent a2f6a28248
commit 0c275a6d9c
7 changed files with 181 additions and 81 deletions

View File

@ -26,6 +26,7 @@
#include "RifTextDataTableFormatter.h"
#include "RigWellPath.h"
#include "RigWellPathGeometryExporter.h"
#include "RimDialogData.h"
#include "RimModeledWellPath.h"
@ -58,43 +59,18 @@ void RicExportSelectedWellPathsFeature::exportWellPath( const RimWellPath* wellP
auto filePtr = openFileForExport( folder, fileName );
auto stream = createOutputFileStream( *filePtr );
writeWellPathGeometryToStream( *stream, wellPath, wellPath->name(), mdStepSize, writeProjectInfo );
std::vector<double> xValues;
std::vector<double> yValues;
std::vector<double> tvdValues;
std::vector<double> mdValues;
bool useMdRkb = false;
RigWellPathGeometryExporter::exportWellPathGeometry( wellPath, mdStepSize, xValues, yValues, tvdValues, mdValues, useMdRkb );
writeWellPathGeometryToStream( *stream, wellPath->name(), xValues, yValues, tvdValues, mdValues, useMdRkb, writeProjectInfo );
filePtr->close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStream& stream,
const RimWellPath* wellPath,
const QString& exportName,
double mdStepSize,
bool writeProjectInfo )
{
auto wellPathGeom = wellPath->wellPathGeometry();
if ( !wellPathGeom ) return;
bool useMdRkb = false;
double rkb = 0.0;
{
const RimModeledWellPath* modeledWellPath = dynamic_cast<const RimModeledWellPath*>( wellPath );
if ( modeledWellPath )
{
useMdRkb = true;
if ( modeledWellPath->geometryDefinition()->airGap() != 0.0 )
{
rkb = modeledWellPath->geometryDefinition()->airGap();
}
else
{
rkb = modeledWellPath->geometryDefinition()->mdAtFirstTarget();
}
}
}
writeWellPathGeometryToStream( stream, wellPathGeom, exportName, mdStepSize, useMdRkb, rkb, writeProjectInfo );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -106,11 +82,27 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre
double rkbOffset,
bool writeProjectInfo )
{
if ( !wellPathGeom ) return;
std::vector<double> xValues;
std::vector<double> yValues;
std::vector<double> tvdValues;
std::vector<double> mdValues;
double currMd = wellPathGeom->measureDepths().front() - mdStepSize;
double endMd = wellPathGeom->measureDepths().back();
RigWellPathGeometryExporter::exportWellPathGeometry( wellPathGeom, mdStepSize, rkbOffset, xValues, yValues, tvdValues, mdValues );
writeWellPathGeometryToStream( stream, exportName, xValues, yValues, tvdValues, mdValues, useMdRkb, writeProjectInfo );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStream& stream,
const QString& exportName,
const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& tvdValues,
const std::vector<double>& mdValues,
bool useMdRkb,
bool writeProjectInfo )
{
RifTextDataTableFormatter formatter( stream );
formatter.setHeaderPrefix( "# " );
formatter.setCommentPrefix( "# " );
@ -130,19 +122,13 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre
{"TVDMSL", numberFormat, RIGHT},
{useMdRkb ? "MDRKB" : "MDMSL", numberFormat, RIGHT}} );
while ( currMd < endMd )
for ( size_t i = 0; i < xValues.size(); i++ )
{
currMd += mdStepSize;
if ( currMd > endMd ) currMd = endMd;
auto pt = wellPathGeom->interpolatedPointAlongWellPath( currMd );
double tvd = -pt.z();
// Write to file
formatter.add( pt.x() );
formatter.add( pt.y() );
formatter.add( tvd );
formatter.add( currMd + rkbOffset );
formatter.add( xValues[i] );
formatter.add( yValues[i] );
formatter.add( tvdValues[i] );
formatter.add( mdValues[i] );
formatter.rowCompleted( "" );
}
formatter.tableCompleted( "", false );

View File

@ -25,6 +25,7 @@
#include <memory>
class RigWellPath;
class RigWellPathGeom;
class RimWellPath;
class RicExportWellPathsUi;
class QTextStream;
@ -65,6 +66,15 @@ class RicExportSelectedWellPathsFeature : public caf::CmdFeature
bool writeProjectInfo );
private:
static void writeWellPathGeometryToStream( QTextStream& stream,
const QString& exportName,
const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& tvdValues,
const std::vector<double>& mdValues,
bool useMdRkb,
bool writeProjectInfo );
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;

View File

@ -41,37 +41,6 @@
CAF_CMD_SOURCE_INIT( RicExportVisibleWellPathsFeature, "RicExportVisibleWellPathsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportVisibleWellPathsFeature::exportWellPath( const RimWellPath* wellPath, double mdStepSize, const QString& folder )
{
auto geom = wellPath->wellPathGeometry();
double currMd = geom->measureDepths().front() - mdStepSize;
double endMd = geom->measureDepths().back();
auto fileName = wellPath->name() + ".dev";
auto filePtr = RicExportSelectedWellPathsFeature::openFileForExport( folder, fileName );
QTextStream stream( filePtr.get() );
stream.setRealNumberNotation( QTextStream::FixedNotation );
stream << "WELLNAME: " << wellPath->name() << endl;
while ( currMd < endMd )
{
currMd += mdStepSize;
if ( currMd > endMd ) currMd = endMd;
auto pt = geom->interpolatedPointAlongWellPath( currMd );
double tvd = -pt.z();
// Write to file
stream << pt.x() << " " << pt.y() << " " << tvd << " " << currMd << endl;
}
filePtr->close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -38,8 +38,6 @@ class RicExportVisibleWellPathsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
void exportWellPath( const RimWellPath* wellPath, double mdStepSize, const QString& folder );
private:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;

View File

@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h
${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryExporter.h
${CMAKE_CURRENT_LIST_DIR}/RigSurface.h
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.h
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechBoreHoleStressCalculator.h
@ -143,6 +144,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryExporter.cpp
${CMAKE_CURRENT_LIST_DIR}/RigSurface.cpp
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.cpp
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechBoreHoleStressCalculator.cpp

View File

@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- 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 "RigWellPathGeometryExporter.h"
#include "RigWellPath.h"
#include "RimModeledWellPath.h"
#include "RimWellPath.h"
#include "RimWellPathGeometryDef.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathGeometryExporter::exportWellPathGeometry( const RimWellPath* wellPath,
double mdStepSize,
std::vector<double>& xValues,
std::vector<double>& yValues,
std::vector<double>& tvdValues,
std::vector<double>& mdValues,
bool& useMdRkb )
{
auto wellPathGeom = wellPath->wellPathGeometry();
if ( !wellPathGeom ) return;
useMdRkb = false;
double rkbOffset = 0.0;
{
const RimModeledWellPath* modeledWellPath = dynamic_cast<const RimModeledWellPath*>( wellPath );
if ( modeledWellPath )
{
useMdRkb = true;
if ( modeledWellPath->geometryDefinition()->airGap() != 0.0 )
{
rkbOffset = modeledWellPath->geometryDefinition()->airGap();
}
else
{
rkbOffset = modeledWellPath->geometryDefinition()->mdAtFirstTarget();
}
}
}
exportWellPathGeometry( wellPathGeom, mdStepSize, rkbOffset, xValues, yValues, tvdValues, mdValues );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathGeometryExporter::exportWellPathGeometry( const RigWellPath* wellPathGeom,
double mdStepSize,
double rkbOffset,
std::vector<double>& xValues,
std::vector<double>& yValues,
std::vector<double>& tvdValues,
std::vector<double>& mdValues )
{
double currMd = wellPathGeom->measureDepths().front() - mdStepSize;
double endMd = wellPathGeom->measureDepths().back();
while ( currMd < endMd )
{
currMd += mdStepSize;
if ( currMd > endMd ) currMd = endMd;
auto pt = wellPathGeom->interpolatedPointAlongWellPath( currMd );
double tvd = -pt.z();
xValues.push_back( pt.x() );
yValues.push_back( pt.y() );
tvdValues.push_back( tvd );
mdValues.push_back( currMd + rkbOffset );
}
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimWellPath;
class RigWellPath;
//==================================================================================================
///
//==================================================================================================
class RigWellPathGeometryExporter
{
public:
static void exportWellPathGeometry( const RimWellPath* wellPath,
double mdStepSize,
std::vector<double>& xValues,
std::vector<double>& yValues,
std::vector<double>& tvdValues,
std::vector<double>& mdValues,
bool& useMdRkb );
static void exportWellPathGeometry( const RigWellPath* wellPath,
double mdStepSize,
double rkbOffset,
std::vector<double>& xValues,
std::vector<double>& yValues,
std::vector<double>& tvdValues,
std::vector<double>& mdValues );
};