//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList& fileNames, std::vector<RimSummaryCase*>* newCases, bool ensembleOrGroup) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (newCases) newCases->clear(); if (!sumCaseColl) return false; RifSummaryCaseRestartSelector fileSelector; fileSelector.setEnsembleOrGroupMode(ensembleOrGroup); fileSelector.determineFilesToImportFromSummaryFiles(fileNames); std::vector<RifSummaryCaseFileResultInfo> importFileInfos = fileSelector.summaryFileInfos(); if (!importFileInfos.empty()) { std::vector<RimSummaryCase*> sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos, true); if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); } if (fileSelector.foundErrors()) { QString errorMessage = fileSelector.createCombinedErrorMessage(); RiaLogging::error(errorMessage); QMessageBox::warning(nullptr, QString("Problem Importing Summary Case File(s)"), errorMessage); } return true; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) { RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); RimSummaryPlot* plot = selectedSummaryPlot(); if (plot) { RimSummaryCurve* newCurve = new RimSummaryCurve(); cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plot->curveCount()); newCurve->setColor(curveColor); plot->addCurveAndUpdate(newCurve); RimSummaryCase* defaultCase = nullptr; if (project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0) { defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(0); newCurve->setSummaryCaseY(defaultCase); newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldVarAddress("FOPT")); newCurve->loadDataAndUpdate(true); } plot->updateConnectedEditors(); RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipseCase* eclipseCase, std::vector<double>& completionTypeCellResult, size_t timeStep) { CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); RimProject* project = nullptr; eclipseCase->firstAncestorOrThisOfTypeAsserted(project); if (project->activeOilField()->wellPathCollection->isActive) { const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) { if (wellPath->showWellPath() && wellPath->wellPathGeometry()) { auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); for (auto& intersection : intersectedCells) { completionTypeCellResult[intersection] = RiaDefines::WELL_PATH; } auto completions = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); if (completions) { for (const auto& completionsForWell : completions->multipleCompletionsPerEclipseCell(wellPath, timeStep)) { RiaDefines::WellPathComponentType appCompletionType = RiaDefines::WELL_PATH; auto appCompletionTypes = fromCompletionData(completionsForWell.second); if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != appCompletionTypes.end()) { appCompletionType = RiaDefines::FRACTURE; } else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != appCompletionTypes.end()) { appCompletionType = RiaDefines::FISHBONES; } else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::PERFORATION_INTERVAL) != appCompletionTypes.end()) { appCompletionType = RiaDefines::PERFORATION_INTERVAL; } completionTypeCellResult[completionsForWell.first] = appCompletionType; } } } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicImportSummaryCasesFeature::addSummaryCases(const std::vector<RimSummaryCase*> cases) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; sumCaseColl->addCases(cases); sumCaseColl->updateAllRequiredEditors(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList<caf::PdmOptionItemInfo> RicCreateMultipleFracturesOptionItemUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { QList<caf::PdmOptionItemInfo> options; RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); if (fieldNeedingOptions == &m_fractureTemplate) { RimOilField* oilField = proj->activeOilField(); if (oilField && oilField->fractureDefinitionCollection()) { RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); for (RimFractureTemplate* fracDef : fracDefColl->fractureTemplates()) { QString displayText = fracDef->nameAndUnit(); options.push_back(caf::PdmOptionItemInfo(displayText, fracDef)); } } } return options; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() { RimProject* project = RiaApplication::instance()->project(); if (project->activeOilField()->wellPathCollection()) { caf::PdmChildArrayField<RimWellPath*>& wellPaths = project->activeOilField()->wellPathCollection()->wellPaths; for (size_t i = 0; i < wellPaths.size(); i++) { if (!wellPaths[i]->wellLogFiles().empty()) { return true; } } } return false; }
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) { RimProject* proj = RiaApplication::instance()->project(); RimAnalysisModels* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { std::vector<QString> groupNames; std::vector<qint64> groupIds; size_t caseGroupCount = analysisModels->caseGroups().size(); quint64 byteCount = 0; for (size_t i = 0; i < caseGroupCount; i++) { RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i]; QString caseGroupName = cg->name; qint64 caseGroupId = cg->groupId; byteCount += caseGroupName.size() * sizeof(QChar); byteCount += sizeof(qint64); groupNames.push_back(caseGroupName); groupIds.push_back(caseGroupId); } socketStream << (quint64)byteCount; socketStream << (quint64)caseGroupCount; for (size_t i = 0; i < caseGroupCount; i++) { socketStream << groupNames[i]; socketStream << groupIds[i]; } } else { // ERROR } return true; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicImportInputEclipseCaseOpmFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); QString fileName = QFileDialog::getOpenFileName(RiuMainWindow::instance(), "Import Eclipse Input file", defaultDir, "Eclipse Input Files (*.GRDECL);;All Files (*.*)"); if (fileName.isEmpty()) return; // Remember the path to next time app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(fileName).absolutePath()); RimProject* proj = app->project(); RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { // This code originates from RiaApplication::openInputEclipseCaseFromFileNames RimEclipseInputCaseOpm* rimInputReservoir = new RimEclipseInputCaseOpm(); proj->assignCaseIdToCase(rimInputReservoir); rimInputReservoir->importNewEclipseGridAndProperties(fileName); analysisModels->cases.push_back(rimInputReservoir); RimEclipseView* riv = rimInputReservoir->createAndAddReservoirView(); riv->cellResult()->setResultType(RimDefines::INPUT_PROPERTY); riv->hasUserRequestedAnimation = true; riv->loadDataAndUpdate(); if (!riv->cellResult()->hasResult()) { riv->cellResult()->setResultVariable(RimDefines::undefinedResultName()); } analysisModels->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult()); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); QString fileName = QFileDialog::getOpenFileName(nullptr, "Open StimPlan XML File", defaultDir, "StimPlan XML File (*.xml);;All files(*.*)"); if (fileName.isEmpty()) return; RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); RimOilField* oilfield = project->activeOilField(); if (oilfield == nullptr) return; RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection(); if (fracDefColl) { RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate(); fracDefColl->addFractureTemplate(fractureDef); QFileInfo stimplanfileFileInfo(fileName); QString name = stimplanfileFileInfo.baseName(); if (name.isEmpty()) { name = "StimPlan Fracture Template"; } fractureDef->setName(name); fractureDef->setFileName(fileName); fractureDef->loadDataAndUpdate(); fractureDef->setDefaultsBasedOnXMLfile(); fractureDef->setDefaultWellDiameterFromUnit(); fractureDef->updateFractureGrid(); fracDefColl->updateConnectedEditors(); std::vector<Rim3dView*> views; project->allVisibleViews(views); for (Rim3dView* view : views) { if (dynamic_cast<RimEclipseView*>(view)) { view->updateConnectedEditors(); } } Riu3DMainWindowTools::selectAsCurrentItem(fractureDef); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimValveTemplate* RicNewValveTemplateFeature::createNewValveTemplate() { RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); RimOilField* oilfield = project->activeOilField(); if (oilfield == nullptr) return nullptr; RimValveTemplateCollection* valveTemplateColl = oilfield->valveTemplateCollection(); if (valveTemplateColl) { RimValveTemplate* valveTemplate = new RimValveTemplate(); QString userLabel = QString("Valve Template #%1").arg(valveTemplateColl->valveTemplates().size() + 1); valveTemplate->setUserLabel(userLabel); valveTemplateColl->addValveTemplate(valveTemplate); valveTemplate->setUnitSystem(valveTemplateColl->defaultUnitSystemType()); valveTemplate->setDefaultValuesFromUnits(); return valveTemplate; } return nullptr; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup) { RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); std::vector<RimEclipseResultCase*> resultCases; for (size_t i = 0; i < objectGroup.objects.size(); i++) { RimEclipseResultCase* eclCase = dynamic_cast<RimEclipseResultCase*>(objectGroup.objects[i]); if (eclCase) { RimEclipseResultCase* eclCaseCopy = dynamic_cast<RimEclipseResultCase*>(eclCase->copyByXmlSerialization(PdmDefaultObjectFactory::instance())); resultCases.push_back(eclCaseCopy); } } if (resultCases.size() == 0) { return; } RimEclipseResultCase* mainResultCase = NULL; std::vector< std::vector<int> > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group if (gridCaseGroup->mainCase()) { mainResultCase = dynamic_cast<RimEclipseResultCase*>(gridCaseGroup->mainCase()); CVF_ASSERT(mainResultCase); mainResultCase->readGridDimensions(mainCaseGridDimensions); } std::vector<RimEclipseResultCase*> insertedCases; // Add cases to case group for (size_t i = 0; i < resultCases.size(); i++) { RimEclipseResultCase* rimResultReservoir = resultCases[i]; proj->assignCaseIdToCase(rimResultReservoir); if (gridCaseGroup->contains(rimResultReservoir)) { continue; } insertedCases.push_back(rimResultReservoir); } // Load stuff for (size_t i = 0; i < insertedCases.size(); i++) { RimEclipseResultCase* rimResultReservoir = insertedCases[i]; if (!mainResultCase) { rimResultReservoir->openEclipseGridFile(); rimResultReservoir->readGridDimensions(mainCaseGridDimensions); mainResultCase = rimResultReservoir; } else { std::vector< std::vector<int> > caseGridDimensions; rimResultReservoir->readGridDimensions(caseGridDimensions); bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions); if (!identicalGrid) { continue; } if (!rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData())) { CVF_ASSERT(false); } } RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir); caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir); gridCaseGroup->updateConnectedEditors(); for (size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++) { RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx]; riv->loadDataAndUpdate(); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList<caf::PdmOptionItemInfo> RimWellLogFileCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { QList<caf::PdmOptionItemInfo> options; options = RimWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); if (options.size() > 0) return options; if (fieldNeedingOptions == &m_wellPath) { RimProject* proj = RiaApplication::instance()->project(); if (proj->activeOilField()->wellPathCollection()) { caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; for (size_t i = 0; i < wellPaths.size(); i++) { // Only include well paths coming from a well log file if (wellPaths[i]->wellLogFiles().size() > 0) { options.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), wellPaths[i])); } } if (options.size() > 0) { options.push_front(caf::PdmOptionItemInfo("None", nullptr)); } } } if (fieldNeedingOptions == &m_wellLogChannnelName) { if (m_wellPath()) { if (m_wellLogFile) { std::vector<RimWellLogFileChannel*> fileLogs = m_wellLogFile->wellLogChannels(); for (size_t i = 0; i < fileLogs.size(); i++) { QString wellLogChannelName = fileLogs[i]->name(); options.push_back(caf::PdmOptionItemInfo(wellLogChannelName, wellLogChannelName)); } } } if (options.size() == 0) { options.push_back(caf::PdmOptionItemInfo("None", "None")); } } if ( fieldNeedingOptions == &m_wellLogFile ) { if ( m_wellPath() && m_wellPath->wellLogFiles().size() > 0 ) { for ( RimWellLogFile* const wellLogFile : m_wellPath->wellLogFiles() ) { QFileInfo fileInfo(wellLogFile->fileName()); options.push_back(caf::PdmOptionItemInfo(fileInfo.baseName(), wellLogFile)); } } } return options; }
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) { int argCaseGroupId = -1; if (args.size() == 2) { argCaseGroupId = args[1].toInt(); } RimProject* proj = RiaApplication::instance()->project(); RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { std::vector<RimCase*> cases; if (argCaseGroupId == -1) { proj->allCases(cases); } else { RimIdenticalGridCaseGroup* caseGroup = NULL; for (size_t i = 0; i < analysisModels->caseGroups().size(); i++) { RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i]; if (argCaseGroupId == cg->groupId()) { caseGroup = cg; } } if (caseGroup) { for (size_t i = 0; i < caseGroup->statisticsCaseCollection()->reservoirs.size(); i++) { cases.push_back(caseGroup->statisticsCaseCollection()->reservoirs[i]); } for (size_t i = 0; i < caseGroup->caseCollection()->reservoirs.size(); i++) { cases.push_back(caseGroup->caseCollection()->reservoirs[i]); } } } std::vector<qint64> caseIds; std::vector<QString> caseNames; std::vector<QString> caseTypes; std::vector<qint64> caseGroupIds; getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds); quint64 byteCount = sizeof(quint64); quint64 caseCount = caseIds.size(); for (size_t i = 0; i < caseCount; i++) { byteCount += 2*sizeof(qint64); byteCount += caseNames[i].size() * sizeof(QChar); byteCount += caseTypes[i].size() * sizeof(QChar); } socketStream << byteCount; socketStream << caseCount; for (size_t i = 0; i < caseCount; i++) { socketStream << caseIds[i]; socketStream << caseNames[i]; socketStream << caseTypes[i]; socketStream << caseGroupIds[i]; } } return true; }