2017-11-29 13:41:13 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-11-29 13:41:13 +01:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-11-29 13:41:13 +01:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-11-29 13:41:13 +01:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RiuPvtPlotUpdater.h"
|
|
|
|
|
|
2023-05-11 08:37:58 +02:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2017-11-29 13:41:13 +01:00
|
|
|
#include "RigEclipseCaseData.h"
|
2023-05-11 08:37:58 +02:00
|
|
|
#include "RigEclipseResultAddress.h"
|
2025-10-01 13:07:26 +02:00
|
|
|
#include "RigFlowDiagSolverInterface.h"
|
2017-11-29 13:41:13 +01:00
|
|
|
#include "RigResultAccessor.h"
|
|
|
|
|
#include "RigResultAccessorFactory.h"
|
|
|
|
|
|
2018-01-09 10:11:28 +01:00
|
|
|
#include "Rim3dView.h"
|
2017-11-29 13:41:13 +01:00
|
|
|
#include "RimEclipseResultCase.h"
|
2021-08-26 08:13:03 +02:00
|
|
|
#include "RimEclipseResultDefinition.h"
|
2017-11-29 13:41:13 +01:00
|
|
|
|
2021-08-26 08:13:03 +02:00
|
|
|
#include "Riu3dSelectionManager.h"
|
|
|
|
|
#include "RiuPvtPlotPanel.h"
|
|
|
|
|
#include "RiuRelativePermeabilityPlotUpdater.h"
|
2017-11-29 13:41:13 +01:00
|
|
|
|
2017-11-30 08:49:21 +01:00
|
|
|
#include <cmath>
|
2017-11-29 13:41:13 +01:00
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
///
|
|
|
|
|
/// \class RiuPvtPlotUpdater
|
|
|
|
|
///
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 13:41:13 +01:00
|
|
|
///
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 13:41:13 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
RiuPvtPlotUpdater::RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel )
|
|
|
|
|
: m_targetPlotPanel( targetPlotPanel )
|
2017-11-29 13:41:13 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 13:41:13 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-02-25 14:58:33 +01:00
|
|
|
void RiuPvtPlotUpdater::clearPlot()
|
2017-11-29 13:41:13 +01:00
|
|
|
{
|
2025-02-25 14:58:33 +01:00
|
|
|
if ( m_targetPlotPanel ) m_targetPlotPanel->clearPlot();
|
2017-11-29 13:41:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 13:41:13 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-02-25 14:58:33 +01:00
|
|
|
QWidget* RiuPvtPlotUpdater::plotPanel()
|
2017-11-29 13:41:13 +01:00
|
|
|
{
|
2025-02-25 14:58:33 +01:00
|
|
|
return m_targetPlotPanel;
|
2017-11-29 13:41:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 13:41:13 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-27 16:03:21 +01:00
|
|
|
bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef,
|
|
|
|
|
size_t timeStepIndex,
|
|
|
|
|
size_t gridIndex,
|
2025-02-25 14:58:33 +01:00
|
|
|
size_t gridLocalCellIndex )
|
2017-11-29 13:41:13 +01:00
|
|
|
{
|
2025-02-25 14:58:33 +01:00
|
|
|
if ( m_targetPlotPanel == nullptr ) return false;
|
2020-01-06 10:41:11 +01:00
|
|
|
if ( !eclipseResDef ) return false;
|
|
|
|
|
|
2023-02-26 10:48:40 +01:00
|
|
|
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseResDef->eclipseCase() );
|
|
|
|
|
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr;
|
|
|
|
|
RiaDefines::PorosityModelType porosityModel = eclipseResDef->porosityModel();
|
2021-02-10 15:05:20 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() )
|
2017-11-29 13:41:13 +01:00
|
|
|
{
|
2021-02-10 15:05:20 +01:00
|
|
|
// cvf::Trace::show("Update PVT plot for active cell index: %d", static_cast<int>(activeCellIndex));
|
|
|
|
|
|
|
|
|
|
// The following calls will read results from file in preparation for the queries below
|
|
|
|
|
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( porosityModel );
|
|
|
|
|
|
2023-02-26 10:48:40 +01:00
|
|
|
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "RS" ) );
|
|
|
|
|
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "RV" ) );
|
|
|
|
|
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "PRESSURE" ) );
|
|
|
|
|
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, "PVTNUM" ) );
|
2021-02-10 15:05:20 +01:00
|
|
|
|
|
|
|
|
cvf::ref<RigResultAccessor> rsAccessor =
|
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
|
|
|
|
|
gridIndex,
|
|
|
|
|
porosityModel,
|
|
|
|
|
timeStepIndex,
|
2023-02-26 10:48:40 +01:00
|
|
|
RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "RS" ) );
|
2021-02-10 15:05:20 +01:00
|
|
|
cvf::ref<RigResultAccessor> rvAccessor =
|
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
|
|
|
|
|
gridIndex,
|
|
|
|
|
porosityModel,
|
|
|
|
|
timeStepIndex,
|
2023-02-26 10:48:40 +01:00
|
|
|
RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "RV" ) );
|
2021-02-10 15:05:20 +01:00
|
|
|
cvf::ref<RigResultAccessor> pressureAccessor =
|
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
|
|
|
|
|
gridIndex,
|
|
|
|
|
porosityModel,
|
|
|
|
|
timeStepIndex,
|
2023-02-26 10:48:40 +01:00
|
|
|
RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "PRESSURE" ) );
|
2021-02-10 15:05:20 +01:00
|
|
|
cvf::ref<RigResultAccessor> pvtnumAccessor =
|
|
|
|
|
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
|
|
|
|
|
gridIndex,
|
|
|
|
|
porosityModel,
|
|
|
|
|
timeStepIndex,
|
2023-02-26 10:48:40 +01:00
|
|
|
RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, "PVTNUM" ) );
|
2021-02-10 15:05:20 +01:00
|
|
|
|
|
|
|
|
RiuPvtPlotPanel::CellValues cellValues;
|
|
|
|
|
cellValues.rs = rsAccessor.notNull() ? rsAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
|
|
|
|
|
cellValues.rv = rvAccessor.notNull() ? rvAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
|
|
|
|
|
cellValues.pressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
|
|
|
|
|
|
2023-02-26 10:48:40 +01:00
|
|
|
const double cellPvtNumDouble = pvtnumAccessor.notNull() ? pvtnumAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
|
2021-02-10 15:05:20 +01:00
|
|
|
|
2023-02-26 10:48:40 +01:00
|
|
|
const int cellPvtNum = ( cellPvtNumDouble != HUGE_VAL ) ? static_cast<int>( cellPvtNumDouble ) : std::numeric_limits<int>::max();
|
2021-02-10 15:05:20 +01:00
|
|
|
|
2025-10-01 13:07:26 +02:00
|
|
|
std::vector<RigFlowDiagDefines::PvtCurve> fvfCurveArr =
|
|
|
|
|
eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurves( RigFlowDiagDefines::PVT_CT_FVF, cellPvtNum );
|
|
|
|
|
std::vector<RigFlowDiagDefines::PvtCurve> viscosityCurveArr =
|
|
|
|
|
eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurves( RigFlowDiagDefines::PVT_CT_VISCOSITY, cellPvtNum );
|
2021-02-10 15:05:20 +01:00
|
|
|
|
|
|
|
|
RiuPvtPlotPanel::FvfDynProps fvfDynProps;
|
|
|
|
|
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf( cellPvtNum,
|
|
|
|
|
cellValues.pressure,
|
|
|
|
|
cellValues.rs,
|
|
|
|
|
cellValues.rv,
|
|
|
|
|
&fvfDynProps.bo,
|
|
|
|
|
&fvfDynProps.bg );
|
|
|
|
|
|
|
|
|
|
RiuPvtPlotPanel::ViscosityDynProps viscosityDynProps;
|
|
|
|
|
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity( cellPvtNum,
|
|
|
|
|
cellValues.pressure,
|
|
|
|
|
cellValues.rs,
|
|
|
|
|
cellValues.rv,
|
|
|
|
|
&viscosityDynProps.mu_o,
|
|
|
|
|
&viscosityDynProps.mu_g );
|
|
|
|
|
|
2026-02-19 10:59:18 +01:00
|
|
|
QString cellRefText =
|
|
|
|
|
RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, porosityModel );
|
2025-11-03 14:26:51 +01:00
|
|
|
cellRefText += QString( ", PVTNUM: %1" ).arg( cellPvtNum );
|
2021-02-10 15:05:20 +01:00
|
|
|
|
2025-02-25 14:58:33 +01:00
|
|
|
m_targetPlotPanel->setPlotData( eclipseCaseData->unitsType(),
|
|
|
|
|
fvfCurveArr,
|
|
|
|
|
viscosityCurveArr,
|
|
|
|
|
fvfDynProps,
|
|
|
|
|
viscosityDynProps,
|
|
|
|
|
cellValues,
|
|
|
|
|
cellRefText );
|
2021-02-10 15:05:20 +01:00
|
|
|
|
|
|
|
|
return true;
|
2017-11-29 13:41:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|