From 08776a09b30fd5690d28673a0ecf536925c1fee0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 23 Oct 2018 21:33:54 +0200 Subject: [PATCH] #3531 Temporary LGR : Move function and whitespace changes --- .../RigCaseCellResultsData.cpp | 649 ++++++++++-------- .../RigCaseCellResultsData.h | 8 +- 2 files changed, 354 insertions(+), 303 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 6a43fa717b..9e400ba738 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -3,17 +3,17 @@ // Copyright (C) 2011- Statoil ASA // Copyright (C) 2013- Ceetron Solutions AS // Copyright (C) 2011-2012 Ceetron AS -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -25,8 +25,8 @@ #include "RigEclipseCaseData.h" #include "RigEclipseMultiPropertyStatCalc.h" #include "RigEclipseNativeStatCalc.h" -#include "RigMainGrid.h" #include "RigEclipseResultInfo.h" +#include "RigMainGrid.h" #include "RigStatisticsDataCache.h" #include "RigStatisticsMath.h" @@ -44,9 +44,10 @@ #include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) : m_activeCellInfo(nullptr) +RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) + : m_activeCellInfo(nullptr) { CVF_ASSERT(ownerCaseData != nullptr); CVF_ASSERT(ownerCaseData->mainGrid() != nullptr); @@ -56,7 +57,7 @@ RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::setMainGrid(RigMainGrid* ownerGrid) { @@ -64,7 +65,15 @@ void RigCaseCellResultsData::setMainGrid(RigMainGrid* ownerGrid) } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::setActiveCellInfo(RigActiveCellInfo* activeCellInfo) +{ + m_activeCellInfo = activeCellInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max) { @@ -72,7 +81,7 @@ void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, do } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max) { @@ -80,7 +89,7 @@ void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, si } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, double& pos, double& neg) { @@ -88,7 +97,7 @@ void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, doubl } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, size_t timeStepIndex, double& pos, double& neg) { @@ -96,7 +105,7 @@ void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, size_ } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex) { @@ -104,7 +113,7 @@ const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(siz } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex, size_t timeStepIndex) { @@ -112,7 +121,7 @@ const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(siz } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90) { @@ -120,7 +129,7 @@ void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, do } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90) { @@ -128,7 +137,7 @@ void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, si } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, double& meanValue) { @@ -136,7 +145,7 @@ void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, doub } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue) { @@ -144,7 +153,7 @@ void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const std::vector& RigCaseCellResultsData::uniqueCellScalarValues(size_t scalarResultIndex) { @@ -152,7 +161,7 @@ const std::vector& RigCaseCellResultsData::uniqueCellScalarValues(size_t sc } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, double& sumValue) { @@ -160,7 +169,7 @@ void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, doubl } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue) { @@ -168,7 +177,7 @@ void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, size_ } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, double& meanValue) { @@ -176,7 +185,7 @@ void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue) { @@ -184,7 +193,7 @@ void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::resultCount() const { @@ -192,7 +201,7 @@ size_t RigCaseCellResultsData::resultCount() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::timeStepCount(size_t scalarResultIndex) const { @@ -202,9 +211,9 @@ size_t RigCaseCellResultsData::timeStepCount(size_t scalarResultIndex) const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -const std::vector< std::vector > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex ) const +const std::vector>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex) const { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); @@ -212,9 +221,9 @@ const std::vector< std::vector > & RigCaseCellResultsData::cellScalarRes } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex ) +std::vector>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex) { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); @@ -222,7 +231,7 @@ std::vector< std::vector > & RigCaseCellResultsData::cellScalarResults( } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex) { @@ -233,7 +242,7 @@ std::vector& RigCaseCellResultsData::cellScalarResults(size_t scalarResu } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName) const { @@ -250,7 +259,7 @@ size_t RigCaseCellResultsData::findScalarResultIndex(RiaDefines::ResultCatType t } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) const { @@ -276,7 +285,7 @@ size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) scalarResultIndex = this->findScalarResultIndex(RiaDefines::INPUT_PROPERTY, resultName); } - if(scalarResultIndex == cvf::UNDEFINED_SIZE_T) + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { scalarResultIndex = this->findScalarResultIndex(RiaDefines::FORMATION_NAMES, resultName); } @@ -288,7 +297,9 @@ size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) /// Adds an empty scalar set, and returns the scalarResultIndex to it. /// if resultName already exists, it just returns the scalarResultIndex to the existing result. //-------------------------------------------------------------------------------------------------- -size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName, bool needsToBeStored) +size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, + const QString& resultName, + bool needsToBeStored) { size_t scalarResultIndex = this->findScalarResultIndex(type, resultName); @@ -302,7 +313,7 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC // Create the new empty result with metadata scalarResultIndex = this->resultCount(); - m_cellScalarResults.push_back(std::vector >()); + m_cellScalarResults.push_back(std::vector>()); RigEclipseResultInfo resInfo(type, resultName, needsToBeStored, false, scalarResultIndex); m_resultInfos.push_back(resInfo); @@ -337,25 +348,34 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC else if (resultName == RiaDefines::combinedRiTranResultName()) { cvf::ref calc = new RigEclipseMultiPropertyStatCalc(); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName())); statisticsCalculator = calc; } else if (resultName == RiaDefines::combinedRiMultResultName()) { cvf::ref calc = new RigEclipseMultiPropertyStatCalc(); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultXResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultYResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultZResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultXResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultYResultName())); + calc->addNativeStatisticsCalculator(this, + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riMultZResultName())); statisticsCalculator = calc; } else if (resultName == RiaDefines::combinedRiAreaNormTranResultName()) { cvf::ref calc = new RigEclipseMultiPropertyStatCalc(); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranXResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranYResultName())); - calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranZResultName())); + calc->addNativeStatisticsCalculator( + this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranXResultName())); + calc->addNativeStatisticsCalculator( + this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranYResultName())); + calc->addNativeStatisticsCalculator( + this, findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranZResultName())); statisticsCalculator = calc; } else if (resultName == RiaDefines::combinedWaterFluxResultName()) @@ -384,8 +404,8 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC } else if (resultName.endsWith("IJK")) { - cvf::ref calc = new RigEclipseMultiPropertyStatCalc(); - QString baseName = resultName.left(resultName.size() - 3); + cvf::ref calc = new RigEclipseMultiPropertyStatCalc(); + QString baseName = resultName.left(resultName.size() - 3); calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::GENERATED, QString("%1I").arg(baseName))); calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::GENERATED, QString("%1J").arg(baseName))); calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RiaDefines::GENERATED, QString("%1K").arg(baseName))); @@ -403,25 +423,41 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QStringList RigCaseCellResultsData::resultNames(RiaDefines::ResultCatType resType) const { - QStringList varList; + QStringList varList; std::vector::const_iterator it; for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it) { - if (it->resultType() == resType ) + if (it->resultType() == resType) { varList.push_back(it->resultName()); } - } + } return varList; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +RigActiveCellInfo* RigCaseCellResultsData::activeCellInfo() +{ + return m_activeCellInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigActiveCellInfo* RigCaseCellResultsData::activeCellInfo() const +{ + return m_activeCellInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::recalculateStatistics(size_t scalarResultIndex) { m_statisticsDataCache[scalarResultIndex]->clearAllStatistics(); @@ -435,7 +471,7 @@ bool RigCaseCellResultsData::isUsingGlobalActiveIndex(size_t scalarResultIndex) CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size()); if (!m_cellScalarResults[scalarResultIndex].size()) return true; - + size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size(); if (firstTimeStepResultValueCount == m_ownerMainGrid->globalCellArray().size()) return false; @@ -443,21 +479,21 @@ bool RigCaseCellResultsData::isUsingGlobalActiveIndex(size_t scalarResultIndex) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RigCaseCellResultsData::hasFlowDiagUsableFluxes() const { QStringList dynResVarNames = resultNames(RiaDefines::DYNAMIC_NATIVE); bool hasFlowFluxes = true; - hasFlowFluxes = dynResVarNames.contains("FLRWATI+"); - hasFlowFluxes = hasFlowFluxes && (dynResVarNames.contains("FLROILI+") || dynResVarNames.contains("FLRGASI+")); + hasFlowFluxes = dynResVarNames.contains("FLRWATI+"); + hasFlowFluxes = hasFlowFluxes && (dynResVarNames.contains("FLROILI+") || dynResVarNames.contains("FLRGASI+")); return hasFlowFluxes; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::allTimeStepDatesFromEclipseReader() const { @@ -465,7 +501,7 @@ std::vector RigCaseCellResultsData::allTimeStepDatesFromEclipseReader if (rifReaderOutput) { return rifReaderOutput->allTimeSteps(); - } + } else { return std::vector(); @@ -473,7 +509,7 @@ std::vector RigCaseCellResultsData::allTimeStepDatesFromEclipseReader } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::timeStepDates(size_t scalarResultIndex) const { @@ -486,7 +522,7 @@ std::vector RigCaseCellResultsData::timeStepDates(size_t scalarResult } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::timeStepDates() const { @@ -497,7 +533,7 @@ std::vector RigCaseCellResultsData::timeStepDates() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::daysSinceSimulationStart() const { @@ -508,7 +544,7 @@ std::vector RigCaseCellResultsData::daysSinceSimulationStart() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::daysSinceSimulationStart(size_t scalarResultIndex) const { @@ -523,7 +559,7 @@ std::vector RigCaseCellResultsData::daysSinceSimulationStart(size_t scal } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RigCaseCellResultsData::reportStepNumber(size_t scalarResultIndex, size_t timeStepIndex) const { @@ -534,7 +570,7 @@ int RigCaseCellResultsData::reportStepNumber(size_t scalarResultIndex, size_t ti } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RigCaseCellResultsData::timeStepInfos(size_t scalarResultIndex) const { @@ -545,31 +581,31 @@ std::vector RigCaseCellResultsData::timeStepInfos(size_t } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::setTimeStepInfos(size_t scalarResultIndex, const std::vector& timeStepInfos) { - CVF_ASSERT(scalarResultIndex < m_resultInfos.size() ); + CVF_ASSERT(scalarResultIndex < m_resultInfos.size()); m_resultInfos[scalarResultIndex].setTimeStepInfos(timeStepInfos); - std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); + std::vector>& dataValues = this->cellScalarResults(scalarResultIndex); dataValues.resize(timeStepInfos.size()); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::maxTimeStepCount(size_t* scalarResultIndexWithMostTimeSteps) const { - size_t maxTsCount = 0; + size_t maxTsCount = 0; size_t scalarResultIndexWithMaxTsCount = cvf::UNDEFINED_SIZE_T; for (size_t i = 0; i < m_resultInfos.size(); i++) { if (m_resultInfos[i].timeStepInfos().size() > maxTsCount) { - maxTsCount = m_resultInfos[i].timeStepInfos().size(); + maxTsCount = m_resultInfos[i].timeStepInfos().size(); scalarResultIndexWithMaxTsCount = i; } } @@ -583,15 +619,15 @@ size_t RigCaseCellResultsData::maxTimeStepCount(size_t* scalarResultIndexWithMos } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNameProposal) const { QString newResultName = resultNameProposal; - size_t resultIndex = cvf::UNDEFINED_SIZE_T; - int nameNum = 1; - int stringLength = newResultName.size(); - while (true) + size_t resultIndex = cvf::UNDEFINED_SIZE_T; + int nameNum = 1; + int stringLength = newResultName.size(); + while (true) { resultIndex = this->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) break; @@ -605,9 +641,9 @@ QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNamePr } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, const QString & resultName) +void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, const QString& resultName) { size_t scalarResultIndex = this->findScalarResultIndex(type, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return; @@ -616,8 +652,8 @@ void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, c { std::vector empty; m_cellScalarResults[scalarResultIndex][tsIdx].swap(empty); - } - + } + recalculateStatistics(scalarResultIndex); } @@ -630,7 +666,7 @@ void RigCaseCellResultsData::clearScalarResult(const RigEclipseResultInfo& resul } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::clearAllResults() { @@ -640,7 +676,7 @@ void RigCaseCellResultsData::clearAllResults() } //-------------------------------------------------------------------------------------------------- -/// Removes all the actual numbers put into this object, and frees up the memory. +/// Removes all the actual numbers put into this object, and frees up the memory. /// Does not touch the metadata in any way //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::freeAllocatedResultsData() @@ -671,13 +707,16 @@ bool RigCaseCellResultsData::isResultLoaded(const RigEclipseResultInfo& resultIn } //-------------------------------------------------------------------------------------------------- -/// Make sure we have a result with given type and name, and make sure one "timestep" result vector +/// Make sure we have a result with given type and name, and make sure one "timestep" result vector // for the static result values are allocated //-------------------------------------------------------------------------------------------------- -size_t RigCaseCellResultsData::addStaticScalarResult(RiaDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount) +size_t RigCaseCellResultsData::addStaticScalarResult(RiaDefines::ResultCatType type, + const QString& resultName, + bool needsToBeStored, + size_t resultValueCount) { size_t resultIdx = findOrCreateScalarResultIndex(type, resultName, needsToBeStored); - + m_cellScalarResults[resultIdx].resize(1, std::vector()); m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL); @@ -685,7 +724,7 @@ size_t RigCaseCellResultsData::addStaticScalarResult(RiaDefines::ResultCatType t } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RigCaseCellResultsData::updateResultName(RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName) { @@ -704,11 +743,15 @@ bool RigCaseCellResultsData::updateResultName(RiaDefines::ResultCatType resultTy } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -const std::vector* RigCaseCellResultsData::getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, RigCaseCellResultsData* gridCellResults, QString porvResultName, std::vector &activeCellsResultsTempContainer) +const std::vector* + RigCaseCellResultsData::getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, + RigCaseCellResultsData* gridCellResults, + QString porvResultName, + std::vector& activeCellsResultsTempContainer) { - size_t resultCellCount = actCellInfo->reservoirCellResultCount(); + size_t resultCellCount = actCellInfo->reservoirCellResultCount(); size_t reservoirCellCount = actCellInfo->reservoirCellCount(); size_t scalarResultIndexPorv = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, porvResultName); @@ -742,6 +785,14 @@ const std::vector* RigCaseCellResultsData::getResultIndexableStaticResul //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +const std::vector& RigCaseCellResultsData::infoForEachResultIndex() +{ + return m_resultInfos; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const { std::vector::const_iterator it; @@ -757,7 +808,7 @@ bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex) { @@ -772,7 +823,7 @@ void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::eraseAllSourSimData() { @@ -787,7 +838,7 @@ void RigCaseCellResultsData::eraseAllSourSimData() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::createPlaceholderResultEntries() { @@ -859,9 +910,9 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // riTRANSXYZ and X,Y,Z { - if ( findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMY") != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMZ") != cvf::UNDEFINED_SIZE_T) + if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T && + findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMY") != cvf::UNDEFINED_SIZE_T && + findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMZ") != cvf::UNDEFINED_SIZE_T) { addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName(), false, 0); @@ -873,10 +924,10 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // riMULTXYZ and X, Y, Z { size_t tranX, tranY, tranZ; - if (findTransmissibilityResults(tranX, tranY, tranZ) - && findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName()) != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName()) != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName()) != cvf::UNDEFINED_SIZE_T) + if (findTransmissibilityResults(tranX, tranY, tranZ) && + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName()) != cvf::UNDEFINED_SIZE_T && + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName()) != cvf::UNDEFINED_SIZE_T && + findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName()) != cvf::UNDEFINED_SIZE_T) { addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultXResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultYResultName(), false, 0); @@ -909,7 +960,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() } } - //Mobile Pore Volume + // Mobile Pore Volume { if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PORV") != cvf::UNDEFINED_SIZE_T) { @@ -919,7 +970,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RigCaseCellResultsData::findTransmissibilityResults(size_t& tranX, size_t& tranY, size_t& tranZ) const { @@ -927,9 +978,7 @@ bool RigCaseCellResultsData::findTransmissibilityResults(size_t& tranX, size_t& tranY = findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANY"); tranZ = findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANZ"); - if (tranX == cvf::UNDEFINED_SIZE_T || - tranY == cvf::UNDEFINED_SIZE_T || - tranZ == cvf::UNDEFINED_SIZE_T) + if (tranX == cvf::UNDEFINED_SIZE_T || tranY == cvf::UNDEFINED_SIZE_T || tranZ == cvf::UNDEFINED_SIZE_T) { return false; } @@ -937,9 +986,8 @@ bool RigCaseCellResultsData::findTransmissibilityResults(size_t& tranX, size_t& return true; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findOrLoadScalarResult(const QString& resultName) { @@ -969,7 +1017,7 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(const QString& resultName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType type, const QString& resultName) { @@ -1002,9 +1050,8 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType computeRiTransComponent(RiaDefines::riTranZResultName()); computeNncCombRiTrans(); } - else if (resultName == RiaDefines::riTranXResultName() - || resultName == RiaDefines::riTranYResultName() - || resultName == RiaDefines::riTranZResultName()) + else if (resultName == RiaDefines::riTranXResultName() || resultName == RiaDefines::riTranYResultName() || + resultName == RiaDefines::riTranZResultName()) { computeRiTransComponent(resultName); } @@ -1016,9 +1063,8 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType computeNncCombRiTrans(); computeNncCombRiMULT(); } - else if (resultName == RiaDefines::riMultXResultName() - || resultName == RiaDefines::riMultYResultName() - || resultName == RiaDefines::riMultZResultName()) + else if (resultName == RiaDefines::riMultXResultName() || resultName == RiaDefines::riMultYResultName() || + resultName == RiaDefines::riMultZResultName()) { computeRiMULTComponent(resultName); } @@ -1029,9 +1075,8 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType computeRiTRANSbyAreaComponent(RiaDefines::riAreaNormTranZResultName()); computeNncCombRiTRANSbyArea(); } - else if (resultName == RiaDefines::riAreaNormTranXResultName() - || resultName == RiaDefines::riAreaNormTranYResultName() - || resultName == RiaDefines::riAreaNormTranZResultName()) + else if (resultName == RiaDefines::riAreaNormTranXResultName() || resultName == RiaDefines::riAreaNormTranYResultName() || + resultName == RiaDefines::riAreaNormTranZResultName()) { computeRiTRANSbyAreaComponent(resultName); } @@ -1168,22 +1213,24 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType this->cellScalarResults(scalarResultIndex).resize(timeStepCount); size_t i; - for ( i = 0; i < timeStepCount; i++ ) + for (i = 0; i < timeStepCount; i++) { std::vector& values = this->cellScalarResults(scalarResultIndex)[i]; eclReader->sourSimRlResult(resultName, i, &values); } - } + } } return scalarResultIndex; } //-------------------------------------------------------------------------------------------------- -/// This method is intended to be used for multicase cross statistical calculations, when +/// This method is intended to be used for multicase cross statistical calculations, when /// we need process one timestep at a time, freeing memory as we go. //-------------------------------------------------------------------------------------------------- -size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) +size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::ResultCatType type, + const QString& resultName, + size_t timeStepIndex) { // Special handling for SOIL if (type == RiaDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") @@ -1268,29 +1315,27 @@ size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::Res std::vector& values = this->cellScalarResults(scalarResultIndex)[timeStepIndex]; - if ( values.size() == 0) + if (values.size() == 0) { eclReader->sourSimRlResult(resultName, timeStepIndex, &values); } - } + } } return scalarResultIndex; - } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) { // Compute SGAS based on SWAT if the simulation contains no oil testAndComputeSgasForTimeStep(timeStepIndex); - size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); - size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); - size_t scalarIndexSSOL = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOL", timeStepIndex); + size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); + size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + size_t scalarIndexSSOL = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOL", timeStepIndex); // Early exit if none of SWAT or SGAS is present if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) @@ -1299,7 +1344,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) } size_t soilResultValueCount = 0; - size_t soilTimeStepCount = 0; + size_t soilTimeStepCount = 0; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { @@ -1307,7 +1352,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) if (swatForTimeStep.size() > 0) { soilResultValueCount = swatForTimeStep.size(); - soilTimeStepCount = this->infoForEachResultIndex()[scalarIndexSWAT].timeStepInfos().size(); + soilTimeStepCount = this->infoForEachResultIndex()[scalarIndexSWAT].timeStepInfos().size(); } } @@ -1319,7 +1364,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep.size()); size_t sgasTimeStepCount = this->infoForEachResultIndex()[scalarIndexSGAS].timeStepInfos().size(); - soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); + soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); } } @@ -1336,8 +1381,8 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) this->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount); - std::vector* swatForTimeStep = nullptr; - std::vector* sgasForTimeStep = nullptr; + std::vector* swatForTimeStep = nullptr; + std::vector* sgasForTimeStep = nullptr; std::vector* ssolForTimeStep = nullptr; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) @@ -1369,7 +1414,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) std::vector& soilForTimeStep = this->cellScalarResults(soilResultScalarIndex, timeStepIndex); - #pragma omp parallel for +#pragma omp parallel for for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) { double soilValue = 1.0; @@ -1392,9 +1437,8 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) } } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) { @@ -1420,14 +1464,14 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) } size_t swatResultValueCount = 0; - size_t swatTimeStepCount = 0; + size_t swatTimeStepCount = 0; { std::vector& swatForTimeStep = this->cellScalarResults(scalarIndexSWAT, timeStepIndex); if (swatForTimeStep.size() > 0) { swatResultValueCount = swatForTimeStep.size(); - swatTimeStepCount = this->infoForEachResultIndex()[scalarIndexSWAT].timeStepInfos().size(); + swatTimeStepCount = this->infoForEachResultIndex()[scalarIndexSWAT].timeStepInfos().size(); } } @@ -1467,7 +1511,7 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeDepthRelatedResults() { @@ -1478,11 +1522,11 @@ void RigCaseCellResultsData::computeDepthRelatedResults() size_t topsResultGridIndex = findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "TOPS"); size_t bottomResultGridIndex = findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "BOTTOM"); - bool computeDepth = false; - bool computeDx = false; - bool computeDy = false; - bool computeDz = false; - bool computeTops = false; + bool computeDepth = false; + bool computeDx = false; + bool computeDy = false; + bool computeDz = false; + bool computeTops = false; bool computeBottom = false; size_t resultValueCount = m_ownerMainGrid->globalCellArray().size(); @@ -1490,45 +1534,45 @@ void RigCaseCellResultsData::computeDepthRelatedResults() if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) { depthResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount); - computeDepth = true; + computeDepth = true; } if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) { dxResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "DX", false, resultValueCount); - computeDx = true; + computeDx = true; } if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) { dyResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "DY", false, resultValueCount); - computeDy = true; + computeDy = true; } if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) { dzResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "DZ", false, resultValueCount); - computeDz = true; + computeDz = true; } if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) { topsResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "TOPS", false, resultValueCount); - computeTops = true; + computeTops = true; } if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) { bottomResultGridIndex = this->addStaticScalarResult(RiaDefines::STATIC_NATIVE, "BOTTOM", false, resultValueCount); - computeBottom = true; + computeBottom = true; } - std::vector< std::vector >& depth = this->cellScalarResults(depthResultGridIndex); - std::vector< std::vector >& dx = this->cellScalarResults(dxResultGridIndex); - std::vector< std::vector >& dy = this->cellScalarResults(dyResultGridIndex); - std::vector< std::vector >& dz = this->cellScalarResults(dzResultGridIndex); - std::vector< std::vector >& tops = this->cellScalarResults(topsResultGridIndex); - std::vector< std::vector >& bottom = this->cellScalarResults(bottomResultGridIndex); + std::vector>& depth = this->cellScalarResults(depthResultGridIndex); + std::vector>& dx = this->cellScalarResults(dxResultGridIndex); + std::vector>& dy = this->cellScalarResults(dyResultGridIndex); + std::vector>& dz = this->cellScalarResults(dzResultGridIndex); + std::vector>& tops = this->cellScalarResults(topsResultGridIndex); + std::vector>& bottom = this->cellScalarResults(bottomResultGridIndex); size_t cellIdx = 0; for (cellIdx = 0; cellIdx < m_ownerMainGrid->globalCellArray().size(); cellIdx++) @@ -1542,19 +1586,22 @@ void RigCaseCellResultsData::computeDepthRelatedResults() if (computeDx) { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I); - dx[0][cellIdx] = cellWidth.length(); + cvf::Vec3d cellWidth = + cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I); + dx[0][cellIdx] = cellWidth.length(); } if (computeDy) { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J); - dy[0][cellIdx] = cellWidth.length(); + cvf::Vec3d cellWidth = + cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J); + dy[0][cellIdx] = cellWidth.length(); } if (computeDz) { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K); + cvf::Vec3d cellWidth = + cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K); dz[0][cellIdx] = cellWidth.length(); } @@ -1572,29 +1619,30 @@ void RigCaseCellResultsData::computeDepthRelatedResults() namespace RigTransmissibilityCalcTools { -void calculateConnectionGeometry(const RigCell& c1, const RigCell& c2, const std::vector& nodes, - cvf::StructGridInterface::FaceType faceId, cvf::Vec3d* faceAreaVec) +void calculateConnectionGeometry(const RigCell& c1, + const RigCell& c2, + const std::vector& nodes, + cvf::StructGridInterface::FaceType faceId, + cvf::Vec3d* faceAreaVec) { CVF_TIGHT_ASSERT(faceAreaVec); *faceAreaVec = cvf::Vec3d::ZERO; - std::vector polygon; + std::vector polygon; std::vector intersections; - std::array face1; - std::array face2; + std::array face1; + std::array face2; c1.faceIndices(faceId, &face1); c2.faceIndices(cvf::StructGridInterface::oppositeFace(faceId), &face2); - bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( - &polygon, - &intersections, - (cvf::EdgeIntersectStorage*)nullptr, - cvf::wrapArrayConst(&nodes), - face1.data(), - face2.data(), - 1e-6); - + bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, + &intersections, + (cvf::EdgeIntersectStorage*)nullptr, + cvf::wrapArrayConst(&nodes), + face1.data(), + face2.data(), + 1e-6); if (foundOverlap) { @@ -1611,21 +1659,19 @@ void calculateConnectionGeometry(const RigCell& c1, const RigCell& c2, const std // Polygon area vector *faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D(realPolygon); - } - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double halfCellTransmissibility(double perm, double ntg, const cvf::Vec3d& centerToFace, const cvf::Vec3d& faceAreaVec) { - return perm*ntg*(faceAreaVec*centerToFace) / (centerToFace*centerToFace); + return perm * ntg * (faceAreaVec * centerToFace) / (centerToFace * centerToFace); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double newtran(double cdarchy, double mult, double halfCellTrans, double neighborHalfCellTrans) { @@ -1640,12 +1686,12 @@ double newtran(double cdarchy, double mult, double halfCellTrans, double neighbo } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -typedef size_t(*ResultIndexFunction)(const RigActiveCellInfo* activeCellinfo, size_t reservoirCellIndex); +typedef size_t (*ResultIndexFunction)(const RigActiveCellInfo* activeCellinfo, size_t reservoirCellIndex); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t directReservoirCellIndex(const RigActiveCellInfo* activeCellinfo, size_t reservoirCellIndex) @@ -1654,41 +1700,41 @@ size_t directReservoirCellIndex(const RigActiveCellInfo* activeCellinfo, size_t } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t reservoirActiveCellIndex(const RigActiveCellInfo* activeCellinfo, size_t reservoirCellIndex) { return activeCellinfo->cellResultIndex(reservoirCellIndex); } -} +} // namespace RigTransmissibilityCalcTools using namespace RigTransmissibilityCalcTools; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransComponentResultName) { // Set up which component to compute cvf::StructGridInterface::FaceType faceId = cvf::StructGridInterface::NO_FACE; - QString permCompName; + QString permCompName; if (riTransComponentResultName == RiaDefines::riTranXResultName()) { permCompName = "PERMX"; - faceId = cvf::StructGridInterface::POS_I; + faceId = cvf::StructGridInterface::POS_I; } else if (riTransComponentResultName == RiaDefines::riTranYResultName()) { permCompName = "PERMY"; - faceId = cvf::StructGridInterface::POS_J; + faceId = cvf::StructGridInterface::POS_J; } else if (riTransComponentResultName == RiaDefines::riTranZResultName()) { permCompName = "PERMZ"; - faceId = cvf::StructGridInterface::POS_K; + faceId = cvf::StructGridInterface::POS_K; } else { @@ -1700,7 +1746,7 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo // Get the needed result indices we depend on size_t permResultIdx = findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, permCompName); - size_t ntgResultIdx = findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + size_t ntgResultIdx = findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; @@ -1712,18 +1758,18 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo // Get the result count, to handle that one of them might be globally defined size_t permxResultValueCount = this->cellScalarResults(permResultIdx)[0].size(); - size_t resultValueCount = permxResultValueCount; + size_t resultValueCount = permxResultValueCount; if (hasNTGResults) { size_t ntgResultValueCount = this->cellScalarResults(ntgResultIdx)[0].size(); - resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); } // Get all the actual result values - std::vector & permResults = this->cellScalarResults(permResultIdx)[0]; - std::vector & riTransResults = this->cellScalarResults(riTransResultIdx)[0]; - std::vector * ntgResults = nullptr; + std::vector& permResults = this->cellScalarResults(permResultIdx)[0]; + std::vector& riTransResults = this->cellScalarResults(riTransResultIdx)[0]; + std::vector* ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); @@ -1749,16 +1795,16 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo // Set up result index function pointers riTranIdxFunc = isTransUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; if (hasNTGResults) { ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; } } - const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); - const std::vector& nodes = m_ownerMainGrid->nodes(); - bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); + const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); + const std::vector& nodes = m_ownerMainGrid->nodes(); + bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->globalCellArray().size(); nativeResvCellIndex++) { @@ -1768,7 +1814,7 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo if (tranResIdx == cvf::UNDEFINED_SIZE_T) continue; const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; - RigGridBase* grid = nativeCell.hostGrid(); + RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -1778,8 +1824,8 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo if (grid->cellIJKNeighbor(i, j, k, faceId, &gridLocalNeighborCellIdx)) { - size_t neighborResvCellIdx = grid->reservoirCellIndex(gridLocalNeighborCellIdx); - const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; + size_t neighborResvCellIdx = grid->reservoirCellIndex(gridLocalNeighborCellIdx); + const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; // Do nothing if neighbor cell has no results size_t neighborCellPermResIdx = (*permIdxFunc)(activeCellInfo, neighborResvCellIdx); @@ -1787,9 +1833,8 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo // Connection geometry - const RigFault* fault = grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, faceId); - bool isOnFault = fault; - + const RigFault* fault = grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, faceId); + bool isOnFault = fault; cvf::Vec3d faceAreaVec; cvf::Vec3d faceCenter; @@ -1800,13 +1845,12 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo } else { - faceAreaVec = nativeCell.faceNormalWithAreaLenght(faceId); } if (!isFaceNormalsOutwards) faceAreaVec = -faceAreaVec; - double halfCellTrans = 0; + double halfCellTrans = 0; double neighborHalfCellTrans = 0; // Native cell half cell transm @@ -1814,13 +1858,13 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo cvf::Vec3d centerToFace = nativeCell.faceCenter(faceId) - nativeCell.center(); size_t permResIdx = (*permIdxFunc)(activeCellInfo, nativeResvCellIndex); - double perm = permResults[permResIdx]; + double perm = permResults[permResIdx]; double ntg = 1.0; if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, nativeResvCellIndex); - ntg = (*ntgResults)[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } halfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, faceAreaVec); @@ -1828,7 +1872,8 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo // Neighbor cell half cell transm { - cvf::Vec3d centerToFace = neighborCell.faceCenter(cvf::StructGridInterface::oppositeFace(faceId)) - neighborCell.center(); + cvf::Vec3d centerToFace = + neighborCell.faceCenter(cvf::StructGridInterface::oppositeFace(faceId)) - neighborCell.center(); double perm = permResults[neighborCellPermResIdx]; @@ -1836,7 +1881,7 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, neighborResvCellIdx); - ntg = (*ntgResults)[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } neighborHalfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, -faceAreaVec); @@ -1844,16 +1889,16 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo riTransResults[tranResIdx] = newtran(cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans); } - } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeNncCombRiTrans() { - size_t riCombTransScalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiTranResultName()); + size_t riCombTransScalarResultIndex = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiTranResultName()); if (m_ownerMainGrid->nncData()->staticConnectionScalarResult(riCombTransScalarResultIndex)) return; double cdarchy = darchysValue(); @@ -1870,13 +1915,14 @@ void RigCaseCellResultsData::computeNncCombRiTrans() // Get all the actual result values - std::vector & permXResults = this->cellScalarResults(permXResultIdx)[0]; - std::vector & permYResults = this->cellScalarResults(permYResultIdx)[0]; - std::vector & permZResults = this->cellScalarResults(permZResultIdx)[0]; - std::vector & riCombTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTrans()); + std::vector& permXResults = this->cellScalarResults(permXResultIdx)[0]; + std::vector& permYResults = this->cellScalarResults(permYResultIdx)[0]; + std::vector& permZResults = this->cellScalarResults(permZResultIdx)[0]; + std::vector& riCombTransResults = + m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTrans()); m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombTrans(), riCombTransScalarResultIndex); - std::vector * ntgResults = nullptr; + std::vector* ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); @@ -1894,7 +1940,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() bool isNtgUsingResIdx = false; if (hasNTGResults) { - isNtgUsingResIdx = this->isUsingGlobalActiveIndex(ntgResultIdx); + isNtgUsingResIdx = this->isUsingGlobalActiveIndex(ntgResultIdx); } // Set up result index function pointers @@ -1904,23 +1950,23 @@ void RigCaseCellResultsData::computeNncCombRiTrans() permZIdxFunc = isPermZUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; if (hasNTGResults) { - ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; } } - const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); - bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); + const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); + bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); // NNC calculation std::vector& nncConnections = m_ownerMainGrid->nncData()->connections(); for (size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++) { - size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx; - size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx; - cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face; + size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx; + size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx; + cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face; - ResultIndexFunction permIdxFunc = nullptr; - std::vector * permResults = nullptr; + ResultIndexFunction permIdxFunc = nullptr; + std::vector* permResults = nullptr; switch (faceId) { @@ -1939,7 +1985,8 @@ void RigCaseCellResultsData::computeNncCombRiTrans() permIdxFunc = permZIdxFunc; permResults = &permZResults; break; - default: break; + default: + break; } if (!permIdxFunc) continue; @@ -1952,15 +1999,13 @@ void RigCaseCellResultsData::computeNncCombRiTrans() size_t neighborCellPermResIdx = (*permIdxFunc)(activeCellInfo, neighborResvCellIdx); if (neighborCellPermResIdx == cvf::UNDEFINED_SIZE_T) continue; - - const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; + const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; - // Connection geometry - cvf::Vec3d faceAreaVec = cvf::Vec3d::ZERO;; - cvf::Vec3d faceCenter = cvf::Vec3d::ZERO;; + cvf::Vec3d faceAreaVec = cvf::Vec3d::ZERO; + cvf::Vec3d faceCenter = cvf::Vec3d::ZERO; // Polygon center const std::vector& realPolygon = nncConnections[connIdx].m_polygon; @@ -1977,7 +2022,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() if (!isFaceNormalsOutwards) faceAreaVec = -faceAreaVec; - double halfCellTrans = 0; + double halfCellTrans = 0; double neighborHalfCellTrans = 0; // Native cell half cell transm @@ -1990,7 +2035,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, nativeResvCellIndex); - ntg = (*ntgResults)[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } halfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, faceAreaVec); @@ -1998,7 +2043,8 @@ void RigCaseCellResultsData::computeNncCombRiTrans() // Neighbor cell half cell transm { - cvf::Vec3d centerToFace = neighborCell.faceCenter(cvf::StructGridInterface::oppositeFace(faceId)) - neighborCell.center(); + cvf::Vec3d centerToFace = + neighborCell.faceCenter(cvf::StructGridInterface::oppositeFace(faceId)) - neighborCell.center(); double perm = (*permResults)[neighborCellPermResIdx]; @@ -2006,27 +2052,25 @@ void RigCaseCellResultsData::computeNncCombRiTrans() if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, neighborResvCellIdx); - ntg = (*ntgResults)[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } neighborHalfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, -faceAreaVec); } - double newtranTemp = newtran(cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans); + double newtranTemp = newtran(cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans); riCombTransResults[connIdx] = newtranTemp; } - } - double riMult(double transResults, double riTransResults) { if (transResults == HUGE_VAL || riTransResults == HUGE_VAL) return HUGE_VAL; // To make 0.0 values give 1.0 in mult value - if (cvf::Math::abs (riTransResults) < 1e-12) + if (cvf::Math::abs(riTransResults) < 1e-12) { - if (cvf::Math::abs (transResults) < 1e-12) + if (cvf::Math::abs(transResults) < 1e-12) { return 1.0; } @@ -2034,14 +2078,13 @@ double riMult(double transResults, double riTransResults) return HUGE_VAL; } - double result = transResults / riTransResults; return result; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompName) { @@ -2053,17 +2096,17 @@ void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompNam if (riMultCompName == RiaDefines::riMultXResultName()) { riTransCompName = RiaDefines::riTranXResultName(); - transCompName = "TRANX"; + transCompName = "TRANX"; } else if (riMultCompName == RiaDefines::riMultYResultName()) { riTransCompName = RiaDefines::riTranYResultName(); - transCompName = "TRANY"; + transCompName = "TRANY"; } else if (riMultCompName == RiaDefines::riMultZResultName()) { riTransCompName = RiaDefines::riTranZResultName(); - transCompName = "TRANZ"; + transCompName = "TRANZ"; } else { @@ -2088,10 +2131,10 @@ void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompNam // Get all the actual result values - std::vector & riTransResults = this->cellScalarResults(riTransResultIdx)[0]; - std::vector & transResults = this->cellScalarResults(transResultIdx)[0]; + std::vector& riTransResults = this->cellScalarResults(riTransResultIdx)[0]; + std::vector& transResults = this->cellScalarResults(transResultIdx)[0]; - std::vector & riMultResults = this->cellScalarResults(riMultResultIdx)[0]; + std::vector& riMultResults = this->cellScalarResults(riMultResultIdx)[0]; // Set up output container to correct number of results @@ -2104,19 +2147,25 @@ void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompNam } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeNncCombRiMULT() { - size_t riCombMultScalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiMultResultName()); - size_t riCombTransScalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiTranResultName()); - size_t combTransScalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedTransmissibilityResultName()); + size_t riCombMultScalarResultIndex = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiMultResultName()); + size_t riCombTransScalarResultIndex = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiTranResultName()); + size_t combTransScalarResultIndex = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedTransmissibilityResultName()); if (m_ownerMainGrid->nncData()->staticConnectionScalarResult(riCombMultScalarResultIndex)) return; - std::vector & riMultResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombMult()); - const std::vector * riTransResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult(riCombTransScalarResultIndex); - const std::vector * transResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult(combTransScalarResultIndex); + std::vector& riMultResults = + m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombMult()); + const std::vector* riTransResults = + m_ownerMainGrid->nncData()->staticConnectionScalarResult(riCombTransScalarResultIndex); + const std::vector* transResults = + m_ownerMainGrid->nncData()->staticConnectionScalarResult(combTransScalarResultIndex); m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombMult(), riCombMultScalarResultIndex); for (size_t nncConIdx = 0; nncConIdx < riMultResults.size(); ++nncConIdx) @@ -2126,29 +2175,29 @@ void RigCaseCellResultsData::computeNncCombRiMULT() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTransByAreaCompResultName) { // Set up which component to compute cvf::StructGridInterface::FaceType faceId = cvf::StructGridInterface::NO_FACE; - QString transCompName; + QString transCompName; if (riTransByAreaCompResultName == RiaDefines::riAreaNormTranXResultName()) { transCompName = "TRANX"; - faceId = cvf::StructGridInterface::POS_I; + faceId = cvf::StructGridInterface::POS_I; } else if (riTransByAreaCompResultName == RiaDefines::riAreaNormTranYResultName()) { transCompName = "TRANY"; - faceId = cvf::StructGridInterface::POS_J; + faceId = cvf::StructGridInterface::POS_J; } else if (riTransByAreaCompResultName == RiaDefines::riAreaNormTranZResultName()) { transCompName = "TRANZ"; - faceId = cvf::StructGridInterface::POS_K; + faceId = cvf::StructGridInterface::POS_K; } else { @@ -2170,8 +2219,8 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran // Get all the actual result values - std::vector & transResults = this->cellScalarResults(tranCompScResIdx)[0]; - std::vector & riTransByAreaResults = this->cellScalarResults(riTranByAreaScResIdx)[0]; + std::vector& transResults = this->cellScalarResults(tranCompScResIdx)[0]; + std::vector& riTransByAreaResults = this->cellScalarResults(riTranByAreaScResIdx)[0]; // Set up output container to correct number of results @@ -2185,8 +2234,8 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran ResultIndexFunction resValIdxFunc = isUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); - const std::vector& nodes = m_ownerMainGrid->nodes(); + const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); + const std::vector& nodes = m_ownerMainGrid->nodes(); for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->globalCellArray().size(); nativeResvCellIndex++) { @@ -2196,7 +2245,7 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran if (nativeCellResValIdx == cvf::UNDEFINED_SIZE_T) continue; const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; - RigGridBase* grid = nativeCell.hostGrid(); + RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -2206,13 +2255,13 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran if (grid->cellIJKNeighbor(i, j, k, faceId, &gridLocalNeighborCellIdx)) { - size_t neighborResvCellIdx = grid->reservoirCellIndex(gridLocalNeighborCellIdx); - const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; + size_t neighborResvCellIdx = grid->reservoirCellIndex(gridLocalNeighborCellIdx); + const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; // Connection geometry - const RigFault* fault = grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, faceId); - bool isOnFault = fault; + const RigFault* fault = grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, faceId); + bool isOnFault = fault; cvf::Vec3d faceAreaVec; @@ -2225,47 +2274,51 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran faceAreaVec = nativeCell.faceNormalWithAreaLenght(faceId); } - double areaOfOverlap = faceAreaVec.length(); + double areaOfOverlap = faceAreaVec.length(); double transCompValue = transResults[nativeCellResValIdx]; riTransByAreaResults[nativeCellResValIdx] = transCompValue / areaOfOverlap; } - } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeNncCombRiTRANSbyArea() { - size_t riCombTransByAreaScResIdx = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiAreaNormTranResultName()); - size_t combTransScalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedTransmissibilityResultName()); + size_t riCombTransByAreaScResIdx = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedRiAreaNormTranResultName()); + size_t combTransScalarResultIndex = + this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::combinedTransmissibilityResultName()); if (m_ownerMainGrid->nncData()->staticConnectionScalarResult(riCombTransByAreaScResIdx)) return; - std::vector & riAreaNormTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTransByArea()); + std::vector& riAreaNormTransResults = + m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTransByArea()); m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombTransByArea(), riCombTransByAreaScResIdx); - const std::vector * transResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult(combTransScalarResultIndex); + const std::vector* transResults = + m_ownerMainGrid->nncData()->staticConnectionScalarResult(combTransScalarResultIndex); const std::vector& connections = m_ownerMainGrid->nncData()->connections(); for (size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx) { - const std::vector& realPolygon = connections[nncConIdx].m_polygon; - cvf::Vec3d faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D(realPolygon); - double areaOfOverlap = faceAreaVec.length(); + const std::vector& realPolygon = connections[nncConIdx].m_polygon; + cvf::Vec3d faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D(realPolygon); + double areaOfOverlap = faceAreaVec.length(); riAreaNormTransResults[nncConIdx] = (*transResults)[nncConIdx] / areaOfOverlap; } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) { - size_t completionTypeResultIndex = this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); + size_t completionTypeResultIndex = + this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); if (this->cellScalarResults(completionTypeResultIndex).size() < this->maxTimeStepCount()) { @@ -2291,9 +2344,8 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(eclipseCase, completionTypeResult, timeStep); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCaseCellResultsData::darchysValue() { @@ -2301,16 +2353,16 @@ double RigCaseCellResultsData::darchysValue() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeMobilePV() { std::vector porvDataTemp; std::vector swcrDataTemp; std::vector multpvDataTemp; - - const std::vector* porvResults = nullptr; - const std::vector* swcrResults = nullptr; + + const std::vector* porvResults = nullptr; + const std::vector* swcrResults = nullptr; const std::vector* multpvResults = nullptr; porvResults = RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "PORV", porvDataTemp); @@ -2320,12 +2372,13 @@ void RigCaseCellResultsData::computeMobilePV() return; } - swcrResults = RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "SWCR", swcrDataTemp); - multpvResults = RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "MULTPV", multpvDataTemp); + swcrResults = RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "SWCR", swcrDataTemp); + multpvResults = + RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "MULTPV", multpvDataTemp); size_t mobPVIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName(), false); - std::vector &mobPVResults = this->cellScalarResults(mobPVIdx)[0]; + std::vector& mobPVResults = this->cellScalarResults(mobPVIdx)[0]; // Set up output container to correct number of results mobPVResults.resize(porvResults->size()); @@ -2358,16 +2411,15 @@ void RigCaseCellResultsData::computeMobilePV() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::setReaderInterface(RifReaderInterface* readerInterface) { m_readerInterface = readerInterface; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::setHdf5Filename(const QString& hdf5SourSimFilename) { @@ -2388,7 +2440,7 @@ bool RigCaseCellResultsData::isDataPresent(size_t scalarResultIndex) const return false; } - const std::vector< std::vector >& data = this->cellScalarResults(scalarResultIndex); + const std::vector>& data = this->cellScalarResults(scalarResultIndex); for (size_t tsIdx = 0; tsIdx < data.size(); ++tsIdx) { @@ -2402,7 +2454,7 @@ bool RigCaseCellResultsData::isDataPresent(size_t scalarResultIndex) const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::assignValuesToTemporaryLgrs(std::vector& valuesForAllReservoirCells) { @@ -2416,8 +2468,8 @@ void RigCaseCellResultsData::assignValuesToTemporaryLgrs(std::vector& va for (size_t localCellIdx = 0; localCellIdx < grid->cellCount(); localCellIdx++) { const RigCell& cell = grid->cell(localCellIdx); - - size_t mainGridCellIndex = cell.mainGridCellIndex(); + + size_t mainGridCellIndex = cell.mainGridCellIndex(); size_t reservoirCellIndex = grid->reservoirCellIndex(localCellIdx); size_t mainGridCellResultIndex = m_activeCellInfo->cellResultIndex(mainGridCellIndex); @@ -2437,4 +2489,3 @@ void RigCaseCellResultsData::assignValuesToTemporaryLgrs(std::vector& va } } } - diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 3112ac7110..24bae5f283 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -50,9 +50,9 @@ public: void setHdf5Filename(const QString& hdf5SourSimFilename ); void setMainGrid(RigMainGrid* ownerGrid); - void setActiveCellInfo(RigActiveCellInfo* activeCellInfo) { m_activeCellInfo = activeCellInfo;} - RigActiveCellInfo* activeCellInfo() { return m_activeCellInfo;} - const RigActiveCellInfo* activeCellInfo() const { return m_activeCellInfo;} + void setActiveCellInfo(RigActiveCellInfo* activeCellInfo); + RigActiveCellInfo* activeCellInfo(); + const RigActiveCellInfo* activeCellInfo() const; // Max and min values of the results void recalculateStatistics(size_t scalarResultIndex); @@ -125,7 +125,7 @@ public: std::vector &activeCellsResultsTempContainer); public: - const std::vector& infoForEachResultIndex() { return m_resultInfos;} + const std::vector& infoForEachResultIndex(); bool mustBeCalculated(size_t scalarResultIndex) const; void setMustBeCalculated(size_t scalarResultIndex);