Thermal Fracture: add python script for exporting template as surface.

This commit is contained in:
Kristian Bendiksen
2022-09-07 13:39:27 +02:00
parent 0e49d983a2
commit 619807b81f
11 changed files with 442 additions and 38 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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 );
};