From 466827e7d0aba2e6dccece30d8d34c2853f16803 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 3 Jun 2020 12:48:57 +0200 Subject: [PATCH] #6007 Reload facies properties when project is reopened. --- .../Application/RiaApplication.cpp | 14 +++ .../Commands/CMakeLists_files.cmake | 2 + .../RicFaciesPropertiesImportTools.cpp | 107 ++++++++++++++++++ .../Commands/RicFaciesPropertiesImportTools.h | 36 ++++++ .../RicImportFaciesPropertiesFeature.cpp | 76 +------------ .../Completions/RimFractureModel.cpp | 11 ++ .../Completions/RimFractureModel.h | 2 + .../ProjectDataModel/RimFaciesProperties.cpp | 17 +++ .../ProjectDataModel/RimFaciesProperties.h | 2 + 9 files changed, 193 insertions(+), 74 deletions(-) create mode 100644 ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp create mode 100644 ApplicationCode/Commands/RicFaciesPropertiesImportTools.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 8dd0ec2759..b051f2f286 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -52,6 +52,8 @@ #include "RimEclipseView.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" +#include "RimFractureModel.h" +#include "RimFractureModelCollection.h" #include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" @@ -93,6 +95,7 @@ #include "RimWellPathFracture.h" #include "RimWellPltPlot.h" #include "RimWellRftPlot.h" +#include "RimWellPath.h" #include "Riu3DMainWindowTools.h" #include "RiuViewer.h" @@ -514,6 +517,17 @@ bool RiaApplication::loadProject( const QString& projectFileName, { oilField->wellPathCollection->loadDataAndUpdate(); oilField->wellPathCollection->readWellPathFormationFiles(); + for ( RimWellPath* wellPath : oilField->wellPathCollection->wellPaths() ) + { + RimFractureModelCollection* fractureModelCollection = wellPath->fractureModelCollection(); + if ( fractureModelCollection ) + { + for ( RimFractureModel* fractureModel : fractureModelCollection->allFractureModels() ) + { + fractureModel->loadDataAndUpdate(); + } + } + } } } diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index f71e93fd66..1b369d4e2f 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellMeasurementFilePathFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicReloadWellMeasurementsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellMeasurementImportTools.h ${CMAKE_CURRENT_LIST_DIR}/RicImportFaciesPropertiesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFaciesPropertiesImportTools.h ${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h @@ -157,6 +158,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellMeasurementFilePathFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicReloadWellMeasurementsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellMeasurementImportTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportFaciesPropertiesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFaciesPropertiesImportTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp diff --git a/ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp b/ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp new file mode 100644 index 0000000000..5949360c71 --- /dev/null +++ b/ApplicationCode/Commands/RicFaciesPropertiesImportTools.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicFaciesPropertiesImportTools.h" + +#include "RiaLogging.h" + +#include "RimFractureModel.h" +#include "RimFaciesProperties.h" + +#include "RifFaciesPropertiesReader.h" +#include "RifFileParseTools.h" + +#include "RigFaciesProperties.h" + +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( const QString& filePath, + RimFractureModel* fractureModel ) +{ + typedef std::tuple FaciesKey; + + // Read the facies properties from file + std::vector rifFaciesProperties; + try + { + QStringList filePaths; + filePaths << filePath; + RifFaciesPropertiesReader::readFaciesProperties( rifFaciesProperties, filePaths ); + } + catch ( FileParseException& exception ) + { + RiaLogging::warning( QString( "Facies properties import failed: '%1'." ).arg( exception.message ) ); + return; + } + + + // Find the unique facies keys (combination of field, formation and facies names) + std::set faciesKeys; + for ( RifFaciesProperties item : rifFaciesProperties ) + { + FaciesKey faciesKey = std::make_tuple( item.fieldName, item.formationName, item.faciesName ); + faciesKeys.insert( faciesKey ); + } + + RimFaciesProperties* rimFaciesProperties = new RimFaciesProperties; + // rimFaciesProperties->setFilePath(); + for ( FaciesKey key : faciesKeys ) + { + std::vector matchingFacies; + + QString fieldName = std::get<0>( key ); + QString formationName = std::get<1>( key ); + QString faciesName = std::get<2>( key ); + + // Group the items with a given facies key + for ( RifFaciesProperties item : rifFaciesProperties ) + { + if ( item.fieldName == fieldName && item.formationName == formationName && item.faciesName == faciesName ) + { + matchingFacies.push_back( item ); + } + } + + // Sort the matching items by porosity + std::sort( matchingFacies.begin(), + matchingFacies.end(), + []( const RifFaciesProperties& a, const RifFaciesProperties& b ) { return a.porosity < b.porosity; } ); + + // Finally add the values + RigFaciesProperties rigFaciesProperties( fieldName, formationName, faciesName ); + for ( RifFaciesProperties item : matchingFacies ) + { + rigFaciesProperties.appendValues( item.porosity, + item.youngsModulus, + item.poissonsRatio, + item.K_Ic, + item.proppantEmbedment ); + } + + rimFaciesProperties->setPropertiesForFacies( key, rigFaciesProperties ); + } + + rimFaciesProperties->setFilePath( filePath ); + fractureModel->setFaciesProperties( rimFaciesProperties ); + fractureModel->updateConnectedEditors(); +} diff --git a/ApplicationCode/Commands/RicFaciesPropertiesImportTools.h b/ApplicationCode/Commands/RicFaciesPropertiesImportTools.h new file mode 100644 index 0000000000..fb92efea22 --- /dev/null +++ b/ApplicationCode/Commands/RicFaciesPropertiesImportTools.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RimFractureModel; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RicFaciesPropertiesImportTools +{ +public: + static void importFaciesPropertiesFromFile( const QString& filePath, RimFractureModel* fractureModel ); + +private: + // Hidden to avoid instantiation + RicFaciesPropertiesImportTools(); +}; diff --git a/ApplicationCode/Commands/RicImportFaciesPropertiesFeature.cpp b/ApplicationCode/Commands/RicImportFaciesPropertiesFeature.cpp index a5b884f88a..94fa945143 100644 --- a/ApplicationCode/Commands/RicImportFaciesPropertiesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFaciesPropertiesFeature.cpp @@ -19,14 +19,9 @@ #include "RicImportFaciesPropertiesFeature.h" #include "RiaApplication.h" -#include "RiaLogging.h" -#include "RifFaciesPropertiesReader.h" -#include "RifFileParseTools.h" +#include "RicFaciesPropertiesImportTools.h" -#include "RigFaciesProperties.h" - -#include "RimFaciesProperties.h" #include "RimFractureModel.h" #include "Riu3DMainWindowTools.h" @@ -36,9 +31,6 @@ #include #include -#include -#include - CAF_CMD_SOURCE_INIT( RicImportFaciesPropertiesFeature, "RicImportFaciesPropertiesFeature" ); //-------------------------------------------------------------------------------------------------- @@ -70,71 +62,7 @@ void RicImportFaciesPropertiesFeature::onActionTriggered( bool isChecked ) // Remember the path to next time app->setLastUsedDialogDirectory( "FACIES_DIR", QFileInfo( filePath ).absolutePath() ); - typedef std::tuple FaciesKey; - - // Read the facies properties from file - std::vector rifFaciesProperties; - try - { - QStringList filePaths; - filePaths << filePath; - RifFaciesPropertiesReader::readFaciesProperties( rifFaciesProperties, filePaths ); - } - catch ( FileParseException& exception ) - { - RiaLogging::warning( QString( "Facies properties import failed: '%1'." ).arg( exception.message ) ); - return; - } - - // Find the unique facies keys (combination of field, formation and facies names) - std::set faciesKeys; - for ( RifFaciesProperties item : rifFaciesProperties ) - { - FaciesKey faciesKey = std::make_tuple( item.fieldName, item.formationName, item.faciesName ); - faciesKeys.insert( faciesKey ); - } - - RimFaciesProperties* rimFaciesProperties = new RimFaciesProperties; - // rimFaciesProperties->setFilePath(); - for ( FaciesKey key : faciesKeys ) - { - std::vector matchingFacies; - - QString fieldName = std::get<0>( key ); - QString formationName = std::get<1>( key ); - QString faciesName = std::get<2>( key ); - - // Group the items with a given facies key - for ( RifFaciesProperties item : rifFaciesProperties ) - { - if ( item.fieldName == fieldName && item.formationName == formationName && item.faciesName == faciesName ) - { - matchingFacies.push_back( item ); - } - } - - // Sort the matching items by porosity - std::sort( matchingFacies.begin(), - matchingFacies.end(), - []( const RifFaciesProperties& a, const RifFaciesProperties& b ) { return a.porosity < b.porosity; } ); - - // Finally add the values - RigFaciesProperties rigFaciesProperties( fieldName, formationName, faciesName ); - for ( RifFaciesProperties item : matchingFacies ) - { - rigFaciesProperties.appendValues( item.porosity, - item.youngsModulus, - item.poissonsRatio, - item.K_Ic, - item.proppantEmbedment ); - } - - rimFaciesProperties->setPropertiesForFacies( key, rigFaciesProperties ); - } - - rimFaciesProperties->setFilePath( filePath ); - fractureModel->setFaciesProperties( rimFaciesProperties ); - fractureModel->updateConnectedEditors(); + RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( filePath, fractureModel ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.cpp index ad60627c05..a7141b806e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.cpp @@ -472,3 +472,14 @@ void RimFractureModel::setFaciesProperties( RimFaciesProperties* faciesPropertie { m_faciesProperties = faciesProperties; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureModel::loadDataAndUpdate() +{ + if ( m_faciesProperties ) + { + m_faciesProperties->loadDataAndUpdate(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.h index a2c3be0658..2931b72715 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureModel.h @@ -71,6 +71,8 @@ public: RimWellPath* wellPath() const; + void loadDataAndUpdate(); + RimModeledWellPath* thicknessDirectionWellPath() const; void setThicknessDirectionWellPath( RimModeledWellPath* thicknessDirectionWellPath ); void setFaciesProperties( RimFaciesProperties* faciesProperties ); diff --git a/ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp b/ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp index f5e1d7f2d6..8ac61c753f 100644 --- a/ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaciesProperties.cpp @@ -18,6 +18,10 @@ #include "RimFaciesProperties.h" +#include "RimFractureModel.h" + +#include "RicFaciesPropertiesImportTools.h" + #include "cafPdmUiLineEditor.h" #include "cafPdmUiTextEditor.h" @@ -170,3 +174,16 @@ QString RimFaciesProperties::generatePropertiesTable() return header + body + footer; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaciesProperties::loadDataAndUpdate() +{ + if ( !m_filePath().path().isEmpty() ) + { + RimFractureModel* fractureModel; + firstAncestorOrThisOfType( fractureModel ); + RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( m_filePath().path(), fractureModel ); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimFaciesProperties.h b/ApplicationCode/ProjectDataModel/RimFaciesProperties.h index d0a5f43cfa..4a56784565 100644 --- a/ApplicationCode/ProjectDataModel/RimFaciesProperties.h +++ b/ApplicationCode/ProjectDataModel/RimFaciesProperties.h @@ -48,6 +48,8 @@ public: bool hasPropertiesForFacies( FaciesKey& key ) const; const RigFaciesProperties& propertiesForFacies( FaciesKey& key ) const; + void loadDataAndUpdate(); + protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName,