#9099 Thermal Fracture Import: include perimter nodes.

This commit is contained in:
Kristian Bendiksen 2022-07-06 10:42:35 +02:00
parent 6f623e9320
commit 44c469c12c
8 changed files with 218 additions and 59 deletions

View File

@ -44,12 +44,12 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
QString separator = ",";
auto appendPropertyValues = [def]( int nodeIndex, int timeStepIndex, int valueOffset, const QStringList& values ) {
auto appendPropertyValues = [def]( int nodeIndex, int valueOffset, const QStringList& values ) {
for ( int i = valueOffset; i < values.size() - 1; i++ )
{
double value = values[i].toDouble();
int propertyIndex = i - valueOffset;
def->appendPropertyValue( propertyIndex, nodeIndex, timeStepIndex, value );
def->appendPropertyValue( propertyIndex, nodeIndex, value );
}
};
@ -60,8 +60,8 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
// The two items in the csv is name and timestep
const int valueOffset = 2;
int nodeIndex = 0;
int timeStepIndex = 0;
bool isFirstHeader = true;
bool isValidNode = false;
while ( !in.atEnd() )
{
QString line = in.readLine();
@ -84,10 +84,9 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
isFirstHeader = false;
}
else
else if ( isValidNode )
{
nodeIndex++;
timeStepIndex = 0;
}
}
else if ( isCenterNodeLine( line ) )
@ -96,27 +95,22 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
auto values = RifFileParseTools::splitLineAndTrim( line, separator );
// Second is the timestamp
QString dateString = values[1];
QString dateFormat = "dd.MM.yyyy hh:mm:ss";
QDateTime dateTime = QDateTime::fromString( dateString, dateFormat );
// Sometimes the datetime field is missing time
if ( !dateTime.isValid() )
{
QString dateFormat = "dd.MM.yyyy";
dateTime = QDateTime::fromString( dateString, dateFormat );
}
QDateTime dateTime = parseDateTime( values[1] );
def->addTimeStep( dateTime.toSecsSinceEpoch() );
//
appendPropertyValues( nodeIndex, timeStepIndex, valueOffset, values );
timeStepIndex = 0;
appendPropertyValues( nodeIndex, valueOffset, values );
isValidNode = true;
}
else if ( isInternalNodeLine( line ) )
else if ( isInternalNodeLine( line ) || isPerimeterNodeLine( line ) )
{
auto values = RifFileParseTools::splitLineAndTrim( line, separator );
appendPropertyValues( nodeIndex, timeStepIndex, valueOffset, values );
timeStepIndex = 0;
appendPropertyValues( nodeIndex, valueOffset, values );
isValidNode = true;
}
else
{
isValidNode = false;
}
lineNumber++;
@ -125,6 +119,23 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
return std::make_pair( def, "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RifThermalFractureReader::parseDateTime( const QString& dateString )
{
QString dateFormat = "dd.MM.yyyy hh:mm:ss";
QDateTime dateTime = QDateTime::fromString( dateString, dateFormat );
// Sometimes the datetime field is missing time
if ( !dateTime.isValid() )
{
QString dateFormat = "dd.MM.yyyy";
dateTime = QDateTime::fromString( dateString, dateFormat );
}
return dateTime;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -149,6 +160,20 @@ bool RifThermalFractureReader::isInternalNodeLine( const QString& line )
return line.contains( "Internal Node" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifThermalFractureReader::isPerimeterNodeLine( const QString& line )
{
std::vector<QString> validPerimeterNames = { "Perimeter Node", "Bottom Node", "Top Node", "Right Node", "Left Node" };
bool result = std::any_of( validPerimeterNames.begin(), validPerimeterNames.end(), [line]( const QString& str ) {
return line.contains( str );
} );
return result;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -18,12 +18,16 @@
#pragma once
#include <QDateTime>
#include <QString>
#include <memory>
class RigThermalFractureDefinition;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RifThermalFractureReader
{
public:
@ -33,6 +37,9 @@ private:
static bool isHeaderLine( const QString& line );
static bool isCenterNodeLine( const QString& line );
static bool isInternalNodeLine( const QString& line );
static bool isPerimeterNodeLine( const QString& line );
static QDateTime parseDateTime( const QString& dateString );
static std::pair<QString, QString> parseNameAndUnit( const QString& value );
};

View File

@ -62,6 +62,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureResultUtil.h
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureResult.h
${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h
${CMAKE_CURRENT_LIST_DIR}/RigConvexHull.h
@ -154,6 +155,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureResultUtil.cpp
${CMAKE_CURRENT_LIST_DIR}/RigThermalFractureResult.cpp
${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp
${CMAKE_CURRENT_LIST_DIR}/RigConvexHull.cpp

View File

@ -110,12 +110,12 @@ std::vector<std::pair<QString, QString>> RigThermalFractureDefinition::getProper
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigThermalFractureDefinition::appendPropertyValue( int propertyIndex, int nodeIndex, int timeStepIndex, double value )
void RigThermalFractureDefinition::appendPropertyValue( int propertyIndex, int nodeIndex, double value )
{
CAF_ASSERT( propertyIndex >= 0 );
CAF_ASSERT( propertyIndex < static_cast<int>( m_results.size() ) );
m_results[propertyIndex].appendValue( nodeIndex, timeStepIndex, value );
m_results[propertyIndex].appendValue( nodeIndex, value );
}
//--------------------------------------------------------------------------------------------------

View File

@ -20,47 +20,14 @@
#include "RiaDefines.h"
#include "RigThermalFractureResult.h"
#include "cvfVector3.h"
#include <QString>
#include <vector>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigThermalFractureResult
{
public:
RigThermalFractureResult( const QString& name, const QString& unit )
: m_name( name )
, m_unit( unit )
{
}
QString name() const { return m_name; }
QString unit() const { return m_unit; }
void appendValue( int nodeIndex, int timeStepIndex, double value )
{
if ( nodeIndex >= static_cast<int>( parameterValues.size() ) )
parameterValues.push_back( { value } );
else
parameterValues[nodeIndex].push_back( value );
}
double getValue( int nodeIndex, int timeStepIndex ) const { return parameterValues[nodeIndex][timeStepIndex]; }
size_t numNodes() const { return parameterValues.size(); }
private:
QString m_name;
QString m_unit;
// Vector for each time step for each node
std::vector<std::vector<double>> parameterValues;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -83,7 +50,7 @@ public:
std::vector<std::pair<QString, QString>> getPropertyNamesUnits() const;
void appendPropertyValue( int propertyIndex, int nodeIndex, int timeStepIndex, double value );
void appendPropertyValue( int propertyIndex, int nodeIndex, double value );
double getPropertyValue( int propertyIndex, int nodeIndex, int timeStepIndex ) const;

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigThermalFractureResult.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigThermalFractureResult::RigThermalFractureResult( const QString& name, const QString& unit )
: m_name( name )
, m_unit( unit )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigThermalFractureResult::name() const
{
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigThermalFractureResult::unit() const
{
return m_unit;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigThermalFractureResult::appendValue( int nodeIndex, double value )
{
if ( nodeIndex >= static_cast<int>( m_parameterValues.size() ) )
m_parameterValues.push_back( { value } );
else
m_parameterValues[nodeIndex].push_back( value );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigThermalFractureResult::getValue( int nodeIndex, int timeStepIndex ) const
{
return m_parameterValues[nodeIndex][timeStepIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigThermalFractureResult::numNodes() const
{
return m_parameterValues.size();
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
#include "RiaDefines.h"
#include "cvfVector3.h"
#include <QString>
#include <vector>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigThermalFractureResult
{
public:
RigThermalFractureResult( const QString& name, const QString& unit );
QString name() const;
QString unit() const;
void appendValue( int nodeIndex, double value );
double getValue( int nodeIndex, int timeStepIndex ) const;
size_t numNodes() const;
private:
QString m_name;
QString m_unit;
// Vector for each time step for each node
std::vector<std::vector<double>> m_parameterValues;
};

View File

@ -21,7 +21,7 @@ TEST( RifThermalFractureReaderTest, LoadFile )
EXPECT_EQ( "frac01", fractureData->name().toStdString() );
EXPECT_EQ( fractureData->numNodes(), 57u );
EXPECT_EQ( fractureData->numNodes(), 81u );
EXPECT_EQ( fractureData->numTimeSteps(), 29u );
@ -42,4 +42,40 @@ TEST( RifThermalFractureReaderTest, LoadFile )
EXPECT_DOUBLE_EQ( centerNodeY, fractureData->getPropertyValue( 1, nodeIndex, static_cast<int>( timeStepIndex ) ) );
EXPECT_DOUBLE_EQ( centerNodeZ, fractureData->getPropertyValue( 2, nodeIndex, static_cast<int>( timeStepIndex ) ) );
}
{
// Sample from center node: LeakoffPressureDrop from last time step
double expectedValue = 18.8747;
int propertyIndex = 18;
int nodeIndex = 0;
int timeStepIndex = 28;
EXPECT_DOUBLE_EQ( expectedValue, fractureData->getPropertyValue( propertyIndex, nodeIndex, timeStepIndex ) );
}
{
// Sample from internal node: EffectiveFracStress from tenth time step
double expectedValue = 7.72785;
int propertyIndex = 17;
int nodeIndex = 2;
int timeStepIndex = 10;
EXPECT_DOUBLE_EQ( expectedValue, fractureData->getPropertyValue( propertyIndex, nodeIndex, timeStepIndex ) );
}
{
// Sample from bottom node: EffectiveResStress from fifth time step
double expectedValue = 28.5565;
int propertyIndex = 16;
int nodeIndex = 57;
int timeStepIndex = 6;
EXPECT_DOUBLE_EQ( expectedValue, fractureData->getPropertyValue( propertyIndex, nodeIndex, timeStepIndex ) );
}
{
// Sample from perimeter node: ResTemperature from eight time step
double expectedValue = 10.3882;
int propertyIndex = 13;
int nodeIndex = 58;
int timeStepIndex = 7;
EXPECT_DOUBLE_EQ( expectedValue, fractureData->getPropertyValue( propertyIndex, nodeIndex, timeStepIndex ) );
}
}