mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3628 2d Maps: Weighting by result parameters
This commit is contained in:
parent
04c993105b
commit
667518c849
@ -505,11 +505,16 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimEclipseView* eclipseView)
|
||||
QString iSize = QString::number(contourMap->contourMapProjection()->surfaceGridSize().x());
|
||||
QString jSize = QString::number(contourMap->contourMapProjection()->surfaceGridSize().y());
|
||||
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
|
||||
QString weightingParameterString;
|
||||
if (contourMap->contourMapProjection()->weightingParameter() != "None")
|
||||
{
|
||||
weightingParameterString += QString(" (Weight: %1)").arg(contourMap->contourMapProjection()->weightingParameter());
|
||||
}
|
||||
|
||||
infoText += QString(
|
||||
"<p><b>-- Contour Map: %1 --</b><p> "
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
|
||||
"<b>Projection Type: %4<br>").arg(caseName, totCellCount, activeCellCountText, aggregationType);
|
||||
"<b>Projection Type: %4%5<br>").arg(caseName, totCellCount, activeCellCountText, aggregationType, weightingParameterString);
|
||||
}
|
||||
else if (eclipseView->mainGrid())
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
@ -71,6 +72,12 @@ RimContourMapProjection::RimContourMapProjection()
|
||||
|
||||
CAF_PDM_InitField(&m_showContourLines, "ContourLines", true, "Show Contour Lines", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_weightByParameter, "WeightByParameter", false, "Weight by Result Parameter", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_weightingResult, "WeightingResult", "", "", "", "");
|
||||
m_weightingResult.uiCapability()->setUiHidden(true);
|
||||
m_weightingResult.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_weightingResult = new RimEclipseResultDefinition;
|
||||
m_weightingResult->findField("MResultType")->uiCapability()->setUiName("Result Type");
|
||||
setName("Map Projection");
|
||||
nameField()->uiCapability()->setUiReadOnly(true);
|
||||
|
||||
@ -113,13 +120,33 @@ void RimContourMapProjection::generateGridMapping()
|
||||
|
||||
int nVertices = vertexCount();
|
||||
|
||||
const std::vector<double>* weightingResultValues = nullptr;
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
size_t gridScalarResultIdx = m_weightingResult->scalarResultIndex();
|
||||
if (gridScalarResultIdx != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
m_weightingResult->loadResult();
|
||||
int timeStep = 0;
|
||||
if (m_weightingResult->hasDynamicResult())
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
timeStep = view->currentTimeStep();
|
||||
|
||||
}
|
||||
weightingResultValues = &(m_weightingResult->currentGridCellResults()->cellScalarResults(gridScalarResultIdx)[timeStep]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = globalPos2d(ij.x(), ij.y());
|
||||
m_projected3dGridIndices[index] = visibleCellsAndWeightMatching2dPoint(globalPos);
|
||||
m_projected3dGridIndices[index] = visibleCellsAndWeightMatching2dPoint(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,6 +398,29 @@ const std::vector<double>& RimContourMapProjection::aggregatedResults() const
|
||||
return m_aggregatedResults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimContourMapProjection::weightingParameter() const
|
||||
{
|
||||
QString parameter = "None";
|
||||
if (m_weightByParameter() && !m_weightingResult->isTernarySaturationSelected())
|
||||
{
|
||||
parameter = m_weightingResult->resultVariableUiShortName();
|
||||
}
|
||||
return parameter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::isMeanResult() const
|
||||
{
|
||||
return m_resultAggregation() == RESULTS_MEAN_VALUE ||
|
||||
m_resultAggregation() == RESULTS_HARM_VALUE ||
|
||||
m_resultAggregation() == RESULTS_GEOM_VALUE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -662,7 +712,7 @@ const std::vector<std::pair<size_t, double>>& RimContourMapProjection::cellsAtPo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d) const
|
||||
std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues) const
|
||||
{
|
||||
cvf::BoundingBox gridBoundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d top2dElementCentroid(globalPos2d, gridBoundingBox.max().z());
|
||||
@ -697,12 +747,27 @@ std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndW
|
||||
double overlapVolume = RigCellGeometryTools::calculateCellVolume(overlapCorners);
|
||||
|
||||
if (overlapVolume > 0.0)
|
||||
{
|
||||
double height = overlapBBox.max().z();
|
||||
matchingVisibleCellsWeightAndHeight.push_back(std::make_tuple(globalCellIdx, overlapVolume, height));
|
||||
sumOverlapVolumes += overlapVolume;
|
||||
maxHeight = std::max(maxHeight, height);
|
||||
minHeight = std::min(minHeight, overlapBBox.min().z());
|
||||
{
|
||||
double weight = overlapVolume;
|
||||
if (weightingResultValues)
|
||||
{
|
||||
const RigActiveCellInfo* activeCellInfo = eclipseCase()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
|
||||
size_t cellResultIdx = activeCellInfo->cellResultIndex(globalCellIdx);
|
||||
double result = std::max((*weightingResultValues)[cellResultIdx], 0.0);
|
||||
if (result < 1.0e-6)
|
||||
{
|
||||
result = 0.0;
|
||||
}
|
||||
weight *= result;
|
||||
}
|
||||
if (weight > 0.0)
|
||||
{
|
||||
double height = overlapBBox.max().z();
|
||||
matchingVisibleCellsWeightAndHeight.push_back(std::make_tuple(globalCellIdx, weight, height));
|
||||
sumOverlapVolumes += overlapVolume;
|
||||
maxHeight = std::max(maxHeight, height);
|
||||
minHeight = std::min(minHeight, overlapBBox.min().z());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -829,7 +894,17 @@ double RimContourMapProjection::findSoilResult(size_t cellGlobalIdx) const
|
||||
const RimEclipseResultCase* RimContourMapProjection::eclipseCase() const
|
||||
{
|
||||
const RimEclipseResultCase* eclipseCase = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(eclipseCase);
|
||||
firstAncestorOrThisOfType(eclipseCase);
|
||||
return eclipseCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseResultCase* RimContourMapProjection::eclipseCase()
|
||||
{
|
||||
RimEclipseResultCase* eclipseCase = nullptr;
|
||||
firstAncestorOrThisOfType(eclipseCase);
|
||||
return eclipseCase;
|
||||
}
|
||||
|
||||
@ -870,7 +945,7 @@ void RimContourMapProjection::updateLegend()
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
|
||||
if (isSummationResult() || (m_resultAggregation != RESULTS_TOP_VALUE && legendConfig()->rangeMode() != RimLegendConfig::AUTOMATIC_ALLTIMESTEPS))
|
||||
if ((isSummationResult() || weightingParameter() != "None") || (m_resultAggregation != RESULTS_TOP_VALUE && legendConfig()->rangeMode() != RimLegendConfig::AUTOMATIC_ALLTIMESTEPS))
|
||||
{
|
||||
double minVal = minValue();
|
||||
double maxVal = maxValue();
|
||||
@ -886,11 +961,18 @@ void RimContourMapProjection::updateLegend()
|
||||
m_resultAggregation() == RESULTS_GAS_COLUMN ||
|
||||
m_resultAggregation() == RESULTS_HC_COLUMN)
|
||||
{
|
||||
legendConfig()->setTitle(QString("2d Projection:\n%1").arg(m_resultAggregation().uiText()));
|
||||
legendConfig()->setTitle(QString("Map Projection\n%1").arg(m_resultAggregation().uiText()));
|
||||
}
|
||||
else
|
||||
{
|
||||
legendConfig()->setTitle(QString("2d Projection:\n%1: %2").arg(m_resultAggregation().uiText()).arg(cellColors->resultVariableUiShortName()));
|
||||
QString projectionLegendText = QString("Map Projection\n%1").arg(m_resultAggregation().uiText());
|
||||
if (weightingParameter() != "None")
|
||||
{
|
||||
projectionLegendText += QString("(W: %1)").arg(weightingParameter());
|
||||
}
|
||||
projectionLegendText += QString("\nResult: %1").arg(cellColors->resultVariableUiShortName());
|
||||
|
||||
legendConfig()->setTitle(projectionLegendText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -910,6 +992,20 @@ QString RimContourMapProjection::resultAggregationText() const
|
||||
return m_resultAggregation().uiText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::updatedWeightingResult()
|
||||
{
|
||||
this->updateConnectedEditors();
|
||||
this->generateResults();
|
||||
this->updateLegend();
|
||||
|
||||
RimProject* proj;
|
||||
this->firstAncestorOrThisOfTypeAsserted(proj);
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -971,6 +1067,8 @@ void RimContourMapProjection::fieldChangedByUi(const caf::PdmFieldHandle* change
|
||||
legendConfig()->disableAllTimeStepsRange(isSummationResult());
|
||||
}
|
||||
|
||||
m_weightingResult->loadResult();
|
||||
|
||||
RimEclipseView* view = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(view);
|
||||
view->updateConnectedEditors();
|
||||
@ -996,6 +1094,34 @@ void RimContourMapProjection::defineEditorAttribute(const caf::PdmFieldHandle* f
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
caf::PdmUiGroup* mainGroup = uiOrdering.addNewGroup("Projection Settings");
|
||||
mainGroup->add(&m_relativeSampleSpacing);
|
||||
mainGroup->add(&m_resultAggregation);
|
||||
mainGroup->add(&m_showContourLines);
|
||||
|
||||
caf::PdmUiGroup* weightingGroup = uiOrdering.addNewGroup("Mean Weighting Options");
|
||||
weightingGroup->add(&m_weightByParameter);
|
||||
weightingGroup->setCollapsedByDefault(true);
|
||||
|
||||
m_weightByParameter.uiCapability()->setUiReadOnly(!isMeanResult());
|
||||
if (!isMeanResult())
|
||||
{
|
||||
m_weightByParameter = false;
|
||||
}
|
||||
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
m_weightingResult->uiOrdering(uiConfigName, *weightingGroup);
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1010,4 +1136,8 @@ void RimContourMapProjection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTre
|
||||
void RimContourMapProjection::initAfterRead()
|
||||
{
|
||||
legendConfig()->disableAllTimeStepsRange(isSummationResult());
|
||||
if (eclipseCase())
|
||||
{
|
||||
m_weightingResult->setEclipseCase(eclipseCase());
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
class RigMainGrid;
|
||||
class RigResultAccessor;
|
||||
class RimEclipseResultCase;
|
||||
class RimEclipseResultDefinition;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -75,6 +76,8 @@ public:
|
||||
bool showContourLines() const;
|
||||
|
||||
const std::vector<double>& aggregatedResults() const;
|
||||
QString weightingParameter() const;
|
||||
bool isMeanResult() const;
|
||||
bool isSummationResult() const;
|
||||
bool isColumnResult() const;
|
||||
|
||||
@ -94,6 +97,8 @@ public:
|
||||
ResultAggregation resultAggregation() const;
|
||||
QString resultAggregationText() const;
|
||||
|
||||
void updatedWeightingResult();
|
||||
|
||||
protected:
|
||||
double calculateValue(uint i, uint j) const;
|
||||
double calculateVolumeSum(uint i, uint j) const;
|
||||
@ -107,26 +112,30 @@ protected:
|
||||
std::vector<double> xPositions() const;
|
||||
std::vector<double> yPositions() const;
|
||||
|
||||
std::vector<std::pair<size_t, double>> visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d) const;
|
||||
std::vector<std::pair<size_t, double>> visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues = nullptr) const;
|
||||
double findColumnResult(ResultAggregation resultAggregation, size_t cellGlobalIdx) const;
|
||||
double findSoilResult(size_t cellGlobalIdx) const;
|
||||
const RimEclipseResultCase* eclipseCase() const;
|
||||
RigMainGrid* mainGrid() const;
|
||||
const RimEclipseResultCase* eclipseCase() const;
|
||||
RimEclipseResultCase* eclipseCase();
|
||||
RigMainGrid* mainGrid() const;
|
||||
|
||||
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 defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
void initAfterRead() override;
|
||||
void initAfterRead() override;
|
||||
|
||||
protected:
|
||||
caf::PdmField<double> m_relativeSampleSpacing;
|
||||
caf::PdmField<ResultAggregation> m_resultAggregation;
|
||||
caf::PdmField<bool> m_showContourLines;
|
||||
|
||||
caf::PdmField<bool> m_weightByParameter;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_weightingResult;
|
||||
cvf::ref<cvf::UByteArray> m_cellGridIdxVisibility;
|
||||
|
||||
std::vector<double> m_aggregatedResults;
|
||||
std::vector<std::vector<std::pair<size_t, double>>> m_projected3dGridIndices;
|
||||
|
||||
cvf::ref<RigResultAccessor> m_resultAccessor;
|
||||
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "Rim3dView.h"
|
||||
#include "Rim3dWellLogCurve.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseFaultColors.h"
|
||||
@ -367,6 +368,13 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged()
|
||||
{
|
||||
rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI();
|
||||
}
|
||||
|
||||
RimContourMapProjection* contourMap = nullptr;
|
||||
this->firstAncestorOrThisOfType(contourMap);
|
||||
if (contourMap)
|
||||
{
|
||||
contourMap->updatedWeightingResult();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user