mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1607 Optionally split export of completions over several files
This commit is contained in:
parent
403bf1890c
commit
14f91736b7
@ -31,8 +31,8 @@ RicCaseAndFileExportSettingsUi::RicCaseAndFileExportSettingsUi()
|
|||||||
{
|
{
|
||||||
CAF_PDM_InitObject("RimCaseAndFileExportSettings", "", "", "");
|
CAF_PDM_InitObject("RimCaseAndFileExportSettings", "", "", "");
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export Filename", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&folder, "Folder", "Export Folder", "", "", "");
|
||||||
fileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
folder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&caseToApply, "CaseToApply", "Case to Apply", "", "", "");
|
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)
|
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);
|
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||||
if (myAttr)
|
if (myAttr)
|
||||||
{
|
{
|
||||||
myAttr->m_selectSaveFileName = true;
|
myAttr->m_selectDirectory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
RicCaseAndFileExportSettingsUi();
|
RicCaseAndFileExportSettingsUi();
|
||||||
|
|
||||||
caf::PdmField<QString> fileName;
|
caf::PdmField<QString> folder;
|
||||||
caf::PdmPtrField<RimEclipseCase*> caseToApply;
|
caf::PdmPtrField<RimEclipseCase*> caseToApply;
|
||||||
|
|
||||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||||
|
@ -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", "");
|
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
|
||||||
if (propertyDialog.exec() == QDialog::Accepted)
|
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;
|
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
|
||||||
for (RimFishbonesMultipleSubs* subs : fishbonesCollection->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)
|
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)
|
if (settings.caseToApply() == nullptr)
|
||||||
{
|
{
|
||||||
@ -163,7 +164,7 @@ void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath
|
|||||||
|
|
||||||
if (!exportFile.open(QIODevice::WriteOnly))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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", "");
|
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
|
||||||
if (propertyDialog.exec() == QDialog::Accepted)
|
if (propertyDialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
|
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
|
||||||
|
|
||||||
exportCompletions(wellPaths, exportSettings);
|
exportCompletions(wellPaths, exportSettings);
|
||||||
}
|
}
|
||||||
@ -140,7 +140,6 @@ std::vector<RimWellPath*> RicWellPathExportCompletionDataFeature::selectedWellPa
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings)
|
void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings)
|
||||||
{
|
{
|
||||||
QFile exportFile(exportSettings.fileName());
|
|
||||||
|
|
||||||
if (exportSettings.caseToApply() == nullptr)
|
if (exportSettings.caseToApply() == nullptr)
|
||||||
{
|
{
|
||||||
@ -148,12 +147,6 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
|
|||||||
return;
|
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;
|
bool unitSystemMismatch = false;
|
||||||
for (const RimWellPath* wellPath : wellPaths)
|
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;
|
std::map<IJKCellIndex, std::vector<RigCompletionData> > completionData;
|
||||||
|
|
||||||
@ -209,16 +200,94 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
|
|||||||
{
|
{
|
||||||
completions.push_back(RigCompletionData::combine(data.second));
|
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
|
// Sort by well name / cell index
|
||||||
std::sort(completions.begin(), completions.end());
|
std::sort(completions.begin(), completions.end());
|
||||||
|
|
||||||
// Print completion data
|
// Print completion data
|
||||||
generateCompdatTable(formatter, completions);
|
generateCompdatTable(formatter, completions);
|
||||||
if (exportSettings.includeWpimult)
|
if (includeWpimult)
|
||||||
{
|
{
|
||||||
generateWpimultTable(formatter, completions);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -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");
|
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:
|
private:
|
||||||
static void exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings);
|
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 generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
|
||||||
static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
|
static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
|
||||||
|
@ -128,7 +128,6 @@ void RimFishbonesMultipleSubs::setMeasuredDepthAndCount(double measuredDepth, do
|
|||||||
|
|
||||||
computeRangesAndLocations();
|
computeRangesAndLocations();
|
||||||
computeRotationAngles();
|
computeRotationAngles();
|
||||||
computeSubLateralIndices();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -275,8 +274,7 @@ void RimFishbonesMultipleSubs::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
|||||||
computeRotationAngles();
|
computeRotationAngles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recomputeLocations ||
|
if (changedField == &m_locationOfSubs ||
|
||||||
changedField == &m_locationOfSubs ||
|
|
||||||
changedField == &m_lateralInstallSuccessFraction ||
|
changedField == &m_lateralInstallSuccessFraction ||
|
||||||
changedField == &m_lateralCountPerSub)
|
changedField == &m_lateralCountPerSub)
|
||||||
{
|
{
|
||||||
@ -338,6 +336,7 @@ void RimFishbonesMultipleSubs::computeRangesAndLocations()
|
|||||||
|
|
||||||
RimFishbonesCollection* collection;
|
RimFishbonesCollection* collection;
|
||||||
this->firstAncestorOrThisOfTypeAsserted(collection);
|
this->firstAncestorOrThisOfTypeAsserted(collection);
|
||||||
|
computeSubLateralIndices();
|
||||||
collection->recalculateStartMD();
|
collection->recalculateStartMD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user