#1758 Add RigCompletionDataGridCell

This commit is contained in:
Magne Sjaastad 2018-01-30 09:20:21 +01:00
parent 028b5303a7
commit 4516941d2c
9 changed files with 216 additions and 150 deletions

View File

@ -348,7 +348,7 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans;
RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply));
RigCompletionData compDat(wellPathName, RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply));
compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor());
compDat.addMetadata(fracture->name(), QString::number(trans));
fractureCompletions.push_back(compDat);

View File

@ -117,7 +117,7 @@ std::vector<RigCompletionData> RicFishbonesTransmissibilityCalculationFeatureImp
for (WellBorePartForTransCalc wellBorePart : wellBoreParts)
{
RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(globalCellIndex, settings.caseToApply));
RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply));
double transmissibility = 0.0;
if (wellBorePart.isMainBore)

View File

@ -288,7 +288,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
}
}
std::map<IJKCellIndex, std::vector<RigCompletionData> > completionsPerEclipseCell;
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > completionsPerEclipseCell;
// FractureTransmissibilityExportInformation
std::unique_ptr<QTextStream> fractureTransmissibilityExportInformationStream = nullptr;
@ -378,7 +378,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
for (auto wellPath : usedWellPaths)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::vector<RigCompletionData> completions;
for (auto& data : filteredWellCompletions)
{
@ -404,7 +404,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
for (auto wellPath : usedWellPaths)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::vector<RigCompletionData> completions;
for (auto& data : filteredWellCompletions)
{
@ -446,7 +446,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
for (auto simWell : simWells)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name());
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name());
std::vector<RigCompletionData> completions;
for (auto& data : filteredWellCompletions)
{
@ -481,7 +481,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp
{
CVF_ASSERT(!completions.empty());
QString wellName = completions[0].wellName();
IJKCellIndex cellIndexIJK = completions[0].cellIndex();
RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell();
RigCompletionData::CompletionType completionType = completions[0].completionType();
//completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore,
@ -580,7 +580,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin
for (const auto& c : completions)
{
gridNames.insert(c.cellIndex().lgrName());
gridNames.insert(c.completionDataGridCell().lgrName());
}
for (const auto& gridName : gridNames)
@ -589,7 +589,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin
for (const auto& c : completions)
{
if (gridName == c.cellIndex().lgrName())
if (gridName == c.completionDataGridCell().lgrName())
{
completionsForGrid.push_back(c);
}
@ -637,7 +637,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QSt
std::sort(completions.begin(), completions.end());
// Print completion data
generateCompdatTable(formatter, completions[0].cellIndex().lgrName(), completions);
generateCompdatTable(formatter, completions[0].completionDataGridCell().lgrName(), completions);
if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS)
{
@ -668,9 +668,9 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::getComple
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<IJKCellIndex, std::vector<RigCompletionData> > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map<IJKCellIndex, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName)
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map<RigCompletionDataGridCell, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > wellCompletions;
std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > wellCompletions;
for (const auto& it : cellToCompletionMap)
{
@ -757,7 +757,7 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData
formatter.add(lgrName);
}
formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK());
formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK());
switch (data.connectionState())
{
case OPEN:
@ -830,7 +830,7 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData
formatter.add(completion.wellName());
formatter.add(completion.wpimult());
formatter.addZeroBasedCellIndex(completion.cellIndex().localCellIndexI()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexK());
formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK());
formatter.rowCompleted();
}
@ -864,7 +864,7 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateP
bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex);
if (!cellIsActive) continue;
RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(cell.globCellIndex, settings.caseToApply));
RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply));
CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS);
double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply,
@ -1077,18 +1077,18 @@ void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranch
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<IJKCellIndex, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data)
void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data)
{
for (auto& completion : data)
{
auto it = completionData->find(completion.cellIndex());
auto it = completionData->find(completion.completionDataGridCell());
if (it != completionData->end())
{
it->second.push_back(completion);
}
else
{
completionData->insert(std::pair<IJKCellIndex, std::vector<RigCompletionData> >(completion.cellIndex(), std::vector<RigCompletionData> {completion}));
completionData->insert(std::pair<RigCompletionDataGridCell, std::vector<RigCompletionData> >(completion.completionDataGridCell(), std::vector<RigCompletionData> {completion}));
}
}
}

View File

@ -159,7 +159,7 @@ private:
static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector<RigCompletionData>& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType);
static std::vector<RigCompletionData> getCompletionsForWellAndCompletionType(const std::vector<RigCompletionData>& completions, const QString& wellName, RigCompletionData::CompletionType completionType);
static std::map<IJKCellIndex, std::vector<RigCompletionData> > getCompletionsForWell(const std::map<IJKCellIndex, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName);
static std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> > getCompletionsForWell(const std::map<RigCompletionDataGridCell, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName);
static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector<RigCompletionData>& completionData);
static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
@ -171,7 +171,7 @@ private:
static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum);
static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector<WellSegmentLocation>* locations);
static void appendCompletionData(std::map<IJKCellIndex, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data);
static void appendCompletionData(std::map<RigCompletionDataGridCell, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data);
};

