From 2651ca91b6e455f36dd8b955a6c54ca5e7b3eea0 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 5 Jul 2024 15:57:26 +0200 Subject: [PATCH] Add well log loaders. --- .../Application/RiaApplication.cpp | 8 ++ .../WellLog/CMakeLists_files.cmake | 6 + .../WellLog/RimOsduWellLogDataLoader.cpp | 111 ++++++++++++++++++ .../WellLog/RimOsduWellLogDataLoader.h | 50 ++++++++ .../WellLog/RimWellLogFileDataLoader.cpp | 62 ++++++++++ .../WellLog/RimWellLogFileDataLoader.h | 40 +++++++ .../WellPath/CMakeLists_files.cmake | 5 +- .../WellPath/RimOsduWellPathDataLoader.cpp | 31 ++--- .../WellPath/RimOsduWellPathDataLoader.h | 1 - .../WellPath/RimWellPathCollection.cpp | 36 ++---- Fwk/AppFwk/cafDataLoader/CMakeLists.txt | 8 +- 11 files changed, 311 insertions(+), 47 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index c615eac49c..7656062f30 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -71,6 +71,8 @@ #include "RimObservedFmuRftData.h" #include "RimObservedSummaryData.h" #include "RimOilField.h" +#include "RimOsduWellLog.h" +#include "RimOsduWellLogDataLoader.h" #include "RimOsduWellPath.h" #include "RimOsduWellPathDataLoader.h" #include "RimPlotWindow.h" @@ -91,6 +93,8 @@ #include "RimSurfaceCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" +#include "RimWellLogFile.h" +#include "RimWellLogFileDataLoader.h" #include "RimWellLogLasFile.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -1758,4 +1762,8 @@ void RiaApplication::initializeDataLoadController() dataLoadController->registerDataLoader( RimModeledWellPath::classKeywordStatic(), wellPathGeometryKeyword, std::make_shared() ); + + const QString wellLogKeyword = "WELL_LOG"; + dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_shared() ); + dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_shared() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index 26f3ed0801..6022f3d169 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -31,6 +31,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.h + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -68,12 +70,16 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCalculatedCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileDataLoader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellLogDataLoader.h) + source_group( "ProjectDataModel\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp new file mode 100644 index 0000000000..707d830e3d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimOsduWellLogDataLoader.h" + +#include "Cloud/RiaOsduConnector.h" +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimOsduWellLog.h" + +#include "RifOsduWellLogReader.h" + +#include "RigWellLogData.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimOsduWellLogDataLoader::RimOsduWellLogDataLoader() + : caf::DataLoader() +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + connect( osduConnector, + SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), + this, + SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ), + Qt::QueuedConnection ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + RiaApplication* app = RiaApplication::instance(); + RiaOsduConnector* osduConnector = app->makeOsduConnector(); + + // TODO: this is weird? + m_dataType = dataType; + + if ( RimOsduWellLog* osduWellLog = dynamic_cast( &pdmObject ) ) + { + QString wellLogId = osduWellLog->wellLogId(); + osduConnector->requestWellLogParquetDataById( wellLogId ); + m_wellLogs[wellLogId] = osduWellLog; + m_taskIds[wellLogId] = taskId; + } + QApplication::processEvents(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimOsduWellLogDataLoader::isRunnable() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimOsduWellLogDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ) +{ + QMutexLocker lock( &m_mutex ); + + if ( m_wellLogs.find( id ) != m_wellLogs.end() ) + { + int taskId = m_taskIds[id]; + + RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); + + if ( !contents.isEmpty() ) + { + auto osduWellLog = m_wellLogs[id]; + auto [wellLogData, errorMessage] = RifOsduWellLogReader::readWellLogData( contents ); + + if ( wellLogData.notNull() ) + { + osduWellLog->setWellLogData( wellLogData.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } + } + + taskDone.send( m_dataType, taskId ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h new file mode 100644 index 0000000000..77123c05be --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLogDataLoader.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include +#include +#include + +class RimOsduWellLog; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimOsduWellLogDataLoader : public QObject, public caf::DataLoader +{ + Q_OBJECT +public: + RimOsduWellLogDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; + +private slots: + void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); + +private: + std::map m_wellLogs; + std::map m_taskIds; + QString m_dataType; + QMutex m_mutex; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp new file mode 100644 index 0000000000..dc9b482dd1 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimWellLogFileDataLoader.h" + +#include "RiaLogging.h" +#include "RimWellLogFile.h" + +#include "RigWellPath.h" + +#include "cafProgressInfo.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileDataLoader::RimWellLogFileDataLoader() + : caf::DataLoader() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFileDataLoader::loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) +{ + if ( RimWellLogFile* wellLogFile = dynamic_cast( &pdmObject ) ) + { + QString errorMessage; + if ( !wellLogFile->readFile( &errorMessage ) ) + { + RiaLogging::warning( errorMessage ); + } + } + + taskDone.send( dataType, taskId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogFileDataLoader::isRunnable() const +{ + return true; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h new file mode 100644 index 0000000000..8186d50948 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileDataLoader.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RimFileWellPath.h" + +#include "cafDataLoader.h" +#include "cafProgressInfo.h" + +#include + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogFileDataLoader : public caf::DataLoader +{ +public: + RimWellLogFileDataLoader(); + void loadData( caf::PdmObject& pdmObject, const QString& dataType, int taskId, caf::ProgressInfo& progressInfo ) override; + bool isRunnable() const override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake index 14418631df..f84f4f9c8b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellPath/CMakeLists_files.cmake @@ -48,8 +48,9 @@ list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h) - +list(APPEND QT_MOC_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/RimOsduWellPathDataLoader.h +) source_group( "ProjectDataModel\\WellPath" diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp index 72f1ea04bf..b823e7b51c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.cpp @@ -84,26 +84,27 @@ bool RimOsduWellPathDataLoader::isRunnable() const //-------------------------------------------------------------------------------------------------- void RimOsduWellPathDataLoader::parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ) { - RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); - QMutexLocker lock( &m_mutex ); - int taskId = m_taskIds[id]; - if ( !contents.isEmpty() ) + if ( m_wellPaths.find( id ) != m_wellPaths.end() ) { - m_parquetData[id] = contents; + RiaLogging::info( QString( "Parquet download complete. Id: %1 Size: %2" ).arg( id ).arg( contents.size() ) ); + int taskId = m_taskIds[id]; - auto oWPath = m_wellPaths[id]; - auto [wellPathGeometry, errorMessage] = RifOsduWellPathReader::readWellPathData( contents, oWPath->datumElevationFromOsdu() ); - if ( wellPathGeometry.notNull() ) + if ( !contents.isEmpty() ) { - oWPath->setWellPathGeometry( wellPathGeometry.p() ); - } - else - { - RiaLogging::warning( errorMessage ); + auto oWPath = m_wellPaths[id]; + auto [wellPathGeometry, errorMessage] = RifOsduWellPathReader::readWellPathData( contents, oWPath->datumElevationFromOsdu() ); + if ( wellPathGeometry.notNull() ) + { + oWPath->setWellPathGeometry( wellPathGeometry.p() ); + } + else + { + RiaLogging::warning( errorMessage ); + } } + + taskDone.send( m_dataType, taskId ); } - - taskDone.send( m_dataType, taskId ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h index 7387e40986..230cb7c6cf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimOsduWellPathDataLoader.h @@ -43,7 +43,6 @@ private slots: void parquetDownloadComplete( const QByteArray& contents, const QString& url, const QString& id ); private: - std::map m_parquetData; std::map m_wellPaths; std::map m_taskIds; QString m_dataType; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index b66067adc4..608081d187 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -151,47 +151,37 @@ void RimWellPathCollection::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::loadDataAndUpdate() { - caf::ProgressInfo progress( m_wellPaths.size(), "Reading well paths from file" ); + caf::ProgressInfo progress( 3, "Reading well paths from file" ); readWellPathFormationFiles(); - RiaApplication* app = RiaApplication::instance(); - caf::DataLoadController* dataLoadController = caf::DataLoadController::instance(); const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY"; + const QString wellLogKeyword = "WELL_LOG"; + progress.setProgressDescription( QString( "Reading well path geometry." ) ); for ( RimWellPath* wellPath : allWellPaths() ) { - progress.setProgressDescription( QString( "Reading well %1" ).arg( wellPath->name() ) ); dataLoadController->loadData( *wellPath, wellPathGeometryKeyword, progress ); } - dataLoadController->blockUntilDone( wellPathGeometryKeyword ); + progress.incrementProgress(); + progress.setProgressDescription( QString( "Reading well logs." ) ); for ( RimWellPath* wellPath : allWellPaths() ) { for ( RimWellLog* wellLog : wellPath->wellLogs() ) { - if ( RimWellLogFile* wellLogFile = dynamic_cast( wellLog ) ) - { - QString errorMessage; - if ( !wellLogFile->readFile( &errorMessage ) ) - { - RiaLogging::warning( errorMessage ); - } - } - else if ( RimOsduWellLog* osduWellLog = dynamic_cast( wellLog ) ) - { - RiaOsduConnector* osduConnector = app->makeOsduConnector(); - auto [wellLogData, errorMessage] = loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() ); - if ( wellLogData.notNull() ) - { - osduWellLog->setWellLogData( wellLogData.p() ); - } - } + dataLoadController->loadData( *wellLog, wellLogKeyword, progress ); } + } + dataLoadController->blockUntilDone( wellLogKeyword ); + progress.incrementProgress(); + progress.setProgressDescription( QString( "Reading additional data." ) ); + for ( RimWellPath* wellPath : allWellPaths() ) + { RimStimPlanModelCollection* stimPlanModelCollection = wellPath->stimPlanModelCollection(); if ( stimPlanModelCollection ) { @@ -200,8 +190,8 @@ void RimWellPathCollection::loadDataAndUpdate() stimPlanModel->loadDataAndUpdate(); } } - progress.incrementProgress(); } + progress.incrementProgress(); rebuildWellPathNodes(); diff --git a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt index a805077cbd..a4296954fe 100644 --- a/Fwk/AppFwk/cafDataLoader/CMakeLists.txt +++ b/Fwk/AppFwk/cafDataLoader/CMakeLists.txt @@ -25,12 +25,8 @@ else() endif() set(PROJECT_FILES - cafDataLoader.h - cafDataLoader.cpp - cafDataLoadTask.h - cafDataLoadTask.cpp - cafDataLoadController.h - cafDataLoadController.cpp + cafDataLoader.h cafDataLoader.cpp cafDataLoadTask.h cafDataLoadTask.cpp + cafDataLoadController.h cafDataLoadController.cpp ) add_library(${PROJECT_NAME} ${PROJECT_FILES})