From d76dd6a588507dc682a72476482741fbe3a9ad2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 27 Aug 2014 11:41:08 +0200 Subject: [PATCH] Added riTRANSXYZbyArea (and X, Y, Z ) --- .../ModelVisualization/RivFaultPartMgr.cpp | 4 +- .../ProjectDataModel/RimDefines.cpp | 4 + ApplicationCode/ProjectDataModel/RimDefines.h | 9 +- .../RimReservoirCellResultsStorage.cpp | 155 ++++++++++++++++++ .../RimReservoirCellResultsStorage.h | 2 + .../ProjectDataModel/RimReservoirView.cpp | 14 ++ .../RigCaseCellResultsData.cpp | 32 ++++ .../RigResultAccessorFactory.cpp | 11 ++ 8 files changed, 229 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 3b788d3f72..487953fdba 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -650,7 +650,9 @@ void RivFaultPartMgr::updateNNCColors(RimResultSlot* cellResultSlot) if (cellResultSlot && ( cellResultSlot->resultVariable() == RimDefines::combinedTransmissibilityResultName() || cellResultSlot->resultVariable() == RimDefines::combinedRiTransResultName() - || cellResultSlot->resultVariable() == RimDefines::combinedRiMultResultName()) ) + || cellResultSlot->resultVariable() == RimDefines::combinedRiMultResultName() + || cellResultSlot->resultVariable() == RimDefines::combinedRiAreaNormTransResultName() + )) { size_t scalarSetIndex = cellResultSlot->gridScalarIndex(); diff --git a/ApplicationCode/ProjectDataModel/RimDefines.cpp b/ApplicationCode/ProjectDataModel/RimDefines.cpp index 7d60d53620..ff6d54af22 100644 --- a/ApplicationCode/ProjectDataModel/RimDefines.cpp +++ b/ApplicationCode/ProjectDataModel/RimDefines.cpp @@ -72,6 +72,10 @@ bool RimDefines::isPerCellFaceResult(const QString& resultName) { return true; } + else if (resultName.compare(RimDefines::combinedRiAreaNormTransResultName(), Qt::CaseInsensitive) == 0) + { + return true; + } return false; } diff --git a/ApplicationCode/ProjectDataModel/RimDefines.h b/ApplicationCode/ProjectDataModel/RimDefines.h index e485d9ce86..32eb08fac7 100644 --- a/ApplicationCode/ProjectDataModel/RimDefines.h +++ b/ApplicationCode/ProjectDataModel/RimDefines.h @@ -46,15 +46,22 @@ public: static QString combinedTransmissibilityResultName() { return "TRANSXYZ"; } static QString ternarySaturationResultName() { return "TERNARY"; } static QString combinedMultResultName() { return "MULTXYZ"; } - static QString combinedRiTransResultName() { return "riTRANSXYZ"; } + static QString riTransXResultName() { return "riTRANSX"; } static QString riTransYResultName() { return "riTRANSY"; } static QString riTransZResultName() { return "riTRANSZ"; } + static QString combinedRiTransResultName() { return "riTRANSXYZ"; } + static QString riMultXResultName() { return "riMULTX"; } static QString riMultYResultName() { return "riMULTY"; } static QString riMultZResultName() { return "riMULTZ"; } static QString combinedRiMultResultName() { return "riMULTXYZ"; } + static QString riAreaNormTransXResultName() { return "riTRANSXbyArea"; } + static QString riAreaNormTransYResultName() { return "riTRANSYbyArea"; } + static QString riAreaNormTransZResultName() { return "riTRANSZbyArea"; } + static QString combinedRiAreaNormTransResultName() { return "riTRANSXYZbyArea"; } + // Mock model text identifiers static QString mockModelBasic() { return "Result Mock Debug Model Simple"; } static QString mockModelBasicWithResults() { return "Result Mock Debug Model With Results"; } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 17e2dabdfa..e3ceead755 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -305,6 +305,19 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result { computeRiMULTComponent(resultName); } + else if (resultName == RimDefines::combinedRiAreaNormTransResultName()) + { + computeRiTRANSbyAreaComponent(RimDefines::riAreaNormTransXResultName()); + computeRiTRANSbyAreaComponent(RimDefines::riAreaNormTransYResultName()); + computeRiTRANSbyAreaComponent(RimDefines::riAreaNormTransZResultName()); + computeNncCombRiTRANSbyArea(); + } + else if (resultName == RimDefines::riAreaNormTransXResultName() + || resultName == RimDefines::riAreaNormTransYResultName() + || resultName == RimDefines::riAreaNormTransZResultName()) + { + computeRiTRANSbyAreaComponent(resultName); + } } @@ -1179,6 +1192,148 @@ void RimReservoirCellResultsStorage::computeNncCombRiMULT() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsStorage::computeRiTRANSbyAreaComponent(const QString& riTransByAreaCompResultName) +{ + if (!m_cellResults) return; + + // Set up which component to compute + + cvf::StructGridInterface::FaceType faceId; + QString transCompName; + + if (riTransByAreaCompResultName == RimDefines::riAreaNormTransXResultName()) + { + transCompName = "TRANX"; + faceId = cvf::StructGridInterface::POS_I; + } + else if (riTransByAreaCompResultName == RimDefines::riAreaNormTransYResultName()) + { + transCompName = "TRANY"; + faceId = cvf::StructGridInterface::POS_J; + } + else if (riTransByAreaCompResultName == RimDefines::riAreaNormTransZResultName()) + { + transCompName = "TRANZ"; + faceId = cvf::StructGridInterface::POS_K; + } + else + { + CVF_ASSERT(false); + } + + // Get the needed result indices we depend on + + size_t tranCompScResIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, transCompName); + + // Get the result index of the output + + size_t riTranByAreaScResIdx = m_cellResults->findScalarResultIndex(RimDefines::STATIC_NATIVE, riTransByAreaCompResultName); + CVF_ASSERT(riTranByAreaScResIdx != cvf::UNDEFINED_SIZE_T); + + // Get the result count, to handle that one of them might be globally defined + + size_t resultValueCount = m_cellResults->cellScalarResults(tranCompScResIdx)[0].size(); + + // Get all the actual result values + + std::vector & transResults = m_cellResults->cellScalarResults(tranCompScResIdx)[0]; + std::vector & riTransByAreaResults = m_cellResults->cellScalarResults(riTranByAreaScResIdx)[0]; + + // Set up output container to correct number of results + + riTransByAreaResults.resize(resultValueCount); + + // Prepare how to index the result values: + + bool isUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(tranCompScResIdx); + + // Set up result index function pointers + + ResultIndexFunction resValIdxFunc = isUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + + const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); + const std::vector& nodes = m_ownerMainGrid->nodes(); + bool isFaceNormalsOutwards = m_ownerMainGrid->faceNormalsIsOutwards(); + + for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cells().size(); nativeResvCellIndex++) + { + // Do nothing if we are only dealing with active cells, and this cell is not active: + size_t nativeCellResValIdx = (*resValIdxFunc)(activeCellInfo, nativeResvCellIndex); + + if (nativeCellResValIdx == cvf::UNDEFINED_SIZE_T) continue; + + const RigCell& nativeCell = m_ownerMainGrid->cells()[nativeResvCellIndex]; + RigGridBase* grid = nativeCell.hostGrid(); + + size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); + + size_t i, j, k, gridLocalNeighborCellIdx; + + grid->ijkFromCellIndex(gridLocalNativeCellIndex, &i, &j, &k); + + if (grid->cellIJKNeighbor(i, j, k, faceId, &gridLocalNeighborCellIdx)) + { + size_t neighborResvCellIdx = grid->reservoirCellIndex(gridLocalNeighborCellIdx); + const RigCell& neighborCell = m_ownerMainGrid->cells()[neighborResvCellIdx]; + + // Connection geometry + + const RigFault* fault = grid->mainGrid()->findFaultFromCellIndexAndCellFace(nativeResvCellIndex, faceId); + bool isOnFault = fault; + + cvf::Vec3d faceAreaVec; + cvf::Vec3d faceCenter; + + if (isOnFault) + { + calculateConnectionGeometry(nativeCell, neighborCell, nodes, faceId, + &faceCenter, &faceAreaVec); + } + else + { + faceCenter = nativeCell.faceCenter(faceId); + faceAreaVec = nativeCell.faceNormalWithAreaLenght(faceId); + } + + double areaOfOverlap = faceAreaVec.length(); + double transCompValue = transResults[nativeCellResValIdx]; + + riTransByAreaResults[nativeCellResValIdx] = transCompValue / areaOfOverlap; + } + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsStorage::computeNncCombRiTRANSbyArea() +{ + if (!m_cellResults) return; + + size_t riCombTransByAreaScResIdx = m_cellResults->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedRiAreaNormTransResultName()); + size_t combTransScalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName()); + + if (m_ownerMainGrid->nncData()->connectionScalarResult(riCombTransByAreaScResIdx)) return; + + std::vector & riAreaNormTransResults = m_ownerMainGrid->nncData()->makeConnectionScalarResult(riCombTransByAreaScResIdx); + const std::vector * transResults = m_ownerMainGrid->nncData()->connectionScalarResult(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(); + + riAreaNormTransResults[nncConIdx] = (*transResults)[nncConIdx] / areaOfOverlap; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h index 4da4b63d50..7570cd0bd6 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h @@ -69,6 +69,8 @@ private: void computeNncCombRiTrans(); void computeRiMULTComponent(const QString& riMultCompName); void computeNncCombRiMULT(); + void computeRiTRANSbyAreaComponent(const QString& riTransByAreaCompResultName); + void computeNncCombRiTRANSbyArea(); QString getValidCacheFileName(); QString getCacheDirectoryPath(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index c7977b8227..cf8bf0c3f4 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -2160,6 +2160,20 @@ void RimReservoirView::appendTextFromResultSlot(RigCaseData* eclipseCase, size_t resultInfoText->append(QString("riMult Z : %1\n").arg(scalarValue)); } } + else if (resultSlot->resultVariable().compare(RimDefines::combinedRiAreaNormTransResultName(), Qt::CaseInsensitive) == 0) + { + cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedRiAreaNormTransResultName()); + { + double scalarValue = resultAccessor->cellFaceScalar(cellIndex, cvf::StructGridInterface::POS_I); + resultInfoText->append(QString("riTransByArea X : %1\n").arg(scalarValue)); + + scalarValue = resultAccessor->cellFaceScalar(cellIndex, cvf::StructGridInterface::POS_J); + resultInfoText->append(QString("riTransByArea Y : %1\n").arg(scalarValue)); + + scalarValue = resultAccessor->cellFaceScalar(cellIndex, cvf::StructGridInterface::POS_K); + resultInfoText->append(QString("riTransByArea Z : %1\n").arg(scalarValue)); + } + } else { resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, resultSlot->gridScalarIndex()); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 55bd00a398..da2a395c32 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -278,6 +278,14 @@ size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType ty calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::riMultZResultName())); statisticsCalculator = calc; } + else if (resultName == RimDefines::combinedRiAreaNormTransResultName()) + { + cvf::ref calc = new RigMultipleDatasetStatCalc(); + calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransXResultName())); + calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransYResultName())); + calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransZResultName())); + statisticsCalculator = calc; + } else { statisticsCalculator = new RigNativeStatCalc(this, scalarResultIndex); @@ -565,6 +573,30 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() addStaticScalarResult(RimDefines::STATIC_NATIVE, RimDefines::combinedRiMultResultName(), false, 0); } } + + // riTRANSXYZbyArea and X, Y, Z + { + if (findScalarResultIndex(RimDefines::STATIC_NATIVE, "TRANX") != cvf::UNDEFINED_SIZE_T) + { + addStaticScalarResult(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransXResultName(), false, 0); + } + + if (findScalarResultIndex(RimDefines::STATIC_NATIVE, "TRANY") != cvf::UNDEFINED_SIZE_T) + { + addStaticScalarResult(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransYResultName(), false, 0); + } + + if (findScalarResultIndex(RimDefines::STATIC_NATIVE, "TRANZ") != cvf::UNDEFINED_SIZE_T) + { + addStaticScalarResult(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTransZResultName(), false, 0); + } + + size_t tranX, tranY, tranZ; + if (findTransmissibilityResults(tranX, tranY, tranZ)) + { + addStaticScalarResult(RimDefines::STATIC_NATIVE, RimDefines::combinedRiAreaNormTransResultName(), false, 0); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp index b9d4e019c3..ff4ec35be8 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp @@ -103,7 +103,18 @@ cvf::ref RigResultAccessorFactory::createResultAccessor(RigCa return cellFaceAccessObject; } + else if (uiResultName == RimDefines::combinedRiAreaNormTransResultName()) + { + cvf::ref cellFaceAccessObject = new RigCombTransResultAccessor(grid); + cvf::ref xRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, RimDefines::riAreaNormTransXResultName()); + cvf::ref yRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, RimDefines::riAreaNormTransYResultName()); + cvf::ref zRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, RimDefines::riAreaNormTransZResultName()); + + cellFaceAccessObject->setTransResultAccessors(xRiAreaNormTransAccessor.p(), yRiAreaNormTransAccessor.p(), zRiAreaNormTransAccessor.p()); + + return cellFaceAccessObject; + } return RigResultAccessorFactory::createNativeResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, uiResultName); }