Skip to content

Commit

Permalink
Change how sampling resolution is specified in statistics contourmap ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Jan 16, 2025
1 parent b999faf commit 1542830
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 17 deletions.
1 change: 1 addition & 0 deletions ApplicationLibCode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ list(
ProjectDataModel/CMakeLists_files.cmake
ProjectDataModel/AnalysisPlots/CMakeLists_files.cmake
ProjectDataModel/CorrelationPlots/CMakeLists_files.cmake
ProjectDataModel/ContourMap/CMakeLists_files.cmake
ProjectDataModel/Cloud/CMakeLists_files.cmake
ProjectDataModel/Faults/CMakeLists_files.cmake
ProjectDataModel/GeoMech/CMakeLists_files.cmake
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimContourMapResolutionTools.h
)

set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimContourMapResolutionTools.cpp
)

list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 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 "RimContourMapResolutionTools.h"

#include "cafAppEnum.h"

namespace caf
{
template <>
void caf::AppEnum<RimContourMapResolutionTools::SamplingResolution>::setUp()
{
addItem( RimContourMapResolutionTools::SamplingResolution::EXTRA_FINE, "Extra Fine", "Extra Fine" );
addItem( RimContourMapResolutionTools::SamplingResolution::FINE, "Fine", "Fine" );
addItem( RimContourMapResolutionTools::SamplingResolution::BASE, "Base", "Normal" );
addItem( RimContourMapResolutionTools::SamplingResolution::COARSE, "Coarse", "Coarse" );
addItem( RimContourMapResolutionTools::SamplingResolution::EXTRA_COARSE, "Extra Coarse", "Extra Coarse" );
setDefault( RimContourMapResolutionTools::SamplingResolution::BASE );
}
}; // namespace caf

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimContourMapResolutionTools::resolutionFromEnumValue( SamplingResolution resEnumVal )
{
switch ( resEnumVal )
{
case RimContourMapResolutionTools::SamplingResolution::EXTRA_FINE:
return 0.5;
case RimContourMapResolutionTools::SamplingResolution::FINE:
return 1.0;
case RimContourMapResolutionTools::SamplingResolution::COARSE:
return 5.0;
case RimContourMapResolutionTools::SamplingResolution::EXTRA_COARSE:
return 8.0;
case RimContourMapResolutionTools::SamplingResolution::BASE:
default:
return 2.0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 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.
//
/////////////////////////////////////////////////////////////////////////////////

class RimContourMapResolutionTools
{
public:
enum class SamplingResolution
{
EXTRA_FINE,
FINE,
BASE,
COARSE,
EXTRA_COARSE
};

static double resolutionFromEnumValue( RimContourMapResolutionTools::SamplingResolution resEnumVal );

private:
RimContourMapResolutionTools(){};
};
27 changes: 11 additions & 16 deletions ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ RimStatisticsContourMap::RimStatisticsContourMap()
{
CAF_PDM_InitObject( "Statistics Contour Map", ":/Histogram16x16.png" );

CAF_PDM_InitField( &m_boundingBoxExpPercent, "BoundingBoxExpPercent", 5.0, "Bounding Box Expansion (%)" );
CAF_PDM_InitField( &m_boundingBoxExpPercent,
"BoundingBoxExpPercent",
5.0,
"Bounding Box Expansion (%)",
"",
"How much to increase the bounding box of the primary case to cover for any grid size differences across the "
"ensemble." );
m_boundingBoxExpPercent.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );

CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 2.0, "Sample Spacing Factor" );
m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_resolution, "Resolution", "Sampling Resolution" );

CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation" );

Expand Down Expand Up @@ -130,8 +135,8 @@ void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUi
auto genGrp = uiOrdering.addNewGroup( "General" );

genGrp->add( &m_resultAggregation );
genGrp->add( &m_resolution );
genGrp->add( &m_primaryCase );
genGrp->add( &m_relativeSampleSpacing );
genGrp->add( &m_boundingBoxExpPercent );

auto tsGroup = uiOrdering.addNewGroup( "Time Step Selection" );
Expand Down Expand Up @@ -289,16 +294,6 @@ void RimStatisticsContourMap::defineEditorAttribute( const caf::PdmFieldHandle*
attrib->m_buttonText = "Compute";
}
}
else if ( &m_relativeSampleSpacing == field )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
myAttr->m_minimum = 0.2;
myAttr->m_maximum = 20.0;
myAttr->m_sliderTickCount = 20;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
else if ( &m_boundingBoxExpPercent == field )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
Expand Down Expand Up @@ -407,7 +402,7 @@ void RimStatisticsContourMap::computeStatistics()
double sampleSpacing = 1.0;
if ( auto mainGrid = eclipseCase()->mainGrid() )
{
sampleSpacing = m_relativeSampleSpacing * mainGrid->characteristicIJCellSize();
sampleSpacing = sampleSpacingFactor() * mainGrid->characteristicIJCellSize();
}

auto contourMapGrid = std::make_unique<RigContourMapGrid>( gridBoundingBox, sampleSpacing );
Expand Down Expand Up @@ -590,7 +585,7 @@ bool RimStatisticsContourMap::isColumnResult() const
//--------------------------------------------------------------------------------------------------
double RimStatisticsContourMap::sampleSpacingFactor() const
{
return m_relativeSampleSpacing;
return RimContourMapResolutionTools::resolutionFromEnumValue( m_resolution() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"

#include "ContourMap/RimContourMapResolutionTools.h"
#include "RimContourMapProjection.h"

#include <map>
Expand Down Expand Up @@ -89,14 +90,15 @@ class RimStatisticsContourMap : public RimNamedObject
void doStatisticsCalculation( std::map<size_t, std::vector<std::vector<double>>>& timestep_results );

caf::PdmField<double> m_boundingBoxExpPercent;
caf::PdmField<double> m_relativeSampleSpacing;
caf::PdmField<RimContourMapProjection::ResultAggregation> m_resultAggregation;
caf::PdmField<std::vector<int>> m_selectedTimeSteps;
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<bool> m_computeStatisticsButton;

caf::PdmField<QString> m_primaryCase;

caf::PdmField<caf::AppEnum<RimContourMapResolutionTools::SamplingResolution>> m_resolution;

std::unique_ptr<RigContourMapGrid> m_contourMapGrid;
std::map<size_t, std::map<StatisticsType, std::vector<double>>> m_timeResults;

Expand Down

0 comments on commit 1542830

Please sign in to comment.