Files
ResInsight/ApplicationLibCode/ReservoirDataModel/RigVfpTables.h
T
Magne Sjaastad 2120a13d63 #14654 Fix Linux Release build defining NO_DEBUG instead of NDEBUG
* #14654 Fix Linux Release build defining NO_DEBUG instead of NDEBUG

CMAKE_CXX_FLAGS_RELEASE was overwritten with -DNO_DEBUG on Linux in
both CMakeLists.txt and Fwk/CMakeLists.txt. NO_DEBUG is not a standard
macro, so NDEBUG was never defined in Linux Release builds.

As a result, cafAssert.h fell back to CAF_ENABLE_ASSERTS 1, keeping
CAF_ASSERT (and standard assert()) active in Release and aborting the
app, even though RESINSIGHT_ENABLE_ASSERTS_IN_RELEASE defaults to OFF.
Windows and macOS Release builds were unaffected.

Drop the override entirely so CMake supplies its default Release
flags (-O3 -DNDEBUG) on Linux, matching Windows and macOS.

Also simplify CEE_USE_QT5/CEE_USE_QT6 handling: set them directly
instead of via option() with malformed NOT DEFINED(...) guards.

Fixed missing initialization in VfpValueSelection and WellPathCellIntersectionInfo
2026-09-14 14:17:33 +02:00

207 lines
10 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "VerticalFlowPerformance/RimVfpDefines.h"
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <QString>
#include <optional>
#include <vector>
namespace Opm
{
class UnitSystem;
} // namespace Opm
class RifVfpInjTable;
class RifVfpProdTable;
class VfpPlotData
{
public:
void setXAxisTitle( const QString& xAxisTitle ) { m_xAxisTitle = xAxisTitle; }
void setYAxisTitle( const QString& yAxisTitle ) { m_yAxisTitle = yAxisTitle; }
const QString& xAxisTitle() const { return m_xAxisTitle; }
const QString& yAxisTitle() const { return m_yAxisTitle; }
void appendCurve( const QString& curveTitle, const std::vector<double>& xData, const std::vector<double>& yData )
{
m_curveTitles.push_back( curveTitle );
m_xData.push_back( xData );
m_yData.push_back( yData );
}
const QString& curveTitle( size_t idx ) const { return m_curveTitles[idx]; }
size_t size() const { return m_xData.size(); }
size_t curveSize( size_t idx ) const { return m_xData[idx].size(); }
const std::vector<double>& xData( size_t idx ) const { return m_xData[idx]; }
const std::vector<double>& yData( size_t idx ) const { return m_yData[idx]; }
private:
QString m_xAxisTitle;
QString m_yAxisTitle;
std::vector<QString> m_curveTitles;
std::vector<std::vector<double>> m_xData;
std::vector<std::vector<double>> m_yData;
};
struct VfpTableSelection
{
int flowRateIdx;
int thpIdx;
int articifialLiftQuantityIdx;
int waterCutIdx;
int gasLiquidRatioIdx;
};
struct VfpValueSelection
{
double flowRateValue = 0.0;
double thpValue = 0.0;
double artificialLiftQuantityValue = 0.0;
double waterCutValue = 0.0;
double gasLiquidRatioValue = 0.0;
std::vector<double> familyValues;
};
struct VfpTableInitialData
{
bool isProductionTable;
int tableNumber;
double datumDepth;
RimVfpDefines::FlowingPhaseType flowingPhase;
RimVfpDefines::FlowingWaterFractionType waterFraction;
RimVfpDefines::FlowingGasFractionType gasFraction;
};
//==================================================================================================
///
//==================================================================================================
class RigVfpTables
{
public:
void setUnitSystem( const Opm::UnitSystem& unitSystem );
const Opm::UnitSystem unitSystem() const;
void addInjectionTable( const RifVfpInjTable& table );
void addProductionTable( const RifVfpProdTable& table );
std::vector<int> injectionTableNumbers() const;
std::vector<int> productionTableNumbers() const;
VfpTableInitialData getTableInitialData( int tableIndex ) const;
std::vector<double> getProductionTableData( int tableIndex, RimVfpDefines::ProductionVariableType variableType ) const;
VfpPlotData populatePlotData( int tableIndex,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase,
const VfpTableSelection& tableSelection ) const;
VfpPlotData populatePlotData( int tableIndex,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase,
const VfpValueSelection& valueSelection ) const;
QString asciiDataForTable( int tableNumber,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase,
const VfpTableSelection& tableSelection ) const;
// Returns the indices of the closest values in valuesToMatch for each value in sourceValues. Returned index value -1 indicates no
// match. A index value is only returned once.
static std::vector<int> uniqueClosestIndices( const std::vector<double>& sourceValues, const std::vector<double>& valuesToMatch );
// Static versions of display and conversion functions that take unit system parameter
static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType, const Opm::UnitSystem& unitSystem );
static QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType, const Opm::UnitSystem& unitSystem );
private:
VfpPlotData populatePlotData( const RifVfpInjTable& table,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase ) const;
VfpPlotData populatePlotData( const RifVfpProdTable& table,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase,
const VfpTableSelection& tableSelection ) const;
VfpPlotData populatePlotData( const RifVfpProdTable& table,
RimVfpDefines::ProductionVariableType primaryVariable,
RimVfpDefines::ProductionVariableType familyVariable,
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
RimVfpDefines::FlowingPhaseType flowingPhase,
const VfpValueSelection& valueSelection ) const;
QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase ) const;
QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ) const;
QString getDisplayUnitWithBracket( RimVfpDefines::ProductionVariableType variableType ) const;
static QString textForPlotData( const VfpPlotData& plotData );
std::vector<double> getProductionTableData( const RifVfpProdTable& table, RimVfpDefines::ProductionVariableType variableType ) const;
size_t getVariableIndex( const RifVfpProdTable& table,
RimVfpDefines::ProductionVariableType targetVariable,
RimVfpDefines::ProductionVariableType primaryVariable,
size_t primaryValue,
RimVfpDefines::ProductionVariableType familyVariable,
size_t familyValue,
const VfpTableSelection& tableSelection ) const;
size_t getVariableIndexForValue( const RifVfpProdTable& table,
RimVfpDefines::ProductionVariableType targetVariable,
RimVfpDefines::ProductionVariableType primaryVariable,
double primaryValue,
RimVfpDefines::ProductionVariableType familyVariable,
double familyValue,
const VfpValueSelection& valueSelection ) const;
std::optional<RifVfpInjTable> injectionTable( int tableNumber ) const;
std::optional<RifVfpProdTable> productionTable( int tableNumber ) const;
static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const RifVfpProdTable& table );
static RimVfpDefines::FlowingPhaseType getFlowingPhaseType( const RifVfpInjTable& table );
static RimVfpDefines::FlowingWaterFractionType getFlowingWaterFractionType( const RifVfpProdTable& table );
static RimVfpDefines::FlowingGasFractionType getFlowingGasFractionType( const RifVfpProdTable& table );
// Returns the indices of the closest values in valuesToMatch for each value in sourceValues. Returned index value -1 indicates no match.
static std::vector<int> findClosestIndices( const std::vector<double>& sourceValues, const std::vector<double>& valuesToMatch );
private:
std::vector<RifVfpInjTable> m_injectionTables;
std::vector<RifVfpProdTable> m_productionTables;
Opm::UnitSystem m_unitSystem;
};