diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 49a7935916..22aa9cad2f 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -100,6 +100,9 @@ #endif #include "RimSummaryPlotCollection.h" #include "RimSummaryPlot.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCase.h" +#include "RimGridSummaryCase.h" namespace caf { @@ -387,6 +390,17 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi if (oilField->wellPathCollection) oilField->wellPathCollection->readWellPathFiles(); } + for (RimOilField* oilField: m_project->oilFields) + { + if (oilField == NULL) continue; + // Temporary + if(!oilField->summaryCaseCollection()) + { + oilField->summaryCaseCollection = new RimSummaryCaseCollection(); + } + oilField->summaryCaseCollection()->createSummaryCasesFromRelevantEclipseResultCases(); + oilField->summaryCaseCollection()->loadAllSummaryCaseData(); + } // If load action is specified to recalculate statistics, do it now. // Apparently this needs to be done before the views are loaded, lest the number of time steps for statistics will be clamped @@ -776,11 +790,21 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas riv->loadDataAndUpdate(); + // Add a corresponding summary case if it exists + { + RimSummaryCaseCollection* sumCaseColl = m_project->activeOilField() ? m_project->activeOilField()->summaryCaseCollection() : NULL; + if(sumCaseColl) + { + RimGridSummaryCase* newSumCase = sumCaseColl->createAndAddSummaryCaseFromEclipseResultCase(rimResultReservoir); + if(newSumCase) newSumCase->loadCase(); + } + } + if (!riv->cellResult()->hasResult()) { riv->cellResult()->setResultVariable(RimDefines::undefinedResultName()); } - + analysisModels->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult()); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index e581273216..17b35a5132 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -31,6 +31,9 @@ #include "RimSummaryCurve.h" #include "RiuMainWindow.h" #include "cafSelectionManager.h" +#include "WellLogCommands\RicWellLogPlotCurveFeatureImpl.h" +#include "RimOilField.h" +#include "RimSummaryCaseCollection.h" CAF_CMD_SOURCE_INIT(RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature"); @@ -62,10 +65,22 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) { RimSummaryCurve* newCurve = new RimSummaryCurve(); plot->addCurve(newCurve); + + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(); + newCurve->setColor(curveColor); + + RimSummaryCase* defaultCase = nullptr; + if (project->activeOilField()->summaryCaseCollection()->summaryCaseCount() > 0) + { + defaultCase = project->activeOilField()->summaryCaseCollection()->summaryCase(0); + newCurve->setSummaryCase(defaultCase); + newCurve->setVariable("FOPT"); + newCurve->loadDataAndUpdate(); + } + plot->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(newCurve); - } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp index cf815e9b6f..bcd4d7f5bf 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -28,6 +28,7 @@ #include "cvfAssert.h" #include "RimSummaryPlotCollection.h" #include "RimMainPlotCollection.h" +#include "RiuMainWindow.h" CAF_CMD_SOURCE_INIT(RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature"); @@ -58,8 +59,11 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) summaryPlotColl->m_summaryPlots().push_back(plot); plot->setDescription(QString("Well Log Plot %1").arg(summaryPlotColl->m_summaryPlots.size())); + summaryPlotColl->updateConnectedEditors(); plot->loadDataAndUpdate(); + + RiuMainWindow::instance()->selectAsCurrentItem(plot); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp index ebc40f39a5..2da05522ae 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp @@ -34,6 +34,62 @@ void RifEclipseSummaryTools::findSummaryHeaderFile(const std::string& inputFile, findSummaryHeaderFileInfo(inputFile, headerFile, NULL, NULL, isFormatted); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseSummaryTools::findSummaryFiles(const std::string& inputFile, + std::string* headerFile, + std::vector* dataFiles) +{ + dataFiles->clear(); + headerFile->clear(); + + char* myPath = NULL; + char* myBase = NULL; + char* myExtention = NULL; + + util_alloc_file_components(inputFile.data(), &myPath, &myBase, &myExtention); + + std::string path; if(myPath) path = myPath; + std::string base; if(myBase) base = myBase; + std::string extention; if(myExtention) extention = myExtention; + + if(path.empty() || base.empty()) return ; + + char* myHeaderFile = NULL; + stringlist_type* summary_file_list = stringlist_alloc_new(); + + ecl_util_alloc_summary_files(path.data(), base.data(), extention.data(), &myHeaderFile, summary_file_list); + (*headerFile) = myHeaderFile; + util_safe_free(myHeaderFile); + + if(stringlist_get_size(summary_file_list) > 0) + { + for(int i = 0; i < stringlist_get_size(summary_file_list); i++) + { + dataFiles->push_back(stringlist_iget(summary_file_list,i)); + } + } + stringlist_free(summary_file_list); + + return; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifEclipseSummaryTools::hasSummaryFiles(const std::string& gridFileName) +{ + std::string headerFileName; + std::vector dataFileNames; + RifEclipseSummaryTools::findSummaryFiles(gridFileName, &headerFileName, &dataFileNames); + if (!headerFileName.empty() && dataFileNames.size()) return true; + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h index 2a27ebd155..48c2b759d8 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h @@ -36,6 +36,8 @@ public: static void findSummaryHeaderFile(const std::string& inputFile, std::string* headerFile, bool* isFormatted); static std::vector findSummaryDataFiles(const std::string& caseFile); + static void findSummaryFiles(const std::string& inputFile, std::string* headerFile, std::vector* dataFiles); + static bool hasSummaryFiles(const std::string& gridFileName); static void dumpMetaData(RifReaderEclipseSummary* readerEclipseSummary); private: diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index e7c7aacd8f..60dfbdb2ee 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -80,6 +80,10 @@ ${CEE_CURRENT_LIST_DIR}RimGridCollection.h ${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.h ${CEE_CURRENT_LIST_DIR}RimSummaryPlot.h ${CEE_CURRENT_LIST_DIR}RimSummaryCurve.h +${CEE_CURRENT_LIST_DIR}RimSummaryCase.h +${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp +${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.h ${CEE_CURRENT_LIST_DIR}RimPlotCurve.h ) @@ -160,6 +164,10 @@ ${CEE_CURRENT_LIST_DIR}RimGridCollection.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryPlot.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCurve.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryCase.cpp +${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp +${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.cpp ${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp ) diff --git a/ApplicationCode/ProjectDataModel/RimFileSummaryCase.cpp b/ApplicationCode/ProjectDataModel/RimFileSummaryCase.cpp new file mode 100644 index 0000000000..313758197a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimFileSummaryCase.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimFileSummaryCase.h" + + +//================================================================================================== +// +// +// +//================================================================================================== +CAF_PDM_SOURCE_INIT(RimFileSummaryCase,"FileSummaryCase"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileSummaryCase::RimFileSummaryCase() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileSummaryCase::~RimFileSummaryCase() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFileSummaryCase::setSummaryHeaderFilename(const QString& fileName) +{ + m_summaryHeaderFilename = fileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFileSummaryCase::summaryHeaderFilename() const +{ + return m_summaryHeaderFilename(); +} + + diff --git a/ApplicationCode/ProjectDataModel/RimFileSummaryCase.h b/ApplicationCode/ProjectDataModel/RimFileSummaryCase.h new file mode 100644 index 0000000000..6d9755afc6 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimFileSummaryCase.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimSummaryCase.h" + +//================================================================================================== +// +// +// +//================================================================================================== + +class RimFileSummaryCase: public RimSummaryCase +{ + CAF_PDM_HEADER_INIT; +public: + RimFileSummaryCase(); + virtual ~RimFileSummaryCase(); + + void setSummaryHeaderFilename(const QString& fileName); + virtual QString summaryHeaderFilename() const override; + +private: + caf::PdmField m_summaryHeaderFilename; +}; + + + diff --git a/ApplicationCode/ProjectDataModel/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/RimGridSummaryCase.cpp new file mode 100644 index 0000000000..bfc84a5b0e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridSummaryCase.cpp @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridSummaryCase.h" +#include "RimEclipseCase.h" +#include +#include "RigSummaryCaseData.h" + +//================================================================================================== +// +// +// +//================================================================================================== + + +CAF_PDM_SOURCE_INIT(RimGridSummaryCase,"GridSummaryCase"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridSummaryCase::RimGridSummaryCase() +{ + CAF_PDM_InitFieldNoDefault(&m_eclipseCase, "Associated3DCase", "Main View", "", "", ""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridSummaryCase::~RimGridSummaryCase() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridSummaryCase::setAssociatedEclipseCase(RimEclipseCase* eclipseCase) +{ + m_eclipseCase = eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGridSummaryCase::summaryHeaderFilename() const +{ + if (!m_eclipseCase()) return QString(); + + QFileInfo gridFileInfo(m_eclipseCase()->gridFileName()); + + QString possibleSumHeaderFileName = gridFileInfo.path() +"/"+ gridFileInfo.completeBaseName() + ".SMSPEC"; + + return possibleSumHeaderFileName; +} + diff --git a/ApplicationCode/ProjectDataModel/RimGridSummaryCase.h b/ApplicationCode/ProjectDataModel/RimGridSummaryCase.h new file mode 100644 index 0000000000..c5d81c4452 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridSummaryCase.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimSummaryCase.h" + +//================================================================================================== +// +// +// +//================================================================================================== + +class RimGridSummaryCase: public RimSummaryCase +{ + CAF_PDM_HEADER_INIT; +public: + RimGridSummaryCase(); + virtual ~RimGridSummaryCase(); + + void setAssociatedEclipseCase(RimEclipseCase* eclipseCase); + RimEclipseCase* associatedEclipseCase() { return m_eclipseCase(); } + + virtual QString summaryHeaderFilename() const override; + +private: + caf::PdmPtrField m_eclipseCase; +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimOilField.cpp b/ApplicationCode/ProjectDataModel/RimOilField.cpp index 7a9440b24a..b825aed24d 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationCode/ProjectDataModel/RimOilField.cpp @@ -23,6 +23,7 @@ #include "RimEclipseCaseCollection.h" #include "RimWellPathCollection.h" #include "RimGeoMechModels.h" +#include "RimSummaryCaseCollection.h" CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField"); //-------------------------------------------------------------------------------------------------- @@ -35,9 +36,11 @@ RimOilField::RimOilField(void) CAF_PDM_InitFieldNoDefault(&analysisModels, "AnalysisModels", "Grid Models", ":/GridModels.png", "", ""); CAF_PDM_InitFieldNoDefault(&geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png", "", ""); CAF_PDM_InitFieldNoDefault(&wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", ""); + CAF_PDM_InitFieldNoDefault(&summaryCaseCollection,"SummaryCaseCollection","Summary Cases",":/GridModels.png","",""); analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); + summaryCaseCollection = new RimSummaryCaseCollection(); } //-------------------------------------------------------------------------------------------------- @@ -48,5 +51,6 @@ RimOilField::~RimOilField(void) if (wellPathCollection()) delete wellPathCollection(); if (geoMechModels()) delete geoMechModels(); if (analysisModels()) delete analysisModels(); + if (summaryCaseCollection()) delete summaryCaseCollection(); } diff --git a/ApplicationCode/ProjectDataModel/RimOilField.h b/ApplicationCode/ProjectDataModel/RimOilField.h index 9240f1793e..c19bfcd9d0 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.h +++ b/ApplicationCode/ProjectDataModel/RimOilField.h @@ -28,7 +28,7 @@ class RimEclipseCaseCollection; class RimGeoMechModels; class RimWellPathCollection; - +class RimSummaryCaseCollection; //================================================================================================== /// /// @@ -44,4 +44,5 @@ public: caf::PdmChildField analysisModels; caf::PdmChildField geoMechModels; caf::PdmChildField wellPathCollection; + caf::PdmChildField summaryCaseCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index fa599e8e05..02797e9474 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -56,6 +56,8 @@ #include #include +#include "RimGridSummaryCase.h" +#include "RimSummaryCaseCollection.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); @@ -471,6 +473,25 @@ void RimProject::allCases(std::vector& cases) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::allSummaryCases(std::vector& sumCases) +{ + for (RimOilField* oilField: oilFields) + { + if(!oilField) continue; + RimSummaryCaseCollection* sumCaseColl = oilField->summaryCaseCollection(); + if(sumCaseColl) + { + for (size_t scIdx = 0; scIdx < sumCaseColl->summaryCaseCount(); ++scIdx) + { + sumCases.push_back(sumCaseColl->summaryCase(scIdx)); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 4554ddfa15..3c020a9a21 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -38,6 +38,7 @@ class RimViewLinkerCollection; class RimMainPlotCollection; class RimOilField; class RimScriptCollection; +class RimSummaryCase; class RimView; class RimWellPathImport; @@ -82,6 +83,7 @@ public: void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup); void allCases(std::vector& cases); + void allSummaryCases(std::vector& sumCases); void allNotLinkedViews(std::vector& views); void allVisibleViews(std::vector& views); diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCase.cpp new file mode 100644 index 0000000000..cf591f652f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCase.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryCase.h" +#include "RimEclipseCase.h" +#include "RigSummaryCaseData.h" +#include + +CAF_PDM_ABSTRACT_SOURCE_INIT(RimSummaryCase,"SummaryCase"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase::RimSummaryCase() +{ + CAF_PDM_InitObject("Summary Case",":/Cases16x16.png","",""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase::~RimSummaryCase() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::loadCase() +{ + if (m_summaryCaseData.isNull()) m_summaryCaseData = new RigSummaryCaseData(this->summaryHeaderFilename()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCase::caseName() +{ + QFileInfo caseFileName(this->summaryHeaderFilename()); + + return caseFileName.completeBaseName(); +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/RimSummaryCase.h new file mode 100644 index 0000000000..a9025861be --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCase.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" +#include "cafPdmField.h" +#include "cvfObject.h" +#include "cafPdmPtrField.h" + +class RimEclipseCase; +class RigSummaryCaseData; + +//================================================================================================== +// +// +// +//================================================================================================== + +class RimSummaryCase : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimSummaryCase(); + virtual ~RimSummaryCase(); + + QString caseName(); + + virtual QString summaryHeaderFilename() const = 0; + void loadCase(); + + RigSummaryCaseData* caseData() { return m_summaryCaseData.p(); } + +protected: + + cvf::ref m_summaryCaseData; +}; diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.cpp new file mode 100644 index 0000000000..cb2af709c8 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.cpp @@ -0,0 +1,136 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCase.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimEclipseResultCase.h" +#include "RimGridSummaryCase.h" +#include "RifEclipseSummaryTools.h" +#include + + +CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection,"SummaryCaseCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection::RimSummaryCaseCollection() +{ + CAF_PDM_InitObject("Summary Cases",":/Cases16x16.png","",""); + + CAF_PDM_InitFieldNoDefault(&m_cases,"SummaryCases","","","",""); + m_cases.uiCapability()->setUiHidden(true); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection::~RimSummaryCaseCollection() +{ + m_cases.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::createSummaryCasesFromRelevantEclipseResultCases() +{ + RimProject* proj = nullptr; + firstAnchestorOrThisOfType(proj); + if (proj) + { + std::vector all3DCases; + proj->allCases(all3DCases); + for (RimCase* aCase: all3DCases) + { + RimEclipseResultCase* eclResCase = dynamic_cast(aCase); + if (eclResCase) + { + // If we have no summary case corresponding to this eclipse case, + // try to create one. + bool isFound = false; + for (size_t scIdx = 0; scIdx < m_cases.size(); ++scIdx) + { + RimGridSummaryCase* grdSumCase = dynamic_cast(m_cases[scIdx]); + if (grdSumCase) + { + if (grdSumCase->associatedEclipseCase() == eclResCase) + { + isFound = true; + break; + } + } + } + + if (!isFound) + { + // Create new GridSummaryCase + createAndAddSummaryCaseFromEclipseResultCase(eclResCase); + + } + } + } + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RimSummaryCaseCollection::summaryCase(size_t idx) +{ + return m_cases[idx]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimSummaryCaseCollection::summaryCaseCount() +{ + return m_cases.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::loadAllSummaryCaseData() +{ + for (RimSummaryCase* sumCase: m_cases) + { + if (sumCase) sumCase->loadCase(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridSummaryCase* RimSummaryCaseCollection::createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) +{ + QString gridFileName = eclResCase->gridFileName(); + if(RifEclipseSummaryTools::hasSummaryFiles(QDir::toNativeSeparators(gridFileName).toStdString())) + { + RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); + newSumCase->setAssociatedEclipseCase(eclResCase); + this->m_cases.push_back(newSumCase); + return newSumCase; + } + return nullptr; +} + diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.h new file mode 100644 index 0000000000..90239bb67a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCaseCollection.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +class RimSummaryCase; +class RimGridSummaryCase; +class RimEclipseResultCase; + +class RimSummaryCaseCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimSummaryCaseCollection(); + virtual ~RimSummaryCaseCollection(); + + RimSummaryCase* summaryCase(size_t idx); + size_t summaryCaseCount(); + + void createSummaryCasesFromRelevantEclipseResultCases(); + + RimGridSummaryCase* createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase); + + void loadAllSummaryCaseData(); + +private: + caf::PdmChildArrayField m_cases; +}; diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp index 29eba5448f..64b6a05be6 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp @@ -32,6 +32,30 @@ #include "cafPdmUiTreeOrdering.h" #include "RiuLineSegmentQwtPlotCurve.h" #include "qwt_date.h" +#include "RimSummaryCase.h" +#include "RigSummaryCaseData.h" + +namespace caf +{ + +template<> +void caf::AppEnum::setUp() +{ + addItem(RifEclipseSummaryAddress::SUMMARY_WELL, "SUMMARY_WELL", "Well"); + addItem(RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION, "SUMMARY_WELL_COMPLETION","Completion"); + addItem(RifEclipseSummaryAddress::SUMMARY_GROUP, "SUMMARY_GROUP", "Group"); + addItem(RifEclipseSummaryAddress::SUMMARY_FIELD, "SUMMARY_FIELD", "Field"); + addItem(RifEclipseSummaryAddress::SUMMARY_REGION, "SUMMARY_REGION", "Region"); + addItem(RifEclipseSummaryAddress::SUMMARY_MISC, "SUMMARY_MISC", "Misc"); + addItem(RifEclipseSummaryAddress::SUMMARY_BLOCK, "SUMMARY_BLOCK", "Block"); + addItem(RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR, "SUMMARY_BLOCK_LGR", "LGR Block"); + addItem(RifEclipseSummaryAddress::SUMMARY_AQUIFIER, "SUMMARY_AQUIFIER", "Aquifier"); + addItem(RifEclipseSummaryAddress::SUMMARY_SEGMENT, "SUMMARY_SEGMENT", "Segment"); + addItem(RifEclipseSummaryAddress::SUMMARY_SEGMENT_RIVER, "SUMMARY_SEGMENT_RIVER", "Segment River"); + setDefault(RifEclipseSummaryAddress::SUMMARY_FIELD); +} + +} CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve"); @@ -42,15 +66,28 @@ RimSummaryCurve::RimSummaryCurve() { CAF_PDM_InitObject("Summary Curve", ":/WellLogCurve16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_eclipseCase, "ReferencedEclipseCase", "Eclipse Case", "", "", ""); - m_eclipseCase.uiCapability()->setUiChildrenHidden(true); + CAF_PDM_InitFieldNoDefault(&m_summaryCase, "SummaryCase", "Summary Case", "", "", ""); + m_summaryCase.uiCapability()->setUiChildrenHidden(true); // TODO: Implement setUiTreeHidden //m_eclipseCase.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_variableName, "SummaryVariableName", "Variable Name", "", "", ""); - m_variableName.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName()); + + CAF_PDM_InitFieldNoDefault(&m_category,"SummaryVarCategory","Category","","",""); + m_category.xmlCapability()->setIOWritable(false); + m_category.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&m_simulationItemName,"SummaryVarItem","Item","","",""); + m_simulationItemName.xmlCapability()->setIOWritable(false); + m_simulationItemName.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&m_quantityName,"SummaryVarQuantity","Quantity","","",""); + m_quantityName.xmlCapability()->setIOWritable(false); + m_quantityName.xmlCapability()->setIOReadable(false); + + updateOptionSensitivity(); } //-------------------------------------------------------------------------------------------------- @@ -60,17 +97,33 @@ RimSummaryCurve::~RimSummaryCurve() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::setSummaryCase(RimSummaryCase* sumCase) +{ + m_summaryCase = sumCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::setVariable(QString varName) +{ + m_variableName = varName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList RimSummaryCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { - this->RimPlotCurve::calculateValueOptions(fieldNeedingOptions,useOptionsOnly); + QList optionList = this->RimPlotCurve::calculateValueOptions(fieldNeedingOptions,useOptionsOnly); + if (!optionList.isEmpty()) return optionList; - QList optionList; if (fieldNeedingOptions == &m_variableName) { - if (m_eclipseCase) + if (m_summaryCase) { RifReaderEclipseSummary* reader = summaryReader(); if (reader) @@ -91,18 +144,18 @@ QList RimSummaryCurve::calculateValueOptions(const caf:: if (useOptionsOnly) *useOptionsOnly = true; } } - else if (fieldNeedingOptions == &m_eclipseCase) + else if (fieldNeedingOptions == &m_summaryCase) { RimProject* proj = RiaApplication::instance()->project(); - std::vector cases; + std::vector cases; - proj->allCases(cases); + proj->allSummaryCases(cases); for (size_t i = 0; i < cases.size(); i++) { - RimCase* rimCase = cases[i]; + RimSummaryCase* rimCase = cases[i]; - optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseUserDescription(), QVariant::fromValue(caf::PdmPointer(rimCase)))); + optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), QVariant::fromValue(caf::PdmPointer(rimCase)))); } if (optionList.size() > 0) @@ -110,6 +163,14 @@ QList RimSummaryCurve::calculateValueOptions(const caf:: optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer(NULL)))); } } + else if (fieldNeedingOptions == &m_simulationItemName) + { + RifReaderEclipseSummary* reader = summaryReader(); + if(reader) + { + const std::vector& addrs = reader->allResultAddresses(); + } + } return optionList; @@ -154,6 +215,29 @@ void RimSummaryCurve::onLoadDataAndUpdate() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + curveDataGroup->add(&m_summaryCase); + curveDataGroup->add(&m_variableName); + //curveDataGroup->add(&m_category); + //curveDataGroup->add(&m_simulationItemName); + //curveDataGroup->add(&m_quantityName); + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + appearanceGroup->add(&m_curveColor); + appearanceGroup->add(&m_curveThickness); + appearanceGroup->add(&m_pointSymbol); + appearanceGroup->add(&m_lineStyle); + appearanceGroup->add(&m_curveName); + appearanceGroup->add(&m_isUsingAutoName); + + uiOrdering.setForgetRemainingFields(true); // For now. +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -165,7 +249,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { this->loadDataAndUpdate(); } - else if (changedField = &m_eclipseCase) + else if (changedField = &m_summaryCase) { this->loadDataAndUpdate(); } @@ -176,10 +260,11 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, //-------------------------------------------------------------------------------------------------- RifReaderEclipseSummary* RimSummaryCurve::summaryReader() { - RimSummaryPlotCollection* plotCollection = NULL; - this->firstAnchestorOrThisOfType(plotCollection); + if (!m_summaryCase()) return nullptr; - return plotCollection->getOrCreateSummaryFileReader(m_eclipseCase); + if (!m_summaryCase->caseData()) return nullptr; + + return m_summaryCase()->caseData()->summaryReader(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.h b/ApplicationCode/ProjectDataModel/RimSummaryCurve.h index 809d91d641..6b4134c80c 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurve.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.h @@ -25,8 +25,10 @@ #include "cafPdmPtrField.h" #include "RimPlotCurve.h" +#include "RifEclipseSummaryAddress.h" +#include "cafAppEnum.h" -class RimEclipseResultCase; +class RimSummaryCase; class RifReaderEclipseSummary; class RiuLineSegmentQwtPlotCurve; @@ -41,6 +43,9 @@ public: RimSummaryCurve(); virtual ~RimSummaryCurve(); + void setSummaryCase(RimSummaryCase* sumCase); + void setVariable(QString varName); + protected: // RimPlotCurve overrides @@ -56,8 +61,16 @@ private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; // Fields - caf::PdmPtrField m_eclipseCase; + caf::PdmPtrField m_summaryCase; caf::PdmField m_variableName; + + // Ui Fields + caf::PdmField > + m_category; + caf::PdmField m_simulationItemName; + caf::PdmField m_quantityName; + }; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 92c65ad47c..b457029d9d 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -39,6 +39,7 @@ ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCurveDataTools.h +${CEE_CURRENT_LIST_DIR}RigSummaryCaseData.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -73,6 +74,7 @@ ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCurveDataTools.cpp +${CEE_CURRENT_LIST_DIR}RigSummaryCaseData.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.cpp new file mode 100644 index 0000000000..b64e163f12 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.cpp @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigSummaryCaseData.h" +#include "RifReaderEclipseSummary.h" +#include "RifEclipseSummaryTools.h" +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigSummaryCaseData::RigSummaryCaseData(const QString& summaryHeaderFileName) +{ + std::string headerFileName; + std::vector dataFileNames; + std::string nativeSumHeadFileName = QDir::toNativeSeparators(summaryHeaderFileName).toStdString(); + RifEclipseSummaryTools::findSummaryFiles(nativeSumHeadFileName, &headerFileName, &dataFileNames); + + m_summaryFileReader = new RifReaderEclipseSummary(); + if (!m_summaryFileReader->open(headerFileName, dataFileNames)) + { + m_summaryFileReader = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigSummaryCaseData::~RigSummaryCaseData() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseSummary* RigSummaryCaseData::summaryReader() +{ + return m_summaryFileReader.p(); +} + + diff --git a/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.h b/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.h new file mode 100644 index 0000000000..36c6fd713f --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigSummaryCaseData.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfObject.h" + +class QString; +class RifReaderEclipseSummary; + +class RigSummaryCaseData: public cvf::Object +{ +public: + RigSummaryCaseData(const QString& summaryHeaderFileName ); + ~RigSummaryCaseData(); + + + RifReaderEclipseSummary* summaryReader(); + +private: + cvf::ref m_summaryFileReader; + +};