Update dev branch after patch release

* Fix calculation for active cell values
Always allocate result data for active cells in destination case. Make sure that active cells is used for both population of expression variables and filtering of data. Improved naming to make it clear that we always work with active cell data.

* Check if scalar result index is valid
* Create the static scalar results once
addStaticScalarResult will clear already computed data, causing calculations to be triggered once more

* Early return if data already is available
If not checking if data is available, data is read from file and appended to result vector.

* Always check date for H5 files, and recreate if required

* Always recreate ESMRY if file exists and is older than SMSPEC

* #11355 Use category if result name starts with FIP or ends with NUM

* #11337 Summary import: Make sure ESMRY includes restart history

* #11334 Fix cvf::Viewport assert triggered for small contour map/2d intersection
Size of the overlay is could become negative, and would overflow for small views.

* #11310 Fix assert on single cell model.
Well pipe radius would become HUGE_VAL due to off-by-one error.
The assert could only happen on model with a single cell.

* Check equal grid size only when required
Equal grid size is required if there is more than one grid case in the expression. If a cell filter view is active, the visibility is based on one view and reused for all other grid models, and requires equal grid size.

* Remove obsolete log message

* Do not show dialog during regression tests

* Fix eclipse case contour map left click (#11378)

* Make sure we operate in the correct domain when picking points in the contour map

* Remove obsolete code causing grid to be loaded for all cases


* Bump version to 2024.03.1

---------

Co-authored-by: Kristian Bendiksen <kristian.bendiksen@gmail.com>
Co-authored-by: jonjenssen <69144954+jonjenssen@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2024-04-19 15:09:15 +02:00
1 parent 932464ea55
commit e9ff3540ba
16 files changed
+262 -150

No files matched your search

@@ -374,8 +374,6 @@ void RimEclipseResultCase::ensureRftDataIsImported()
if ( rftFileInfo.exists() )
{
RiaLogging::info( QString( "RFT file found" ) );
if ( m_useOpmRftReader )
{
m_readerOpmRft = new RifReaderOpmRft( rftFileInfo.filePath() );
@@ -1426,6 +1426,8 @@ bool RimEclipseResultDefinition::isCompletionTypeSelected() const
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition::hasCategoryResult() const
{
if ( RiaResultNames::isCategoryResult( m_resultVariable() ) ) return true;
if ( auto* gridCellResults = currentGridCellResults() )
{
const auto addresses = gridCellResults->existingResults();
@@ -22,6 +22,7 @@
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPorosityModel.h"
#include "RiaRegressionTestRunner.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
@@ -118,7 +119,8 @@ RimGridCalculation::RimGridCalculation()
//--------------------------------------------------------------------------------------------------
bool RimGridCalculation::preCalculate() const
{
if ( RiaGuiApplication::isRunning() && m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::NONE )
if ( !RiaRegressionTestRunner::instance()->isRunningRegressionTests() && RiaGuiApplication::isRunning() &&
m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::NONE )
{
const QString cacheKey = "GridCalculatorMessage";
@@ -171,18 +173,40 @@ RimGridCalculationVariable* RimGridCalculation::createVariable()
//--------------------------------------------------------------------------------------------------
bool RimGridCalculation::calculate()
{
// Equal grid size is required if there is more than one grid case in the expression. If a cell filter view is active, the visibility is
// based on one view and reused for all other grid models, and requires equal grid size.
bool checkIfGridSizeIsEqual = !allSourceCasesAreEqualToDestinationCase() || m_cellFilterView != nullptr;
for ( auto calculationCase : outputEclipseCases() )
{
if ( !calculationCase ) continue;
for ( auto inputCase : inputCases() )
if ( !calculationCase->eclipseCaseData() )
{
if ( !calculationCase->isGridSizeEqualTo( inputCase ) )
QString msg = QString( "No data available for case %1, aborting calculation" ).arg( calculationCase->caseUserDescription() );
RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg );
return false;
}
if ( !calculationCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ) )
{
QString msg =
QString( "No active cell data available for case %1, aborting calculation" ).arg( calculationCase->caseUserDescription() );
RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg );
return false;
}
if ( checkIfGridSizeIsEqual )
{
for ( auto inputCase : inputCases() )
{
QString msg = "Detected IJK mismatch between input cases and destination case. All grid "
"cases must have identical IJK sizes.";
RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg );
return false;
if ( !calculationCase->isGridSizeEqualTo( inputCase ) )
{
QString msg = "Detected IJK mismatch between input cases and destination case. All grid "
"cases must have identical IJK sizes.";
RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", msg );
return false;
}
}
}
}
@@ -537,11 +561,11 @@ RigEclipseResultAddress RimGridCalculation::outputAddress() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimGridCalculation::getDataForVariable( RimGridCalculationVariable* variable,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const
std::vector<double> RimGridCalculation::getActiveCellValuesForVariable( RimGridCalculationVariable* variable,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const
{
if ( !sourceCase || !destinationCase ) return {};
@@ -562,18 +586,19 @@ std::vector<double> RimGridCalculation::getDataForVariable( RimGridCalculationVa
timeStepToUse = timeStep;
}
return getDataForResult( variable->resultVariable(), resultCategoryType, timeStepToUse, porosityModel, sourceCase, destinationCase );
return getActiveCellValues( variable->resultVariable(), resultCategoryType, timeStepToUse, porosityModel, sourceCase, destinationCase );
}
//--------------------------------------------------------------------------------------------------
///
/// Return values for active cells, both for dynamic and static results. Use the active cell info from the destination case, and read data
/// from the source case.
//--------------------------------------------------------------------------------------------------
std::vector<double> RimGridCalculation::getDataForResult( const QString& resultName,
const RiaDefines::ResultCatType resultCategoryType,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const
std::vector<double> RimGridCalculation::getActiveCellValues( const QString& resultName,
const RiaDefines::ResultCatType resultCategoryType,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const
{
if ( !sourceCase || !destinationCase ) return {};
@@ -588,12 +613,15 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
auto eclipseCaseData = sourceCase->eclipseCaseData();
auto rigCaseCellResultsData = eclipseCaseData->results( porosityModel );
if ( !rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) ) return {};
if ( rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) == cvf::UNDEFINED_SIZE_T ) return {};
// Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as
// number of active cells in the destination case. Active cells can be different between source and destination case.
auto activeCellInfoDestination = destinationCase->eclipseCaseData()->activeCellInfo( porosityModel );
auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices();
if ( !activeCellInfoDestination ) return {};
auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices();
if ( activeReservoirCells.empty() ) return {};
std::vector<double> values( activeCellInfoDestination->activeReservoirCellIndices().size() );
@@ -621,23 +649,25 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector<double>& inputValues,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* outputEclipseCase )
void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector<double>& inputValues,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RigActiveCellInfo* activeCellInfo )
{
auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel );
int numCells = static_cast<int>( visibility->size() );
auto activeReservoirCellIndices = activeCellInfo->activeReservoirCellIndices();
int numActiveCells = static_cast<int>( activeReservoirCellIndices.size() );
CAF_ASSERT( numActiveCells == (int)resultValues.size() );
CAF_ASSERT( numActiveCells == (int)inputValues.size() );
#pragma omp parallel for
for ( int i = 0; i < numCells; i++ )
for ( int i = 0; i < numActiveCells; i++ )
{
if ( !visibility->val( i ) && activeCellInfo->isActive( i ) )
const auto reservoirCellIndex = activeReservoirCellIndices[i];
if ( !visibility->val( reservoirCellIndex ) )
{
size_t cellResultIndex = activeCellInfo->cellResultIndex( i );
resultValues[cellResultIndex] = inputValues[cellResultIndex];
resultValues[i] = inputValues[i];
}
}
}
@@ -645,23 +675,24 @@ void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector<doub
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* outputEclipseCase )
void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RigActiveCellInfo* activeCellInfo )
{
auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel );
int numCells = static_cast<int>( visibility->size() );
auto activeReservoirCellIndices = activeCellInfo->activeReservoirCellIndices();
int numActiveCells = static_cast<int>( activeReservoirCellIndices.size() );
CAF_ASSERT( numActiveCells == (int)resultValues.size() );
#pragma omp parallel for
for ( int i = 0; i < numCells; i++ )
for ( int i = 0; i < numActiveCells; i++ )
{
if ( !visibility->val( i ) && activeCellInfo->isActive( i ) )
const auto reservoirCellIndex = activeReservoirCellIndices[i];
if ( !visibility->val( reservoirCellIndex ) )
{
size_t cellResultIndex = activeCellInfo->cellResultIndex( i );
resultValues[cellResultIndex] = defaultValue;
resultValues[i] = defaultValue;
}
}
}
@@ -681,18 +712,20 @@ void RimGridCalculation::filterResults( RimGridView*
{
auto visibility = cellFilterView->currentTotalCellVisibility();
auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel );
if ( defaultValueType == RimGridCalculation::DefaultValueType::FROM_PROPERTY )
{
auto nonVisibleValues = getDataForResult( m_nonVisibleResultAddress->resultName(),
m_nonVisibleResultAddress->resultType(),
timeStep,
porosityModel,
m_nonVisibleResultAddress->eclipseCase(),
outputEclipseCase );
auto nonVisibleValues = getActiveCellValues( m_nonVisibleResultAddress->resultName(),
m_nonVisibleResultAddress->resultType(),
timeStep,
porosityModel,
outputEclipseCase,
outputEclipseCase );
if ( !nonVisibleValues.empty() )
{
replaceFilteredValuesWithVector( nonVisibleValues, visibility, resultValues, porosityModel, outputEclipseCase );
replaceFilteredValuesWithVector( nonVisibleValues, visibility, resultValues, activeCellInfo );
}
else
{
@@ -706,7 +739,7 @@ void RimGridCalculation::filterResults( RimGridView*
double valueToUse = defaultValue;
if ( defaultValueType == RimGridCalculation::DefaultValueType::POSITIVE_INFINITY ) valueToUse = HUGE_VAL;
replaceFilteredValuesWithDefaultValue( valueToUse, visibility, resultValues, porosityModel, outputEclipseCase );
replaceFilteredValuesWithDefaultValue( valueToUse, visibility, resultValues, activeCellInfo );
}
}
@@ -873,15 +906,16 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
bool useDataFromSourceCase = ( v->eclipseCase() == m_destinationCase );
auto sourceCase = useDataFromSourceCase ? calculationCase : v->eclipseCase();
auto dataForVariable = getDataForVariable( v, tsId, porosityModel, sourceCase, calculationCase );
auto dataForVariable = getActiveCellValuesForVariable( v, tsId, porosityModel, sourceCase, calculationCase );
if ( dataForVariable.empty() )
{
RiaLogging::error( QString( " No data found for variable '%1'." ).arg( v->name() ) );
}
else if ( inputValueVisibilityFilter && hasAggregationExpression )
{
const double defaultValue = 0.0;
replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, porosityModel, calculationCase );
const double defaultValue = 0.0;
auto activeCellInfo = calculationCase->eclipseCaseData()->activeCellInfo( porosityModel );
replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, activeCellInfo );
}
dataForAllVariables.push_back( dataForVariable );
@@ -896,10 +930,10 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
}
std::vector<double> resultValues;
if ( m_destinationCase && m_destinationCase->eclipseCaseData() )
if ( calculationCase && calculationCase->eclipseCaseData() )
{
// Find number of active cells in the destination case.
auto activeCellInfoDestination = m_destinationCase->eclipseCaseData()->activeCellInfo( porosityModel );
auto activeCellInfoDestination = calculationCase->eclipseCaseData()->activeCellInfo( porosityModel );
if ( activeCellInfoDestination )
{
resultValues.resize( activeCellInfoDestination->reservoirActiveCellCount() );
@@ -34,6 +34,7 @@ class RimGridView;
class RigEclipseResultAddress;
class RimEclipseResultAddress;
class RimIdenticalGridCaseGroup;
class RigActiveCellInfo;
//==================================================================================================
///
@@ -88,18 +89,18 @@ protected:
std::pair<bool, QString> validateVariables();
std::vector<double> getDataForVariable( RimGridCalculationVariable* variable,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const;
std::vector<double> getActiveCellValuesForVariable( RimGridCalculationVariable* variable,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const;
std::vector<double> getDataForResult( const QString& resultName,
const RiaDefines::ResultCatType resultCategoryType,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const;
std::vector<double> getActiveCellValues( const QString& resultName,
const RiaDefines::ResultCatType resultCategoryType,
size_t tsId,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const;
void filterResults( RimGridView* cellFilterView,
const std::vector<std::vector<double>>& values,
@@ -110,17 +111,15 @@ protected:
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* outputEclipseCase ) const;
static void replaceFilteredValuesWithVector( const std::vector<double>& inputValues,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* outputEclipseCase );
static void replaceFilteredValuesWithVector( const std::vector<double>& inputValues,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RigActiveCellInfo* activeCellInfo );
static void replaceFilteredValuesWithDefaultValue( double defaultValue,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RiaDefines::PorosityModelType porosityModel,
RimEclipseCase* outputEclipseCase );
static void replaceFilteredValuesWithDefaultValue( double defaultValue,
cvf::ref<cvf::UByteArray> visibility,
std::vector<double>& resultValues,
RigActiveCellInfo* activeCellInfo );
using DefaultValueConfig = std::pair<RimGridCalculation::DefaultValueType, double>;
DefaultValueConfig defaultValueConfiguration() const;
@@ -411,7 +411,7 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( std::vector<RimFileS
// If h5 mode, check all summary files and create or recreate h5 files if required
#ifdef USE_HDF5
{
if ( prefs->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON && prefs->createH5SummaryDataFiles() )
if ( prefs->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON )
{
int threadCount = 1;
#ifdef USE_OPENMP
@@ -433,7 +433,10 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( std::vector<RimFileS
h5FileNames.push_back( h5FilenameCandidate.toStdString() );
}
RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( headerFileNames, h5FileNames, threadCount );
RifHdf5SummaryExporter::ensureHdf5FileIsCreatedMultithreaded( headerFileNames,
h5FileNames,
prefs->createH5SummaryDataFiles(),
threadCount );
}
}
#endif