mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3603 Export completions. Also export CARFIN if temporary LGRs exist
This commit is contained in:
parent
fe3fe5c8f8
commit
9b8584c707
@ -22,6 +22,7 @@
|
||||
|
||||
class RimSimWellInView;
|
||||
class RimWellPath;
|
||||
class RigMainGrid;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicExportFeatureImpl.h"
|
||||
#include "ExportCommands/RicExportLgrFeature.h"
|
||||
|
||||
#include "RimDialogData.h"
|
||||
#include "RimFishbonesMultipleSubs.h"
|
||||
@ -135,6 +136,16 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl
|
||||
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder);
|
||||
|
||||
RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings);
|
||||
|
||||
const auto mainGrid = exportSettings->caseToApply->mainGrid();
|
||||
if (!mainGrid) return;
|
||||
|
||||
const auto& lgrInfosForWells = RicExportLgrFeature::createLgrInfoListForTemporaryLgrs(mainGrid);
|
||||
|
||||
for (const auto& lgrInfoForWell : lgrInfosForWells)
|
||||
{
|
||||
RicExportLgrFeature::exportLgrs(exportSettings->folder, lgrInfoForWell.first, lgrInfoForWell.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,13 +248,10 @@ bool RicExportLgrFeature::openFileForExport(const QString& folderName, const QSt
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos)
|
||||
void RicExportLgrFeature::writeLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos)
|
||||
{
|
||||
int count = 0;
|
||||
for (auto lgrInfo : lgrInfos)
|
||||
{
|
||||
auto lgrName = QString("LGR_%1").arg(++count);
|
||||
|
||||
{
|
||||
RifEclipseDataTableFormatter formatter(stream);
|
||||
formatter.comment(QString("LGR: ") + lgrInfo.name);
|
||||
@ -270,7 +267,7 @@ void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrI
|
||||
RifEclipseOutputTableColumn("NY"),
|
||||
RifEclipseOutputTableColumn("NZ")});
|
||||
|
||||
formatter.add(lgrInfo.shortName);
|
||||
formatter.add(lgrInfo.name);
|
||||
formatter.addOneBasedCellIndex(lgrInfo.mainGridStartCell.i());
|
||||
formatter.addOneBasedCellIndex(lgrInfo.mainGridEndCell.i());
|
||||
formatter.addOneBasedCellIndex(lgrInfo.mainGridStartCell.j());
|
||||
@ -315,15 +312,26 @@ void RicExportLgrFeature::exportLgrsForWellPath(const QString& export
|
||||
intersectingOtherLgrs);
|
||||
|
||||
if (!*intersectingOtherLgrs && !lgrs.empty())
|
||||
{
|
||||
exportLgrs(exportFolder, wellPath->name(), lgrs);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportLgrFeature::exportLgrs(const QString& exportFolder, const QString& wellName, const std::vector<LgrInfo>& lgrInfos)
|
||||
{
|
||||
if (!lgrInfos.empty())
|
||||
{
|
||||
// Export
|
||||
QFile file;
|
||||
QString fileName = caf::Utils::makeValidFileBasename(QString("LGR_%1").arg(wellPath->name())) + ".dat";
|
||||
QString fileName = caf::Utils::makeValidFileBasename(QString("LGR_%1").arg(wellName)) + ".dat";
|
||||
openFileForExport(exportFolder, fileName, &file);
|
||||
QTextStream stream(&file);
|
||||
stream.setRealNumberNotation(QTextStream::FixedNotation);
|
||||
stream.setRealNumberPrecision(2);
|
||||
exportLgrs(stream, lgrs);
|
||||
writeLgrs(stream, lgrInfos);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@ -356,8 +364,8 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsForWellPath(RimWellPath*
|
||||
auto intersectingCells = cellsIntersectingCompletions(eclipseCase, wellPath, timeStep, completionTypes, intersectingOtherLgrs);
|
||||
|
||||
int lgrId = firstAvailableLgrId(eclipseCase->mainGrid());
|
||||
auto lgrName = createLgrName("", lgrId);
|
||||
lgrs.push_back(buildLgr(lgrId, lgrName, lgrName, eclipseCase, wellPath, intersectingCells, lgrCellCounts));
|
||||
auto lgrName = createLgrName("WELL", lgrId);
|
||||
lgrs.push_back(buildLgr(lgrId, lgrName, eclipseCase, wellPath, intersectingCells, lgrCellCounts));
|
||||
}
|
||||
return lgrs;
|
||||
}
|
||||
@ -376,7 +384,7 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerMainCell(RimEclipseCase*
|
||||
for (const auto& intersectionCell : intersectingCells)
|
||||
{
|
||||
auto lgrName = createLgrName("", lgrId);
|
||||
lgrs.push_back(buildLgr(lgrId++, lgrName, lgrName, eclipseCase, wellPath, {intersectionCell}, lgrSizes));
|
||||
lgrs.push_back(buildLgr(lgrId++, lgrName, eclipseCase, wellPath, {intersectionCell}, lgrSizes));
|
||||
}
|
||||
return lgrs;
|
||||
}
|
||||
@ -399,11 +407,10 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerCompletion(
|
||||
int lgrId = firstAvailableLgrId(eclipseCase->mainGrid());
|
||||
for (auto complInfo : completionInfo)
|
||||
{
|
||||
auto lgrName = createLgrName(complInfo.first.name, complInfo.first.number);
|
||||
auto& typeName = namesAndCounters[complInfo.first.type].first;
|
||||
auto& typeCounter = namesAndCounters[complInfo.first.type].second;
|
||||
auto lgrShortName = createShortLgrName(typeName, typeCounter++);
|
||||
lgrs.push_back(buildLgr(lgrId++, lgrName, lgrShortName, eclipseCase, wellPath, complInfo.second, lgrSizesPerMainGridCell));
|
||||
auto lgrName = createLgrName(typeName, typeCounter++);
|
||||
lgrs.push_back(buildLgr(lgrId++, lgrName, eclipseCase, wellPath, complInfo.second, lgrSizesPerMainGridCell));
|
||||
}
|
||||
return lgrs;
|
||||
}
|
||||
@ -413,7 +420,6 @@ std::vector<LgrInfo> RicExportLgrFeature::buildLgrsPerCompletion(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
LgrInfo RicExportLgrFeature::buildLgr(int lgrId,
|
||||
const QString& lgrName,
|
||||
const QString& shortLgrName,
|
||||
RimEclipseCase* eclipseCase,
|
||||
RimWellPath* wellPath,
|
||||
const std::vector<RigCompletionDataGridCell>& intersectingCells,
|
||||
@ -442,7 +448,7 @@ LgrInfo RicExportLgrFeature::buildLgr(int
|
||||
caf::VecIjk mainGridStartCell(iRange.first, jRange.first, kRange.first);
|
||||
caf::VecIjk mainGridEndCell(iRange.second, jRange.second, kRange.second);
|
||||
|
||||
return LgrInfo(lgrId, lgrName, shortLgrName, wellPath->name(), lgrSizes, mainGridStartCell, mainGridEndCell);
|
||||
return LgrInfo(lgrId, lgrName, wellPath->name(), lgrSizes, mainGridStartCell, mainGridEndCell);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -730,6 +736,68 @@ std::vector<RimWellPath*> RicExportLgrFeature::selectedWellPaths()
|
||||
return wellPaths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<caf::VecIjk, caf::VecIjk> mainGridCellBoundingBoxFromLgr(const RigGridBase* lgr)
|
||||
{
|
||||
auto mainGrid = lgr->mainGrid();
|
||||
|
||||
// Find min and max IJK
|
||||
auto iRange = RicExportLgrFeature::initRange();
|
||||
auto jRange = RicExportLgrFeature::initRange();
|
||||
auto kRange = RicExportLgrFeature::initRange();
|
||||
|
||||
for (size_t c = 0; c < lgr->cellCount(); c++)
|
||||
{
|
||||
const auto& cell = lgr->cell(c);
|
||||
size_t mainGridCellIndex = cell.mainGridCellIndex();
|
||||
|
||||
size_t i, j, k;
|
||||
mainGrid->ijkFromCellIndex(mainGridCellIndex, &i, &j, &k);
|
||||
|
||||
iRange.first = std::min(i, iRange.first);
|
||||
iRange.second = std::max(i, iRange.second);
|
||||
jRange.first = std::min(j, jRange.first);
|
||||
jRange.second = std::max(j, jRange.second);
|
||||
kRange.first = std::min(k, kRange.first);
|
||||
kRange.second = std::max(k, kRange.second);
|
||||
}
|
||||
|
||||
caf::VecIjk mainGridStartCell(iRange.first, jRange.first, kRange.first);
|
||||
caf::VecIjk mainGridEndCell(iRange.second, jRange.second, kRange.second);
|
||||
return std::make_pair(mainGridStartCell, mainGridEndCell);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString /*wellName*/, std::vector<LgrInfo>> RicExportLgrFeature::createLgrInfoListForTemporaryLgrs(const RigMainGrid* mainGrid)
|
||||
{
|
||||
std::map<QString, std::vector<LgrInfo>> lgrInfosPerWell;
|
||||
|
||||
for (size_t i = 0; i < mainGrid->gridCount(); i++)
|
||||
{
|
||||
const auto grid = mainGrid->gridByIndex(i);
|
||||
if (!grid->isTempGrid()) continue;
|
||||
|
||||
caf::VecIjk lgrSizes(grid->cellCountI(), grid->cellCountJ(), grid->cellCountK());
|
||||
std::pair<caf::VecIjk, caf::VecIjk> mainGridBoundingBox = mainGridCellBoundingBoxFromLgr(grid);
|
||||
|
||||
QString wellName = QString::fromStdString(grid->associatedWellPathName());
|
||||
auto& item = lgrInfosPerWell[wellName];
|
||||
|
||||
item.emplace_back(LgrInfo(grid->gridId(),
|
||||
QString::fromStdString(grid->gridName()),
|
||||
QString::fromStdString(grid->associatedWellPathName()),
|
||||
lgrSizes,
|
||||
mainGridBoundingBox.first,
|
||||
mainGridBoundingBox.second));
|
||||
}
|
||||
|
||||
return lgrInfosPerWell;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -750,24 +818,8 @@ int RicExportLgrFeature::firstAvailableLgrId(const RigMainGrid* mainGrid)
|
||||
QString RicExportLgrFeature::createLgrName(const QString& baseName, int number)
|
||||
{
|
||||
QString lgrName;
|
||||
|
||||
if (!baseName.isEmpty())
|
||||
{
|
||||
lgrName += "_" + baseName;
|
||||
}
|
||||
if (number > 0)
|
||||
{
|
||||
lgrName += "_" + QString::number(number);
|
||||
}
|
||||
return lgrName.replace(" ", "_");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportLgrFeature::createShortLgrName(const QString& baseName, int number)
|
||||
{
|
||||
QString lgrName = baseName + "_" + QString::number(number + 1);
|
||||
if(baseName.isEmpty()) lgrName = "LGR_";
|
||||
lgrName += baseName + "_" + QString::number(number + 1);
|
||||
return lgrName.replace(" ", "_");
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
class RigMainGrid;
|
||||
class RimEclipseCase;
|
||||
class RimSimWellInView;
|
||||
class RimWellPath;
|
||||
@ -44,12 +45,11 @@ class LgrInfo
|
||||
public:
|
||||
LgrInfo(int id,
|
||||
const QString& name,
|
||||
const QString& shortName,
|
||||
const QString& associatedWellPathName,
|
||||
const caf::VecIjk& sizes,
|
||||
const caf::VecIjk& mainGridStartCell,
|
||||
const caf::VecIjk& mainGridEndCell)
|
||||
: id(id), name(name), shortName(shortName), associatedWellPathName(associatedWellPathName),
|
||||
: id(id), name(name), associatedWellPathName(associatedWellPathName),
|
||||
sizes(sizes), mainGridStartCell(mainGridStartCell), mainGridEndCell(mainGridEndCell)
|
||||
{
|
||||
}
|
||||
@ -68,7 +68,6 @@ public:
|
||||
|
||||
int id;
|
||||
QString name;
|
||||
QString shortName;
|
||||
QString associatedWellPathName;
|
||||
caf::VecIjk sizes;
|
||||
|
||||
@ -129,7 +128,7 @@ class RicExportLgrFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
typedef std::pair<size_t, size_t> Range;
|
||||
using Range = std::pair<size_t, size_t>;
|
||||
static Range initRange() { return std::make_pair(std::numeric_limits<size_t>::max(), 0); }
|
||||
|
||||
static RicExportLgrUi* openDialog(const QString& dialogTitle,
|
||||
@ -146,6 +145,10 @@ class RicExportLgrFeature : public caf::CmdFeature
|
||||
const std::set<RigCompletionData::CompletionType>& completionTypes,
|
||||
bool* intersectingOtherLgrs);
|
||||
|
||||
static void exportLgrs(const QString& exportFolder,
|
||||
const QString& wellName,
|
||||
const std::vector<LgrInfo>& lgrInfos);
|
||||
|
||||
static std::vector<LgrInfo> buildLgrsForWellPath(RimWellPath* wellPath,
|
||||
RimEclipseCase* eclipseCase,
|
||||
size_t timeStep,
|
||||
@ -156,13 +159,15 @@ class RicExportLgrFeature : public caf::CmdFeature
|
||||
|
||||
static std::vector<RimWellPath*> selectedWellPaths();
|
||||
|
||||
static std::map<QString /*wellName*/, std::vector<LgrInfo>> createLgrInfoListForTemporaryLgrs(const RigMainGrid* mainGrid);
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
private:
|
||||
static void exportLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos);
|
||||
static void writeLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos);
|
||||
|
||||
static std::vector<LgrInfo> buildLgrsPerMainCell(RimEclipseCase* eclipseCase,
|
||||
RimWellPath* wellPath,
|
||||
@ -175,7 +180,6 @@ private:
|
||||
const caf::VecIjk& lgrSizesPerMainGridCell);
|
||||
static LgrInfo buildLgr(int lgrId,
|
||||
const QString& lgrName,
|
||||
const QString& shortLgrName,
|
||||
RimEclipseCase* eclipseCase,
|
||||
RimWellPath* wellPath,
|
||||
const std::vector<RigCompletionDataGridCell>& intersectingCells,
|
||||
@ -194,6 +198,5 @@ private:
|
||||
bool* isIntersectingOtherLgrs);
|
||||
|
||||
static int firstAvailableLgrId(const RigMainGrid* mainGrid);
|
||||
static QString createLgrName(const QString& baseName, int number = 0);
|
||||
static QString createShortLgrName(const QString& baseName, int number);
|
||||
static QString createLgrName(const QString& baseName, int number);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user