Merged in VFP-tables commit 263beb8cf6a9f84a0a68ae50456eb8af2d44053b.

This commit is contained in:
Ruben Thoms 2020-11-13 10:58:24 +01:00 committed by Magne Sjaastad
parent 6636a29882
commit 1b9a674213
5 changed files with 182 additions and 24 deletions

View File

@ -161,6 +161,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.h ${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.h
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.h ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.h
${CMAKE_CURRENT_LIST_DIR}/RimAbstractPlotCollection.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}/RimColorLegendCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.cpp ${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.cpp
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -22,6 +22,7 @@
#include "RimFlowDiagSolution.h" #include "RimFlowDiagSolution.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h" #include "RimTools.h"
#include "RimVfpTableExtractor.h"
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
#include "RigTofWellDistributionCalculator.h" #include "RigTofWellDistributionCalculator.h"
@ -34,6 +35,7 @@
#include "qwt_legend_label.h" #include "qwt_legend_label.h"
#include "qwt_plot.h" #include "qwt_plot.h"
#include "qwt_plot_curve.h" #include "qwt_plot_curve.h"
#include "qwt_symbol.h"
#include <QGridLayout> #include <QGridLayout>
#include <QTextBrowser> #include <QTextBrowser>
@ -44,6 +46,10 @@
#include "cvfDebugTimer.h" #include "cvfDebugTimer.h"
#include "cvfTrace.h" #include "cvfTrace.h"
#include <QFileInfo>
#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp"
//================================================================================================== //==================================================================================================
// //
// //
@ -322,17 +328,31 @@ void RimVfpPlot::onLoadDataAndUpdate()
if ( m_case && m_case->ensureReservoirCaseIsOpen() ) if ( m_case && m_case->ensureReservoirCaseIsOpen() )
{ {
// TODO: extract data from data file // TODO: extract data from data file
//
// TODO: populate with real data std::set<std::string> wells = {"F2H", "C1H", "C2H", "C3H", "C4AH", "C4H", "F1H", "F3H", "F4H"};
populatePlotWidgetWithCurveData( m_plotWidget ); std::string strippedWellName = QString( m_wellName() ).remove( "-" ).toStdString();
// TODO: Maybe display the phase? if ( wells.find( strippedWellName ) != wells.end() )
// if ( m_phase == RiaDefines::OIL_PHASE ) {
// phaseString = "Oil"; QString gridFileName = m_case->gridFileName();
// else if ( m_phase == RiaDefines::GAS_PHASE ) std::cout << "Grid file name: " << gridFileName.toStdString() << std::endl;
// phaseString = "Gas"; QFileInfo fi( gridFileName );
// else if ( m_phase == RiaDefines::WATER_PHASE )
// phaseString = "Water"; std::string filename = fi.canonicalPath().toStdString() + "/INCLUDE/VFP/" + strippedWellName + ".Ecl";
const std::vector<Opm::VFPInjTable> 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 ); 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<Opm::VFPInjTable>& tables )
{ {
cvf::Trace::show( "RimVfpPlot::populatePlotWidgetWithCurves()" ); cvf::Trace::show( "RimVfpPlot::populatePlotWidgetWithCurves()" );
@ -359,25 +379,59 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget )
plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
size_t numTables = 4; size_t numTables = tables.size();
for ( size_t i = 0; i < numTables; i++ ) for ( size_t i = 0; i < numTables; i++ )
{ {
// Just create some dummy values for now const Opm::VFPInjTable table = tables[i];
int numDummyValues = 100; std::cout << "Datum depth: " << table.getDatumDepth() << std::endl;
std::vector<double> xVals( numDummyValues, 10 * i ); std::cout << "Table number: " << table.getTableNum() << std::endl;
std::vector<double> yVals( numDummyValues, 100 * i ); std::cout << "Flow type: " << static_cast<int>( 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; std::cout << "THP Axis:\n";
QColor qtClr = RiaColorTools::toQColor( cvfClr ); for ( size_t x = 0; x < table.getTHPAxis().size(); x++ )
{
std::cout << " " << table.getTHPAxis()[x];
}
std::cout << "\n";
QwtPlotCurve* curve = new QwtPlotCurve; for ( size_t y = 0; y < table.getFloAxis().size(); y++ )
curve->setTitle( QString( "Table: %1" ).arg( i ) ); {
curve->setBrush( qtClr ); 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 ); for ( size_t thp = 0; thp < table.getTHPAxis().size(); thp++ )
curve->attach( plotWidget ); {
curve->show(); // Just create some dummy values for now
size_t numValues = table.getFloAxis().size();
std::vector<double> xVals = table.getFloAxis();
std::vector<double> 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();
}
} }
} }

View File

@ -24,6 +24,8 @@
#include <QPointer> #include <QPointer>
#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp"
class RimEclipseResultCase; class RimEclipseResultCase;
class RimFlowDiagSolution; class RimFlowDiagSolution;
class RigTofWellDistributionCalculator; class RigTofWellDistributionCalculator;
@ -79,7 +81,7 @@ private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
void fixupDependentFieldsAfterCaseChange(); void fixupDependentFieldsAfterCaseChange();
static void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ); static void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const std::vector<Opm::VFPInjTable>& tables );
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QDateTime>
// #include <QDir>
// #include <QFileInfo>
#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<Opm::VFPInjTable> RimVfpTableExtractor::extractVfpInjectionTables( const std::string& filename )
{
std::vector<Opm::VFPInjTable> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include <vector>
#include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimVfpTableExtractor
{
public:
static std::vector<Opm::VFPInjTable> extractVfpInjectionTables( const std::string& filename );
};