#1462 Add support for exporting WPIMULT

This commit is contained in:
Bjørnar Grip Fjær
2017-05-16 09:43:41 +02:00
parent 46d8f83424
commit 0b872dbf3a
6 changed files with 179 additions and 43 deletions

View File

@@ -25,7 +25,7 @@
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimCaseAndFileExportSettings.h"
#include "RimExportCompletionDataSettings.h"
#include "RiuMainWindow.h"
@@ -78,7 +78,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
QString projectFolder = app->currentProjectPath();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder);
RimCaseAndFileExportSettings exportSettings;
RimExportCompletionDataSettings exportSettings;
exportSettings.fileName = QDir(defaultDir).filePath("Completions");
@@ -91,7 +91,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
exportToFolder(objects[0], exportSettings.fileName, exportSettings.caseToApply);
exportToFolder(objects[0], exportSettings.fileName, exportSettings.caseToApply, exportSettings.includeWpimult());
}
}
@@ -106,10 +106,16 @@ void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPath, const QString& fileName, const RimEclipseCase* caseToApply)
void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPath, const QString& fileName, const RimEclipseCase* caseToApply, bool includeWpimult)
{
QFile exportFile(fileName);
if (caseToApply == nullptr)
{
RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case");
return;
}
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(fileName));
@@ -120,8 +126,12 @@ void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPat
const RigEclipseCaseData* caseData = caseToApply->eclipseCaseData();
std::vector<size_t> wellPathCells = findIntersectingCells(caseData, wellPath->wellPathGeometry()->m_wellPathPoints);
std::map<size_t, double> lateralsPerCell;
RifEclipseOutputTableFormatter formatter(stream);
// COMPDAT
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn{"Well", LEFT},
RifEclipseOutputTableColumn{"I", LEFT},
@@ -152,6 +162,12 @@ void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPat
std::vector<size_t> lateralCells = findIntersectingCells(caseData, lateralCoords);
if (includeWpimult)
{
// Only need this data if WPIMULT should be included in file
addLateralToCells(&lateralsPerCell, lateralCells);
}
std::vector<size_t> cellsUniqueToLateral = filterWellPathCells(lateralCells, wellPathCells);
std::vector<EclipseCellIndexRange> cellRanges = getCellIndexRange(caseData->mainGrid(), cellsUniqueToLateral);
@@ -169,6 +185,31 @@ void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPat
}
}
formatter.flush();
}
// WPIMULT
if (includeWpimult)
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn{"Well", LEFT},
RifEclipseOutputTableColumn{"Mult", LEFT},
RifEclipseOutputTableColumn{"I", LEFT},
RifEclipseOutputTableColumn{"J", LEFT},
RifEclipseOutputTableColumn{"K", LEFT},
};
formatter.keyword("WPIMULT");
formatter.header(header);
for (auto lateralsInCell : lateralsPerCell)
{
size_t i, j, k;
caseData->mainGrid()->ijkFromCellIndex(lateralsInCell.first, &i, &j, &k);
formatter.add(wellPath->name()).add(lateralsInCell.second).addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k);
formatter.rowCompleted();
}
formatter.flush();
}
}
//--------------------------------------------------------------------------------------------------
@@ -351,4 +392,23 @@ std::vector<size_t> RicWellPathExportCompletionDataFeature::filterWellPathCells(
return filteredCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::addLateralToCells(std::map<size_t, double>* lateralsPerCell, const std::vector<size_t>& lateralCells)
{
for (size_t cell : lateralCells)
{
std::map<size_t, double>::iterator it = lateralsPerCell->find(cell);
if (it == lateralsPerCell->end())
{
(*lateralsPerCell)[cell] = 1;
}
else
{
(*lateralsPerCell)[cell] = it->second + 1;
}
}
}
} // end namespace caf

View File

@@ -57,13 +57,14 @@ protected:
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static void exportToFolder(RimWellPath* wellPath, const QString& fileName, const RimEclipseCase* caseToApply);
static void exportToFolder(RimWellPath* wellPath, const QString& fileName, const RimEclipseCase* caseToApply, bool includeWpimult);
static std::vector<size_t> findCloseCells(const RigEclipseCaseData* caseData, const cvf::BoundingBox& bb);
static std::vector<EclipseCellIndexRange> getCellIndexRange(const RigMainGrid* grid, const std::vector<size_t>& cellIndices);
static bool cellOrdering(const EclipseCellIndex& cell1, const EclipseCellIndex& cell2);
static std::vector<size_t> findIntersectingCells(const RigEclipseCaseData* grid, const std::vector<cvf::Vec3d>& coords);
static void setHexCorners(const RigCell& cell, const std::vector<cvf::Vec3d>& nodeCoords, cvf::Vec3d* hexCorners);
static std::vector<size_t> filterWellPathCells(const std::vector<size_t>& completionCells, const std::vector<size_t>& wellPathCells);
static void addLateralToCells(std::map<size_t, double>* lateralsPerCell, const std::vector<size_t>& lateralCells);
};

View File

@@ -74,6 +74,9 @@ void RifEclipseOutputTableFormatter::outputBuffer()
m_out << " /" << "\n";
}
}
// If we finished a table, output an "empty" line after it
if (!m_columns.empty()) m_out << "/\n";
m_columns.clear();
m_buffer.clear();
}

View File

@@ -8,6 +8,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.h
${CEE_CURRENT_LIST_DIR}RimCaseCollection.h
${CEE_CURRENT_LIST_DIR}RimCaseAndFileExportSettings.h
${CEE_CURRENT_LIST_DIR}RimExportCompletionDataSettings.h
${CEE_CURRENT_LIST_DIR}RimCellFilter.h
${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.h
${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.h
@@ -101,6 +102,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.cpp
${CEE_CURRENT_LIST_DIR}RimCaseCollection.cpp
${CEE_CURRENT_LIST_DIR}RimCaseAndFileExportSettings.cpp
${CEE_CURRENT_LIST_DIR}RimExportCompletionDataSettings.cpp
${CEE_CURRENT_LIST_DIR}RimCellFilter.cpp
${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.cpp
${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.cpp

View File

@@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
// Copyright (C) 2017- Ceetron Solutions AS
//
// 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 "RimExportCompletionDataSettings.h"
CAF_PDM_SOURCE_INIT(RimExportCompletionDataSettings, "RimExportCompletionDataSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimExportCompletionDataSettings::RimExportCompletionDataSettings()
{
CAF_PDM_InitObject("RimExportCompletionDataSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&includeWpimult, "IncludeWPIMULT", "Include WPIMLUT", "", "", "");
}

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
// Copyright (C) 2017- Ceetron Solutions AS
//
// 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 "RimCaseAndFileExportSettings.h"
#include "cafPdmField.h"
//==================================================================================================
///
///
//==================================================================================================
class RimExportCompletionDataSettings : public RimCaseAndFileExportSettings
{
CAF_PDM_HEADER_INIT;
public:
RimExportCompletionDataSettings();
caf::PdmField<bool> includeWpimult;
};