diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index da0e0c9152..fd1c1df8e2 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -353,10 +353,8 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - size_t i, j, k; - mainGrid->ijkFromCellIndex(externalCell.m_globalCellIdx, &i, &j, &k); - RigCompletionData compDat(wellPathName, {i,j,k}); + RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 5920b73087..33334c8b27 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -87,17 +87,14 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp std::vector completionData; - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); for (const auto& cellAndWellBoreParts : wellBorePartsInCells) { - size_t cellIndex = cellAndWellBoreParts.first; + size_t globalCellIndex = cellAndWellBoreParts.first; const std::vector& wellBoreParts = cellAndWellBoreParts.second; - size_t i, j, k; - grid->ijkFromCellIndex(cellIndex, &i, &j, &k); - bool cellIsActive = activeCellInfo->isActive(cellIndex); + bool cellIsActive = activeCellInfo->isActive(globalCellIndex); if (!cellIsActive) continue; // Find main bore and number of laterals @@ -113,14 +110,14 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp else { mainBoreDirection = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + globalCellIndex, wellBorePart.lengthsInCell); } } for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(globalCellIndex, settings.caseToApply)); double transmissibility = 0.0; if (wellBorePart.isMainBore) @@ -131,7 +128,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG); } @@ -143,7 +140,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG, numberOfLaterals, mainBoreDirection); @@ -151,7 +148,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp } CellDirection direction = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + globalCellIndex, wellBorePart.lengthsInCell); completion.setTransAndWPImultBackgroundDataFromFishbone(transmissibility, diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index e1a974241f..c2d7302c3c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -482,8 +482,6 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp CVF_ASSERT(!completions.empty()); QString wellName = completions[0].wellName(); IJKCellIndex cellIndexIJK = completions[0].cellIndex(); - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); - size_t cellIndex = grid->cellIndexFromIJK(cellIndexIJK.i, cellIndexIJK.j, cellIndexIJK.k); RigCompletionData::CompletionType completionType = completions[0].completionType(); //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, @@ -515,7 +513,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.completionType() != completions[0].completionType()) { - QString errorMessage = QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -523,7 +521,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.wellName() != completions[0].wellName()) { - QString errorMessage = QString("Cannot combine completions from different wells in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -531,7 +529,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.transmissibility() == HUGE_VAL) { - QString errorMessage = QString("Transmissibility calculation has failed for cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -556,7 +554,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), skinfactor, wellBoreDiameter / 2, - cellIndex, + cellIndexIJK.globalCellIndex(), cellDirection); double wpimult = totalTrans / transmissibilityEclipseCalculation; @@ -692,7 +690,7 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); } formatter.add(data.wellName()); - formatter.addZeroBasedCellIndex(data.cellIndex().i).addZeroBasedCellIndex(data.cellIndex().j).addZeroBasedCellIndex(data.cellIndex().k).addZeroBasedCellIndex(data.cellIndex().k); + formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()); switch (data.connectionState()) { case OPEN: @@ -765,7 +763,7 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData formatter.add(completion.wellName()); formatter.add(completion.wpimult()); - formatter.addZeroBasedCellIndex(completion.cellIndex().i).addZeroBasedCellIndex(completion.cellIndex().j).addZeroBasedCellIndex(completion.cellIndex().k); + formatter.addZeroBasedCellIndex(completion.cellIndex().localCellIndexI()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexK()); formatter.rowCompleted(); } @@ -782,7 +780,6 @@ std::vector RicWellPathExportCompletionDataFeature::generateP std::vector completionData; const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); - if (wellPath->perforationIntervalCollection()->isChecked()) { for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) @@ -800,9 +797,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); if (!cellIsActive) continue; - size_t i, j, k; - settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.globCellIndex, &i, &j, &k); - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(cell.globCellIndex, settings.caseToApply)); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 805a0f1183..9ed28d6361 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -18,6 +18,10 @@ #include "RigCompletionData.h" +#include "RimEclipseCase.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" + #include "RiaLogging.h" #include "cvfAssert.h" @@ -79,7 +83,7 @@ RigCompletionData RigCompletionData::combine(const std::vectorcompletionType() != result.completionType()) { - RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k)); + RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.localCellIndexI()).arg(result.m_cellIndex.localCellIndexJ()).arg(result.m_cellIndex.localCellIndexK())); continue; } if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility)) @@ -390,3 +394,76 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& target.m_wpimult = from.m_wpimult; target.m_completionType = from.m_completionType; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +IJKCellIndex::IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase) : m_globalCellIndex(globalCellIndex) +{ + if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid()) + { + const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); + const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + RigGridBase* grid = cell.hostGrid(); + if (grid) + { + size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + + size_t i = 0; + size_t j = 0; + size_t k = 0; + grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); + + m_localCellIndexI = i; + m_localCellIndexJ = j; + m_localCellIndexK = k; + + if (grid != mainGrid) + { + m_lgrName = QString::fromStdString(grid->gridName()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::globalCellIndex() const +{ + return m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexI() const +{ + return m_localCellIndexI; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexJ() const +{ + return m_localCellIndexJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexK() const +{ + return m_localCellIndexK; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString IJKCellIndex::oneBasedLocalCellIndexString() const +{ + QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1); + + return text; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index db398c9fb5..e10657d1bf 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -22,6 +22,8 @@ #include +class RimEclipseCase; + //================================================================================================== /// //================================================================================================== @@ -47,30 +49,44 @@ enum CellDirection { class IJKCellIndex { public: IJKCellIndex() {}; - IJKCellIndex(size_t i, size_t j, size_t k) : i(i), j(j), k(k) {}; + + IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase); + IJKCellIndex(const IJKCellIndex& other) { - i = other.i; - j = other.j; - k = other.k; + m_localCellIndexI = other.m_localCellIndexI; + m_localCellIndexJ = other.m_localCellIndexJ; + m_localCellIndexK = other.m_localCellIndexK; } bool operator==(const IJKCellIndex& other) const { - return i == other.i && j == other.j && k == other.k; + return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK; } bool operator<(const IJKCellIndex& other) const { - if (i != other.i) return i < other.i; - if (j != other.j) return j < other.j; - if (k != other.k) return k < other.k; + if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; + if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; + if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; return false; } - size_t i; - size_t j; - size_t k; + size_t globalCellIndex() const; + + size_t localCellIndexI() const; + size_t localCellIndexJ() const; + size_t localCellIndexK() const; + + QString oneBasedLocalCellIndexString() const; + +private: + size_t m_globalCellIndex; + QString m_lgrName; + + size_t m_localCellIndexI; + size_t m_localCellIndexJ; + size_t m_localCellIndexK; }; //==================================================================================================