#3493 LGR Export. Command file command exportLgrForCompletions

This commit is contained in:
Bjørn Erik Jensen
2018-10-22 09:31:25 +02:00
parent 4632fd7dff
commit fc4620985f
7 changed files with 230 additions and 21 deletions

View File

@@ -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)

View File

@@ -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);