Add Statistics Contour Map for eclipse grid ensembles.

This commit is contained in:
Kristian Bendiksen 2024-11-13 14:06:23 +01:00
parent feba066b49
commit 925403764e
25 changed files with 1232 additions and 28 deletions

View File

@ -98,6 +98,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellTargetCandidatesGeneratorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapViewFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -200,6 +201,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCustomVfpPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellTargetCandidatesGeneratorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsContourMapViewFeature.cpp
)
if(RESINSIGHT_USE_QT_CHARTS)

View File

@ -0,0 +1,128 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewStatisticsContourMapViewFeature.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseContourMapViewCollection.h"
#include "RimFaultInViewCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInViewCollection.h"
#include "RimStatisticsContourMap.h"
#include "RimStatisticsContourMapView.h"
#include "RimSurfaceInViewCollection.h"
#include "Riu3DMainWindowTools.h"
#include "RiuGuiTheme.h"
#include "RiaColorTools.h"
#include "cafPdmDocument.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewStatisticsContourMapViewFeature, "RicNewStatisticsContourMapViewFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewStatisticsContourMapViewFeature::isCommandEnabled() const
{
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
return contourMap != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewStatisticsContourMapViewFeature::onActionTriggered( bool isChecked )
{
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
if ( !contourMap ) return;
RimEclipseCase* eclipseCase = contourMap->eclipseCase();
if ( !eclipseCase ) return;
if ( auto eclipseContourMap = createStatisticsContourMapView( contourMap, eclipseCase ) )
{
// Must be run before buildViewItems, as wells are created in this function
eclipseContourMap->loadDataAndUpdate();
// make sure no surfaces are shown in the view when the contourmap is generated
if ( eclipseContourMap->surfaceInViewCollection() ) eclipseContourMap->surfaceInViewCollection()->setCheckState( Qt::Unchecked );
if ( eclipseCase )
{
eclipseCase->updateConnectedEditors();
eclipseContourMap->cellFilterCollection()->setCase( eclipseCase );
}
caf::SelectionManager::instance()->setSelectedItem( eclipseContourMap );
eclipseContourMap->createDisplayModelAndRedraw();
eclipseContourMap->zoomAll();
RimProject* project = RimProject::current();
RimOilField* oilField = project->activeOilField();
oilField->eclipseContourMapCollection()->updateConnectedEditors();
Riu3DMainWindowTools::setExpanded( eclipseContourMap );
Riu3DMainWindowTools::selectAsCurrentItem( eclipseContourMap );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewStatisticsContourMapViewFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create View" );
actionToSetup->setIcon( QIcon( ":/2DMap16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase )
{
RimStatisticsContourMapView* contourMap = new RimStatisticsContourMapView;
contourMap->setStatisticsContourMap( statisticsContourMap );
contourMap->setEclipseCase( eclipseCase );
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
size_t i = eclipseCase->contourMapCollection()->views().size();
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
contourMap->faultCollection()->setActive( false );
contourMap->wellCollection()->isActive = false;
eclipseCase->contourMapCollection()->addView( contourMap );
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
contourMap->initAfterReadRecursively();
return contourMap;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
class RimEclipseCase;
class RimStatisticsContourMapView;
class RimStatisticsContourMap;
//==================================================================================================
///
//==================================================================================================
class RicNewStatisticsContourMapViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
RimEclipseCase* eclipseCase );
};

View File

@ -135,6 +135,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.h
${CMAKE_CURRENT_LIST_DIR}/RimWellTargetCandidatesGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMap.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapProjection.h
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapView.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -270,6 +272,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimCameraPosition.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellTargetCandidatesGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMap.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapProjection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStatisticsContourMapView.cpp
)
if(RESINSIGHT_USE_QT_CHARTS)

View File

@ -75,12 +75,36 @@ QString RimGeoMechContourMapProjection::resultDescriptionText() const
return resultText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechContourMapProjection::resultVariableName() const
{
if ( auto v = view() )
{
if ( auto c = v->cellResult() )
{
return c->resultFieldUiName();
}
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimGeoMechContourMapProjection::legendConfig() const
{
return view()->cellResult()->legendConfig();
if ( auto v = view() )
{
if ( auto c = v->cellResult() )
{
return c->legendConfig();
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------

View File

@ -45,6 +45,7 @@ public:
~RimGeoMechContourMapProjection() override;
// GeoMech case overrides for contour map methods
QString resultVariableName() const override;
QString resultDescriptionText() const override;
RimRegularLegendConfig* legendConfig() const override;
void updateLegend() override;

View File

@ -316,15 +316,17 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>( eclipseView );
if ( contourMap && contourMap->contourMapProjection() && contourMap->contourMapProjection()->mapProjection() )
{
RimEclipseContourMapProjection* eclipseProjection =
dynamic_cast<RimEclipseContourMapProjection*>( contourMap->contourMapProjection() );
QString totCellCount =
localeWithSpaceAsGroupSeparator.toString( contourMap->contourMapProjection()->mapProjection()->numberOfCells() );
cvf::uint validCellCount = contourMap->contourMapProjection()->mapProjection()->numberOfValidCells();
QString activeCellCountText = localeWithSpaceAsGroupSeparator.toString( validCellCount );
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
QString weightingParameterString;
if ( contourMap->contourMapProjection()->weightingParameter() != "None" )
if ( eclipseProjection && eclipseProjection->weightingParameter() != "None" )
{
weightingParameterString += QString( " (Weight: %1)" ).arg( contourMap->contourMapProjection()->weightingParameter() );
weightingParameterString += QString( " (Weight: %1)" ).arg( eclipseProjection->weightingParameter() );
}
infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
@ -452,7 +454,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText( const RigHistogramData& histData
bool isResultsInfoRelevant = contourMap->contourMapProjection()->mapProjection()->numberOfValidCells() > 0u;
if ( isResultsInfoRelevant )
{
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
QString propName = contourMap->contourMapProjection()->resultVariableName();
QString diffResString = eclipseView->cellResult()->additionalResultText();
if ( !contourMap->contourMapProjection()->isColumnResult() )
{

View File

@ -63,14 +63,14 @@ public:
bool showContourLines() const;
bool showContourLabels() const;
QString resultAggregationText() const;
virtual QString resultAggregationText() const;
QString caseName() const;
QString currentTimeStepName() const;
bool isColumnResult() const;
bool isMeanResult() const;
bool isStraightSummationResult() const;
virtual bool isColumnResult() const;
bool isMeanResult() const;
bool isStraightSummationResult() const;
void setPickPoint( cvf::Vec2d globalPickPoint );
cvf::Vec2d pickPoint() const;
@ -78,6 +78,7 @@ public:
cvf::Vec3d origin3d() const;
// Pure-virtual public methods which should be overridden by Eclipse and Geo-mechanical contour map implementations
virtual QString resultVariableName() const = 0;
virtual QString resultDescriptionText() const = 0;
virtual RimRegularLegendConfig* legendConfig() const = 0;
virtual void updateLegend() = 0;

View File

@ -75,6 +75,15 @@ QString RimEclipseContourMapProjection::resultDescriptionText() const
return resultText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseContourMapProjection::resultVariableName() const
{
if ( !isColumnResult() ) return view()->cellResult()->resultVariable();
return resultAggregationText();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@ public:
void clearGridMappingAndRedraw();
// Eclipse case overrides for contour map methods
QString resultVariableName() const override;
QString resultDescriptionText() const override;
RimRegularLegendConfig* legendConfig() const override;
void updateLegend() override;

View File

@ -88,7 +88,7 @@ RimEclipseContourMapView::RimEclipseContourMapView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseContourMapProjection* RimEclipseContourMapView::contourMapProjection() const
RimContourMapProjection* RimEclipseContourMapView::contourMapProjection() const
{
return m_contourMapProjection().p();
}

View File

@ -28,6 +28,7 @@ class RimRegularLegendConfig;
class RimViewNameConfig;
class RimScaleLegendConfig;
class RivContourMapProjectionPartMgr;
class RimContourMapProjection;
class RimEclipseContourMapView : public RimEclipseView
{
@ -35,7 +36,7 @@ class RimEclipseContourMapView : public RimEclipseView
public:
RimEclipseContourMapView();
RimEclipseContourMapProjection* contourMapProjection() const;
RimContourMapProjection* contourMapProjection() const;
RiaDefines::View3dContent viewContent() const override;
@ -83,14 +84,12 @@ protected:
void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType );
private:
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimContourMapProjection*> m_contourMapProjection;
bool isFaultLinesVisible() const;
void setFaultLinesVisible( const bool& visible );
private:
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimEclipseContourMapProjection*> m_contourMapProjection;
caf::PdmProxyValueField<bool> m_showFaultLines;
caf::PdmField<bool> m_showAxisLines;
caf::PdmField<bool> m_showScaleLegend;

View File

@ -326,7 +326,8 @@ void RimEclipseResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
if ( contourMapView )
{
contourMapView->contourMapProjection()->clearGridMappingAndRedraw();
if ( auto projection = dynamic_cast<RimEclipseContourMapProjection*>( contourMapView->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
}
loadDataAndUpdate();
@ -336,7 +337,8 @@ void RimEclipseResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* ch
{
if ( contourMapView )
{
contourMapView->contourMapProjection()->clearGridMappingAndRedraw();
if ( auto projection = dynamic_cast<RimEclipseContourMapProjection*>( contourMapView->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
}
loadDataAndUpdate();

View File

@ -150,7 +150,8 @@ void RimReloadCaseTools::updateAll3dViews( RimEclipseCase* eclipseCase )
// computations are updated based on new data.
// See RimEclipseContourMapProjection::generateResults()
contourMap->contourMapProjection()->clearGeometry();
contourMap->contourMapProjection()->clearGridMappingAndRedraw();
if ( auto projection = dynamic_cast<RimEclipseContourMapProjection*>( contourMap->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
}
contourMap->loadDataAndUpdate();

View File

@ -22,6 +22,7 @@
#include "RiaStatisticsTools.h"
#include "RigCaseCellResultsData.h"
#include "RigContourMapCalculator.h"
#include "RigContourMapGrid.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseContourMapProjection.h"
@ -36,6 +37,7 @@
#include "RimProject.h"
#include "RimTools.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafProgressInfo.h"
@ -44,6 +46,21 @@
CAF_PDM_SOURCE_INIT( RimStatisticsContourMap, "RimStatisticalContourMap" );
namespace caf
{
template <>
void caf::AppEnum<RimStatisticsContourMap::StatisticsType>::setUp()
{
addItem( RimStatisticsContourMap::StatisticsType::P10, "P10", "P10" );
addItem( RimStatisticsContourMap::StatisticsType::P50, "P50", "P50" );
addItem( RimStatisticsContourMap::StatisticsType::P90, "P90", "P90" );
addItem( RimStatisticsContourMap::StatisticsType::MEAN, "MEAN", "Mean" );
addItem( RimStatisticsContourMap::StatisticsType::MIN, "MIN", "Minimum" );
addItem( RimStatisticsContourMap::StatisticsType::MAX, "MAX", "Maximum" );
setDefault( RimStatisticsContourMap::StatisticsType::MEAN );
}
}; // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -93,6 +110,14 @@ void RimStatisticsContourMap::setEclipseCase( RimEclipseCase* eclipseCase )
m_resultDefinition->setEclipseCase( eclipseCase );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCaseEnsemble* RimStatisticsContourMap::ensemble() const
{
return firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -198,6 +223,12 @@ void RimStatisticsContourMap::computeStatistics()
auto contourMapGrid = std::make_unique<RigContourMapGrid>( gridBoundingBox, sampleSpacing );
auto firstEclipseCaseData = firstEclipseCase->eclipseCaseData();
auto firstResultData = firstEclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *firstEclipseCaseData, *firstResultData );
m_gridMapping = contourMapProjection.generateGridMapping( resultAggregation, {} );
std::vector<std::vector<double>> results;
for ( RimEclipseCase* eclipseCase : ensemble->cases() )
{
@ -235,17 +266,107 @@ void RimStatisticsContourMap::computeStatistics()
for ( size_t s = 0; s < numSamples; s++ )
samples[s] = results[s][i];
double p10, p50, p90, mean;
double p10 = std::numeric_limits<double>::infinity();
double p50 = std::numeric_limits<double>::infinity();
double p90 = std::numeric_limits<double>::infinity();
double mean = std::numeric_limits<double>::infinity();
RigStatisticsMath::calculateStatisticsCurves( samples, &p10, &p50, &p90, &mean, RigStatisticsMath::PercentileStyle::SWITCHED );
p10Results[i] = p10;
p50Results[i] = p50;
p90Results[i] = p90;
meanResults[i] = mean;
if ( RiaStatisticsTools::isValidNumber( p10 ) ) p10Results[i] = p10;
if ( RiaStatisticsTools::isValidNumber( p50 ) ) p50Results[i] = p50;
if ( RiaStatisticsTools::isValidNumber( p90 ) ) p90Results[i] = p90;
if ( RiaStatisticsTools::isValidNumber( mean ) ) meanResults[i] = mean;
minResults[i] = RiaStatisticsTools::minimumValue( samples );
maxResults[i] = RiaStatisticsTools::maximumValue( samples );
double minValue = RiaStatisticsTools::minimumValue( samples );
if ( RiaStatisticsTools::isValidNumber( minValue ) && minValue < std::numeric_limits<double>::max() ) minResults[i] = minValue;
double maxValue = RiaStatisticsTools::maximumValue( samples );
if ( RiaStatisticsTools::isValidNumber( maxValue ) && maxValue > -std::numeric_limits<double>::max() ) maxResults[i] = maxValue;
}
m_contourMapGrid = std::move( contourMapGrid );
m_result[StatisticsType::P10] = p10Results;
m_result[StatisticsType::P50] = p50Results;
m_result[StatisticsType::P90] = p90Results;
m_result[StatisticsType::MEAN] = meanResults;
m_result[StatisticsType::MIN] = minResults;
m_result[StatisticsType::MAX] = maxResults;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimStatisticsContourMap::eclipseCase() const
{
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
if ( !ensemble || ensemble->cases().empty() ) return nullptr;
return ensemble->cases().front();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMap::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicNewStatisticsContourMapViewFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigContourMapGrid* RimStatisticsContourMap::contourMapGrid() const
{
return m_contourMapGrid.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStatisticsContourMap::result( StatisticsType statisticsType ) const
{
if ( auto it = m_result.find( statisticsType ); it != m_result.end() ) return it->second;
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMap::ensureResultsComputed()
{
if ( !m_contourMapGrid ) computeStatistics();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMap::resultAggregationText() const
{
return m_resultAggregation().uiText();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMap::resultVariable() const
{
return m_resultDefinition()->resultVariable();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimStatisticsContourMap::isColumnResult() const
{
return RigContourMapCalculator::isColumnResult( m_resultAggregation() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimStatisticsContourMap::sampleSpacingFactor() const
{
return m_relativeSampleSpacing;
}

View File

@ -23,8 +23,11 @@
#include "RimContourMapProjection.h"
#include <map>
class RimEclipseCase;
class RimEclipseResultDefinition;
class RimEclipseCaseEnsemble;
//==================================================================================================
//
@ -36,15 +39,41 @@ class RimStatisticsContourMap : public caf::PdmObject
CAF_PDM_HEADER_INIT;
public:
enum class StatisticsType
{
P10,
P50,
P90,
MEAN,
MIN,
MAX
};
RimStatisticsContourMap();
void setEclipseCase( RimEclipseCase* eclipseCase );
void setEclipseCase( RimEclipseCase* eclipseCase );
RimEclipseCase* eclipseCase() const;
RimEclipseCaseEnsemble* ensemble() const;
RigContourMapGrid* contourMapGrid() const;
std::vector<double> result( StatisticsType statisticsType ) const;
std::vector<std::vector<std::pair<size_t, double>>> gridMapping() const;
void ensureResultsComputed();
QString resultAggregationText() const;
QString resultVariable() const;
double sampleSpacingFactor() const;
bool isColumnResult() const;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void initAfterRead() override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
private:
@ -56,4 +85,8 @@ private:
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<bool> m_computeStatisticsButton;
std::unique_ptr<RigContourMapGrid> m_contourMapGrid;
std::map<StatisticsType, std::vector<double>> m_result;
std::vector<std::vector<std::pair<size_t, double>>> m_gridMapping;
};

View File

@ -0,0 +1,304 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimStatisticsContourMapProjection.h"
#include "RigCaseCellResultsData.h"
#include "RigContourMapCalculator.h"
#include "RigContourMapGrid.h"
#include "RigContourMapProjection.h"
#include "RigEclipseCaseData.h"
#include "RigStatisticsContourMapProjection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimRegularLegendConfig.h"
#include "RimStatisticsContourMap.h"
#include "RimStatisticsContourMapView.h"
#include <memory>
CAF_PDM_SOURCE_INIT( RimStatisticsContourMapProjection, "RimStatisticsContourMapProjection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapProjection::RimStatisticsContourMapProjection()
: RimContourMapProjection()
{
CAF_PDM_InitObject( "RimStatisticsContourMapProjection", ":/2DMapProjection16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_statisticsType, "StatisticsType", "Statistics Type" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapProjection::~RimStatisticsContourMapProjection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMapProjection::resultDescriptionText() const
{
QString resultText;
if ( auto scm = statisticsContourMap() )
{
resultText = scm->resultAggregationText();
QString statisticsText = m_statisticsType().uiText();
if ( !scm->isColumnResult() )
{
resultText += QString( ", %1" ).arg( scm->resultVariable() );
}
resultText += ", " + statisticsText;
}
return resultText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMapProjection::resultVariableName() const
{
if ( auto scm = statisticsContourMap() )
{
QString stasticsText = m_statisticsType().uiText();
if ( !scm->isColumnResult() )
return scm->resultVariable() + ", " + stasticsText;
else
return scm->resultAggregationText() + ", " + stasticsText;
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimStatisticsContourMapProjection::legendConfig() const
{
return view()->cellResult()->legendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::updateLegend()
{
double minVal = m_contourMapProjection ? m_contourMapProjection->minValue() : std::numeric_limits<double>::infinity();
double maxVal = m_contourMapProjection ? m_contourMapProjection->maxValue() : -std::numeric_limits<double>::infinity();
auto [minValAllTimeSteps, maxValAllTimeSteps] = minmaxValuesAllTimeSteps();
legendConfig()->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
if ( statisticsContourMap()->isColumnResult() )
{
legendConfig()->setTitle( QString( "Map Projection\n%1" ).arg( resultVariableName() ) );
}
else
{
QString projectionLegendText = QString( "Map Projection\n%1" ).arg( resultAggregationText() );
projectionLegendText += QString( "\nResult: %1" ).arg( resultVariableName() );
legendConfig()->setTitle( projectionLegendText );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimStatisticsContourMapProjection::sampleSpacing() const
{
if ( RimStatisticsContourMap* contourMap = statisticsContourMap() )
{
if ( RigContourMapGrid* contourMapGrid = contourMap->contourMapGrid() )
{
return contourMapGrid->sampleSpacing();
}
}
return 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::clearGridMappingAndRedraw()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStatisticsContourMapProjection::generateResults( int timeStep ) const
{
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::generateAndSaveResults( int timeStep )
{
if ( auto statistics = statisticsContourMap() )
{
dynamic_cast<RigStatisticsContourMapProjection*>( m_contourMapProjection.get() )
->generateAndSaveResults( statistics->result( m_statisticsType() ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimStatisticsContourMapProjection::resultVariableChanged() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::clearResultVariable()
{
m_currentResultName = "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::updateGridInformation()
{
RimStatisticsContourMap* contourMap = statisticsContourMap();
contourMap->ensureResultsComputed();
m_contourMapGrid = std::make_unique<RigContourMapGrid>( *contourMap->contourMapGrid() );
m_contourMapProjection = std::make_unique<RigStatisticsContourMapProjection>( *m_contourMapGrid );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimStatisticsContourMapProjection::retrieveParameterWeights()
{
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimStatisticsContourMapProjection::eclipseCase() const
{
auto v = view();
if ( !v ) return nullptr;
return dynamic_cast<RimEclipseCase*>( v->ownerCase() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMap* RimStatisticsContourMapProjection::statisticsContourMap() const
{
auto v = view();
if ( !v ) return nullptr;
return v->statisticsContourMap();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGridView* RimStatisticsContourMapProjection::baseView() const
{
return view();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMapView* RimStatisticsContourMapProjection::view() const
{
return firstAncestorOrThisOfTypeAsserted<RimStatisticsContourMapView>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::updateAfterResultGeneration( int timeStep )
{
m_currentResultTimestep = timeStep;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimStatisticsContourMapProjection::minmaxValuesAllTimeSteps()
{
if ( !resultRangeIsValid() )
{
clearTimeStepRange();
std::vector<double> aggregatedResults = statisticsContourMap()->result( m_statisticsType() );
m_minResultAllTimeSteps = RigContourMapProjection::minValue( aggregatedResults );
m_maxResultAllTimeSteps = RigContourMapProjection::maxValue( aggregatedResults );
}
return std::make_pair( m_minResultAllTimeSteps, m_maxResultAllTimeSteps );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapProjection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_statisticsType );
caf::PdmUiGroup* mainGroup = uiOrdering.addNewGroup( "Projection Settings" );
mainGroup->add( &m_showContourLines );
mainGroup->add( &m_showContourLabels );
m_showContourLabels.uiCapability()->setUiReadOnly( !m_showContourLines() );
mainGroup->add( &m_smoothContourLines );
m_smoothContourLines.uiCapability()->setUiReadOnly( !m_showContourLines() );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimStatisticsContourMapProjection::isColumnResult() const
{
return ( statisticsContourMap() && statisticsContourMap()->isColumnResult() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMapProjection::resultAggregationText() const
{
if ( statisticsContourMap() )
return statisticsContourMap()->resultAggregationText();
else
return "";
}

View File

@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimContourMapProjection.h"
#include "RimStatisticsContourMap.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RigActiveCellInfo;
class RigMainGrid;
class RigContourMapGrid;
class RigResultAccessor;
class RimStatisticsContourMapView;
class RimEclipseCase;
class RimEclipseResultDefinition;
//==================================================================================================
///
///
//==================================================================================================
class RimStatisticsContourMapProjection : public RimContourMapProjection
{
CAF_PDM_HEADER_INIT;
public:
RimStatisticsContourMapProjection();
~RimStatisticsContourMapProjection() override;
void clearGridMappingAndRedraw();
QString resultVariableName() const override;
QString resultDescriptionText() const override;
RimRegularLegendConfig* legendConfig() const override;
void updateLegend() override;
double sampleSpacing() const override;
bool isColumnResult() const override;
QString resultAggregationText() const override;
protected:
void updateGridInformation() override;
std::vector<double> retrieveParameterWeights() override;
std::vector<double> generateResults( int timeStep ) const override;
void generateAndSaveResults( int timeStep ) override;
bool resultVariableChanged() const override;
void clearResultVariable() override;
RimGridView* baseView() const override;
RimEclipseCase* eclipseCase() const;
RimStatisticsContourMap* statisticsContourMap() const;
RimStatisticsContourMapView* view() const;
std::pair<double, double> minmaxValuesAllTimeSteps() override;
void updateAfterResultGeneration( int timeStep ) override;
protected:
// Framework overrides
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
protected:
caf::PdmField<caf::AppEnum<RimStatisticsContourMap::StatisticsType>> m_statisticsType;
QString m_currentResultName;
};

View File

@ -0,0 +1,194 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimStatisticsContourMapView.h"
#include "RiuViewer.h"
#include "RivContourMapProjectionPartMgr.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimAnnotationInViewCollection.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCaseEnsemble.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseContourMapView.h"
#include "RimEclipseFaultColors.h"
#include "RimFaultInViewCollection.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInViewCollection.h"
#include "RimStatisticsContourMap.h"
#include "RimStatisticsContourMapProjection.h"
#include "RimViewLinker.h"
#include "RimViewNameConfig.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafProgressInfo.h"
CAF_PDM_SOURCE_INIT( RimStatisticsContourMapView, "RimStatisticsContourMapView" );
RimStatisticsContourMapView::RimStatisticsContourMapView()
: RimEclipseContourMapView()
{
CAF_PDM_InitObject( "Contour Map View", ":/2DMap16x16.png", "", "", "StatisticsContourMap", "A contour map for Eclipse cases" );
CAF_PDM_InitFieldNoDefault( &m_statisticsContourMap, "StatisticsContourMap", "Statistics Contour Map" );
m_contourMapProjection = new RimStatisticsContourMapProjection();
setFaultVisParameters();
setDefaultCustomName();
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr( contourMapProjection() );
cellResult()->setTernaryEnabled( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapView::setStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap )
{
m_statisticsContourMap = statisticsContourMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStatisticsContourMapView::createAutoName() const
{
QStringList autoName;
if ( !nameConfig()->customName().isEmpty() )
{
autoName.push_back( nameConfig()->customName() );
}
QStringList generatedAutoTags;
if ( nameConfig()->addCaseName() && m_statisticsContourMap->ensemble() )
{
generatedAutoTags.push_back( m_statisticsContourMap->ensemble()->name() );
}
if ( nameConfig()->addAggregationType() )
{
generatedAutoTags.push_back( m_statisticsContourMap->resultAggregationText() );
}
if ( nameConfig()->addProperty() && !m_statisticsContourMap->isColumnResult() )
{
generatedAutoTags.push_back( m_statisticsContourMap->resultVariable() );
}
if ( nameConfig()->addSampleSpacing() )
{
generatedAutoTags.push_back( QString( "%1" ).arg( m_statisticsContourMap->sampleSpacingFactor(), 3, 'f', 2 ) );
}
if ( !generatedAutoTags.empty() )
{
autoName.push_back( generatedAutoTags.join( ", " ) );
}
return autoName.join( ": " );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapView::setDefaultCustomName()
{
nameConfig()->setCustomName( "Contour Map" );
nameConfig()->hideCaseNameField( false );
nameConfig()->hideAggregationTypeField( false );
nameConfig()->hidePropertyField( false );
nameConfig()->hideSampleSpacingField( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
{
uiTreeOrdering.add( m_overlayInfoConfig() );
uiTreeOrdering.add( m_contourMapProjection );
uiTreeOrdering.add( cellResult()->legendConfig() );
uiTreeOrdering.add( wellCollection() );
uiTreeOrdering.add( faultCollection() );
uiTreeOrdering.add( annotationCollection() );
uiTreeOrdering.skipRemainingChildren();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapView::onUpdateLegends()
{
if ( nativeOrOverrideViewer() )
{
if ( !isUsingOverrideViewer() )
{
nativeOrOverrideViewer()->removeAllColorLegends();
}
else if ( cellResult() && cellResult()->legendConfig() )
{
nativeOrOverrideViewer()->removeColorLegend( cellResult()->legendConfig()->titledOverlayFrame() );
}
if ( m_contourMapProjection && m_contourMapProjection->isChecked() )
{
RimRegularLegendConfig* projectionLegend = m_contourMapProjection->legendConfig();
if ( projectionLegend )
{
m_contourMapProjection->updateLegend();
if ( projectionLegend->showLegend() )
{
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(),
isUsingOverrideViewer() );
}
}
}
// Hide the scale widget if any 3D views are present, as the display of the scale widget is only working for
// default rotation. The update is triggered in RimViewLinker::updateScaleWidgetVisibility()
bool any3DViewsLinked = false;
if ( auto viewLinker = assosiatedViewLinker() )
{
auto views = viewLinker->allViews();
for ( auto v : views )
{
if ( dynamic_cast<RimStatisticsContourMapView*>( v ) ) continue;
any3DViewsLinked = true;
}
}
nativeOrOverrideViewer()->showScaleLegend( any3DViewsLinked ? false : m_showScaleLegend() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsContourMap* RimStatisticsContourMapView::statisticsContourMap() const
{
return m_statisticsContourMap;
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimEclipseContourMapView.h"
class RimStatisticsContourMap;
class RimStatisticsContourMapView : public RimEclipseContourMapView
{
CAF_PDM_HEADER_INIT;
public:
RimStatisticsContourMapView();
void setStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap );
RimStatisticsContourMap* statisticsContourMap() const;
QString createAutoName() const override;
void setDefaultCustomName();
protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void createContourMapGeometry();
void onUpdateLegends() override;
private:
caf::PdmPtrField<RimStatisticsContourMap*> m_statisticsContourMap;
};

View File

@ -88,6 +88,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RigContourMapTrianglesGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RigEclipseContourMapProjection.h
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechContourMapProjection.h
${CMAKE_CURRENT_LIST_DIR}/RigStatisticsContourMapProjection.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -178,6 +179,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RigContourMapTrianglesGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigEclipseContourMapProjection.cpp
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechContourMapProjection.cpp
${CMAKE_CURRENT_LIST_DIR}/RigStatisticsContourMapProjection.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -33,6 +33,15 @@ public:
RigContourMapGrid( const cvf::BoundingBox& originalBoundingBox, double sampleSpacing );
RigContourMapGrid( const cvf::BoundingBox& originalBoundingBox, const cvf::BoundingBox& expandedBoundingBox, double sampleSpacing );
// Copy constructor
RigContourMapGrid( const RigContourMapGrid& other )
: m_sampleSpacing( other.m_sampleSpacing )
, m_mapSize( other.m_mapSize )
, m_expandedBoundingBox( other.m_expandedBoundingBox )
, m_originalBoundingBox( other.m_originalBoundingBox )
{
}
double sampleSpacing() const;
cvf::Vec2ui numberOfElementsIJ() const;

View File

@ -80,7 +80,7 @@ public:
void setCellVisibility( cvf::ref<cvf::UByteArray> cellVisibility );
cvf::ref<cvf::UByteArray> getCellVisibility() const;
std::vector<std::vector<std::pair<size_t, double>>>
virtual std::vector<std::vector<std::pair<size_t, double>>>
generateGridMapping( RigContourMapCalculator::ResultAggregationType resultAggregation, const std::vector<double>& weights );
double interpolateValue( const cvf::Vec2d& gridPosition2d ) const;
@ -90,7 +90,7 @@ public:
const std::vector<std::vector<std::pair<size_t, double>>>& projected3dGridIndices() const;
// Cell index and position conversion
std::vector<CellIndexAndResult> cellsAtIJ( unsigned int i, unsigned int j ) const;
virtual std::vector<CellIndexAndResult> cellsAtIJ( unsigned int i, unsigned int j ) const;
static double maxValue( const std::vector<double>& aggregatedResults );
static double minValue( const std::vector<double>& aggregatedResults );

View File

@ -0,0 +1,139 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigStatisticsContourMapProjection.h"
#include "RigContourMapCalculator.h"
#include "RigContourMapGrid.h"
#include "cafAssert.h"
#include <cmath>
#include <utility>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigStatisticsContourMapProjection::RigStatisticsContourMapProjection( const RigContourMapGrid& contourMapGrid )
: RigContourMapProjection( contourMapGrid )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigStatisticsContourMapProjection::~RigStatisticsContourMapProjection()
{
}
std::vector<std::vector<std::pair<size_t, double>>>
RigStatisticsContourMapProjection::generateGridMapping( RigContourMapCalculator::ResultAggregationType resultAggregation,
const std::vector<double>& weights )
{
// The grid mapping is usually necessary to produce the data. For the statistics projection
// the data is already available, so we can just ignore it.
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsContourMapProjection::generateAndSaveResults( const std::vector<double>& result )
{
m_aggregatedResults = result;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RigStatisticsContourMapProjection::findIntersectingCells( const cvf::BoundingBox& bbox ) const
{
CAF_ASSERT( false );
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigStatisticsContourMapProjection::kLayer( size_t globalCellIdx ) const
{
CAF_ASSERT( false );
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigStatisticsContourMapProjection::kLayers() const
{
CAF_ASSERT( false );
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigStatisticsContourMapProjection::calculateOverlapVolume( size_t globalCellIdx, const cvf::BoundingBox& bbox ) const
{
CAF_ASSERT( false );
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigStatisticsContourMapProjection::calculateRayLengthInCell( size_t globalCellIdx,
const cvf::Vec3d& highestPoint,
const cvf::Vec3d& lowestPoint ) const
{
CAF_ASSERT( false );
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigStatisticsContourMapProjection::getParameterWeightForCell( size_t cellResultIdx, const std::vector<double>& cellWeights ) const
{
return 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<bool> RigStatisticsContourMapProjection::getMapCellVisibility( int viewStepIndex,
RigContourMapCalculator::ResultAggregationType resultAggregation )
{
return std::vector<bool>( numberOfCells(), true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<size_t, double>> RigStatisticsContourMapProjection::cellsAtIJ( unsigned int i, unsigned int j ) const
{
size_t cellIndex = m_contourMapGrid.cellIndexFromIJ( i, j );
if ( cellIndex < m_aggregatedResults.size() && !std::isinf( m_aggregatedResults[cellIndex] ) &&
!std::isnan( m_aggregatedResults[cellIndex] ) )
{
return { std::make_pair( cellIndex, m_aggregatedResults[cellIndex] ) };
}
return std::vector<std::pair<size_t, double>>();
}

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigContourMapCalculator.h"
#include "RigContourMapProjection.h"
#include "cvfBoundingBox.h"
class RigContourMapGrid;
//==================================================================================================
///
///
//==================================================================================================
class RigStatisticsContourMapProjection : public RigContourMapProjection
{
public:
RigStatisticsContourMapProjection( const RigContourMapGrid& contourMapGrid );
virtual ~RigStatisticsContourMapProjection();
std::vector<std::pair<size_t, double>> cellsAtIJ( unsigned int i, unsigned int j ) const override;
void generateAndSaveResults( const std::vector<double>& results );
std::vector<std::vector<std::pair<size_t, double>>>
generateGridMapping( RigContourMapCalculator::ResultAggregationType resultAggregation, const std::vector<double>& weights ) override;
std::vector<bool> getMapCellVisibility( int viewStepIndex, RigContourMapCalculator::ResultAggregationType resultAggregation ) override;
protected:
using CellIndexAndResult = RigContourMapProjection::CellIndexAndResult;
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& bbox ) const override;
size_t kLayer( size_t globalCellIdx ) const override;
size_t kLayers() const override;
double calculateOverlapVolume( size_t globalCellIdx, const cvf::BoundingBox& bbox ) const override;
double calculateRayLengthInCell( size_t globalCellIdx, const cvf::Vec3d& highestPoint, const cvf::Vec3d& lowestPoint ) const override;
double getParameterWeightForCell( size_t cellResultIdx, const std::vector<double>& parameterWeights ) const override;
};