diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index b18309ebbf..1be966dc4b 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -810,6 +810,8 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr size_t permResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, permCompName); size_t ntgResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG"); + bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; + // Get the result index of the output size_t riTransResultIdx = m_cellResults->findScalarResultIndex(RimDefines::STATIC_NATIVE, riTransComponentResultName); @@ -818,32 +820,49 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr // Get the result count, to handle that one of them might be globally defined size_t permxResultValueCount = m_cellResults->cellScalarResults(permResultIdx)[0].size(); - size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); - - size_t resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + size_t resultValueCount = permxResultValueCount; + if (hasNTGResults) + { + size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); + resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + } // Get all the actual result values - std::vector & permResults = m_cellResults->cellScalarResults(permResultIdx)[0]; - std::vector & ntgResults = m_cellResults->cellScalarResults(ntgResultIdx)[0]; + std::vector & permResults = m_cellResults->cellScalarResults(permResultIdx)[0]; std::vector & riTransResults = m_cellResults->cellScalarResults(riTransResultIdx)[0]; + std::vector * ntgResults = NULL; + if (hasNTGResults) + { + ntgResults = &(m_cellResults->cellScalarResults(ntgResultIdx)[0]); + } // Set up output container to correct number of results riTransResults.resize(resultValueCount); // Prepare how to index the result values: + ResultIndexFunction riTranIdxFunc = NULL; + ResultIndexFunction permIdxFunc = NULL; + ResultIndexFunction ntgIdxFunc = NULL; + { + bool isPermUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permResultIdx); + bool isTransUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(riTransResultIdx); + bool isNtgUsingResIdx = false; + if (hasNTGResults) + { + isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); + } - bool isPermUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permResultIdx); - bool isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); - bool isTransUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(riTransResultIdx); - - // Set up result index function pointers - - ResultIndexFunction riTranIdxFunc = isTransUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + // Set up result index function pointers + riTranIdxFunc = isTransUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + if (hasNTGResults) + { + ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + } + } const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const std::vector& nodes = m_ownerMainGrid->nodes(); @@ -906,10 +925,10 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr double perm = permResults[permResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + 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); @@ -922,10 +941,10 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr double perm = permResults[neighborCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + 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); @@ -957,37 +976,56 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() size_t ntgResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG"); + bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; + // Get the result count, to handle that one of them might be globally defined size_t permxResultValueCount = m_cellResults->cellScalarResults(permXResultIdx)[0].size(); - size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); - - size_t resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + size_t resultValueCount = permxResultValueCount; + if (hasNTGResults) + { + size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); + resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + } // Get all the actual result values std::vector & permXResults = m_cellResults->cellScalarResults(permXResultIdx)[0]; std::vector & permYResults = m_cellResults->cellScalarResults(permYResultIdx)[0]; std::vector & permZResults = m_cellResults->cellScalarResults(permZResultIdx)[0]; - std::vector & ntgResults = m_cellResults->cellScalarResults(ntgResultIdx)[0]; std::vector & riCombTransResults = m_ownerMainGrid->nncData()->makeConnectionScalarResult(riCombTransScalarResultIndex); + std::vector * ntgResults = NULL; + if (hasNTGResults) + { + ntgResults = &(m_cellResults->cellScalarResults(ntgResultIdx)[0]); + } // Prepare how to index the result values: + ResultIndexFunction permXIdxFunc = NULL; + ResultIndexFunction permYIdxFunc = NULL; + ResultIndexFunction permZIdxFunc = NULL; + ResultIndexFunction ntgIdxFunc = NULL; + { + bool isPermXUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permXResultIdx); + bool isPermYUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permYResultIdx); + bool isPermZUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permZResultIdx); + bool isNtgUsingResIdx = false; + if (hasNTGResults) + { + isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); + } - bool isPermXUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permXResultIdx); - bool isPermYUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permYResultIdx); - bool isPermZUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permZResultIdx); - bool isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); - - - // Set up result index function pointers - - ResultIndexFunction permXIdxFunc = isPermXUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permYIdxFunc = isPermYUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permZIdxFunc = isPermZUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + // Set up result index function pointers + permXIdxFunc = isPermXUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permYIdxFunc = isPermYUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permZIdxFunc = isPermZUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + if (hasNTGResults) + { + ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + } + } const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const std::vector& nodes = m_ownerMainGrid->nodes(); @@ -1068,10 +1106,10 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double perm = (*permResults)[nativeCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + 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); @@ -1084,10 +1122,10 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double perm = (*permResults)[neighborCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + 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); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index e2e853f214..6a1ca42898 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -554,9 +554,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // riTRANSXYZ and X,Y,Z { - size_t ntgResIdx = findScalarResultIndex(RimDefines::STATIC_NATIVE, "NTG"); - if ( findScalarResultIndex(RimDefines::STATIC_NATIVE, "NTG") != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T + if ( findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMY") != cvf::UNDEFINED_SIZE_T && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMZ") != cvf::UNDEFINED_SIZE_T) {