View File

@ -66,6 +66,7 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h
${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h
${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h
${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h
${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h
)
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)
@ -138,6 +139,7 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp
${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp
${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp
${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp
${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp
)
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)

View File

@ -18,10 +18,6 @@
#include "RigCompletionData.h"
#include "RimEclipseCase.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RiaLogging.h"
#include "cvfAssert.h"
@ -34,7 +30,7 @@
//==================================================================================================
///
//==================================================================================================
RigCompletionData::RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex)
RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex)
: m_wellName(wellName),
m_cellIndex(cellIndex),
m_saturation(HUGE_VAL),
@ -235,7 +231,7 @@ const QString& RigCompletionData::wellName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const IJKCellIndex& RigCompletionData::cellIndex() const
const RigCompletionDataGridCell& RigCompletionData::completionDataGridCell() const
{
return m_cellIndex;
}
@ -395,83 +391,3 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData&
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString IJKCellIndex::lgrName() const
{
return m_lgrName;
}

View File

@ -18,6 +18,8 @@
#pragma once
#include "RigCompletionDataGridCell.h"
#include <QString>
#include <vector>
@ -43,47 +45,6 @@ enum CellDirection {
DIR_UNDEF,
};
//==================================================================================================
///
//==================================================================================================
class IJKCellIndex {
public:
IJKCellIndex() {};
IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase);
bool operator==(const IJKCellIndex& other) const
{
return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK;
}
bool operator<(const IJKCellIndex& other) const
{
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 globalCellIndex() const;
size_t localCellIndexI() const;
size_t localCellIndexJ() const;
size_t localCellIndexK() const;
QString oneBasedLocalCellIndexString() const;
QString lgrName() const;
private:
size_t m_globalCellIndex;
QString m_lgrName;
size_t m_localCellIndexI;
size_t m_localCellIndexJ;
size_t m_localCellIndexK;
};
//==================================================================================================
///
//==================================================================================================
@ -107,7 +68,7 @@ public:
CT_UNDEFINED
};
RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex);
RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex);
~RigCompletionData();
RigCompletionData(const RigCompletionData& other);
@ -142,7 +103,7 @@ public:
const std::vector<RigCompletionMetaData>& metadata() const;
const QString& wellName() const;
const IJKCellIndex& cellIndex() const;
const RigCompletionDataGridCell& completionDataGridCell() const;
WellConnectionState connectionState() const;
double saturation() const;
double transmissibility() const;
@ -161,7 +122,7 @@ public:
private:
QString m_wellName;
IJKCellIndex m_cellIndex;
RigCompletionDataGridCell m_cellIndex;
WellConnectionState m_connectionState;
double m_saturation; //TODO: remove, always use default in Eclipse?
double m_transmissibility;

View File

@ -0,0 +1,131 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigCompletionDataGridCell.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCompletionDataGridCell::RigCompletionDataGridCell() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCompletionDataGridCell::RigCompletionDataGridCell(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());
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionDataGridCell::operator==(const RigCompletionDataGridCell& other) const
{
return m_globalCellIndex == other.m_globalCellIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCompletionDataGridCell::operator<(const RigCompletionDataGridCell& other) const
{
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 RigCompletionDataGridCell::globalCellIndex() const
{
return m_globalCellIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCompletionDataGridCell::localCellIndexI() const
{
return m_localCellIndexI;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCompletionDataGridCell::localCellIndexJ() const
{
return m_localCellIndexJ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCompletionDataGridCell::localCellIndexK() const
{
return m_localCellIndexK;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigCompletionDataGridCell::oneBasedLocalCellIndexString() const
{
QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1);
return text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigCompletionDataGridCell::lgrName() const
{
return m_lgrName;
}

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
class RimEclipseCase;
//==================================================================================================
///
//==================================================================================================
class RigCompletionDataGridCell
{
public:
RigCompletionDataGridCell();
RigCompletionDataGridCell(size_t globalCellIndex, const RimEclipseCase* eclipseCase);
bool operator==(const RigCompletionDataGridCell& other) const;
bool operator<(const RigCompletionDataGridCell& other) const;
size_t globalCellIndex() const;
size_t localCellIndexI() const;
size_t localCellIndexJ() const;
size_t localCellIndexK() const;
QString oneBasedLocalCellIndexString() const;
QString lgrName() const;
private:
size_t m_globalCellIndex;
QString m_lgrName;
size_t m_localCellIndexI;
size_t m_localCellIndexJ;
size_t m_localCellIndexK;
};