#1607 Optionally split export of completions over several files

This commit is contained in:
Bjørnar Grip Fjær 2017-06-15 11:21:37 +02:00
parent 403bf1890c
commit 14f91736b7
6 changed files with 96 additions and 25 deletions

View File

@ -31,8 +31,8 @@ RicCaseAndFileExportSettingsUi::RicCaseAndFileExportSettingsUi()
{
CAF_PDM_InitObject("RimCaseAndFileExportSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export Filename", "", "", "");
fileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&folder, "Folder", "Export Folder", "", "", "");
folder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&caseToApply, "CaseToApply", "Case to Apply", "", "", "");
}
@ -57,12 +57,12 @@ QList<caf::PdmOptionItemInfo> RicCaseAndFileExportSettingsUi::calculateValueOpti
//--------------------------------------------------------------------------------------------------
void RicCaseAndFileExportSettingsUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &fileName)
if (field == &folder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
myAttr->m_selectDirectory = true;
}
}
}

View File

@ -35,7 +35,7 @@ public:
RicCaseAndFileExportSettingsUi();
caf::PdmField<QString> fileName;
caf::PdmField<QString> folder;
caf::PdmPtrField<RimEclipseCase*> caseToApply;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;

View File

@ -74,12 +74,12 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked)
}
}
exportSettings.fileName = QDir(defaultDir).filePath("WellSegments");
exportSettings.folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
for (RimFishbonesMultipleSubs* subs : fishbonesCollection->fishbonesSubs)
@ -153,7 +153,8 @@ bool RicExportFishbonesWellSegmentsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicExportWellSegmentsSettingsUi& settings)
{
QFile exportFile(settings.fileName());
QString filePath = QDir(settings.folder()).filePath("Welsegs");
QFile exportFile(filePath);
if (settings.caseToApply() == nullptr)
{
@ -163,7 +164,7 @@ void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Well Segments: Could not open the file: %1").arg(settings.fileName()));
RiaLogging::error(QString("Export Well Segments: Could not open the file: %1").arg(filePath));
return;
}

View File

@ -92,12 +92,12 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
}
}
exportSettings.fileName = QDir(defaultDir).filePath("Completions");
exportSettings.folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
exportCompletions(wellPaths, exportSettings);
}
@ -140,7 +140,6 @@ std::vector<RimWellPath*> RicWellPathExportCompletionDataFeature::selectedWellPa
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings)
{
QFile exportFile(exportSettings.fileName());
if (exportSettings.caseToApply() == nullptr)
{
@ -148,12 +147,6 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
return;
}
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(exportSettings.fileName()));
return;
}
{
bool unitSystemMismatch = false;
for (const RimWellPath* wellPath : wellPaths)
@ -176,8 +169,6 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
}
}
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
std::map<IJKCellIndex, std::vector<RigCompletionData> > completionData;
@ -209,16 +200,94 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
completions.push_back(RigCompletionData::combine(data.second));
}
const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription();
if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE)
{
const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName);
printCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.includeWpimult);
}
else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL)
{
for (auto wellPath : wellPaths)
{
std::vector<RigCompletionData> wellCompletions;
for (auto completion : completions)
{
if (completion.wellName() == wellPath->completions()->wellNameForExport())
{
wellCompletions.push_back(completion);
}
}
QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName);
printCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.includeWpimult);
}
}
else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE)
{
for (auto wellPath : wellPaths)
{
{
std::vector<RigCompletionData> fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES);
QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName);
printCompletionsToFile(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.includeWpimult);
}
{
std::vector<RigCompletionData> perforationCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION);
QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName);
printCompletionsToFile(exportSettings.folder, fileName, perforationCompletions, exportSettings.includeWpimult);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector<RigCompletionData>& completions, bool includeWpimult)
{
QString filePath = QDir(exportFolder).filePath(fileName);
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath));
return;
}
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
// Sort by well name / cell index
std::sort(completions.begin(), completions.end());
// Print completion data
generateCompdatTable(formatter, completions);
if (exportSettings.includeWpimult)
if (includeWpimult)
{
generateWpimultTable(formatter, completions);
}
RiaLogging::info(QString("Successfully exported completion data to %1").arg(exportSettings.fileName()));
RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::getCompletionsForWellAndCompletionType(const std::vector<RigCompletionData>& completions,
const QString& wellName,
RigCompletionData::CompletionType completionType)
{
std::vector<RigCompletionData> filteredCompletions;
for (auto completion : completions)
{
if (completion.wellName() == wellName && completion.completionType() == completionType)
{
filteredCompletions.push_back(completion);
}
}
return filteredCompletions;
}
//--------------------------------------------------------------------------------------------------

View File

@ -139,6 +139,8 @@ public:
static double calculateTransmissibility(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, const cvf::Vec3d& internalCellLengths, double skinFactor, double wellRadius, size_t cellIndex, size_t volumeScaleConstant = 1, QString directionForVolumeScaling = "DX");
private:
static void exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings);
static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector<RigCompletionData>& completions, bool includeWpimult);
static std::vector<RigCompletionData> getCompletionsForWellAndCompletionType(const std::vector<RigCompletionData>& completions, const QString& wellName, RigCompletionData::CompletionType completionType);
static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);

View File

@ -128,7 +128,6 @@ void RimFishbonesMultipleSubs::setMeasuredDepthAndCount(double measuredDepth, do
computeRangesAndLocations();
computeRotationAngles();
computeSubLateralIndices();
}
//--------------------------------------------------------------------------------------------------
@ -275,8 +274,7 @@ void RimFishbonesMultipleSubs::fieldChangedByUi(const caf::PdmFieldHandle* chang
computeRotationAngles();
}
if (recomputeLocations ||
changedField == &m_locationOfSubs ||
if (changedField == &m_locationOfSubs ||
changedField == &m_lateralInstallSuccessFraction ||
changedField == &m_lateralCountPerSub)
{
@ -338,6 +336,7 @@ void RimFishbonesMultipleSubs::computeRangesAndLocations()
RimFishbonesCollection* collection;
this->firstAncestorOrThisOfTypeAsserted(collection);
computeSubLateralIndices();
collection->recalculateStartMD();
}