From 1b9a6742138b0fe97a0972928131980e81c3cfba Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Fri, 13 Nov 2020 10:58:24 +0100 Subject: [PATCH] Merged in VFP-tables commit 263beb8cf6a9f84a0a68ae50456eb8af2d44053b. --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimVfpPlot.cpp | 100 ++++++++++++++---- ApplicationCode/ProjectDataModel/RimVfpPlot.h | 4 +- .../ProjectDataModel/RimVfpTableExtractor.cpp | 67 ++++++++++++ .../ProjectDataModel/RimVfpTableExtractor.h | 33 ++++++ 5 files changed, 182 insertions(+), 24 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimVfpTableExtractor.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimVfpTableExtractor.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index d42ecd41ea..935c1c180c 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -161,6 +161,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.h ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.h ${CMAKE_CURRENT_LIST_DIR}/RimAbstractPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.h ) @@ -325,6 +326,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimElementVectorResult.cpp ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.cpp ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp index 45c1875c51..e20b31f2a0 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp @@ -22,6 +22,7 @@ #include "RimFlowDiagSolution.h" #include "RimProject.h" #include "RimTools.h" +#include "RimVfpTableExtractor.h" #include "RigEclipseCaseData.h" #include "RigTofWellDistributionCalculator.h" @@ -34,6 +35,7 @@ #include "qwt_legend_label.h" #include "qwt_plot.h" #include "qwt_plot_curve.h" +#include "qwt_symbol.h" #include #include @@ -44,6 +46,10 @@ #include "cvfDebugTimer.h" #include "cvfTrace.h" +#include + +#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" + //================================================================================================== // // @@ -322,17 +328,31 @@ void RimVfpPlot::onLoadDataAndUpdate() if ( m_case && m_case->ensureReservoirCaseIsOpen() ) { // TODO: extract data from data file + // - // TODO: populate with real data - populatePlotWidgetWithCurveData( m_plotWidget ); + std::set wells = {"F2H", "C1H", "C2H", "C3H", "C4AH", "C4H", "F1H", "F3H", "F4H"}; + std::string strippedWellName = QString( m_wellName() ).remove( "-" ).toStdString(); - // TODO: Maybe display the phase? - // if ( m_phase == RiaDefines::OIL_PHASE ) - // phaseString = "Oil"; - // else if ( m_phase == RiaDefines::GAS_PHASE ) - // phaseString = "Gas"; - // else if ( m_phase == RiaDefines::WATER_PHASE ) - // phaseString = "Water"; + if ( wells.find( strippedWellName ) != wells.end() ) + { + QString gridFileName = m_case->gridFileName(); + std::cout << "Grid file name: " << gridFileName.toStdString() << std::endl; + QFileInfo fi( gridFileName ); + + std::string filename = fi.canonicalPath().toStdString() + "/INCLUDE/VFP/" + strippedWellName + ".Ecl"; + const std::vector tables = RimVfpTableExtractor::extractVfpInjectionTables( filename ); + + // TODO: populate with real data + populatePlotWidgetWithCurveData( m_plotWidget, tables ); + + // TODO: Maybe display the phase? + // if ( m_phase == RiaDefines::OIL_PHASE ) + // phaseString = "Oil"; + // else if ( m_phase == RiaDefines::GAS_PHASE ) + // phaseString = "Gas"; + // else if ( m_phase == RiaDefines::WATER_PHASE ) + // phaseString = "Water"; + } } const QString plotTitleStr = QString( "%1 Vertical Flow Performance Plot" ).arg( m_wellName ); @@ -349,7 +369,7 @@ void RimVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ) +void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const std::vector& tables ) { cvf::Trace::show( "RimVfpPlot::populatePlotWidgetWithCurves()" ); @@ -359,25 +379,59 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ) plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); - size_t numTables = 4; + size_t numTables = tables.size(); for ( size_t i = 0; i < numTables; i++ ) { - // Just create some dummy values for now - int numDummyValues = 100; - std::vector xVals( numDummyValues, 10 * i ); - std::vector yVals( numDummyValues, 100 * i ); + const Opm::VFPInjTable table = tables[i]; + std::cout << "Datum depth: " << table.getDatumDepth() << std::endl; + std::cout << "Table number: " << table.getTableNum() << std::endl; + std::cout << "Flow type: " << static_cast( table.getFloType() ) << std::endl; + std::cout << "Flo axis: " << table.getFloAxis().size() << std::endl; + std::cout << "THP axis: " << table.getTHPAxis().size() << std::endl; - cvf::Color3f cvfClr = cvf::Color3::BLUE; - QColor qtClr = RiaColorTools::toQColor( cvfClr ); + std::cout << "THP Axis:\n"; + for ( size_t x = 0; x < table.getTHPAxis().size(); x++ ) + { + std::cout << " " << table.getTHPAxis()[x]; + } + std::cout << "\n"; - QwtPlotCurve* curve = new QwtPlotCurve; - curve->setTitle( QString( "Table: %1" ).arg( i ) ); - curve->setBrush( qtClr ); + for ( size_t y = 0; y < table.getFloAxis().size(); y++ ) + { + for ( size_t x = 0; x < table.getTHPAxis().size(); x++ ) + { + std::cout << " " << table( x, y ); + } + std::cout << std::endl; + } - curve->setSamples( xVals.data(), yVals.data(), numDummyValues ); - curve->attach( plotWidget ); - curve->show(); + for ( size_t thp = 0; thp < table.getTHPAxis().size(); thp++ ) + { + // Just create some dummy values for now + size_t numValues = table.getFloAxis().size(); + std::vector xVals = table.getFloAxis(); + std::vector yVals( numValues, 0.0 ); + for ( size_t y = 0; y < numValues; y++ ) + { + // Convert from Pascal to Bar + yVals[y] = table( thp, y ) / 100000.0; + } + + cvf::Color3f cvfClr = cvf::Color3::BLUE; + QColor qtClr = RiaColorTools::toQColor( cvfClr ); + + QwtPlotCurve* curve = new QwtPlotCurve; + // Convert from Pascal to Bar + curve->setTitle( QString( "THP: %1 Bar" ).arg( table.getTHPAxis()[thp] / 100000.0 ) ); + // curve->setBrush( qtClr ); + QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( qtClr ), QPen( Qt::red, 2 ), QSize( 8, 8 ) ); + curve->setSymbol( symbol ); + + curve->setSamples( xVals.data(), yVals.data(), numValues ); + curve->attach( plotWidget ); + curve->show(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.h b/ApplicationCode/ProjectDataModel/RimVfpPlot.h index 1683401f46..12ed3c4bda 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.h +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.h @@ -24,6 +24,8 @@ #include +#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" + class RimEclipseResultCase; class RimFlowDiagSolution; class RigTofWellDistributionCalculator; @@ -79,7 +81,7 @@ private: RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; void fixupDependentFieldsAfterCaseChange(); - static void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ); + static void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const std::vector& tables ); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.cpp b/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.cpp new file mode 100644 index 0000000000..e17db1f1b7 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.cpp @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimVfpTableExtractor.h" + +// #include "RiaApplication.h" + +// #include "RimCase.h" +// #include "RimEclipseCase.h" +// #include "RimGeoMechCase.h" +// #include "RimOilField.h" +// #include "RimProject.h" +// #include "RimWellLogFile.h" +// #include "RimWellPath.h" +// #include "RimWellPathCollection.h" + +#include "cafPdmUiItem.h" +#include "cafUtils.h" + +// #include +// #include +// #include + +#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" +#include "opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp" +#include "opm/parser/eclipse/Parser/Parser.hpp" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpTableExtractor::extractVfpInjectionTables( const std::string& filename ) +{ + std::vector tables; + + Opm::Parser parser; + auto deck = parser.parseFile( filename ); + + std::string myKeyword = "VFPINJ"; + auto keywordList = deck.getKeywordList( myKeyword ); + + Opm::UnitSystem unitSystem; + + for ( auto kw : keywordList ) + { + auto name = kw->name(); + + Opm::VFPInjTable table( *kw, unitSystem ); + tables.push_back( table ); + } + + return tables; +} diff --git a/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.h b/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.h new file mode 100644 index 0000000000..49882fd8e4 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpTableExtractor.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +#include + +#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RimVfpTableExtractor +{ +public: + static std::vector extractVfpInjectionTables( const std::string& filename ); +};