From 815689372ae6593438ccbb48bc9489689f76357f Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 3 Apr 2019 11:46:26 +0200 Subject: [PATCH] Fix Linux build problem by forcing use of function value to yield case diff values --- .../RigFemPartResultsCollection.cpp | 14 ++++++------- .../GeoMechDataModel/RigFemResultAddress.h | 12 ++++++++--- .../RimEclipseResultDefinition.cpp | 10 +++++----- .../RimGeoMechResultDefinition.cpp | 20 +++++++++---------- .../RigCaseCellResultCalculator.cpp | 4 ++-- .../RigEclipseResultAddress.h | 11 +++++++--- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index df50ca367a..004443b92f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -193,12 +193,12 @@ void RigFemPartResultsCollection::setCalculationParameters(double cohesion, doub m_frictionAngleRad = frictionAngleRad; // Todo, delete all dependent results - this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "SFI", RigFemResultAddress::ALL_TIME_LAPSES)); - this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "SFI", RigFemResultAddress::ALL_TIME_LAPSES)); - this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "DSM", RigFemResultAddress::ALL_TIME_LAPSES)); - this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "DSM", RigFemResultAddress::ALL_TIME_LAPSES)); - this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); - this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); + this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "SFI", RigFemResultAddress::allTimeLapsesValue())); + this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "SFI", RigFemResultAddress::allTimeLapsesValue())); + this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "DSM", RigFemResultAddress::allTimeLapsesValue())); + this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "DSM", RigFemResultAddress::allTimeLapsesValue())); + this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "FOS", RigFemResultAddress::allTimeLapsesValue())); + this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "FOS", RigFemResultAddress::allTimeLapsesValue())); } //-------------------------------------------------------------------------------------------------- @@ -605,7 +605,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult( frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName, RigFemResultAddress::NO_TIME_LAPSE, resVarAddr.refKLayerIndex); + RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName, RigFemResultAddress::noTimeLapseValue(), resVarAddr.refKLayerIndex); RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, resVarNative); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index 72b1e8cd0d..834ddf5d20 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -57,9 +57,9 @@ public: int timeLapseBaseFrameIdx; int refKLayerIndex; - static const int ALL_TIME_LAPSES = -2; - static const int NO_TIME_LAPSE = -1; - static const int NO_COMPACTION = -1; + static constexpr int allTimeLapsesValue() { return ALL_TIME_LAPSES; } + static constexpr int noTimeLapseValue() { return NO_TIME_LAPSE; } + static constexpr int noCompactionValue() { return NO_COMPACTION; } bool isTimeLapse() const { return timeLapseBaseFrameIdx > NO_TIME_LAPSE;} bool representsAllTimeLapses() const { return timeLapseBaseFrameIdx == ALL_TIME_LAPSES;} @@ -114,6 +114,12 @@ public: return true; } + +private: + static const int ALL_TIME_LAPSES = -2; + static const int NO_TIME_LAPSE = -1; + static const int NO_COMPACTION = -1; + }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 7fcd88180c..e790f44153 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -94,7 +94,7 @@ RimEclipseResultDefinition::RimEclipseResultDefinition() m_flowSolution.uiCapability()->setUiHidden(true); CAF_PDM_InitField( - &m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigEclipseResultAddress::NO_TIME_LAPSE, "Base Time Step", "", "", ""); + &m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigEclipseResultAddress::noTimeLapseValue(), "Base Time Step", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_differenceCase, "DifferenceCase", "Difference Case", "", "", ""); @@ -269,7 +269,7 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha if (&m_differenceCase == changedField) { - m_timeLapseBaseTimestep = RigEclipseResultAddress::NO_TIME_LAPSE; + m_timeLapseBaseTimestep = RigEclipseResultAddress::noTimeLapseValue(); loadDataAndUpdate(); } @@ -690,7 +690,7 @@ QList RimEclipseResultDefinition::calculateValueOptions( baseCase = m_differenceCase; } - options.push_back(caf::PdmOptionItemInfo("Disabled", RigEclipseResultAddress::NO_TIME_LAPSE)); + options.push_back(caf::PdmOptionItemInfo("Disabled", RigEclipseResultAddress::noTimeLapseValue())); std::vector stepDates = baseCase->timeStepDates(); for (size_t stepIdx = 0; stepIdx < stepDates.size(); ++stepIdx) @@ -718,8 +718,8 @@ RigEclipseResultAddress RimEclipseResultDefinition::eclipseResultAddress() const const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); if (gridCellResults) { - int timelapseTimeStep = RigEclipseResultAddress::NO_TIME_LAPSE; - int diffCaseId = RigEclipseResultAddress::NO_CASE_DIFF; + int timelapseTimeStep = RigEclipseResultAddress::noTimeLapseValue(); + int diffCaseId = RigEclipseResultAddress::noCaseDiffValue(); if (isTimeDiffResult()) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index e0219f6967..98f5c66a15 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -77,7 +77,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", ""); m_resultComponentName.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", (int) RigFemResultAddress::NO_TIME_LAPSE, "Base Time Step", "", "", ""); + CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigFemResultAddress::noTimeLapseValue(), "Base Time Step", "", "", ""); CAF_PDM_InitField(&m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer", "", "", ""); m_compactionRefLayer.uiCapability()->setUiHidden(true); @@ -91,7 +91,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", (int)RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", RigFemResultAddress::noCompactionValue(), "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->disableIO(); // OBSOLETE FIELDS @@ -120,7 +120,7 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm uiOrdering.add(&m_resultVariableUiField); QString valueLabel = "Value"; - if (m_timeLapseBaseTimestep != RigFemResultAddress::NO_TIME_LAPSE) + if (m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue()) { valueLabel += QString(" (%1)").arg(diffResultUiName()); } @@ -137,7 +137,7 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); compactionGroup->add(&m_compactionRefLayerUiField); - if (m_compactionRefLayerUiField == (int)RigFemResultAddress::NO_COMPACTION) + if (m_compactionRefLayerUiField == RigFemResultAddress::noCompactionValue()) { if (m_geomCase && m_geomCase->geoMechData() ) { @@ -201,7 +201,7 @@ QList RimGeoMechResultDefinition::calculateValueOptions( stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); } - options.push_back(caf::PdmOptionItemInfo(QString("Disabled"), (int)RigFemResultAddress::NO_TIME_LAPSE)); + options.push_back(caf::PdmOptionItemInfo(QString("Disabled"), RigFemResultAddress::noTimeLapseValue())); for (size_t stepIdx = 0; stepIdx < stepNames.size(); ++stepIdx) { options.push_back(caf::PdmOptionItemInfo(QString("%1 (#%2)").arg(QString::fromStdString(stepNames[stepIdx])).arg(stepIdx), static_cast(stepIdx))); @@ -244,7 +244,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha { if (m_resultPositionTypeUiField() == RIG_WELLPATH_DERIVED || m_resultPositionType() == RIG_FORMATION_NAMES) { - m_timeLapseBaseTimestep = RigFemResultAddress::NO_TIME_LAPSE; + m_timeLapseBaseTimestep = RigFemResultAddress::noTimeLapseValue(); m_timeLapseBaseTimestep.uiCapability()->setUiReadOnly(true); } else @@ -435,7 +435,7 @@ void RimGeoMechResultDefinition::initAfterRead() { if (!m_isTimeLapseResult_OBSOLETE()) { - m_timeLapseBaseTimestep = RigFemResultAddress::NO_TIME_LAPSE; + m_timeLapseBaseTimestep = RigFemResultAddress::noTimeLapseValue(); } m_resultPositionTypeUiField = m_resultPositionType; @@ -486,7 +486,7 @@ RigFemResultAddress RimGeoMechResultDefinition::resultAddress() const resultFieldName().toStdString(), resultComponentName().toStdString(), m_timeLapseBaseTimestep(), - resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION); + resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::noCompactionValue()); } //-------------------------------------------------------------------------------------------------- @@ -527,7 +527,7 @@ QString RimGeoMechResultDefinition::resultComponentName() const QString RimGeoMechResultDefinition::diffResultUiName() const { QString diffResultString; - if (m_timeLapseBaseTimestep != RigFemResultAddress::NO_TIME_LAPSE) + if (m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue()) { if (m_geomCase->geoMechData()) { @@ -545,7 +545,7 @@ QString RimGeoMechResultDefinition::diffResultUiName() const QString RimGeoMechResultDefinition::diffResultUiShortName() const { QString diffResultString; - if (m_timeLapseBaseTimestep != RigFemResultAddress::NO_TIME_LAPSE) + if (m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue()) { if (m_geomCase->geoMechData()) { diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp index 2fa369feb6..18e8886bd1 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp @@ -93,8 +93,8 @@ bool RigCaseCellResultCalculator::computeDifference(RigEclipseCaseData* } RigEclipseResultAddress nativeAddress(address); - nativeAddress.m_differenceCaseId = RigEclipseResultAddress::NO_CASE_DIFF; - nativeAddress.m_timeLapseBaseFrameIdx = RigEclipseResultAddress::NO_TIME_LAPSE; + nativeAddress.m_differenceCaseId = RigEclipseResultAddress::noCaseDiffValue(); + nativeAddress.m_timeLapseBaseFrameIdx = RigEclipseResultAddress::noTimeLapseValue(); if (!sourceCaseResults->ensureKnownResultLoaded(nativeAddress)) { RiaLogging::error("Failed to load destination diff result"); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseResultAddress.h b/ApplicationCode/ReservoirDataModel/RigEclipseResultAddress.h index 9aca81e1bd..5e600ccf41 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseResultAddress.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseResultAddress.h @@ -57,9 +57,9 @@ public: } } - static const int ALL_TIME_LAPSES = -2; - static const int NO_TIME_LAPSE = -1; - static const int NO_CASE_DIFF = -1; + static constexpr int allTimeLapsesValue() { return ALL_TIME_LAPSES; } + static constexpr int noTimeLapseValue() { return NO_TIME_LAPSE; } + static constexpr int noCaseDiffValue() { return NO_CASE_DIFF; } bool isTimeLapse() const { return m_timeLapseBaseFrameIdx > NO_TIME_LAPSE;} bool representsAllTimeLapses() const { return m_timeLapseBaseFrameIdx == ALL_TIME_LAPSES;} @@ -104,6 +104,11 @@ public: int m_timeLapseBaseFrameIdx; int m_differenceCaseId; + +private: + static const int ALL_TIME_LAPSES = -2; + static const int NO_TIME_LAPSE = -1; + static const int NO_CASE_DIFF = -1; };