mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-05 21:53:27 -06:00
#3493 LGR Export. Command file command exportLgrForCompletions
This commit is contained in:
parent
4632fd7dff
commit
fc4620985f
@ -24,6 +24,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -51,6 +52,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -36,6 +36,7 @@ namespace caf {
|
||||
addItem(RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics");
|
||||
addItem(RicfCommandFileExecutor::WELLPATHS, "WELLPATHS", "Well Path");
|
||||
addItem(RicfCommandFileExecutor::CELLS, "CELLS", "Cells");
|
||||
addItem(RicfCommandFileExecutor::LGRS, "LGRS", "Lgrs");
|
||||
setDefault(RicfCommandFileExecutor::COMPLETIONS);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
PROPERTIES,
|
||||
STATISTICS,
|
||||
WELLPATHS,
|
||||
CELLS
|
||||
CELLS,
|
||||
LGRS
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<ExportType> ExportTypeEnum;
|
||||
|
@ -0,0 +1,122 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 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 "RicfExportLgrForCompletions.h"
|
||||
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
#include "RicfCreateMultipleFractures.h"
|
||||
|
||||
#include "ExportCommands/RicExportLgrFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaWellNameComparer.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfExportLgrForCompletions, "exportLgrForCompletions");
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void RicfExportLgrForCompletions::LgrSplitType::setUp()
|
||||
{
|
||||
addItem(ExportLgr::ONE_LGR_PER_GRID_CELL, "ONE_LGR_PER_GRID_CELL", "One LGR per Main Grid Cell");
|
||||
addItem(ExportLgr::SINGLE_LGR_ALL_GRID_CELLS, "SINGLE_LGR_ALL_GRID_CELLS", "One Single LGR for all Main Grid Cells");
|
||||
|
||||
setDefault(ExportLgr::NONE);
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfExportLgrForCompletions::RicfExportLgrForCompletions()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", "");
|
||||
RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names", "", "", "");
|
||||
RICF_InitField(&m_refinementI, "refinementI", -1, "RefinementI", "", "", "");
|
||||
RICF_InitField(&m_refinementJ, "refinementJ", -1, "RefinementJ", "", "", "");
|
||||
RICF_InitField(&m_refinementK, "refinementK", -1, "RefinementK", "", "", "");
|
||||
RICF_InitField(&m_splitType, "splitType", LgrSplitType(ExportLgr::ONE_LGR_PER_GRID_CELL), "SplitType", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfExportLgrForCompletions::execute()
|
||||
{
|
||||
const auto wellPaths = RicfCreateMultipleFractures::wellPaths(m_wellPathNames);
|
||||
if (!wellPaths.empty())
|
||||
{
|
||||
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::LGRS);
|
||||
if (exportFolder.isNull())
|
||||
{
|
||||
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("LGR");
|
||||
}
|
||||
|
||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||
auto feature = dynamic_cast<RicExportLgrFeature*>(commandManager->getCommandFeature("RicExportLgrFeature"));
|
||||
|
||||
RimEclipseCase* eclipseCase = nullptr;
|
||||
{
|
||||
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
||||
{
|
||||
if (c->caseId() == m_caseId())
|
||||
{
|
||||
eclipseCase = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!eclipseCase)
|
||||
{
|
||||
RiaLogging::error(QString("exportLgrForCompletions: Could not find case with ID %1").arg(m_caseId()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
caf::VecIjk lgrCellCounts(m_refinementI, m_refinementJ, m_refinementK);
|
||||
bool lgrIntersected = false;
|
||||
for (const auto wellPath : wellPaths)
|
||||
{
|
||||
if (wellPath)
|
||||
{
|
||||
if (!feature->exportLgrsForWellPath(exportFolder, wellPath, eclipseCase, m_timeStep, lgrCellCounts, m_splitType == ExportLgr::SINGLE_LGR_ALL_GRID_CELLS))
|
||||
{
|
||||
lgrIntersected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lgrIntersected)
|
||||
{
|
||||
RiaLogging::error("exportLgrForCompletions: At least one completion intersects with an LGR. No output for those completions produced");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 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 "RicfCommandObject.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
namespace ExportLgr
|
||||
{
|
||||
enum SplitType
|
||||
{
|
||||
NONE,
|
||||
ONE_LGR_PER_GRID_CELL,
|
||||
SINGLE_LGR_ALL_GRID_CELLS
|
||||
};
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicfExportLgrForCompletions : public RicfCommandObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
typedef caf::AppEnum<ExportLgr::SplitType> LgrSplitType;
|
||||
|
||||
public:
|
||||
RicfExportLgrForCompletions();
|
||||
|
||||
void execute() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_caseId;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmField<std::vector<QString>> m_wellPathNames;
|
||||
caf::PdmField<int> m_refinementI;
|
||||
caf::PdmField<int> m_refinementJ;
|
||||
caf::PdmField<int> m_refinementK;
|
||||
caf::PdmField<LgrSplitType> m_splitType;
|
||||
};
|
@ -182,6 +182,40 @@ void RicExportLgrFeature::exportLgrs(QTextStream& stream, const std::vector<LgrI
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExportLgrFeature::exportLgrsForWellPath(const QString& exportFolder,
|
||||
RimWellPath* wellPath,
|
||||
RimEclipseCase* eclipseCase,
|
||||
size_t timeStep,
|
||||
caf::VecIjk lgrCellCounts,
|
||||
bool oneSingleLgr)
|
||||
{
|
||||
auto intersectingCells = cellsIntersectingCompletions(eclipseCase, wellPath, timeStep);
|
||||
if (containsAnyNonMainGridCells(intersectingCells))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<LgrInfo> lgrs;
|
||||
if (oneSingleLgr)
|
||||
lgrs = buildSingleLgr(eclipseCase, intersectingCells, lgrCellCounts);
|
||||
else
|
||||
lgrs = buildOneLgrPerMainCell(eclipseCase, intersectingCells, lgrCellCounts);
|
||||
|
||||
// Export
|
||||
QFile file;
|
||||
QString fileName = caf::Utils::makeValidFileBasename(QString("LGR_%1").arg(wellPath->name())) + ".dat";
|
||||
openFileForExport(exportFolder, fileName, &file);
|
||||
QTextStream stream(&file);
|
||||
stream.setRealNumberNotation(QTextStream::FixedNotation);
|
||||
stream.setRealNumberPrecision(2);
|
||||
exportLgrs(stream, lgrs);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -364,28 +398,10 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked)
|
||||
bool lgrIntersected = false;
|
||||
for (const auto& wellPath : wellPaths)
|
||||
{
|
||||
auto intersectingCells = cellsIntersectingCompletions(eclipseCase, wellPath, timeStep);
|
||||
if (containsAnyNonMainGridCells(intersectingCells))
|
||||
if (!exportLgrsForWellPath(dialogData->exportFolder(), wellPath, eclipseCase, timeStep, lgrCellCounts, dialogData->singleLgrSplit()))
|
||||
{
|
||||
lgrIntersected = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<LgrInfo> lgrs;
|
||||
if(dialogData->singleLgrSplit())
|
||||
lgrs = buildSingleLgr(eclipseCase, intersectingCells, lgrCellCounts);
|
||||
else
|
||||
lgrs = buildOneLgrPerMainCell(eclipseCase, intersectingCells, lgrCellCounts);
|
||||
|
||||
// Export
|
||||
QFile file;
|
||||
QString fileName = caf::Utils::makeValidFileBasename(QString("LGR_%1").arg(wellPath->name())) + ".dat";
|
||||
openFileForExport(dialogData->exportFolder(), fileName, &file);
|
||||
QTextStream stream(&file);
|
||||
stream.setRealNumberNotation(QTextStream::FixedNotation);
|
||||
stream.setRealNumberPrecision(2);
|
||||
exportLgrs(stream, lgrs);
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (lgrIntersected)
|
||||
|
@ -86,7 +86,12 @@ class RicExportLgrFeature : public caf::CmdFeature
|
||||
static RicExportLgrUi* openDialog(const QString& dialogTitle, RimEclipseCase* defaultCase = nullptr, int defaultTimeStep = 0);
|
||||
static bool openFileForExport(const QString& folderName, const QString& fileName, QFile* exportFile);
|
||||
static void exportLgrs(QTextStream& stream, const std::vector<LgrInfo>& lgrInfos);
|
||||
|
||||
static bool exportLgrsForWellPath(const QString& exportFolder,
|
||||
RimWellPath* wellPath,
|
||||
RimEclipseCase* eclipseCase,
|
||||
size_t timeStep,
|
||||
caf::VecIjk lgrCellCounts,
|
||||
bool oneSingleLgr);
|
||||
static std::vector<LgrInfo> buildOneLgrPerMainCell(RimEclipseCase* eclipseCase,
|
||||
const std::vector<RigCompletionDataGridCell>& intersectingCells,
|
||||
const caf::VecIjk& lgrSizes);
|
||||
|
Loading…
Reference in New Issue
Block a user