#3566 Temp LGR. Command file command createLgrForCompletions

This commit is contained in:
Bjørn Erik Jensen 2018-11-07 07:00:12 +01:00
parent 10394f1571
commit 7d9c858f13
7 changed files with 262 additions and 57 deletions

View File

@ -25,6 +25,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.h
${CMAKE_CURRENT_LIST_DIR}/RicfCreateLgrForCompletions.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -53,6 +54,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfCreateLgrForCompletions.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfCreateLgrForCompletions.h"
#include "RicfCommandFileExecutor.h"
#include "RicfCreateMultipleFractures.h"
#include "RicCreateTemporaryLgrFeature.h"
#include "ExportCommands/RicExportLgrFeature.h"
#include "RimDialogData.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimFractureTemplate.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaWellNameComparer.h"
#include "cafCmdFeatureManager.h"
#include <QStringList>
CAF_PDM_SOURCE_INIT(RicfCreateLgrForCompletions, "createLgrForCompletions");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCreateLgrForCompletions::RicfCreateLgrForCompletions()
{
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", Lgr::SplitTypeEnum(), "SplitType", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCreateLgrForCompletions::execute()
{
const auto wellPaths = RicfCreateMultipleFractures::wellPaths(m_wellPathNames);
if (!wellPaths.empty())
{
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
auto feature = dynamic_cast<RicCreateTemporaryLgrFeature*>(commandManager->getCommandFeature("RicCreateTemporaryLgrFeature"));
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("createLgrForCompletions: Could not find case with ID %1").arg(m_caseId()));
return;
}
}
caf::VecIjk lgrCellCounts(m_refinementI, m_refinementJ, m_refinementK);
QStringList wellsWithIntersectingLgrs;
for (const auto wellPath : wellPaths)
{
if (wellPath)
{
bool intersectingLgrs = false;
feature->createLgrsForWellPath(
wellPath,
eclipseCase,
m_timeStep,
lgrCellCounts,
m_splitType(),
{RigCompletionData::PERFORATION, RigCompletionData::FRACTURE, RigCompletionData::FISHBONES},
&intersectingLgrs);
if (intersectingLgrs) wellsWithIntersectingLgrs.push_back(wellPath->name());
}
}
feature->updateViews(eclipseCase);
if (!wellsWithIntersectingLgrs.empty())
{
auto wellsList = wellsWithIntersectingLgrs.join(", ");
RiaLogging::error(
"createLgrForCompletions: No LGRs created for some wells due to existing intersecting LGR(s).Affected wells : " +
wellsList);
}
}
}

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "ExportCommands/RicLgrSplitType.h"
#include "cafPdmField.h"
#include "cafAppEnum.h"
class RimWellPath;
//==================================================================================================
//
//
//
//==================================================================================================
class RicfCreateLgrForCompletions : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfCreateLgrForCompletions();
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<Lgr::SplitTypeEnum> m_splitType;
};

View File

@ -22,7 +22,6 @@
#include "RicfCreateMultipleFractures.h"
#include "ExportCommands/RicExportLgrFeature.h"
#include "ExportCommands/RicExportLgrUi.h"
#include "RimProject.h"
#include "RimDialogData.h"

View File

@ -20,7 +20,7 @@
#include "RicfCommandObject.h"
#include "ExportCommands/RicExportLgrUi.h"
#include "ExportCommands/RicLgrSplitType.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"

View File

