mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Thermal Fracture: add python script for exporting template as surface.
This commit is contained in:
@@ -59,6 +59,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelDeviationFrkExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelPerfsFrkExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelAsymmetricFrkExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifThermalFractureTemplateSurfaceExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFaultRAXmlWriter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFaultRAJsonWriter.h
|
||||
@@ -135,6 +136,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelDeviationFrkExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelPerfsFrkExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelAsymmetricFrkExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifThermalFractureTemplateSurfaceExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFaultRAXmlWriter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFaultRAJsonWriter.cpp
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022- 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 "RifThermalFractureTemplateSurfaceExporter.h"
|
||||
|
||||
#include "RigThermalFractureDefinition.h"
|
||||
#include "RimThermalFractureTemplate.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifThermalFractureTemplateSurfaceExporter::writeToFile( RimThermalFractureTemplate* fractureTemplate,
|
||||
int timeStepIndex,
|
||||
const QString& filePath )
|
||||
{
|
||||
auto fractureData = fractureTemplate->fractureDefinition();
|
||||
auto numNodes = fractureData->numNodes();
|
||||
auto numTimeSteps = fractureData->numTimeSteps();
|
||||
auto properties = fractureData->getPropertyNamesUnits();
|
||||
|
||||
if ( timeStepIndex < 0 || timeStepIndex >= static_cast<int>( numTimeSteps ) ) return false;
|
||||
|
||||
QFile file( filePath );
|
||||
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
QTextStream out( &file );
|
||||
|
||||
out.setRealNumberPrecision( 16 );
|
||||
|
||||
auto nameAndUnits = fractureData->getPropertyNamesUnits();
|
||||
int numProperties = nameAndUnits.size();
|
||||
|
||||
for ( auto [name, unit] : nameAndUnits )
|
||||
{
|
||||
out << name << " ";
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
|
||||
for ( int nodeIndex = 0; nodeIndex < static_cast<int>( numNodes ); nodeIndex++ )
|
||||
{
|
||||
for ( int propertyIndex = 0; propertyIndex < numProperties; propertyIndex++ )
|
||||
{
|
||||
double value = fractureData->getPropertyValue( propertyIndex, nodeIndex, timeStepIndex );
|
||||
out << value;
|
||||
if ( propertyIndex < numProperties - 1 ) out << " ";
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022- 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
|
||||
|
||||
class RimThermalFractureTemplate;
|
||||
class QString;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifThermalFractureTemplateSurfaceExporter
|
||||
{
|
||||
public:
|
||||
static bool writeToFile( RimThermalFractureTemplate* stimPlanModel, int timeStep, const QString& filePath );
|
||||
};
|
||||
@@ -115,7 +115,7 @@ RimFractureTemplate::RimFractureTemplate()
|
||||
CAF_PDM_InitField( &m_id, "Id", -1, "ID" );
|
||||
m_id.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitField( &m_name, "UserDescription", QString( "Fracture Template" ), "Name" );
|
||||
CAF_PDM_InitScriptableField( &m_name, "UserDescription", QString( "Fracture Template" ), "Name" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_nameAndUnit, "NameAndUnit", "NameAndUnit" );
|
||||
m_nameAndUnit.registerGetMethod( this, &RimFractureTemplate::nameAndUnit );
|
||||
|
||||
@@ -712,3 +712,11 @@ bool RimThermalFractureTemplate::isValidResult( double value ) const
|
||||
{
|
||||
return !std::isinf( value ) && !std::isnan( value );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigThermalFractureDefinition* RimThermalFractureTemplate::fractureDefinition() const
|
||||
{
|
||||
return m_fractureDefinitionData.get();
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ public:
|
||||
|
||||
std::pair<cvf::Vec3d, cvf::Vec3d> computePositionAndRotation() const;
|
||||
|
||||
const RigThermalFractureDefinition* fractureDefinition() const;
|
||||
|
||||
protected:
|
||||
QString getFileSelectionFilter() const override;
|
||||
QStringList conductivityResultNames() const override;
|
||||
|
||||
@@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcThermalFractureTemplate.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.h
|
||||
)
|
||||
|
||||
@@ -45,6 +46,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcThermalFractureTemplate.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022- 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 "RimcThermalFractureTemplate.h"
|
||||
|
||||
#include "RifThermalFractureTemplateSurfaceExporter.h"
|
||||
|
||||
#include "RimThermalFractureTemplate.h"
|
||||
|
||||
#include "RimcDataContainerString.h"
|
||||
|
||||
#include "cafPdmAbstractFieldScriptingCapability.h"
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimThermalFractureTemplate, RimcThermalFractureTemplate_exportToFile, "ExportToFile" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcThermalFractureTemplate_exportToFile::RimcThermalFractureTemplate_exportToFile( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Export Thermal Fracture Template", "", "", "Export Thermal Fracture Template to File" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path" );
|
||||
CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcThermalFractureTemplate_exportToFile::execute()
|
||||
{
|
||||
RimThermalFractureTemplate* thermalFracture = self<RimThermalFractureTemplate>();
|
||||
RifThermalFractureTemplateSurfaceExporter::writeToFile( thermalFracture, m_timeStep(), m_filePath() );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcThermalFractureTemplate_exportToFile::resultIsPersistent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcThermalFractureTemplate_exportToFile::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimThermalFractureTemplate );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcThermalFractureTemplate_exportToFile::isNullptrValidResult() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimThermalFractureTemplate, RimcThermalFractureTemplate_timeSteps, "TimeSteps" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcThermalFractureTemplate_timeSteps::RimcThermalFractureTemplate_timeSteps( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Get Thermal Fracture Template Time Steps", "", "", "Get Thermal Fracture Template Time Steps" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcThermalFractureTemplate_timeSteps::execute()
|
||||
{
|
||||
RimThermalFractureTemplate* thermalFracture = self<RimThermalFractureTemplate>();
|
||||
auto timeSteps = thermalFracture->timeStepsStrings();
|
||||
|
||||
auto dataObject = new RimcDataContainerString;
|
||||
dataObject->m_stringValues = timeSteps;
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcThermalFractureTemplate_timeSteps::resultIsPersistent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcThermalFractureTemplate_timeSteps::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerString );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcThermalFractureTemplate_timeSteps::isNullptrValidResult() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmObjectMethod.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimThermalFractureTemplate;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcThermalFractureTemplate_exportToFile : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcThermalFractureTemplate_exportToFile( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute() override;
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
bool isNullptrValidResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_filePath;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcThermalFractureTemplate_timeSteps : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcThermalFractureTemplate_timeSteps( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute() override;
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
bool isNullptrValidResult() const override;
|
||||
};
|
||||
@@ -117,41 +117,5 @@ TEST( DISABLED_RifThermalFractureReaderTest, CreateXyzPointCloud )
|
||||
QString fileName = CASE_REAL_TEST_DATA_DIRECTORY_03 + "fracture_OS_metric_units_final.csv";
|
||||
|
||||
auto [fractureData, errorMessage] = RifThermalFractureReader::readFractureCsvFile( fileName );
|
||||
|
||||
auto numNodes = fractureData->numNodes();
|
||||
auto numTimeSteps = fractureData->numTimeSteps();
|
||||
auto properties = fractureData->getPropertyNamesUnits();
|
||||
|
||||
for ( size_t timeStepIndex = 0; timeStepIndex < numTimeSteps; timeStepIndex++ )
|
||||
{
|
||||
QString exportfileName = QString( CASE_REAL_TEST_DATA_DIRECTORY_03 + "msjtest-%1.xyz" ).arg( timeStepIndex );
|
||||
|
||||
std::vector<double> xs;
|
||||
std::vector<double> ys;
|
||||
std::vector<double> zs;
|
||||
|
||||
for ( int nodeIndex = 0; nodeIndex < static_cast<int>( numNodes ); nodeIndex++ )
|
||||
{
|
||||
xs.push_back(
|
||||
fractureData->getPropertyValue( 0, static_cast<int>( nodeIndex ), static_cast<int>( timeStepIndex ) ) );
|
||||
ys.push_back(
|
||||
fractureData->getPropertyValue( 1, static_cast<int>( nodeIndex ), static_cast<int>( timeStepIndex ) ) );
|
||||
zs.push_back(
|
||||
fractureData->getPropertyValue( 2, static_cast<int>( nodeIndex ), static_cast<int>( timeStepIndex ) ) );
|
||||
}
|
||||
|
||||
QFile file( exportfileName );
|
||||
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
QTextStream out( &file );
|
||||
|
||||
out.setRealNumberPrecision( 16 );
|
||||
|
||||
for ( size_t i = 0; i < xs.size(); i++ )
|
||||
{
|
||||
out << xs[i] << " " << ys[i] << " " << zs[i] << "\n";
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
// EXPECT_TRUE( );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user