@ -67,9 +67,71 @@
#include <algorithm>
#include <limits>
#include <set>
CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateTemporaryLgrFeature::createLgrsForWellPath(RimWellPath* wellPath,
RimEclipseCase* eclipseCase,
size_t timeStep,
caf::VecIjk lgrCellCounts,
Lgr::SplitType splitType,
const std::set<RigCompletionData::CompletionType>& completionTypes,
bool* intersectingOtherLgrs)
{
auto eclipseCaseData = eclipseCase->eclipseCaseData();
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL);
bool intersectingLgrs = false;
auto lgrs = RicExportLgrFeature::buildLgrsForWellPath(
wellPath, eclipseCase, timeStep, lgrCellCounts, splitType, completionTypes, &intersectingLgrs);
if (intersectingLgrs) *intersectingOtherLgrs = true;
for (const auto& lgr : lgrs)
{
createLgr(lgr, eclipseCase->eclipseCaseData()->mainGrid());
size_t lgrCellCount = lgr.cellCount();
activeCellInfo->addLgr(lgrCellCount);
if (fractureActiveCellInfo->reservoirActiveCellCount() > 0)
{
fractureActiveCellInfo->addLgr(lgrCellCount);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateTemporaryLgrFeature::updateViews(RimEclipseCase* eclipseCase)
{
RiaApplication::clearAllSelections();
deleteAllCachedData(eclipseCase);
RiaApplication::instance()->project()->mainPlotCollection()->deleteAllCachedData();
computeCachedData(eclipseCase);
RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots();
for (const auto& v : eclipseCase->views())
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(v);
if (eclipseView)
{
eclipseView->scheduleReservoirGridGeometryRegen();
}
v->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -107,65 +169,26 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked)
auto lgrCellCounts = dialogData->lgrCellCount();
size_t timeStep = dialogData->timeStep();
auto splitType = dialogData->splitType();
auto completionTypes = dialogData->completionTypes();
const auto completionTypes = dialogData->completionTypes();
auto eclipseCaseData = eclipseCase->eclipseCaseData();
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL);
bool intersectingOtherLgr = false;
bool intersectingOtherLgrs = false;
for (const auto& wellPath : wellPaths)
{
bool intersectingLgrs = false;
createLgrsForWellPath(wellPath,
eclipseCase,
timeStep,
lgrCellCounts,
splitType,
completionTypes,
&intersectingLgrs);
auto lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath,
eclipseCase,
timeStep,
lgrCellCounts,
splitType,
completionTypes,
&intersectingLgrs);
if (intersectingLgrs) intersectingOtherLgr = true;
auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid();
for (auto lgr : lgrs)
{
createLgr(lgr, eclipseCase->eclipseCaseData()->mainGrid());
size_t lgrCellCount = lgr.cellCount();
activeCellInfo->addLgr(lgrCellCount);
if (fractureActiveCellInfo->reservoirActiveCellCount() > 0)
{
fractureActiveCellInfo->addLgr(lgrCellCount);
}
}
mainGrid->calculateFaults(activeCellInfo);
if (intersectingLgrs) intersectingOtherLgrs = true;
}
RiaApplication::clearAllSelections();
updateViews(eclipseCase);
deleteAllCachedData(eclipseCase);
RiaApplication::instance()->project()->mainPlotCollection()->deleteAllCachedData();
computeCachedData(eclipseCase);
RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots();
for (const auto& v : eclipseCase->views())
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(v);
if (eclipseView)
{
eclipseView->scheduleReservoirGridGeometryRegen();
}
v->loadDataAndUpdate();
}
if (intersectingOtherLgr)
if (intersectingOtherLgrs)
{
QMessageBox::warning(nullptr,
"LGR cells intersected",

View File

@ -18,7 +18,9 @@
#pragma once
#include "ExportCommands/RicLgrSplitType.h"
#include "RigCompletionDataGridCell.h"
#include "RigCompletionData.h"
#include "cafCmdFeature.h"
#include "cafVecIjk.h"
@ -43,14 +45,25 @@ class RicCreateTemporaryLgrFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
void createLgrsForWellPath(RimWellPath* wellPath,
RimEclipseCase* eclipseCase,
size_t timeStep,
caf::VecIjk lgrCellCounts,
Lgr::SplitType splitType,
const std::set<RigCompletionData::CompletionType>& completionTypes,
bool* intersectingOtherLgrs);
void updateViews(RimEclipseCase* eclipseCase);
protected:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
private:
static void createLgr(const LgrInfo& lgrInfo, RigMainGrid* mainGrid);
static void computeCachedData(RimEclipseCase* eclipseCase);
static void deleteAllCachedData(RimEclipseCase* eclipseCase);
static bool containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells);
void createLgr(const LgrInfo& lgrInfo, RigMainGrid* mainGrid);
void computeCachedData(RimEclipseCase* eclipseCase);
void deleteAllCachedData(RimEclipseCase* eclipseCase);
bool containsAnyNonMainGridCells(const std::vector<RigCompletionDataGridCell>& cells);
};